Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/facebook.../admin
File: publish.php
<?php
[0] Fix | Delete
if( !defined('ABSPATH') ){ exit();}
[1] Fix | Delete
/*add_action('publish_post', 'xyz_fbap_link_publish');
[2] Fix | Delete
add_action('publish_page', 'xyz_fbap_link_publish');
[3] Fix | Delete
$xyz_fbap_future_to_publish=get_option('xyz_fbap_future_to_publish');
[4] Fix | Delete
[5] Fix | Delete
if($xyz_fbap_future_to_publish==1)
[6] Fix | Delete
add_action('future_to_publish', 'xyz_link_fbap_future_to_publish');
[7] Fix | Delete
[8] Fix | Delete
function xyz_link_fbap_future_to_publish($post){
[9] Fix | Delete
$postid =$post->ID;
[10] Fix | Delete
xyz_fbap_link_publish($postid);
[11] Fix | Delete
}*/
[12] Fix | Delete
//////////////
[13] Fix | Delete
add_action( 'transition_post_status', 'xyz_link_fbap_future_to_publish', 10, 3 );
[14] Fix | Delete
[15] Fix | Delete
function xyz_link_fbap_future_to_publish($new_status, $old_status, $post){
[16] Fix | Delete
[17] Fix | Delete
if (isset($_GET['_locale']) && empty($_POST))
[18] Fix | Delete
return ;
[19] Fix | Delete
[20] Fix | Delete
if(!isset($GLOBALS['fbap_dup_publish']))
[21] Fix | Delete
$GLOBALS['fbap_dup_publish']=array();
[22] Fix | Delete
$postid =$post->ID;
[23] Fix | Delete
$get_post_meta=get_post_meta($postid,"xyz_fbap",true);
[24] Fix | Delete
$post_permissin=get_option('xyz_fbap_post_permission');
[25] Fix | Delete
if(isset($_POST['xyz_fbap_post_permission']))
[26] Fix | Delete
{
[27] Fix | Delete
$post_permissin=intval($_POST['xyz_fbap_post_permission']);
[28] Fix | Delete
if ( (isset($_POST['xyz_fbap_post_permission']) && isset($_POST['xyz_fbap_po_method'])) )
[29] Fix | Delete
{
[30] Fix | Delete
$futToPubDataArray=array( 'post_fb_permission' => $post_permissin,
[31] Fix | Delete
'xyz_fbap_po_method' => $_POST['xyz_fbap_po_method'],
[32] Fix | Delete
'xyz_fbap_message' => $_POST['xyz_fbap_message']);
[33] Fix | Delete
update_post_meta($postid, "xyz_fbap_future_to_publish", $futToPubDataArray);
[34] Fix | Delete
}
[35] Fix | Delete
}
[36] Fix | Delete
else
[37] Fix | Delete
{
[38] Fix | Delete
if ($post_permissin == 1) {
[39] Fix | Delete
if($new_status == 'publish')
[40] Fix | Delete
{
[41] Fix | Delete
if ($get_post_meta == 1 ) {
[42] Fix | Delete
return;
[43] Fix | Delete
}
[44] Fix | Delete
}
[45] Fix | Delete
else return;
[46] Fix | Delete
}
[47] Fix | Delete
}
[48] Fix | Delete
if($post_permissin == 1)
[49] Fix | Delete
{
[50] Fix | Delete
if($new_status == 'publish')
[51] Fix | Delete
{
[52] Fix | Delete
if(!in_array($postid,$GLOBALS['fbap_dup_publish'])) {
[53] Fix | Delete
$GLOBALS['fbap_dup_publish'][]=$postid;
[54] Fix | Delete
xyz_fbap_link_publish($postid);
[55] Fix | Delete
[56] Fix | Delete
}
[57] Fix | Delete
[58] Fix | Delete
}
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
}
[62] Fix | Delete
[63] Fix | Delete
function xyz_fbap_link_publish($post_ID) {
[64] Fix | Delete
$_POST_CPY=$_POST;
[65] Fix | Delete
$_POST=stripslashes_deep($_POST);
[66] Fix | Delete
$get_post_meta_future_data=get_post_meta($post_ID,"xyz_fbap_future_to_publish",true);
[67] Fix | Delete
$xyz_fbap_po_method=$xyz_fbap_message='';
[68] Fix | Delete
$post_permissin=get_option('xyz_fbap_post_permission');
[69] Fix | Delete
if(isset($_POST['xyz_fbap_post_permission']))
[70] Fix | Delete
$post_permissin=intval($_POST['xyz_fbap_post_permission']);
[71] Fix | Delete
elseif(!empty($get_post_meta_future_data) && get_option('xyz_fbap_default_selection_edit')==2 )///select values from post meta
[72] Fix | Delete
{
[73] Fix | Delete
$post_permissin=$get_post_meta_future_data['post_fb_permission'];
[74] Fix | Delete
$xyz_fbap_po_method=$get_post_meta_future_data['xyz_fbap_po_method'];
[75] Fix | Delete
$xyz_fbap_message=$get_post_meta_future_data['xyz_fbap_message'];
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
if ($post_permissin != 1) {
[79] Fix | Delete
$_POST=$_POST_CPY;
[80] Fix | Delete
return ;
[81] Fix | Delete
[82] Fix | Delete
}elseif(( (isset($_POST['_inline_edit'])) || (isset($_REQUEST['bulk_edit'])) ) && (get_option('xyz_fbap_default_selection_edit') == 0) ) {
[83] Fix | Delete
$_POST=$_POST_CPY;
[84] Fix | Delete
return;
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
[88] Fix | Delete
global $current_user;
[89] Fix | Delete
wp_get_current_user();
[90] Fix | Delete
[91] Fix | Delete
////////////fb///////////
[92] Fix | Delete
$appid=get_option('xyz_fbap_application_id');
[93] Fix | Delete
$appsecret=get_option('xyz_fbap_application_secret');
[94] Fix | Delete
$useracces_token=get_option('xyz_fbap_fb_token');
[95] Fix | Delete
$app_name=get_option('xyz_fbap_application_name');
[96] Fix | Delete
[97] Fix | Delete
$message=get_option('xyz_fbap_message');
[98] Fix | Delete
if(isset($_POST['xyz_fbap_message']))
[99] Fix | Delete
$message=$_POST['xyz_fbap_message'];
[100] Fix | Delete
elseif($xyz_fbap_message !='')
[101] Fix | Delete
$message=$xyz_fbap_message;
[102] Fix | Delete
[103] Fix | Delete
//$fbid=get_option('xyz_fbap_fb_id');
[104] Fix | Delete
[105] Fix | Delete
$posting_method=get_option('xyz_fbap_po_method');
[106] Fix | Delete
if(isset($_POST['xyz_fbap_po_method']))
[107] Fix | Delete
$posting_method=intval($_POST['xyz_fbap_po_method']);
[108] Fix | Delete
elseif($xyz_fbap_po_method !='')
[109] Fix | Delete
$posting_method=$xyz_fbap_po_method;
[110] Fix | Delete
[111] Fix | Delete
$af=get_option('xyz_fbap_af');
[112] Fix | Delete
[113] Fix | Delete
$postpp= get_post($post_ID);global $wpdb;
[114] Fix | Delete
$entries0 = $wpdb->get_results($wpdb->prepare( 'SELECT user_nicename,display_name FROM '.$wpdb->base_prefix.'users WHERE ID=%d',$postpp->post_author));
[115] Fix | Delete
foreach( $entries0 as $entry ) {
[116] Fix | Delete
$user_nicename=$entry->user_nicename;
[117] Fix | Delete
$user_displayname=$entry->display_name;
[118] Fix | Delete
}
[119] Fix | Delete
if ($postpp->post_status == 'publish')
[120] Fix | Delete
{
[121] Fix | Delete
$posttype=$postpp->post_type;
[122] Fix | Delete
$fb_publish_status=array();
[123] Fix | Delete
[124] Fix | Delete
if ($posttype=="page")
[125] Fix | Delete
{
[126] Fix | Delete
[127] Fix | Delete
$xyz_fbap_include_pages=get_option('xyz_fbap_include_pages');
[128] Fix | Delete
if($xyz_fbap_include_pages==0)
[129] Fix | Delete
{
[130] Fix | Delete
$_POST=$_POST_CPY;
[131] Fix | Delete
return;
[132] Fix | Delete
}
[133] Fix | Delete
}
[134] Fix | Delete
[135] Fix | Delete
else if($posttype=="post")
[136] Fix | Delete
{
[137] Fix | Delete
$xyz_fbap_include_posts=get_option('xyz_fbap_include_posts');
[138] Fix | Delete
if($xyz_fbap_include_posts==0)
[139] Fix | Delete
{
[140] Fix | Delete
$_POST=$_POST_CPY;return;
[141] Fix | Delete
}
[142] Fix | Delete
[143] Fix | Delete
$xyz_fbap_include_categories=get_option('xyz_fbap_include_categories');
[144] Fix | Delete
if($xyz_fbap_include_categories!="All")
[145] Fix | Delete
{
[146] Fix | Delete
$carr1=explode(',', $xyz_fbap_include_categories);
[147] Fix | Delete
[148] Fix | Delete
$defaults = array('fields' => 'ids');
[149] Fix | Delete
$carr2=wp_get_post_categories( $post_ID, $defaults );
[150] Fix | Delete
$retflag=1;
[151] Fix | Delete
foreach ($carr2 as $key=>$catg_ids)
[152] Fix | Delete
{
[153] Fix | Delete
if(in_array($catg_ids, $carr1))
[154] Fix | Delete
$retflag=0;
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
[158] Fix | Delete
if($retflag==1)
[159] Fix | Delete
{
[160] Fix | Delete
$_POST=$_POST_CPY;
[161] Fix | Delete
return;
[162] Fix | Delete
}
[163] Fix | Delete
}
[164] Fix | Delete
}
[165] Fix | Delete
else
[166] Fix | Delete
{
[167] Fix | Delete
[168] Fix | Delete
$xyz_fbap_include_customposttypes=get_option('xyz_fbap_include_customposttypes');
[169] Fix | Delete
if($xyz_fbap_include_customposttypes!='')
[170] Fix | Delete
{
[171] Fix | Delete
$carr=explode(',', $xyz_fbap_include_customposttypes);
[172] Fix | Delete
[173] Fix | Delete
if(!in_array($posttype, $carr))
[174] Fix | Delete
{
[175] Fix | Delete
$_POST=$_POST_CPY;return;
[176] Fix | Delete
}
[177] Fix | Delete
[178] Fix | Delete
}
[179] Fix | Delete
else
[180] Fix | Delete
{
[181] Fix | Delete
$_POST=$_POST_CPY;return;
[182] Fix | Delete
}
[183] Fix | Delete
[184] Fix | Delete
}
[185] Fix | Delete
$get_post_meta=get_post_meta($post_ID,"xyz_fbap",true);
[186] Fix | Delete
if($get_post_meta!=1)
[187] Fix | Delete
add_post_meta($post_ID, "xyz_fbap", "1");
[188] Fix | Delete
[189] Fix | Delete
include_once ABSPATH.'wp-admin/includes/plugin.php';
[190] Fix | Delete
[191] Fix | Delete
$pluginName = 'bitly/bitly.php';
[192] Fix | Delete
[193] Fix | Delete
if (is_plugin_active($pluginName)) {
[194] Fix | Delete
remove_all_filters('post_link');
[195] Fix | Delete
}
[196] Fix | Delete
$link = get_permalink($postpp->ID);
[197] Fix | Delete
[198] Fix | Delete
[199] Fix | Delete
$xyz_fbap_apply_filters=get_option('xyz_fbap_apply_filters');
[200] Fix | Delete
$ar2=explode(",",$xyz_fbap_apply_filters);
[201] Fix | Delete
$con_flag=$exc_flag=$tit_flag=0;
[202] Fix | Delete
if(isset($ar2))
[203] Fix | Delete
{
[204] Fix | Delete
if(in_array(1, $ar2)) $con_flag=1;
[205] Fix | Delete
if(in_array(2, $ar2)) $exc_flag=1;
[206] Fix | Delete
if(in_array(3, $ar2)) $tit_flag=1;
[207] Fix | Delete
}
[208] Fix | Delete
[209] Fix | Delete
$content = $postpp->post_content;
[210] Fix | Delete
if($con_flag==1)
[211] Fix | Delete
$content = apply_filters('the_content', $content);
[212] Fix | Delete
$content = html_entity_decode($content, ENT_QUOTES, get_bloginfo('charset'));
[213] Fix | Delete
$excerpt = $postpp->post_excerpt;
[214] Fix | Delete
if($exc_flag==1)
[215] Fix | Delete
$excerpt = apply_filters('the_excerpt', $excerpt);
[216] Fix | Delete
$excerpt = html_entity_decode($excerpt, ENT_QUOTES, get_bloginfo('charset'));
[217] Fix | Delete
$content = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $content);
[218] Fix | Delete
$content= preg_replace("/\\[caption.*?\\].*?\\[.caption\\]/is", '', $content);
[219] Fix | Delete
$content = preg_replace('/\[.+?\]/', '', $content);
[220] Fix | Delete
$excerpt = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $excerpt);
[221] Fix | Delete
[222] Fix | Delete
if($excerpt=="")
[223] Fix | Delete
{
[224] Fix | Delete
if($content!="")
[225] Fix | Delete
{
[226] Fix | Delete
$content1=$content;
[227] Fix | Delete
$content1=strip_tags($content1);
[228] Fix | Delete
$content1=strip_shortcodes($content1);
[229] Fix | Delete
[230] Fix | Delete
$excerpt=implode(' ', array_slice(explode(' ', $content1), 0, 50));
[231] Fix | Delete
}
[232] Fix | Delete
}
[233] Fix | Delete
else
[234] Fix | Delete
{
[235] Fix | Delete
$excerpt=strip_tags($excerpt);
[236] Fix | Delete
$excerpt=strip_shortcodes($excerpt);
[237] Fix | Delete
}
[238] Fix | Delete
$description = $content;
[239] Fix | Delete
$description_org=$description;
[240] Fix | Delete
[241] Fix | Delete
$attachmenturl=xyz_fbap_getimage($post_ID, $postpp->post_content);
[242] Fix | Delete
if(!empty($attachmenturl))
[243] Fix | Delete
$image_found=1;
[244] Fix | Delete
else
[245] Fix | Delete
$image_found=0;
[246] Fix | Delete
[247] Fix | Delete
$name = $postpp->post_title;
[248] Fix | Delete
[249] Fix | Delete
$xyz_fbap_caption_for_fb_attachment=get_option('xyz_fbap_caption_for_fb_attachment');
[250] Fix | Delete
[251] Fix | Delete
$caption=get_bloginfo('title');
[252] Fix | Delete
$caption = html_entity_decode($caption, ENT_QUOTES, get_bloginfo('charset'));
[253] Fix | Delete
[254] Fix | Delete
if($tit_flag==1)
[255] Fix | Delete
$name = apply_filters('the_title', $name,$post_ID);
[256] Fix | Delete
$name = html_entity_decode($name, ENT_QUOTES, get_bloginfo('charset'));
[257] Fix | Delete
[258] Fix | Delete
$name=strip_tags($name);
[259] Fix | Delete
$name=strip_shortcodes($name);
[260] Fix | Delete
$description=strip_tags($description);
[261] Fix | Delete
$description=strip_shortcodes($description);
[262] Fix | Delete
$description=str_replace("&nbsp;","",$description);
[263] Fix | Delete
[264] Fix | Delete
$excerpt=str_replace("&nbsp;","",$excerpt);
[265] Fix | Delete
$xyz_fbap_app_sel_mode=get_option('xyz_fbap_app_sel_mode');
[266] Fix | Delete
$fbap_secretkey=get_option('xyz_fbap_secret_key');
[267] Fix | Delete
[268] Fix | Delete
if((($xyz_fbap_app_sel_mode==0 && $useracces_token!="" && $appsecret!="" && $appid!="")|| $xyz_fbap_app_sel_mode==1) && $post_permissin==1 && $af==0 )
[269] Fix | Delete
{
[270] Fix | Delete
$description_li=xyz_fbap_string_limit($description, 10000);
[271] Fix | Delete
if ($xyz_fbap_app_sel_mode==1){
[272] Fix | Delete
$xyz_fbap_page_names=json_decode(stripslashes(get_option('xyz_fbap_page_names')));
[273] Fix | Delete
foreach ($xyz_fbap_page_names as $xyz_fbap_page_id => $xyz_fbap_page_name)
[274] Fix | Delete
{
[275] Fix | Delete
$xyz_fbap_pages_ids1[]=$xyz_fbap_page_id;
[276] Fix | Delete
}
[277] Fix | Delete
}
[278] Fix | Delete
else{
[279] Fix | Delete
$xyz_fbap_pages_ids=get_option('xyz_fbap_pages_ids');
[280] Fix | Delete
[281] Fix | Delete
$xyz_fbap_pages_ids1=explode(",",$xyz_fbap_pages_ids);
[282] Fix | Delete
}
[283] Fix | Delete
$xyz_fbap_clear_fb_cache=get_option('xyz_fbap_clear_fb_cache');
[284] Fix | Delete
[285] Fix | Delete
foreach ($xyz_fbap_pages_ids1 as $key=>$value)
[286] Fix | Delete
{
[287] Fix | Delete
[288] Fix | Delete
if ($xyz_fbap_app_sel_mode==0){
[289] Fix | Delete
$value1=explode("-",$value);
[290] Fix | Delete
$acces_token=$value1[1];$page_id=$value1[0];
[291] Fix | Delete
}
[292] Fix | Delete
else
[293] Fix | Delete
$page_id=$value;
[294] Fix | Delete
[295] Fix | Delete
if ($xyz_fbap_app_sel_mode==0)
[296] Fix | Delete
require_once (dirname(__FILE__) . '/../api/facebook.php');
[297] Fix | Delete
if ($xyz_fbap_clear_fb_cache == 1 && $xyz_fbap_app_sel_mode == 0 && ($posting_method == 1 || $posting_method == 2)) {
[298] Fix | Delete
xyz_fbap_clear_open_graph_cache($link,$acces_token,$appid,$appsecret);
[299] Fix | Delete
}
[300] Fix | Delete
$message1=str_replace('{POST_TITLE}', $name, $message);
[301] Fix | Delete
$message2=str_replace('{BLOG_TITLE}', $caption,$message1);
[302] Fix | Delete
$message3=str_replace('{PERMALINK}', $link, $message2);
[303] Fix | Delete
$message4=str_replace('{POST_EXCERPT}', $excerpt, $message3);
[304] Fix | Delete
$message5=str_replace('{POST_CONTENT}', $description, $message4);
[305] Fix | Delete
$message5=str_replace('{USER_NICENAME}', $user_nicename, $message5);
[306] Fix | Delete
$message5=str_replace('{USER_DISPLAY_NAME}', $user_displayname, $message5);
[307] Fix | Delete
$publish_time=get_the_time(get_option('date_format'),$post_ID );
[308] Fix | Delete
$message5=str_replace('{POST_PUBLISH_DATE}', $publish_time, $message5);
[309] Fix | Delete
$message5=str_replace('{POST_ID}', $post_ID, $message5);
[310] Fix | Delete
$message5=str_replace("&nbsp;","",$message5);
[311] Fix | Delete
[312] Fix | Delete
$disp_type="feed";
[313] Fix | Delete
$fbap_sslverify= get_option('xyz_fbap_peer_verification')=='1' ? true : false;
[314] Fix | Delete
if($posting_method==1) //attach
[315] Fix | Delete
{
[316] Fix | Delete
$attachment = array('message' => $message5, 'link' => $link, 'actions' => json_encode(array('name' => $name, 'link' => $link)));
[317] Fix | Delete
[318] Fix | Delete
} else if ($posting_method == 2) //share link
[319] Fix | Delete
{
[320] Fix | Delete
$attachment = array('message' => $message5, 'link' => $link);
[321] Fix | Delete
[322] Fix | Delete
} else if ($posting_method == 3) //simple text message
[323] Fix | Delete
{
[324] Fix | Delete
$attachment = array('message' => $message5);
[325] Fix | Delete
[326] Fix | Delete
[327] Fix | Delete
} else if ($posting_method == 4 || $posting_method == 5) //text message with image 4 - app album, 5-timeline
[328] Fix | Delete
{
[329] Fix | Delete
if (!empty($attachmenturl)) {
[330] Fix | Delete
if ($xyz_fbap_app_sel_mode == 0) {
[331] Fix | Delete
try{
[332] Fix | Delete
$album_fount=0;
[333] Fix | Delete
$error_net = 0;
[334] Fix | Delete
$xyz_fb_params[0] = $page_id;
[335] Fix | Delete
$xyz_fb_params[1] = 'albums';
[336] Fix | Delete
$xyz_fb_params[2] = $acces_token;
[337] Fix | Delete
$xyz_fb_params[3] = $fbap_sslverify;
[338] Fix | Delete
$xyz_fb_params_enc = json_encode($xyz_fb_params);
[339] Fix | Delete
$result = xyz_fbap_get_album($xyz_fb_params_enc);
[340] Fix | Delete
$result = json_decode($result, true);
[341] Fix | Delete
if (isset($result['error']['message'])) $fb_publish_status[].= "<span style=\"color:red\"> " . $page_id . "/" . $disp_type . "/" . ($result['error']['message']) . "<br/>";
[342] Fix | Delete
[343] Fix | Delete
}
[344] Fix | Delete
catch(Exception $e) {
[345] Fix | Delete
$fb_publish_status[$page_id."/albums"]=$e->getMessage();
[346] Fix | Delete
}
[347] Fix | Delete
if (isset($result)) {
[348] Fix | Delete
if ($posting_method == 5) {
[349] Fix | Delete
foreach ($result['data'] as $album) {
[350] Fix | Delete
if (isset($album['name']) && $album['name'] == "Timeline photos") {
[351] Fix | Delete
$album_fount = 1;
[352] Fix | Delete
$timeline_album = $album;
[353] Fix | Delete
break;
[354] Fix | Delete
}
[355] Fix | Delete
}
[356] Fix | Delete
if (isset($timeline_album) && isset($timeline_album['id'])) $page_id = $timeline_album['id'];
[357] Fix | Delete
[358] Fix | Delete
if ($album_fount == 0) $fb_publish_status[$page_id . "/albums"] = '<span style=\"color:red\">Invalid album name<span><br>';
[359] Fix | Delete
} else {
[360] Fix | Delete
[361] Fix | Delete
[362] Fix | Delete
foreach ($result['data'] as $album) if (isset($album['name']) && $album['name'] == $app_name) {
[363] Fix | Delete
$album_fount=1;
[364] Fix | Delete
$app_album = $album;
[365] Fix | Delete
break;
[366] Fix | Delete
}
[367] Fix | Delete
[368] Fix | Delete
if (isset($app_album) && isset($app_album['id'])) $page_id = $app_album['id'];
[369] Fix | Delete
if ($album_fount == 0) $fb_publish_status[$page_id . "/albums"] = '<span style=\"color:red\">Invalid album name<span>';
[370] Fix | Delete
}
[371] Fix | Delete
} else {
[372] Fix | Delete
$error_net = 1;
[373] Fix | Delete
[374] Fix | Delete
$fb_publish_status[].= "<span style=\"color:red\"> " . $page_id . "/" . $disp_type . "/Check network connection <br/>";
[375] Fix | Delete
}
[376] Fix | Delete
}
[377] Fix | Delete
[378] Fix | Delete
$disp_type="photos";
[379] Fix | Delete
$attachment = array('message' => $message5, 'url' => $attachmenturl);
[380] Fix | Delete
[381] Fix | Delete
} else {
[382] Fix | Delete
$attachment = array('message' => $message5);
[383] Fix | Delete
[384] Fix | Delete
}
[385] Fix | Delete
[386] Fix | Delete
}
[387] Fix | Delete
if ($posting_method == 1 || $posting_method == 2) {
[388] Fix | Delete
[389] Fix | Delete
update_post_meta($post_ID, "xyz_fbap_insert_og", "1");
[390] Fix | Delete
}
[391] Fix | Delete
try{
[392] Fix | Delete
[393] Fix | Delete
if ($xyz_fbap_app_sel_mode == 1) {
[394] Fix | Delete
$post_id_string="";
[395] Fix | Delete
$fbap_smapsoln_userid=get_option('xyz_fbap_smapsoln_userid');
[396] Fix | Delete
$xyz_fbap_secret_key=get_option('xyz_fbap_secret_key');
[397] Fix | Delete
$xyz_fbap_fb_numericid=get_option('xyz_fbap_fb_numericid');
[398] Fix | Delete
$xyz_fbap_xyzscripts_userid=get_option('xyz_fbap_xyzscripts_user_id');
[399] Fix | Delete
$post_details=array('xyz_smap_userid'=>$fbap_smapsoln_userid,//smap_id
[400] Fix | Delete
'xyz_smap_attachment' => $attachment, 'xyz_smap_disp_type' => $disp_type, 'xyz_smap_posting_method' => $posting_method, 'xyz_smap_page_id' => $page_id, 'xyz_smap_app_name' => $app_name,
[401] Fix | Delete
//'xyz_smap_secret_key' =>$xyz_fbap_secret_key,
[402] Fix | Delete
'xyz_fb_numericid' => $xyz_fbap_fb_numericid, 'xyz_smap_xyzscripts_userid' => $xyz_fbap_xyzscripts_userid, 'xyz_smap_clear_fb_cache' => $xyz_fbap_clear_fb_cache);
[403] Fix | Delete
$url=XYZ_SMAP_SOLUTION_PUBLISH_URL.'api/facebook.php';
[404] Fix | Delete
$result_smap_solns=xyz_fbap_post_to_smap_api($post_details,$url,$xyz_fbap_secret_key);
[405] Fix | Delete
$result_smap_solns=json_decode($result_smap_solns);
[406] Fix | Delete
if (!empty($result_smap_solns)) {
[407] Fix | Delete
$fb_api_count_returned=$result_smap_solns->fb_api_count;
[408] Fix | Delete
if ($result_smap_solns->status == 0) $fb_publish_status[].= "<span style=\"color:red\"> " . $page_id . "/" . $disp_type . "/" . $result_smap_solns->msg . "</span><br/><span style=\"color:#21759B\">No. of api calls used: " . $fb_api_count_returned . "</span><br/>";
[409] Fix | Delete
elseif ($result_smap_solns->status==1){
[410] Fix | Delete
[411] Fix | Delete
if (isset($result_smap_solns->postid) && !empty($result_smap_solns->postid)){
[412] Fix | Delete
[413] Fix | Delete
$fb_postid =$result_smap_solns->postid;
[414] Fix | Delete
if (strpos($fb_postid, '_') !== false) {
[415] Fix | Delete
$fb_post_id_explode=explode('_', $fb_postid);
[416] Fix | Delete
$link_to_fb_post='https://www.facebook.com/'.$fb_post_id_explode[0].'_'.$fb_post_id_explode[1];
[417] Fix | Delete
} else {
[418] Fix | Delete
$link_to_fb_post='https://www.facebook.com/'.$page_id.'_'.$fb_postid;
[419] Fix | Delete
}
[420] Fix | Delete
$post_id_string="<span style=\"color:#21759B;text-decoration:underline;\"><a target=\"_blank\" href=".$link_to_fb_post.">View Post</a></span>";
[421] Fix | Delete
}
[422] Fix | Delete
[423] Fix | Delete
$fb_publish_status[].="<span style=\"color:green\"> ".$page_id."/".$disp_type."/".$result_smap_solns->msg."</span><br/><span style=\"color:#21759B\">No. of api calls used: ".$fb_api_count_returned."</span><br/>".$post_id_string;
[424] Fix | Delete
}
[425] Fix | Delete
[426] Fix | Delete
}
[427] Fix | Delete
} else {
[428] Fix | Delete
$attachment['access_token']=$acces_token;
[429] Fix | Delete
$xyz_fb_params[0] = $page_id;
[430] Fix | Delete
$xyz_fb_params[1] = $disp_type;
[431] Fix | Delete
$xyz_fb_params[2] = $attachment;
[432] Fix | Delete
$xyz_fb_params[3] = $fbap_sslverify;
[433] Fix | Delete
$xyz_fb_params_enc = json_encode($xyz_fb_params);
[434] Fix | Delete
$result = xyz_fbap_make_fb_post($xyz_fb_params_enc);
[435] Fix | Delete
$result = json_decode($result, true);
[436] Fix | Delete
if (isset($result['error']['message'])) {
[437] Fix | Delete
$fb_publish_status[].= "<span style=\"color:red\"> " . $page_id . "/" . $disp_type . "/" . ($result['error']['message']) . "<br/>";
[438] Fix | Delete
}
[439] Fix | Delete
$post_id_string_from_ownApp='';
[440] Fix | Delete
if (!empty($result)) {
[441] Fix | Delete
$fb_postid = $result['id'];
[442] Fix | Delete
if (!empty($fb_postid)){
[443] Fix | Delete
if (strpos($fb_postid, '_') !== false) {
[444] Fix | Delete
$fb_post_id_explode=explode('_', $fb_postid);
[445] Fix | Delete
$link_to_fb_post='https://www.facebook.com/'.$fb_post_id_explode[0].'_'.$fb_post_id_explode[1];
[446] Fix | Delete
} else {
[447] Fix | Delete
$link_to_fb_post='https://www.facebook.com/'.$page_id.'_'.$fb_postid;
[448] Fix | Delete
}
[449] Fix | Delete
$post_id_string_from_ownApp="<span style=\"color:#21759B;text-decoration:underline;\"><a target=\"_blank\" href=".$link_to_fb_post."> View Post</a></span>";
[450] Fix | Delete
$fb_publish_status[]="<span style=\"color:green\">Success</span><br/>".$post_id_string_from_ownApp;
[451] Fix | Delete
}
[452] Fix | Delete
} else if ($error_net != 1) $fb_publish_status[].= "<span style=\"color:red\"> " . $page_id . "/" . $disp_type . "/Check network connection <br/>";
[453] Fix | Delete
}
[454] Fix | Delete
}
[455] Fix | Delete
catch(Exception $e) {
[456] Fix | Delete
$fb_publish_status[]="<span style=\"color:red\"> ".$page_id."/".$disp_type."/".$e->getMessage()."</span><br/>";
[457] Fix | Delete
}
[458] Fix | Delete
[459] Fix | Delete
}
[460] Fix | Delete
[461] Fix | Delete
[462] Fix | Delete
if (count($fb_publish_status) > 0) $fb_publish_status_insert = serialize($fb_publish_status);
[463] Fix | Delete
else{
[464] Fix | Delete
$fb_publish_status[]="<span style=\"color:green\">Success</span><br/>".$post_id_string_from_ownApp;
[465] Fix | Delete
$fb_publish_status_insert=serialize($fb_publish_status);
[466] Fix | Delete
}
[467] Fix | Delete
[468] Fix | Delete
$time=time();
[469] Fix | Delete
$post_fb_options = array('postid' => $post_ID, 'acc_type' => "Facebook", 'publishtime' => $time, 'status' => $fb_publish_status_insert,);
[470] Fix | Delete
[471] Fix | Delete
$update_opt_array=array();
[472] Fix | Delete
[473] Fix | Delete
$arr_retrive=(get_option('xyz_fbap_post_logs'));
[474] Fix | Delete
[475] Fix | Delete
$update_opt_array[0]=isset($arr_retrive[0]) ? $arr_retrive[0] : '';
[476] Fix | Delete
$update_opt_array[1]=isset($arr_retrive[1]) ? $arr_retrive[1] : '';
[477] Fix | Delete
$update_opt_array[2]=isset($arr_retrive[2]) ? $arr_retrive[2] : '';
[478] Fix | Delete
$update_opt_array[3]=isset($arr_retrive[3]) ? $arr_retrive[3] : '';
[479] Fix | Delete
$update_opt_array[4]=isset($arr_retrive[4]) ? $arr_retrive[4] : '';
[480] Fix | Delete
[481] Fix | Delete
$update_opt_array[5]=isset($arr_retrive[5]) ? $arr_retrive[5] : '';
[482] Fix | Delete
$update_opt_array[6]=isset($arr_retrive[6]) ? $arr_retrive[6] : '';
[483] Fix | Delete
$update_opt_array[7]=isset($arr_retrive[7]) ? $arr_retrive[7] : '';
[484] Fix | Delete
$update_opt_array[8]=isset($arr_retrive[8]) ? $arr_retrive[8] : '';
[485] Fix | Delete
$update_opt_array[9]=isset($arr_retrive[9]) ? $arr_retrive[9] : '';
[486] Fix | Delete
array_shift($update_opt_array);
[487] Fix | Delete
array_push($update_opt_array,$post_fb_options);
[488] Fix | Delete
update_option('xyz_fbap_post_logs', $update_opt_array);
[489] Fix | Delete
[490] Fix | Delete
[491] Fix | Delete
}
[492] Fix | Delete
[493] Fix | Delete
}
[494] Fix | Delete
[495] Fix | Delete
$_POST=$_POST_CPY;
[496] Fix | Delete
}
[497] Fix | Delete
?>
[498] Fix | Delete
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function