: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
use TwitterFeed\V2\CtfOauthConnect;
use TwitterFeed\CTF_GDPR_Integrations;
if ( ! defined( 'ABSPATH' ) ) {
public static function get_tweet_id( $data ) {
public static function get_post_id( $data ) {
* Get Tweet Author User name
public static function get_user_name( $data ) {
if ( ! empty( $data['screen_name'] ) ) {
return $data['screen_name'];
if ( ! empty( $data['user']['screen_name'] ) ) {
return $data['user']['screen_name'];
public static function get_author_name( $data ) {
return strtolower( $data['user']['name'] );
public static function get_display_author_name( $data ) {
return $data['user']['name'];
* Get Tweet Author Screen Name
public static function get_author_screen_name( $data ) {
if ( ! empty( $data['user'] ) ) {
if ( is_array( $data['user'] ) ) {
return strtolower( $data['user']['screen_name'] );
return strtolower( $data['user'] );
if ( ! empty( $data['screen_name'] ) ) {
return strtolower( $data['screen_name'] );
public static function get_quoted_name( $data ) {
return $data['user']['name'];
public static function get_quoted_screen_name( $data ) {
return $data['user']['screen_name'];
public static function get_quoted_verified( $data ) {
return $data['user']['verified'];
public static function get_post($tweet_set) {
if ( isset( $tweet_set['retweeted_status'] ) ) {
return $tweet_set['retweeted_status'];
public static function get_avatar_url( $post, $feed_options ) {
if ( CTF_GDPR_Integrations::doing_gdpr( $feed_options ) ) {
return trailingslashit( CTF_PLUGIN_URL ) . 'img/placeholder.png';
return self::get_avatar( $post );
public static function get_avatar( $data ) {
if ( isset( $data['retweeted_status'] ) ) {
return $data['retweeted_status']['user']['profile_image_url_https'];
} elseif ( isset( $data['user'] ) ) {
return $data['user']['profile_image_url_https'];
} elseif ( isset( $data['profile_image_url_https'] ) ) {
return $data['profile_image_url_https'];
public static function get_utc_offset ( $data ) {
if ( empty( $data['user']['utc_offset'] ) ) {
return $data['user']['utc_offset'];
* Get Tweet Original TimeStamp
public static function get_original_timestamp( $data ) {
return $data['created_at'];
* Get Tweet Author Verified
public static function get_verified ( $data ) {
return $data['user']['verified'];
* Get Generic Header Text
public static function get_generic_header_text( $data ) {
if ( $data['type'] === 'search' || $data['type'] === 'hashtag' ) {
$using_custom = $data['headertext'] != '';
$raw_header_text = $using_custom ? $data['headertext'] : $data['feed_term'];
$hashtags = explode(" OR ", $data['feed_term']);
$default_header_text = '';
foreach ( $hashtags as $hashtag ) {
if( $h_index > 0 ) $default_header_text .= ', ';
$default_header_text .= $hashtag;
$default_header_text = $data['headertext'];
$default_header_text = str_replace( ' -filter:retweets', '', $default_header_text );
return $default_header_text;
$default_header_text = 'Twitter';
// $url_part = $data['screenname']; //Need to get screenname here
return $default_header_text;
//Header for combined feed types
if ( ! empty( $data['feed_types_and_terms'] ) ) {
if ( $data['headertext'] != '' ) {
$default_header_text = $data['headertext'];
if ( $data['feed_types_and_terms'][0][0] === 'search' || $data['feed_types_and_terms'][0][0] === 'hashtag' ) {
$raw_header_text = $data['feed_types_and_terms'][0][1];
return $default_header_text;
$default_header_text = '';
foreach ( $data['feed_types_and_terms'] as $feed_set ) {
if ( $feed_set[0] == 'lists' ) {
$default_header_text .= '';
$default_header_text .= ', ';
if ( $feed_set[0] == 'usertimeline' ) {
$default_header_text .= '@';
$default_header_text .= $feed_set[1];
if ( empty( $default_header_text ) ) {
return $default_header_text = 'Twitter';
public static function get_generic_header_url ( $data ) {
$hashtags = isset($data['feed_term']) ? explode(" OR ", $data['feed_term']) : '';
if ( $data['type'] === 'search' || $data['type'] === 'hashtag' ) {
if ( $data['type'] === 'hashtag' ) {
$url_part = 'hashtag/' . str_replace("#", "", $hashtags[0]);
$url_part = 'search?q=' . rawurlencode( str_replace( array( ', ', "'" ), array( ' OR ', '"' ), $data['feed_term'] ) );
if ( ! empty( $data['feed_types_and_terms'] ) ) {
if ( $data['feed_types_and_terms'][0][0] === 'search' || $data['feed_types_and_terms'][0][0] === 'hashtag' ) {
$raw_header_text = $data['feed_types_and_terms'][0][1];
$hashtags = explode( " OR ", $data['feed_types_and_terms'][0][1] );
if ( $data['feed_types_and_terms'][0][0] === 'hashtag' ) {
$url_part = 'hashtag/' . str_replace( "#", "", $hashtags[0] );
$url_part = 'search?q=' . rawurlencode( str_replace( array( ', ', "'" ), array(
), $data['feed_types_and_terms'][0][1] ) );
public static function get_header_text( $header_info, $feed_options ) {
if ( empty( $header_info ) || ! is_array( $header_info ) ) {
if ( $feed_options['headertext'] !== '' ) {
$header_text = $feed_options['headertext'];
$header_text = $header_info['name'];
public static function get_header_description( $data ) {
return $data['description'];
* Get User Header JSON info
public static function get_user_header_json( $data, $post_info ) {
$type = ! empty( $data['type'] ) ? $data['type'] : 'usertimeline';
$types_and_terms = isset($data['feed_types_and_terms']) ? $data['feed_types_and_terms'] : [];
$timelines_included = array();
foreach ( $types_and_terms as $type_and_term ) {
if ( $type_and_term[0] === 'usertimeline' ) {
$timelines_included[] = str_replace( '@', '', strtolower( $type_and_term[1] ) );
if ( $type === 'usertimeline' ) {
if ( ! empty( $post_info[0]['user'] ) ) {
return $post_info[0]['user'];
public static function get_header_avatar( $data, $feed_options = array() ) {
$settings = ctf_get_database_settings();
if ( CTF_GDPR_Integrations::doing_gdpr( $settings ) ) {
$avatar = trailingslashit( CTF_PLUGIN_URL ) . 'img/placeholder.png';
$avatar = $data['profile_image_url_https'];
public static function get_quoted_tc( $data ) {
if ( isset( $data['quoted_status'] ) ) {
$quoted = $data['quoted_status'];
public static function get_quoted_media( $data, $num_media ) {
if ( isset( $data['extended_entities']['media'] ) ) {
$num_media = count( $data['extended_entities']['media'] );
for( $ii = 0; $ii < $num_media; $ii++ ) {
if ( $data['extended_entities']['media'][$ii]['type'] == 'video' || $data['extended_entities']['media'][$ii]['type'] == 'animated_gif' ) {
$quoted_media[$ii]['url'] = $data['extended_entities']['media'][$ii]['video_info']['variants'][$ii]['url'];
$quoted_media[$ii]['url'] = $data['extended_entities']['media'][$ii]['media_url_https'];
$quoted_media[$ii]['type'] = $data['extended_entities']['media'][$ii]['type'];
if ( $quoted_media[$ii]['type'] == 'video' ) {
$quoted_media[$ii]['video_atts'] = 'controls';
} elseif ( $quoted_media[$ii]['type'] == 'animated_gif' ) {
$quoted_media[$ii]['video_atts'] = 'controls loop autoplay muted';
$quoted_media[$ii]['poster'] = $data['extended_entities']['media'][$ii]['media_url_https'];
} elseif ( isset( $data['entities']['media'] ) ) {
$num_media = count( $data['entities']['media'] );
for( $ii = 0; $ii < $num_media; $ii++ ) {
if ( $data['entities']['media'][$ii]['type'] == 'video' || $data['entities']['media'][$ii]['type'] == 'animated_gif' ) {
$quoted_media[$ii]['url'] = $data['entities']['media'][$ii]['video_info']['variants'][$ii]['url'];
$quoted_media[$ii]['url'] = $data['entities']['media'][$ii]['media_url_https'];
$quoted_media[$ii]['type'] = $data['entities']['media'][$ii]['type'];
if ( $quoted_media[$ii]['type'] == 'video' ) {
$quoted_media[$ii]['video_atts'] = 'controls';
} elseif ( $quoted_media[$ii]['type'] == 'animated_gif' ) {
$quoted_media[$ii]['video_atts'] = 'controls loop autoplay muted';
$quoted_media[$ii]['poster'] = $data['entities']['media'][$ii]['media_url_https'];
public static function get_feed_classes( $feed_options, $check_for_duplicates, $feed_id = false) {
if( ctf_doing_customizer( $feed_options ) ){
return ' :class="$parent.getFeedClasses()" ';
$ctf_feed_classes = 'ctf ctf-type-' . CTF_Parse::get_feed_type( $feed_options );
$ctf_feed_classes .= \ctf_should_rebrand_to_x() ? ' ctf-rebranded' : '';
$ctf_feed_classes .= ($feed_id !== false ) ? ' ctf-feed-' . $feed_id : '';
$ctf_feed_classes .= ' ' . $feed_options['class'] . ' ctf-styles';
$ctf_feed_classes .= ($feed_options['layout']) ? ' ctf-' . $feed_options['layout']: '';
$ctf_feed_classes .= ( isset( $feed_options['tweetpoststyle'] ) ) ? ' ctf-' . $feed_options['tweetpoststyle'] . '-style' : '';
if ( ! empty( $feed_options['height'] ) ) $ctf_feed_classes .= ' ctf-fixed-height';
$ctf_feed_classes .= $feed_options['width_mobile_no_fixed'] ? ' ctf-width-resp' : '';
if ( $check_for_duplicates ) { $ctf_feed_classes .= ' ctf-no-duplicates'; }
if( isset($feed_options['colorpalette']) && $feed_options['colorpalette'] !== 'inherit' && $feed_id !== false ){
$feed_id_class = $feed_options['colorpalette'] === 'custom' ? ('_' . $feed_id) : '';
$ctf_feed_classes .= ' ctf_palette_' . $feed_options['colorpalette'] . $feed_id_class;
$ctf_feed_classes = apply_filters( 'ctf_feed_classes', $ctf_feed_classes );
return 'class=" ' . $ctf_feed_classes .'" ';
public static function get_tweet_count( $data ) {
if ( isset( $data['statuses'] ) && is_array( $data['statuses'] ) ) {
$tweet_count = count( $data['statuses'] );
} elseif ( is_array( $data ) ) {
$tweet_count = count( $data );
public static function get_feed_type( $feed_options ) {
$ctf_feed_type = ! empty ( $feed_options['type'] ) ? $feed_options['type'] : 'multiple';
public static function get_retweet_count( $data ) {
if ( isset( $data['retweeted_status']['retweet_count'] ) ) {
return $data['retweeted_status']['retweet_count'];
return $data['retweet_count'];
public static function get_favorite_count( $data ) {
if ( isset( $data['retweeted_status']['favorite_count'] ) ) {
return $data['retweeted_status']['favorite_count'];
return $data['favorite_count'];
* Get Global Twitter Feed CSS
public static function parse_css_style ( $css_array ) {