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/twitter-...
File: xyz-functions.php
<?php
[0] Fix | Delete
if( !defined('ABSPATH') ){ exit();}
[1] Fix | Delete
if(!function_exists('xyz_trim_deep'))
[2] Fix | Delete
{
[3] Fix | Delete
[4] Fix | Delete
function xyz_trim_deep($value) {
[5] Fix | Delete
if ( is_array($value) ) {
[6] Fix | Delete
$value = array_map('xyz_trim_deep', $value);
[7] Fix | Delete
} elseif ( is_object($value) ) {
[8] Fix | Delete
$vars = get_object_vars( $value );
[9] Fix | Delete
foreach ($vars as $key=>$data) {
[10] Fix | Delete
$value->{$key} = xyz_trim_deep( $data );
[11] Fix | Delete
}
[12] Fix | Delete
} else {
[13] Fix | Delete
$value = trim($value);
[14] Fix | Delete
}
[15] Fix | Delete
[16] Fix | Delete
return $value;
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
if(!function_exists('esc_textarea'))
[22] Fix | Delete
{
[23] Fix | Delete
function esc_textarea($text)
[24] Fix | Delete
{
[25] Fix | Delete
$safe_text = htmlspecialchars( $text, ENT_QUOTES );
[26] Fix | Delete
return $safe_text;
[27] Fix | Delete
}
[28] Fix | Delete
}
[29] Fix | Delete
[30] Fix | Delete
if(!function_exists('xyz_twap_plugin_get_version'))
[31] Fix | Delete
{
[32] Fix | Delete
function xyz_twap_plugin_get_version()
[33] Fix | Delete
{
[34] Fix | Delete
if ( ! function_exists( 'get_plugins' ) )
[35] Fix | Delete
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
[36] Fix | Delete
$plugin_folder = get_plugins( '/' . plugin_basename( dirname( XYZ_TWAP_PLUGIN_FILE ) ) );
[37] Fix | Delete
// print_r($plugin_folder);
[38] Fix | Delete
return $plugin_folder['twitter-auto-publish.php']['Version'];
[39] Fix | Delete
}
[40] Fix | Delete
}
[41] Fix | Delete
[42] Fix | Delete
[43] Fix | Delete
if(!function_exists('xyz_twap_links')){
[44] Fix | Delete
function xyz_twap_links($links, $file) {
[45] Fix | Delete
$base = plugin_basename(XYZ_TWAP_PLUGIN_FILE);
[46] Fix | Delete
if ($file == $base) {
[47] Fix | Delete
[48] Fix | Delete
$links[] = '<a href="http://help.xyzscripts.com/docs/twitter-auto-publish/faq/" title="FAQ">FAQ</a>';
[49] Fix | Delete
$links[] = '<a href="http://help.xyzscripts.com/docs/twitter-auto-publish/" title="Read Me">README</a>';
[50] Fix | Delete
$links[] = '<a href="https://xyzscripts.com/support/" class="xyz_support" title="Support"></a>';
[51] Fix | Delete
$links[] = '<a href="http://twitter.com/xyzscripts" class="xyz_twitt" title="Follow us on twitter"></a>';
[52] Fix | Delete
$links[] = '<a href="https://www.facebook.com/xyzscripts" class="xyz_fbook" title="Facebook"></a>';
[53] Fix | Delete
$links[] = '<a href="http://www.linkedin.com/company/xyzscripts" class="xyz_linkdin" title="Follow us on linkedIn"></a>';
[54] Fix | Delete
}
[55] Fix | Delete
return $links;
[56] Fix | Delete
}
[57] Fix | Delete
}
[58] Fix | Delete
[59] Fix | Delete
if(!function_exists('xyz_twap_string_limit')){
[60] Fix | Delete
function xyz_twap_string_limit($string, $limit) {
[61] Fix | Delete
[62] Fix | Delete
$space=" ";$appendstr=" ...";
[63] Fix | Delete
if (function_exists('mb_strlen') && function_exists('mb_substr') && function_exists('mb_strripos')) {
[64] Fix | Delete
if(mb_strlen($string) <= $limit) return $string;
[65] Fix | Delete
if(mb_strlen($appendstr) >= $limit) return '';
[66] Fix | Delete
$string = mb_substr($string, 0, $limit-mb_strlen($appendstr));
[67] Fix | Delete
$rpos = mb_strripos($string, $space);
[68] Fix | Delete
if ($rpos===false)
[69] Fix | Delete
return $string.$appendstr;
[70] Fix | Delete
else
[71] Fix | Delete
return mb_substr($string, 0, $rpos).$appendstr;
[72] Fix | Delete
}
[73] Fix | Delete
else {
[74] Fix | Delete
if(strlen($string) <= $limit) return $string;
[75] Fix | Delete
if(strlen($appendstr) >= $limit) return '';
[76] Fix | Delete
$string = substr($string, 0, $limit-strlen($appendstr));
[77] Fix | Delete
$rpos = strripos($string, $space);
[78] Fix | Delete
if ($rpos===false)
[79] Fix | Delete
return $string.$appendstr;
[80] Fix | Delete
else
[81] Fix | Delete
return substr($string, 0, $rpos).$appendstr;
[82] Fix | Delete
}
[83] Fix | Delete
}
[84] Fix | Delete
}
[85] Fix | Delete
if(!function_exists('xyz_twap_getimage')){
[86] Fix | Delete
function xyz_twap_getimage($post_ID,$description_org)
[87] Fix | Delete
{
[88] Fix | Delete
$attachmenturl="";
[89] Fix | Delete
$post_thumbnail_id = get_post_thumbnail_id( $post_ID );
[90] Fix | Delete
if(!empty($post_thumbnail_id))
[91] Fix | Delete
$attachmenturl=wp_get_attachment_url($post_thumbnail_id);
[92] Fix | Delete
else {
[93] Fix | Delete
preg_match_all('/< *img[^>]*src *= *["\']?([^"\']*)/is', $description_org, $matches);
[94] Fix | Delete
if(isset($matches[1][0]))
[95] Fix | Delete
$attachmenturl = $matches[1][0];
[96] Fix | Delete
else
[97] Fix | Delete
{
[98] Fix | Delete
$matches=array();
[99] Fix | Delete
$description_org=apply_filters('the_content', $description_org);
[100] Fix | Delete
preg_match_all('/< *img[^>]*src *= *["\']?([^"\']*)/is', $description_org, $matches);
[101] Fix | Delete
if(isset($matches[1][0]))
[102] Fix | Delete
$attachmenturl = $matches[1][0];
[103] Fix | Delete
else
[104] Fix | Delete
$attachmenturl=xyz_twap_get_post_gallery_images_with_info($description_org,1);
[105] Fix | Delete
}
[106] Fix | Delete
}
[107] Fix | Delete
return $attachmenturl;
[108] Fix | Delete
}
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
if(!function_exists('xyz_twap_get_post_gallery_images_with_info'))
[112] Fix | Delete
{
[113] Fix | Delete
function xyz_twap_get_post_gallery_images_with_info($post_content,$single=1) {
[114] Fix | Delete
$ids=$images_id=array();
[115] Fix | Delete
preg_match('/\[gallery.*ids=.(.*).\]/', $post_content, $ids);
[116] Fix | Delete
if (isset($ids[1]))
[117] Fix | Delete
$images_id = explode(",", $ids[1]);
[118] Fix | Delete
$image_gallery_with_info = array();
[119] Fix | Delete
foreach ($images_id as $image_id) {
[120] Fix | Delete
$attachment = get_post($image_id);
[121] Fix | Delete
$img_src=$attachment->guid;
[122] Fix | Delete
if($single==1)
[123] Fix | Delete
return $img_src;
[124] Fix | Delete
else
[125] Fix | Delete
$image_gallery_with_info[]=$img_src;
[126] Fix | Delete
}
[127] Fix | Delete
return $image_gallery_with_info;
[128] Fix | Delete
}
[129] Fix | Delete
}
[130] Fix | Delete
/* Local time formating */
[131] Fix | Delete
if(!function_exists('xyz_twap_local_date_time')){
[132] Fix | Delete
function xyz_twap_local_date_time($format,$timestamp){
[133] Fix | Delete
return date($format, $timestamp + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ));
[134] Fix | Delete
}
[135] Fix | Delete
}
[136] Fix | Delete
[137] Fix | Delete
if (!function_exists("xyz_twap_split_replace"))
[138] Fix | Delete
{
[139] Fix | Delete
function xyz_twap_split_replace($search, $replace, $subject)//case insensitive
[140] Fix | Delete
{
[141] Fix | Delete
if(!stristr($subject,$search))
[142] Fix | Delete
{
[143] Fix | Delete
$search_tmp=str_replace("}", "", $search);
[144] Fix | Delete
preg_match_all("@(".preg_quote($search_tmp)."\:)(l|w)\-(\d+)}@i",$subject,$matches); // @ is same as /
[145] Fix | Delete
if(is_array($matches) && isset($matches[0]))
[146] Fix | Delete
{
[147] Fix | Delete
foreach ($matches[0] as $k=>$v)
[148] Fix | Delete
{
[149] Fix | Delete
$limit=$matches[3][$k];
[150] Fix | Delete
if(strcasecmp($matches[2][$k],"l")==0)//lines
[151] Fix | Delete
{
[152] Fix | Delete
$replace_arr = preg_split( "/(\.|;|\!)/", $replace ,0,PREG_SPLIT_DELIM_CAPTURE );
[153] Fix | Delete
if(is_array($replace_arr) && count($replace_arr)>0)
[154] Fix | Delete
{
[155] Fix | Delete
$replace_new=implode(array_slice($replace_arr,0,(2*$limit)));
[156] Fix | Delete
$subject=str_replace($matches[0][$k], $replace_new, $subject);
[157] Fix | Delete
}
[158] Fix | Delete
}
[159] Fix | Delete
if(strcasecmp($matches[2][$k],"w")==0)//words
[160] Fix | Delete
{
[161] Fix | Delete
$replace_arr=explode(" ",$replace);
[162] Fix | Delete
if(is_array($replace_arr) && count($replace_arr)>0)
[163] Fix | Delete
{
[164] Fix | Delete
$replace_new=implode(" ",array_slice($replace_arr,0,$limit));
[165] Fix | Delete
$subject=str_replace($matches[0][$k], $replace_new, $subject);
[166] Fix | Delete
}
[167] Fix | Delete
}
[168] Fix | Delete
}
[169] Fix | Delete
}
[170] Fix | Delete
}
[171] Fix | Delete
else
[172] Fix | Delete
$subject=str_replace($search, $replace, $subject);
[173] Fix | Delete
return $subject;
[174] Fix | Delete
}
[175] Fix | Delete
}
[176] Fix | Delete
[177] Fix | Delete
add_filter( 'plugin_row_meta','xyz_twap_links',10,2);
[178] Fix | Delete
[179] Fix | Delete
if(!function_exists('xyz_twap_post_to_smap_api'))
[180] Fix | Delete
{
[181] Fix | Delete
function xyz_twap_post_to_smap_api($post_details,$url,$xyzscripts_hash_val='') {
[182] Fix | Delete
if (function_exists('curl_init'))
[183] Fix | Delete
{
[184] Fix | Delete
$post_parameters['post_params'] = serialize($post_details);
[185] Fix | Delete
$post_parameters['request_hash'] = md5($post_parameters['post_params'].$xyzscripts_hash_val);
[186] Fix | Delete
$ch = curl_init();
[187] Fix | Delete
curl_setopt($ch, CURLOPT_URL, $url);
[188] Fix | Delete
curl_setopt($ch, CURLOPT_POST, true);
[189] Fix | Delete
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_parameters);
[190] Fix | Delete
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
[191] Fix | Delete
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER,(get_option('xyz_twap_peer_verification')=='1') ? true : false);
[192] Fix | Delete
$content = curl_exec($ch);
[193] Fix | Delete
curl_close($ch);
[194] Fix | Delete
if (empty($content))
[195] Fix | Delete
{
[196] Fix | Delete
$response=array('status'=>0,'tw_api_count'=>0,'msg'=>'Error:unable to connect');
[197] Fix | Delete
$content=json_encode($response);
[198] Fix | Delete
}
[199] Fix | Delete
return $content;
[200] Fix | Delete
}
[201] Fix | Delete
}
[202] Fix | Delete
}
[203] Fix | Delete
?>
[204] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function