--- shorten2ping/shorten2ping.php 2010-04-12 10:22:34.000000000 -0700 +++ shorten2ping.mine/shorten2ping.php 2010-04-19 06:47:58.000000000 -0700 @@ -119,6 +119,15 @@ $post_url = get_permalink($post_id); $post_title = strip_tags($post->post_title); + // add some tag bits here + $tags = wp_get_post_tags($post_id); + $my_tag_list = ''; + if (is_array($tags)) { + foreach ($tags as $j=>$tag) { + $my_tag_list .= '#'.$tag->slug.' '; + } + } + $short_url_exists = get_post_meta($post_id, 'short_url', true); if (empty($short_url_exists)) { @@ -205,9 +214,19 @@ //get message from settings and process title and link $message = $s2p_options['message']; + $message_bare_char_count = strlen(str_replace(array('[title]','[link]','[tags]'), '',$message)); + $title_count = strlen($post_title); + $link_count = strlen($short_url); + $tag_count = strlen($my_tag_list); + $over = $message_bare_count + $title_count + $link_count + $tag_count - 140; + if ($over > 0 && $over <= $post_title/2) { + // if the overage is more than half the post title then skip it and let tags get truncated + $post_title = substr($post_title, 0, $title_count - $over); + } $message = str_replace('[title]', $post_title, $message); $message = str_replace('[link]', $short_url, $message); - + $message = str_replace('[tags]', $my_tag_list, $message); + if ($s2p_options['ping_service'] == 'pingfm'){ send_pingfm($pingfm_user_key,$post_id,$message);