: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Class for converting tweet sub attribute from Twitter API v1.1 to v2.
* @package twitter-api-v2
namespace TwitterFeed\V2;
if (! defined('ABSPATH')) {
class TweetAdapter extends Adapter {
public function getMappedFields()
'conversation_id' => 'conversation_id_str',
* @param string $text Tweet text.
public function removeRetweetPrefix($text)
if (strpos($text, 'RT') !== 0) {
preg_match('/^RT\s*@[^:]*:(.*)/s', $text, $matches);
if (! isset($matches[1])) {
* Convert entity from v1.1 to v2 format.
* @param array $entity Entity.
public function convert($entity)
$entity['text'] = $this->removeRetweetPrefix($entity['text']);
if (isset($entity['retweeted_status']['text'])) {
$entity['retweeted_status']['text'] = $this->removeRetweetPrefix($entity['retweeted_status']['text']);
return parent::convert($entity);