Skip to content

Instantly share code, notes, and snippets.

@alexkingorg
Created August 15, 2011 06:38
Show Gist options
  • Save alexkingorg/1145805 to your computer and use it in GitHub Desktop.
Save alexkingorg/1145805 to your computer and use it in GitHub Desktop.
Social WordPress Plugin "status broadcast" customization
<?php
// set format for status posts to exclude title
// if status post is short enough, do not include URL either
function akv3_social_broadcast_format($format, $post, $service) {
if (get_post_format($post) == 'status') {
$format = (strlen($post->post_content) <= $service->max_broadcast_length() ? '{content}' : '{content} {url}');
}
return $format;
}
add_filter('social_broadcast_format', 'akv3_social_broadcast_format', 10, 3);
// remove URL in comments if comment is short enough to be included
function akv3_social_comment_broadcast_format($format, $comment, $service) {
return (strlen($comment->comment_content) <= $service->max_broadcast_length() ? '{content}' : '{content} {url}');
}
add_filter('social_comment_broadcast_format', 'akv3_social_comment_broadcast_format', 10, 3);
// broadcast status posts by default
function akv3_social_default_broadcast_on_status_format() {
?>
<script type="text/javascript">
(function($) {
$('#publish').click(function() {
if ($('#post-format-status:checked').size()) {
$('#social_notify_yes').prop('checked', true);
}
});
}(jQuery));
</script>
<?php
}
add_action('dbx_post_sidebar', 'akv3_social_default_broadcast_on_status_format');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment