public

Social WordPress Plugin "status broadcast" customization

  • Download Gist
wp-social-status-broadcast.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
<?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');

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.