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/flow-flo.../libs/flowflow/social/src/flow/social
File: FFPosts.php
<?php namespace flow\social;
[0] Fix | Delete
if ( ! defined( 'WPINC' ) ) die;
[1] Fix | Delete
[2] Fix | Delete
/**
[3] Fix | Delete
* Flow-Flow.
[4] Fix | Delete
*
[5] Fix | Delete
* @package FlowFlow
[6] Fix | Delete
* @author Looks Awesome <email@looks-awesome.com>
[7] Fix | Delete
* @link http://looks-awesome.com
[8] Fix | Delete
* @copyright 2014-2016 Looks Awesome
[9] Fix | Delete
*/
[10] Fix | Delete
class FFPosts extends FFBaseFeed implements LAFeedWithComments {
[11] Fix | Delete
private $args;
[12] Fix | Delete
private $shortcodes;
[13] Fix | Delete
private $authors;
[14] Fix | Delete
private $profileImage;
[15] Fix | Delete
private $use_excerpt;
[16] Fix | Delete
[17] Fix | Delete
public function __construct() {
[18] Fix | Delete
parent::__construct( 'posts' );
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
public function deferredInit($feed){
[22] Fix | Delete
if ( isset( $feed->{'shortcodes'} ) ) {
[23] Fix | Delete
$this->shortcodes = $feed->{'shortcodes'};
[24] Fix | Delete
}
[25] Fix | Delete
$this->args = array(
[26] Fix | Delete
'numberposts' => $this->getCount(),
[27] Fix | Delete
'post_status' => 'publish',
[28] Fix | Delete
'has_password' => false
[29] Fix | Delete
);
[30] Fix | Delete
if ( isset( $feed->{'category-name'} ) ) {
[31] Fix | Delete
$this->args['category_name'] = $feed->{'category-name'};
[32] Fix | Delete
}
[33] Fix | Delete
if (isset($feed->{'slug'})) {
[34] Fix | Delete
$this->args['post_type'] = $feed->{'slug'};
[35] Fix | Delete
}
[36] Fix | Delete
$this->use_excerpt = $feed->{'use-excerpt'};
[37] Fix | Delete
$this->profileImage = $this->context['plugin_url'] . '/' . $this->context['slug'] . '/assets/avatar_default.png';
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
public function onePagePosts(){
[41] Fix | Delete
$posts = wp_get_recent_posts($this->args);
[42] Fix | Delete
$result = array();
[43] Fix | Delete
foreach($posts as $item){
[44] Fix | Delete
$post = $this->parse($item);
[45] Fix | Delete
if ($this->isSuitablePost($post)) $result[$post->id] = $post;
[46] Fix | Delete
}
[47] Fix | Delete
return $result;
[48] Fix | Delete
}
[49] Fix | Delete
[50] Fix | Delete
private function parse($post){
[51] Fix | Delete
$tc = new \stdClass();
[52] Fix | Delete
$tc->feed_id = $this->id();
[53] Fix | Delete
$tc->id = (string)$post['ID'];
[54] Fix | Delete
$tc->smart_order = 0;
[55] Fix | Delete
$tc->type = $this->getType();
[56] Fix | Delete
$tc->header = $post['post_title'];
[57] Fix | Delete
$tc->nickname = $this->getAuthor($post['post_author'], 'nicename');
[58] Fix | Delete
$tc->screenname = trim($this->getAuthor($post['post_author'], 'user_full_name'));
[59] Fix | Delete
if (empty($tc->screenname)) $tc->screenname = get_bloginfo('name');
[60] Fix | Delete
$tc->system_timestamp = strtotime($post['post_date_gmt']);
[61] Fix | Delete
$tc->text = $this->getText($post);
[62] Fix | Delete
$userpic = get_avatar($post['post_author'], 80, '');
[63] Fix | Delete
$tc->userpic = (strpos($userpic,'avatar-default') !== false) ? $this->profileImage : FFFeedUtils::getUrlFromImg($userpic);
[64] Fix | Delete
if (empty($tc->userpic)) $tc->userpic = $this->profileImage;
[65] Fix | Delete
$tc->userlink = get_author_posts_url($post['post_author']);
[66] Fix | Delete
$tc->permalink = get_permalink($post["ID"]);
[67] Fix | Delete
[68] Fix | Delete
if ( has_post_thumbnail($post["ID"]) ) {
[69] Fix | Delete
$thumb_id = get_post_thumbnail_id($post["ID"]);
[70] Fix | Delete
$thumb = wp_get_attachment_image_src($thumb_id, 'medium', true);
[71] Fix | Delete
$full = wp_get_attachment_image_src($thumb_id, 'thumbnail-size', true);
[72] Fix | Delete
$tc->img = $this->createImage($thumb[0], $thumb[1], $thumb[2]);
[73] Fix | Delete
$tc->media = $this->createMedia($full[0], $full[1], $full[2]);
[74] Fix | Delete
}
[75] Fix | Delete
$counter = wp_count_comments($post["ID"]);
[76] Fix | Delete
@$tc->additional = array('comments' => (string)$counter->approved);
[77] Fix | Delete
return $tc;
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
private function getText( $post ) {
[81] Fix | Delete
$text = ($this->use_excerpt === true) ? $post['post_excerpt'] : $post['post_content'];
[82] Fix | Delete
$text = ($this->shortcodes == 'strip') ? strip_shortcodes($this->removeVcShortcodes($text)) : do_shortcode($text);
[83] Fix | Delete
// workaround for divi shortcodes
[84] Fix | Delete
$text = preg_replace('/\[\/?et_pb.*?\]/', '', $text);
[85] Fix | Delete
return $text;
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
private function removeVcShortcodes( $text ) {
[89] Fix | Delete
$patterns = "/\[[\/]?vc_[^\]]*\]/";
[90] Fix | Delete
$replacements = "";
[91] Fix | Delete
return preg_replace($patterns, $replacements, $text);
[92] Fix | Delete
}
[93] Fix | Delete
[94] Fix | Delete
private function getAuthor( $author_id, $key ) {
[95] Fix | Delete
if ( ! isset( $this->authors[ $author_id ] ) ) {
[96] Fix | Delete
$this->authors[ $author_id ] = array(
[97] Fix | Delete
'nicename' => (string) get_the_author_meta( 'nicename', $author_id ),
[98] Fix | Delete
'url' => (string) get_the_author_meta( 'url', $author_id ),
[99] Fix | Delete
'user_full_name' => (string) get_the_author_meta( 'display_name', $author_id ),
[100] Fix | Delete
);
[101] Fix | Delete
}
[102] Fix | Delete
return $this->authors[ $author_id ][ $key ];
[103] Fix | Delete
}
[104] Fix | Delete
[105] Fix | Delete
public function getComments($item) {
[106] Fix | Delete
if (is_object($item)){
[107] Fix | Delete
return array();
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
$objectId = $item;
[111] Fix | Delete
$comments = get_comments(array(
[112] Fix | Delete
"post_id" => $objectId,
[113] Fix | Delete
"status" => "approve",
[114] Fix | Delete
"type" => "comment"
[115] Fix | Delete
));
[116] Fix | Delete
[117] Fix | Delete
if (!is_array($comments)) {
[118] Fix | Delete
$this->errors[] = array('type'=>'wordpress', 'message' => 'Bad request, post ID issue. <a href="http://docs.social-streams.com/article/55-400-bad-request" target="_blank">Troubleshooting</a>.', 'post_id' => $objectId);
[119] Fix | Delete
throw new \Exception();
[120] Fix | Delete
}
[121] Fix | Delete
else {
[122] Fix | Delete
// return first 5 comments
[123] Fix | Delete
$data = array_slice($comments, 0, 5);
[124] Fix | Delete
$result = array();
[125] Fix | Delete
foreach ($data as $item){
[126] Fix | Delete
$obj = new \stdClass();
[127] Fix | Delete
$obj->id = $item->comment_ID;
[128] Fix | Delete
$obj->from = array(
[129] Fix | Delete
"id" => $item->user_id,
[130] Fix | Delete
"name" => $item->comment_author,
[131] Fix | Delete
);
[132] Fix | Delete
$obj->text = $item->comment_content;
[133] Fix | Delete
$obj->created_time = $item->comment_date;
[134] Fix | Delete
$result[] = $obj;
[135] Fix | Delete
}
[136] Fix | Delete
return $result;
[137] Fix | Delete
}
[138] Fix | Delete
}
[139] Fix | Delete
}
[140] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function