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: FFTumblr.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
[8] Fix | Delete
* @link http://looks-awesome.com
[9] Fix | Delete
* @copyright 2014-2016 Looks Awesome
[10] Fix | Delete
*
[11] Fix | Delete
* https://www.tumblr.com/docs/en/api/v1
[12] Fix | Delete
*/
[13] Fix | Delete
class FFTumblr extends FFHttpRequestFeed{
[14] Fix | Delete
private $blog_name;
[15] Fix | Delete
private $media;
[16] Fix | Delete
private $isRichText;
[17] Fix | Delete
[18] Fix | Delete
public function __construct() {
[19] Fix | Delete
parent::__construct( 'tumblr' );
[20] Fix | Delete
}
[21] Fix | Delete
[22] Fix | Delete
public function deferredInit($feed) {
[23] Fix | Delete
$num = $this->getCount();
[24] Fix | Delete
$this->blog_name = (string) $feed->content;
[25] Fix | Delete
$this->isRichText = $feed->{'rich-text'};
[26] Fix | Delete
$this->url = "http://{$this->blog_name}.tumblr.com/api/read/json?debug=1&num={$num}&type=photo";
[27] Fix | Delete
}
[28] Fix | Delete
[29] Fix | Delete
protected function getUrl() {
[30] Fix | Delete
return $this->url;
[31] Fix | Delete
}
[32] Fix | Delete
[33] Fix | Delete
protected function items( $response ) {
[34] Fix | Delete
$response = trim(preg_replace('/^var tumblr_api_read = /', '', trim($response)), ';');
[35] Fix | Delete
$pxml = json_decode($response);
[36] Fix | Delete
if ($pxml == null){
[37] Fix | Delete
$error = [
[38] Fix | Delete
'type' => $this->getType(),
[39] Fix | Delete
'message' => 'Something went wrong. Please report issue.',
[40] Fix | Delete
];
[41] Fix | Delete
$this->errors[] = $error;
[42] Fix | Delete
return [];
[43] Fix | Delete
}
[44] Fix | Delete
return $pxml->posts;
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
protected function prepare( $item ) {
[48] Fix | Delete
$this->media = null;
[49] Fix | Delete
return parent::prepare( $item );
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
[53] Fix | Delete
protected function getId( $item ) {
[54] Fix | Delete
return $item->id;
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
protected function getHeader( $item ) {
[58] Fix | Delete
return '';
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
protected function getScreenName( $item ) {
[62] Fix | Delete
return $this->blog_name;
[63] Fix | Delete
}
[64] Fix | Delete
[65] Fix | Delete
protected function getProfileImage( $item ) {
[66] Fix | Delete
return "http://api.tumblr.com/v2/blog/{$this->blog_name}.tumblr.com/avatar/64";
[67] Fix | Delete
}
[68] Fix | Delete
[69] Fix | Delete
protected function getSystemDate( $item ) {
[70] Fix | Delete
$date = date("Y-m-d\TH:i:s\Z",$item->{'unix-timestamp'});
[71] Fix | Delete
return strtotime($date);
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
protected function getContent( $item ) {
[75] Fix | Delete
$text = '';
[76] Fix | Delete
switch ($item->type) {
[77] Fix | Delete
// case 'answer':
[78] Fix | Delete
// $text = 'question: ' . $item->question . '<br/>answer: ' . $item->answer . '<br/>';
[79] Fix | Delete
// break;
[80] Fix | Delete
// case 'audio':
[81] Fix | Delete
// $text .= $item->{'audio-caption'} . '<br/>';
[82] Fix | Delete
// id3-artist
[83] Fix | Delete
// id3-album
[84] Fix | Delete
// id3-title
[85] Fix | Delete
// $this->media = $this->createMedia($item->{'audio-embed'}, null, null, 'html');
[86] Fix | Delete
// break;
[87] Fix | Delete
// case 'video':
[88] Fix | Delete
// http://stackoverflow.com/questions/17481898/video-posts-with-auto-thumbnaillike-in-facebook-in-tumblr-com/17544279#17544279
[89] Fix | Delete
// break;
[90] Fix | Delete
case 'photo':
[91] Fix | Delete
$exclude = array("(previous)", "(next)", "(more)", "(via)");
[92] Fix | Delete
$text .= $this->isRichText ? $item->{'photo-caption'} : str_replace($exclude, '', strip_tags($item->{'photo-caption'}));
[93] Fix | Delete
break;
[94] Fix | Delete
}
[95] Fix | Delete
if (isset($item->tags)) $text .= ' ' . $this->wrapHashTag($item->tags);
[96] Fix | Delete
return $text;
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
protected function getUserlink( $item ) {
[100] Fix | Delete
return "http://{$this->blog_name}.tumblr.com";
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
protected function getPermalink( $item ) {
[104] Fix | Delete
return $item->url;
[105] Fix | Delete
}
[106] Fix | Delete
[107] Fix | Delete
protected function showImage( $item ) {
[108] Fix | Delete
if ($item->type == 'photo'){
[109] Fix | Delete
//TODO Add support gallery
[110] Fix | Delete
$this->media = $this->createMedia($item->{'photo-url-500'}, $item->width, $item->height);
[111] Fix | Delete
}
[112] Fix | Delete
return true;
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
protected function getImage( $item ) {
[116] Fix | Delete
return $this->createImage($item->{'photo-url-250'}, $item->width, $item->height);
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
protected function getMedia( $item ) {
[120] Fix | Delete
return $this->media;
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
/**
[124] Fix | Delete
* @param $tags
[125] Fix | Delete
*
[126] Fix | Delete
* @return mixed
[127] Fix | Delete
*/
[128] Fix | Delete
private function wrapHashTag($tags){
[129] Fix | Delete
$text = '';
[130] Fix | Delete
foreach($tags as $tag){
[131] Fix | Delete
//$tagEncode = str_replace(' ', '-', $tag);
[132] Fix | Delete
$tagEncode = urlencode($tag);
[133] Fix | Delete
$text = $text . "<a href=\"https://www.tumblr.com/tagged/{$tagEncode}\">#{$tag}</a> ";
[134] Fix | Delete
}
[135] Fix | Delete
return $text;
[136] Fix | Delete
}
[137] Fix | Delete
}
[138] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function