HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wpbiancoarte/wp-content/plugins/custom-twitter-feeds/inc/V2/TweetAdapter.php
<?php

/**
 * Class for converting tweet sub attribute from Twitter API v1.1 to v2.
 *
 * @package twitter-api-v2
 */

namespace TwitterFeed\V2;

// Don't load directly.
if (! defined('ABSPATH')) {
	die('-1');
}

/**
 * TweetAdapter class.
 */
class TweetAdapter extends Adapter {
	/**
	 * Get mapped fields.
	 *
	 * @return string[]
	 */
	public function getMappedFields()
	{
		return [
			'id_str'          => 'id',
			'conversation_id' => 'conversation_id_str',
		];
	}

	/**
	 * Remove retweet prefix.
	 *
	 * @param string $text Tweet text.
	 *
	 * @return string
	 */
	public function removeRetweetPrefix($text)
	{
		if (strpos($text, 'RT') !== 0) {
			return $text;
		}

		preg_match('/^RT\s*@[^:]*:(.*)/s', $text, $matches);

		if (! isset($matches[1])) {
			return $text;
		}

		return $matches[1];
	}

	/**
	 * Convert entity from v1.1 to v2 format.
	 *
	 * @param array $entity Entity.
	 *
	 * @return array
	 */
	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);
	}
}