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/wp-conte.../plugins/twitter-.../admin
File: publish.php
<?php
[0] Fix | Delete
if( !defined('ABSPATH') ){ exit();}
[1] Fix | Delete
/*add_action('publish_post', 'xyz_twap_link_publish');
[2] Fix | Delete
add_action('publish_page', 'xyz_twap_link_publish');
[3] Fix | Delete
$xyz_twap_future_to_publish=get_option('xyz_twap_future_to_publish');
[4] Fix | Delete
[5] Fix | Delete
if($xyz_twap_future_to_publish==1)
[6] Fix | Delete
add_action('future_to_publish', 'xyz_link_twap_future_to_publish');
[7] Fix | Delete
[8] Fix | Delete
function xyz_link_twap_future_to_publish($post){
[9] Fix | Delete
$postid =$post->ID;
[10] Fix | Delete
xyz_twap_link_publish($postid);
[11] Fix | Delete
}*/
[12] Fix | Delete
///////////////////////////////////////////////////////////////
[13] Fix | Delete
add_action( 'transition_post_status', 'xyz_link_twap_future_to_publish', 10, 3 );
[14] Fix | Delete
[15] Fix | Delete
function xyz_link_twap_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
if(!isset($GLOBALS['twap_dup_publish']))
[20] Fix | Delete
$GLOBALS['twap_dup_publish']=array();
[21] Fix | Delete
[22] Fix | Delete
$postid =$post->ID;
[23] Fix | Delete
$get_post_meta=get_post_meta($postid,"xyz_twap",true);
[24] Fix | Delete
[25] Fix | Delete
$post_twitter_permission=get_option('xyz_twap_twpost_permission');
[26] Fix | Delete
if(isset($_POST['xyz_twap_twpost_permission'])){
[27] Fix | Delete
$post_twitter_permission=$_POST['xyz_twap_twpost_permission'];
[28] Fix | Delete
if ( (isset($_POST['xyz_twap_twpost_permission']) && isset($_POST['xyz_twap_twpost_image_permission'])) )
[29] Fix | Delete
{
[30] Fix | Delete
$futToPubDataArray=array( 'xyz_twap_twpost_permission' => $_POST['xyz_twap_twpost_permission'],
[31] Fix | Delete
'xyz_twap_twpost_image_permission' => $_POST['xyz_twap_twpost_image_permission'],
[32] Fix | Delete
'xyz_twap_twmessage' => $_POST['xyz_twap_twmessage']);
[33] Fix | Delete
update_post_meta($postid, "xyz_twap_future_to_publish", $futToPubDataArray);
[34] Fix | Delete
}
[35] Fix | Delete
}
[36] Fix | Delete
else
[37] Fix | Delete
{
[38] Fix | Delete
if ($post_twitter_permission == 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_twitter_permission == 1)
[49] Fix | Delete
{
[50] Fix | Delete
if($new_status == 'publish')
[51] Fix | Delete
{
[52] Fix | Delete
if(!in_array($postid,$GLOBALS['twap_dup_publish'])) {
[53] Fix | Delete
$GLOBALS['twap_dup_publish'][]=$postid;
[54] Fix | Delete
xyz_twap_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
////////////////////////////////////////////////////////////////////////////////////
[64] Fix | Delete
/*$xyz_twap_include_customposttypes=get_option('xyz_twap_include_customposttypes');
[65] Fix | Delete
$carr=explode(',', $xyz_twap_include_customposttypes);
[66] Fix | Delete
foreach ($carr as $cstyps ) {
[67] Fix | Delete
add_action('publish_'.$cstyps, 'xyz_twap_link_publish');
[68] Fix | Delete
[69] Fix | Delete
}
[70] Fix | Delete
*/
[71] Fix | Delete
[72] Fix | Delete
function xyz_twap_link_publish($post_ID) {
[73] Fix | Delete
$_POST_CPY=$_POST;
[74] Fix | Delete
$_POST=stripslashes_deep($_POST);
[75] Fix | Delete
$post_twitter_image_permission=0;$messagetopost='';
[76] Fix | Delete
$get_post_meta_future_data=get_post_meta($post_ID,"xyz_twap_future_to_publish",true);
[77] Fix | Delete
$post_twitter_permission=get_option('xyz_twap_twpost_permission');
[78] Fix | Delete
if(isset($_POST['xyz_twap_twpost_permission']))
[79] Fix | Delete
$post_twitter_permission=$_POST['xyz_twap_twpost_permission'];
[80] Fix | Delete
elseif(!empty($get_post_meta_future_data) && get_option('xyz_twap_default_selection_edit')==2 )///select values from post meta
[81] Fix | Delete
{
[82] Fix | Delete
$post_twitter_permission=$get_post_meta_future_data['xyz_twap_twpost_permission'];
[83] Fix | Delete
$post_twitter_image_permission=$get_post_meta_future_data['xyz_twap_twpost_image_permission'];
[84] Fix | Delete
$messagetopost=$get_post_meta_future_data['xyz_twap_twmessage'];
[85] Fix | Delete
}
[86] Fix | Delete
if ($post_twitter_permission != 1) {
[87] Fix | Delete
$_POST=$_POST_CPY;
[88] Fix | Delete
return ;
[89] Fix | Delete
} else if(( (isset($_POST['_inline_edit'])) || (isset($_REQUEST['bulk_edit'])) ) && (get_option('xyz_twap_default_selection_edit') == 0) ) {
[90] Fix | Delete
$_POST=$_POST_CPY;
[91] Fix | Delete
return;
[92] Fix | Delete
}
[93] Fix | Delete
global $current_user;
[94] Fix | Delete
wp_get_current_user();
[95] Fix | Delete
//$af=get_option('xyz_twap_af');
[96] Fix | Delete
[97] Fix | Delete
[98] Fix | Delete
/////////////twitter//////////
[99] Fix | Delete
$tappid=get_option('xyz_twap_twconsumer_id');
[100] Fix | Delete
$tappsecret=get_option('xyz_twap_twconsumer_secret');
[101] Fix | Delete
$twid=get_option('xyz_twap_tw_id');
[102] Fix | Delete
$taccess_token=get_option('xyz_twap_current_twappln_token');
[103] Fix | Delete
$taccess_token_secret=get_option('xyz_twap_twaccestok_secret');
[104] Fix | Delete
$xyz_twap_tw_app_sel_mode=get_option('xyz_twap_tw_app_sel_mode');
[105] Fix | Delete
$xyz_twap_smapsoln_userid=get_option('xyz_twap_smapsoln_userid');
[106] Fix | Delete
$xyz_twap_smapsoln_secret_key=get_option('xyz_twap_smapsoln_secret_key');
[107] Fix | Delete
$xyz_twap_xyzscripts_user_id=get_option('xyz_twap_xyzscripts_user_id');
[108] Fix | Delete
$xyz_twap_xyzscripts_hash_val=get_option('xyz_twap_xyzscripts_hash_val');
[109] Fix | Delete
if ($messagetopost=='')
[110] Fix | Delete
$messagetopost=get_option('xyz_twap_twmessage');
[111] Fix | Delete
if(isset($_POST['xyz_twap_twmessage']))
[112] Fix | Delete
$messagetopost=$_POST['xyz_twap_twmessage'];
[113] Fix | Delete
[114] Fix | Delete
if ($post_twitter_image_permission==0)
[115] Fix | Delete
$post_twitter_image_permission=get_option('xyz_twap_twpost_image_permission');
[116] Fix | Delete
if(isset($_POST['xyz_twap_twpost_image_permission']))
[117] Fix | Delete
$post_twitter_image_permission=$_POST['xyz_twap_twpost_image_permission'];
[118] Fix | Delete
[119] Fix | Delete
[120] Fix | Delete
$postpp= get_post($post_ID);global $wpdb;
[121] Fix | Delete
$reg_exUrl = "/(http|https)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";
[122] Fix | Delete
$entries0 = $wpdb->get_results($wpdb->prepare( 'SELECT user_nicename,display_name FROM '.$wpdb->base_prefix.'users WHERE ID=%d',$postpp->post_author));
[123] Fix | Delete
foreach( $entries0 as $entry ) {
[124] Fix | Delete
$user_nicename=$entry->user_nicename;
[125] Fix | Delete
$user_displayname=$entry->display_name;
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
if ($postpp->post_status == 'publish')
[129] Fix | Delete
{
[130] Fix | Delete
$posttype=$postpp->post_type;
[131] Fix | Delete
if ($posttype=="page")
[132] Fix | Delete
{
[133] Fix | Delete
$xyz_twap_include_pages=get_option('xyz_twap_include_pages');
[134] Fix | Delete
if($xyz_twap_include_pages==0)
[135] Fix | Delete
{
[136] Fix | Delete
$_POST=$_POST_CPY;return;
[137] Fix | Delete
}
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
else if($posttype=="post")
[141] Fix | Delete
{
[142] Fix | Delete
$xyz_twap_include_posts=get_option('xyz_twap_include_posts');
[143] Fix | Delete
if($xyz_twap_include_posts==0)
[144] Fix | Delete
{
[145] Fix | Delete
$_POST=$_POST_CPY;return;
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
$xyz_twap_include_categories=get_option('xyz_twap_include_categories');
[149] Fix | Delete
if($xyz_twap_include_categories!="All")
[150] Fix | Delete
{
[151] Fix | Delete
$carr1=explode(',', $xyz_twap_include_categories);
[152] Fix | Delete
$defaults = array('fields' => 'ids');
[153] Fix | Delete
$carr2=wp_get_post_categories( $post_ID, $defaults );
[154] Fix | Delete
$retflag=1;
[155] Fix | Delete
foreach ($carr2 as $key=>$catg_ids)
[156] Fix | Delete
{
[157] Fix | Delete
if(in_array($catg_ids, $carr1))
[158] Fix | Delete
$retflag=0;
[159] Fix | Delete
}
[160] Fix | Delete
[161] Fix | Delete
[162] Fix | Delete
if($retflag==1)
[163] Fix | Delete
{$_POST=$_POST_CPY;return;}
[164] Fix | Delete
}
[165] Fix | Delete
}
[166] Fix | Delete
else
[167] Fix | Delete
{
[168] Fix | Delete
[169] Fix | Delete
$xyz_twap_include_customposttypes=get_option('xyz_twap_include_customposttypes');
[170] Fix | Delete
if($xyz_twap_include_customposttypes!='')
[171] Fix | Delete
{
[172] Fix | Delete
[173] Fix | Delete
$carr=explode(',', $xyz_twap_include_customposttypes);
[174] Fix | Delete
[175] Fix | Delete
if(!in_array($posttype, $carr))
[176] Fix | Delete
{
[177] Fix | Delete
$_POST=$_POST_CPY;return;
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
}
[181] Fix | Delete
else
[182] Fix | Delete
{
[183] Fix | Delete
$_POST=$_POST_CPY;return;
[184] Fix | Delete
}
[185] Fix | Delete
[186] Fix | Delete
}
[187] Fix | Delete
[188] Fix | Delete
$get_post_meta=get_post_meta($post_ID,"xyz_twap",true);
[189] Fix | Delete
if($get_post_meta!=1)
[190] Fix | Delete
add_post_meta($post_ID, "xyz_twap", "1");
[191] Fix | Delete
include_once ABSPATH.'wp-admin/includes/plugin.php';
[192] Fix | Delete
$pluginName = 'bitly/bitly.php';
[193] Fix | Delete
[194] Fix | Delete
if (is_plugin_active($pluginName)) {
[195] Fix | Delete
remove_all_filters('post_link');
[196] Fix | Delete
}
[197] Fix | Delete
$link = get_permalink($postpp->ID);
[198] Fix | Delete
[199] Fix | Delete
[200] Fix | Delete
$xyz_twap_apply_filters=get_option('xyz_twap_apply_filters');
[201] Fix | Delete
$ar2=explode(",",$xyz_twap_apply_filters);
[202] Fix | Delete
$con_flag=$exc_flag=$tit_flag=0;
[203] Fix | Delete
if(isset($ar2))
[204] Fix | Delete
{
[205] Fix | Delete
if(in_array(1, $ar2)) $con_flag=1;
[206] Fix | Delete
if(in_array(2, $ar2)) $exc_flag=1;
[207] Fix | Delete
if(in_array(3, $ar2)) $tit_flag=1;
[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
[213] Fix | Delete
$content = html_entity_decode($content, ENT_QUOTES, get_bloginfo('charset'));
[214] Fix | Delete
$excerpt = $postpp->post_excerpt;
[215] Fix | Delete
if($exc_flag==1)
[216] Fix | Delete
$excerpt = apply_filters('the_excerpt', $excerpt);
[217] Fix | Delete
[218] Fix | Delete
$excerpt = html_entity_decode($excerpt, ENT_QUOTES, get_bloginfo('charset'));
[219] Fix | Delete
$content = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $content);
[220] Fix | Delete
$content= preg_replace("/\\[caption.*?\\].*?\\[.caption\\]/is","", $content);
[221] Fix | Delete
$content = preg_replace('/\[.+?\]/', '', $content);
[222] Fix | Delete
$excerpt = preg_replace('/<script\b[^>]*>(.*?)<\/script>/is', "", $excerpt);
[223] Fix | Delete
[224] Fix | Delete
if($excerpt=="")
[225] Fix | Delete
{
[226] Fix | Delete
if($content!="")
[227] Fix | Delete
{
[228] Fix | Delete
$content1=$content;
[229] Fix | Delete
$content1=strip_tags($content1);
[230] Fix | Delete
$content1=strip_shortcodes($content1);
[231] Fix | Delete
[232] Fix | Delete
$excerpt=implode(' ', array_slice(explode(' ', $content1), 0, 50));
[233] Fix | Delete
}
[234] Fix | Delete
}
[235] Fix | Delete
else
[236] Fix | Delete
{
[237] Fix | Delete
$excerpt=strip_tags($excerpt);
[238] Fix | Delete
$excerpt=strip_shortcodes($excerpt);
[239] Fix | Delete
}
[240] Fix | Delete
$description = $content;
[241] Fix | Delete
[242] Fix | Delete
$description_org=$description;
[243] Fix | Delete
$attachmenturl=xyz_twap_getimage($post_ID, $postpp->post_content);
[244] Fix | Delete
if(!empty($attachmenturl))
[245] Fix | Delete
$image_found=1;
[246] Fix | Delete
else
[247] Fix | Delete
$image_found=0;
[248] Fix | Delete
[249] Fix | Delete
$name = $postpp->post_title;
[250] Fix | Delete
$caption = html_entity_decode(get_bloginfo('title'), ENT_QUOTES, get_bloginfo('charset'));
[251] Fix | Delete
[252] Fix | Delete
if($tit_flag==1)
[253] Fix | Delete
$name = apply_filters('the_title', $name,$post_ID);
[254] Fix | Delete
[255] Fix | Delete
$name = html_entity_decode($name, ENT_QUOTES, get_bloginfo('charset'));
[256] Fix | Delete
$name=strip_tags($name);
[257] Fix | Delete
$name=strip_shortcodes($name);
[258] Fix | Delete
[259] Fix | Delete
$description=strip_tags($description);
[260] Fix | Delete
$description=strip_shortcodes($description);
[261] Fix | Delete
[262] Fix | Delete
$description=str_replace("&nbsp;","",$description);
[263] Fix | Delete
[264] Fix | Delete
$excerpt=str_replace("&nbsp;","",$excerpt);
[265] Fix | Delete
[266] Fix | Delete
[267] Fix | Delete
if((($xyz_twap_tw_app_sel_mode==1 && !empty($xyz_twap_smapsoln_userid) && !empty($xyz_twap_smapsoln_secret_key) ) || ($taccess_token!="" && $taccess_token_secret!="" && $tappid!="" && $tappsecret!="" && $xyz_twap_tw_app_sel_mode==0) ) && $post_twitter_permission==1)
[268] Fix | Delete
{
[269] Fix | Delete
[270] Fix | Delete
////image up start///
[271] Fix | Delete
$api_exceed_err=0;$remaining_tw_api_count=0;$tw_api_count=0;
[272] Fix | Delete
$img_status="";
[273] Fix | Delete
if($post_twitter_image_permission==1)
[274] Fix | Delete
{
[275] Fix | Delete
update_post_meta($post_ID, "xyz_twap_insert_twitter_card", "1");
[276] Fix | Delete
[277] Fix | Delete
$img=array();
[278] Fix | Delete
if(!empty($attachmenturl))
[279] Fix | Delete
$img = wp_remote_get($attachmenturl,array('sslverify'=> (get_option('xyz_twap_peer_verification')=='1') ? true : false));
[280] Fix | Delete
[281] Fix | Delete
if(is_array($img) && ! is_wp_error( $img ) )
[282] Fix | Delete
{
[283] Fix | Delete
if (isset($img['body'])&& trim($img['body'])!='')
[284] Fix | Delete
{
[285] Fix | Delete
$image_found = 1;
[286] Fix | Delete
if (($img['headers']['content-length']) && trim($img['headers']['content-length'])!='')
[287] Fix | Delete
{
[288] Fix | Delete
$img_size=$img['headers']['content-length']/(1024*1024);
[289] Fix | Delete
if($img_size>3){
[290] Fix | Delete
$image_found=0;$img_status="Image skipped(greater than 3MB)";
[291] Fix | Delete
$image_found = 0;
[292] Fix | Delete
}
[293] Fix | Delete
}
[294] Fix | Delete
[295] Fix | Delete
$img = $img['body'];
[296] Fix | Delete
///////////////////////Create temp folder ß
[297] Fix | Delete
$wp_twap_img_targetfolder = realpath(dirname(__FILE__) . '/../../../')."/uploads/xyz_twap_temp_images";
[298] Fix | Delete
if (file_exists($wp_twap_img_targetfolder)==false)
[299] Fix | Delete
{
[300] Fix | Delete
if (mkdir($wp_twap_img_targetfolder, 0777, true))
[301] Fix | Delete
{
[302] Fix | Delete
chmod($wp_twap_img_targetfolder,0777);
[303] Fix | Delete
}
[304] Fix | Delete
}
[305] Fix | Delete
////////////upload image to temporary folder and get path
[306] Fix | Delete
$xyz_twap_ext = pathinfo($attachmenturl, PATHINFO_EXTENSION);
[307] Fix | Delete
$xyz_twap_filename=pathinfo($attachmenturl, PATHINFO_FILENAME);
[308] Fix | Delete
$xyz_twap_image_files=$wp_twap_img_targetfolder."/".$xyz_twap_filename.".".$xyz_twap_ext;
[309] Fix | Delete
file_put_contents($xyz_twap_image_files, $img);
[310] Fix | Delete
[311] Fix | Delete
////////////////////////////
[312] Fix | Delete
}
[313] Fix | Delete
else
[314] Fix | Delete
$image_found = 0;
[315] Fix | Delete
}
[316] Fix | Delete
else
[317] Fix | Delete
$image_found = 0;
[318] Fix | Delete
[319] Fix | Delete
}
[320] Fix | Delete
///Twitter upload image end/////
[321] Fix | Delete
$messagetopost=str_replace("&nbsp;","",$messagetopost);
[322] Fix | Delete
[323] Fix | Delete
$substring="";$islink=0;$issubstr=0;
[324] Fix | Delete
[325] Fix | Delete
$substring=str_replace('{POST_TITLE}', $name, $messagetopost);
[326] Fix | Delete
$substring=str_replace('{BLOG_TITLE}', $caption,$substring);
[327] Fix | Delete
$substring=str_replace('{PERMALINK}', ' '.$link.' ', $substring);
[328] Fix | Delete
$substring=str_replace('{POST_EXCERPT}', $excerpt, $substring);
[329] Fix | Delete
$substring=str_replace('{POST_CONTENT}', $description, $substring);
[330] Fix | Delete
$substring=str_replace('{USER_NICENAME}', $user_nicename, $substring);
[331] Fix | Delete
$substring=str_replace('{USER_DISPLAY_NAME}', $user_displayname, $substring);
[332] Fix | Delete
$publish_time=get_the_time(get_option('date_format'),$post_ID );
[333] Fix | Delete
$substring=str_replace('{POST_PUBLISH_DATE}', $publish_time, $substring);
[334] Fix | Delete
$substring=str_replace('{POST_ID}', $post_ID, $substring);
[335] Fix | Delete
preg_match_all($reg_exUrl,$substring,$matches); // @ is same as /
[336] Fix | Delete
[337] Fix | Delete
if(is_array($matches) && isset($matches[0]))
[338] Fix | Delete
{
[339] Fix | Delete
$matches=$matches[0];
[340] Fix | Delete
$final_str='';
[341] Fix | Delete
$len=0;
[342] Fix | Delete
$tw_max_len=get_option('xyz_twap_tw_char_limit');
[343] Fix | Delete
if (function_exists('mb_strlen') && function_exists('mb_substr') && function_exists('mb_strpos')) {
[344] Fix | Delete
foreach ($matches as $key=>$val)
[345] Fix | Delete
{
[346] Fix | Delete
$url_max_len=23;//23 for https and 22 for http
[347] Fix | Delete
$messagepart=mb_substr($substring, 0, mb_strpos($substring, $val));
[348] Fix | Delete
[349] Fix | Delete
if(mb_strlen($messagepart)>($tw_max_len-$len))
[350] Fix | Delete
{
[351] Fix | Delete
$final_str.=mb_substr($messagepart,0,$tw_max_len-$len-3)."...";
[352] Fix | Delete
$len+=($tw_max_len-$len);
[353] Fix | Delete
break;
[354] Fix | Delete
}
[355] Fix | Delete
else
[356] Fix | Delete
{
[357] Fix | Delete
$final_str.=$messagepart;
[358] Fix | Delete
$len+=mb_strlen($messagepart);
[359] Fix | Delete
}
[360] Fix | Delete
[361] Fix | Delete
$cur_url_len=mb_strlen($val);
[362] Fix | Delete
if(mb_strlen($val)>$url_max_len)
[363] Fix | Delete
$cur_url_len=$url_max_len;
[364] Fix | Delete
[365] Fix | Delete
$substring=mb_substr($substring, mb_strpos($substring, $val)+strlen($val));
[366] Fix | Delete
if($cur_url_len>($tw_max_len-$len))
[367] Fix | Delete
{
[368] Fix | Delete
$final_str.="...";
[369] Fix | Delete
$len+=3;
[370] Fix | Delete
break;
[371] Fix | Delete
}
[372] Fix | Delete
else
[373] Fix | Delete
{
[374] Fix | Delete
$final_str.=$val;
[375] Fix | Delete
$len+=$cur_url_len;
[376] Fix | Delete
}
[377] Fix | Delete
}
[378] Fix | Delete
[379] Fix | Delete
if(mb_strlen($substring)>0 && $tw_max_len>$len)
[380] Fix | Delete
{
[381] Fix | Delete
[382] Fix | Delete
if(mb_strlen($substring)>($tw_max_len-$len))
[383] Fix | Delete
{
[384] Fix | Delete
$final_str.=mb_substr($substring,0,$tw_max_len-$len-3)."...";
[385] Fix | Delete
}
[386] Fix | Delete
else
[387] Fix | Delete
{
[388] Fix | Delete
$final_str.=$substring;
[389] Fix | Delete
}
[390] Fix | Delete
}
[391] Fix | Delete
}
[392] Fix | Delete
else {
[393] Fix | Delete
foreach ($matches as $key=>$val)
[394] Fix | Delete
{
[395] Fix | Delete
[396] Fix | Delete
$url_max_len=23;
[397] Fix | Delete
$messagepart=substr($substring, 0, strpos($substring, $val));
[398] Fix | Delete
[399] Fix | Delete
if(strlen($messagepart)>($tw_max_len-$len))
[400] Fix | Delete
{
[401] Fix | Delete
$final_str.=substr($messagepart,0,$tw_max_len-$len-3)."...";
[402] Fix | Delete
$len+=($tw_max_len-$len);
[403] Fix | Delete
break;
[404] Fix | Delete
}
[405] Fix | Delete
else
[406] Fix | Delete
{
[407] Fix | Delete
$final_str.=$messagepart;
[408] Fix | Delete
$len+=strlen($messagepart);
[409] Fix | Delete
}
[410] Fix | Delete
[411] Fix | Delete
$cur_url_len=strlen($val);
[412] Fix | Delete
if(strlen($val)>$url_max_len)
[413] Fix | Delete
$cur_url_len=$url_max_len;
[414] Fix | Delete
[415] Fix | Delete
$substring=substr($substring, strpos($substring, $val)+strlen($val));
[416] Fix | Delete
if($cur_url_len>($tw_max_len-$len))
[417] Fix | Delete
{
[418] Fix | Delete
$final_str.="...";
[419] Fix | Delete
$len+=3;
[420] Fix | Delete
break;
[421] Fix | Delete
}
[422] Fix | Delete
else
[423] Fix | Delete
{
[424] Fix | Delete
$final_str.=$val;
[425] Fix | Delete
$len+=$cur_url_len;
[426] Fix | Delete
}
[427] Fix | Delete
[428] Fix | Delete
}
[429] Fix | Delete
[430] Fix | Delete
if(strlen($substring)>0 && $tw_max_len>$len)
[431] Fix | Delete
{
[432] Fix | Delete
[433] Fix | Delete
if(strlen($substring)>($tw_max_len-$len))
[434] Fix | Delete
{
[435] Fix | Delete
$final_str.=substr($substring,0,$tw_max_len-$len-3)."...";
[436] Fix | Delete
}
[437] Fix | Delete
else
[438] Fix | Delete
{
[439] Fix | Delete
$final_str.=$substring;
[440] Fix | Delete
}
[441] Fix | Delete
}
[442] Fix | Delete
}
[443] Fix | Delete
[444] Fix | Delete
[445] Fix | Delete
$substring=$final_str;
[446] Fix | Delete
}
[447] Fix | Delete
/* if (strlen($substring)>$tw_max_len)
[448] Fix | Delete
$substring=substr($substring, 0, $tw_max_len-3)."...";*/
[449] Fix | Delete
[450] Fix | Delete
if($xyz_twap_tw_app_sel_mode==0)
[451] Fix | Delete
{
[452] Fix | Delete
$twobj = new Abraham\TwitterOAuth\TwitterOAuth(
[453] Fix | Delete
$tappid,
[454] Fix | Delete
$tappsecret,
[455] Fix | Delete
$taccess_token,
[456] Fix | Delete
$taccess_token_secret,
[457] Fix | Delete
);
[458] Fix | Delete
$twobj->userId = explode('-', $taccess_token)[0];
[459] Fix | Delete
$twobj->setApiVersion('2');
[460] Fix | Delete
[461] Fix | Delete
}
[462] Fix | Delete
$tw_publish_status='';
[463] Fix | Delete
if($image_found==1 && $post_twitter_image_permission==1 && $xyz_twap_tw_app_sel_mode==0)
[464] Fix | Delete
{
[465] Fix | Delete
$twobj->setTimeouts( 10, 60 );
[466] Fix | Delete
$twobj->setApiVersion( '1.1' );
[467] Fix | Delete
$response = $twobj->upload( 'media/upload', array( 'media' => $xyz_twap_image_files ) );
[468] Fix | Delete
if ( ! isset( $response->media_id ) ) {
[469] Fix | Delete
$media_upload_id = 0;
[470] Fix | Delete
} else {
[471] Fix | Delete
$media_upload_id = $response->media_id;
[472] Fix | Delete
}
[473] Fix | Delete
[474] Fix | Delete
if ( $media_upload_id ) {
[475] Fix | Delete
$twobj->setTimeouts( 10, 30 );
[476] Fix | Delete
$twobj->setApiVersion( '2' );
[477] Fix | Delete
$resultfrtw = $twobj->post(
[478] Fix | Delete
'tweets',
[479] Fix | Delete
array('text' =>$substring,'media'=>array(
[480] Fix | Delete
'media_ids' => [ (string) $media_upload_id ],
[481] Fix | Delete
) ),
[482] Fix | Delete
true
[483] Fix | Delete
);
[484] Fix | Delete
if ( isset( $resultfrtw->data ) && ! is_wp_error( $resultfrtw->data ) ) {
[485] Fix | Delete
// Tweet posted successfully
[486] Fix | Delete
$tw_publish_status="<span style=\"color:green\">statuses/update : Success.</span>";
[487] Fix | Delete
} else if( is_wp_error( $resultfrtw->data )) {
[488] Fix | Delete
$error_string = $resultfrtw->data->get_error_message();
[489] Fix | Delete
$tw_publish_status="<span style=\"color:red\">".$error_string.".</span>";
[490] Fix | Delete
}
[491] Fix | Delete
else
[492] Fix | Delete
{
[493] Fix | Delete
if(!empty($resultfrtw->detail))
[494] Fix | Delete
$tw_publish_status="<span style=\"color:red\">".$resultfrtw->status.":".$resultfrtw->detail.".</span>";
[495] Fix | Delete
else
[496] Fix | Delete
$tw_publish_status="<span style=\"color:red\">Not Available</span>";
[497] Fix | Delete
}
[498] Fix | Delete
if($img_status!="")
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function