Example #1
0
 /**
  * Main function of this plugin called on publish_post action hook
  * 
  *
  * @param   int  $post_ID ID of the new/updated post
  * @return  void
  */
 public static function update_old_post($post_ID)
 {
     $shortcode_title_max_length = MicroblogPoster_Poster::get_shortcode_title_max_length();
     $shortcode_firstwords_max_length = MicroblogPoster_Poster::get_shortcode_firstwords_max_length();
     $shortcode_excerpt_max_length = MicroblogPoster_Poster::get_shortcode_excerpt_max_length();
     $apply_filters = MicroblogPoster_Poster::is_apply_filters_activated();
     $post = get_post($post_ID);
     if ($apply_filters) {
         $post_title = apply_filters('the_title', $post->post_title);
     } else {
         $post_title = $post->post_title;
     }
     $post_title = MicroblogPoster_Poster::shorten_title($post_title, $shortcode_title_max_length, ' ');
     if ($apply_filters) {
         $post_content_actual = apply_filters('the_content', $post->post_content);
     } else {
         $post_content_actual = $post->post_content;
     }
     $post_content_actual_lkn = MicroblogPoster_Poster::clean_up_and_shorten_content($post_content_actual, 350, ' ');
     $post_content_actual_tmb = MicroblogPoster_Poster::shorten_content($post_content_actual, 500, '.');
     $permalink = get_permalink($post_ID);
     $permalink_actual = $permalink;
     $update = $post_title . " {$permalink}";
     $post_thumbnail_id = get_post_thumbnail_id($post_ID);
     $featured_image_src_full = MicroblogPoster_Poster::get_featured_image_src_full($post_thumbnail_id);
     $featured_image_src_thumbnail = MicroblogPoster_Poster::get_featured_image_src_thumbnail($post_thumbnail_id);
     $featured_image_src_medium = MicroblogPoster_Poster::get_featured_image_src_medium($post_thumbnail_id);
     $post_content = array();
     $post_content[] = home_url();
     $post_content[] = $post_title;
     $post_content[] = $permalink;
     $shortened_permalink = '';
     $shortened_permalink_twitter = '';
     $short_url_results = MicroblogPoster_Poster::shorten_long_url($permalink);
     if ($short_url_results['shortened_permalink']) {
         $shortened_permalink = $short_url_results['shortened_permalink'];
         $update = $post_title . " {$shortened_permalink}";
         $permalink = $shortened_permalink;
     }
     if ($short_url_results['shortened_permalink_twitter']) {
         $shortened_permalink_twitter = $short_url_results['shortened_permalink_twitter'];
     }
     $post_content[] = $shortened_permalink;
     $post_excerpt_manual = '';
     if ($apply_filters) {
         $post_excerpt_tmp = apply_filters('the_content', $post->post_excerpt);
         $post_excerpt_tmp = MicroblogPoster_Poster::strip_shortcodes_and_tags($post_excerpt_tmp);
     } else {
         $post_excerpt_tmp = MicroblogPoster_Poster::strip_shortcodes_and_tags($post->post_excerpt);
     }
     if ($post_excerpt_tmp) {
         $post_excerpt_manual = $post_excerpt_tmp;
         $post_content_actual_lkn = $post_excerpt_tmp;
     }
     $post_content[] = $post_excerpt_manual;
     if ($post_excerpt_manual != '') {
         $post_content[] = $post_excerpt_manual;
     } else {
         $post_excerpt = MicroblogPoster_Poster::shorten_content($post_content_actual, $shortcode_excerpt_max_length, '.');
         $post_content[] = $post_excerpt;
     }
     $author = MicroblogPoster_Poster::get_author((int) $post->post_author);
     $post_content[] = $author;
     $post_content_first_words = MicroblogPoster_Poster::clean_up_and_shorten_content($post_content_actual, $shortcode_firstwords_max_length, ' ');
     $post_content[] = $post_content_first_words;
     $post_content_twitter = $post_content;
     $post_content_twitter[3] = $shortened_permalink_twitter;
     $tags = MicroblogPoster_Poster::get_post_tags($post_ID);
     $old = 1;
     $dash = 1;
     $mp = array();
     $mp['val'] = 0;
     $mp['type'] = '';
     @ini_set('max_execution_time', '0');
     MicroblogPoster_Poster::update_twitter($old, $mp, $dash, $update, $post_content_twitter, $post_ID, $featured_image_src_full);
     MicroblogPoster_Poster::update_plurk($old, $mp, $dash, $update, $post_content, $post_ID);
     MicroblogPoster_Poster::update_delicious($old, $mp, $dash, $post_title, $permalink, $tags, $post_content, $post_ID);
     MicroblogPoster_Poster::update_friendfeed($old, $mp, $dash, $post_title, $permalink, $post_content, $post_ID);
     MicroblogPoster_Poster::update_facebook($old, $mp, $dash, $update, $post_content, $post_ID, $post_title, $permalink, $post_content_actual_lkn, $featured_image_src_full);
     MicroblogPoster_Poster::update_diigo($old, $mp, $dash, $post_title, $permalink, $tags, $post_content, $post_ID);
     MicroblogPoster_Poster::update_linkedin($old, $mp, $dash, $update, $post_content, $post_ID, $post_title, $permalink, $post_content_actual_lkn, $featured_image_src_medium);
     MicroblogPoster_Poster::update_tumblr($old, $mp, $dash, $update, $post_content, $post_ID, $post_title, $permalink, $post_content_actual_tmb, $featured_image_src_full);
     MicroblogPoster_Poster::update_blogger($old, $mp, $dash, $update, $post_content, $post_ID, $post_title, $permalink, $post_content_actual_tmb, $featured_image_src_full);
     MicroblogPoster_Poster::update_instapaper($old, $mp, $dash, $post_title, $permalink, $post_content, $post_ID);
     MicroblogPoster_Poster::update_vkontakte($old, $mp, $dash, $update, $post_content, $post_ID, $post_title, $permalink, $post_content_actual_lkn, $featured_image_src_thumbnail, $permalink_actual);
     MicroblogPoster_Poster::update_xing($old, $mp, $dash, $update, $post_content, $post_ID, $post_title, $permalink, $post_content_actual_tmb);
     MicroblogPoster_Poster::maintain_logs();
 }