/** * Updates status on tumblr * * @param string $update Text to be posted on microblogging site * @param array $post_content * @return void */ public static function update_tumblr($old, $mp, $dash, $update, $post_content, $post_ID, $post_title, $permalink, $post_content_actual, $featured_image_src_full) { $tumblr_accounts = MicroblogPoster_Poster::get_accounts_by_mode('tumblr', $post_ID); if (!empty($tumblr_accounts)) { foreach ($tumblr_accounts as $tumblr_account) { if (MicroblogPoster_Poster::is_method_callable('MicroblogPoster_Poster_Pro', 'filter_single_account') && $dash == 1 && $mp['val'] == 0 && $old == 0) { $active = MicroblogPoster_Poster_Pro::filter_single_account($tumblr_account['account_id']); if ($active === false) { continue; } else { if (isset($active['message_format']) && $active['message_format']) { $tumblr_account['message_format'] = $active['message_format']; } } } elseif (MicroblogPoster_Poster::is_method_callable('MicroblogPoster_Poster_Enterprise', 'filter_single_account_mp') && $dash == 1 && $mp['val'] == 1 && $old == 0) { $active = MicroblogPoster_Poster_Enterprise::filter_single_account_mp($tumblr_account['account_id']); if ($active === false) { continue; } else { if (isset($active['message_format']) && $active['message_format']) { $tumblr_account['message_format'] = $active['message_format']; } } } elseif (MicroblogPoster_Poster::is_method_callable('MicroblogPoster_Poster', 'filter_single_account_old') && $dash == 1 && $mp['val'] == 0 && $old == 1) { $active = MicroblogPoster_Poster::filter_single_account_old($tumblr_account['account_id']); if ($active === false) { continue; } else { if (isset($active['message_format']) && $active['message_format']) { $tumblr_account['message_format'] = $active['message_format']; } } } if ($tumblr_account['message_format'] && $mp['val'] == 0) { $update = str_ireplace(MicroblogPoster_Poster::get_shortcodes(), $post_content, $tumblr_account['message_format']); } elseif ($tumblr_account['message_format'] && $mp['val'] == 1 && $mp['type'] == 'link') { $update = str_ireplace(MicroblogPoster_Poster::get_shortcodes_mp(), $post_content, $tumblr_account['message_format']); } $extra = json_decode($tumblr_account['extra'], true); if (!$extra) { continue; } if (isset($extra['include_featured_image']) && $extra['include_featured_image'] == 1 && $featured_image_src_full && $extra['post_type'] == 'text') { $extra['post_type'] = 'photo'; } if ($mp['val'] == 1 && $mp['type'] == 'text') { $extra['post_type'] = 'text'; } $post_data = array(); $post_data['update'] = $update; $post_data['post_title'] = $post_title; $post_data['permalink'] = $permalink; $post_data['post_content_actual'] = $post_content_actual; $acc_extra = $extra; if ($extra['post_type'] == 'text') { $result = MicroblogPoster_Poster::send_signed_request($tumblr_account['consumer_key'], $tumblr_account['consumer_secret'], $tumblr_account['access_token'], $tumblr_account['access_token_secret'], "http://api.tumblr.com/v2/blog/{$extra['blog_hostname']}/post", array("type" => 'text', "title" => $post_title, "body" => $update)); } elseif ($extra['post_type'] == 'photo') { $featured_image_src_full = "http://www.pingminghealth.com/wp-content/uploads/2010/12/cherries.jpg"; $result = MicroblogPoster_Poster::send_signed_request($tumblr_account['consumer_key'], $tumblr_account['consumer_secret'], $tumblr_account['access_token'], $tumblr_account['access_token_secret'], "http://api.tumblr.com/v2/blog/{$extra['blog_hostname']}/post", array("type" => 'photo', "caption" => $update, "source" => $featured_image_src_full)); } elseif ($extra['post_type'] == 'link') { if (MicroblogPoster_Poster::is_method_callable('MicroblogPoster_Poster_Pro', 'update_tumblr_link')) { $result = MicroblogPoster_Poster_Pro::update_tumblr_link($tumblr_account, $acc_extra, $post_data); } } $action_result = 2; $result_dec = json_decode($result, true); if ($result_dec && isset($result_dec['meta']['msg']) && $result_dec['meta']['msg'] == "Created") { $action_result = 1; $result = "Success"; } $log_data = array(); $log_data['account_id'] = $tumblr_account['account_id']; $log_data['account_type'] = "tumblr"; $log_data['username'] = $tumblr_account['username']; $log_data['post_id'] = $post_ID; $log_data['action_result'] = $action_result; $log_data['update_message'] = $update; $log_data['log_message'] = $result; if ($mp['val'] == 1) { $log_data['log_type'] = 'manual'; } elseif ($old == 1) { $log_data['log_type'] = 'old'; } MicroblogPoster_Poster::insert_log($log_data); } } }