: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Class CTF_Display_Elements
use TwitterFeed\Builder\CTF_Feed_Builder;
if ( ! defined( 'ABSPATH' ) ) {
class CTF_Display_Elements {
* Get Feed Item CSS Classes
public static function get_item_classes( $data, $feed_options, $i ) {
$tweet_classes = 'ctf-item ctf-author-' . CTF_Parse::get_author_screen_name( $data ) .' ctf-new';
$tweet_classes .= ( !ctf_show( 'avatar', $feed_options ) ) ? ' ctf-hide-avatar' : '';
$tweet_classes = apply_filters( 'ctf_tweet_classes', $tweet_classes );
$tweet_classes .= isset( $data['retweeted_status'] ) ? ' ctf-retweet' : '';
$tweet_classes .= isset( $data['quoted_status'] ) ? ' ctf-quoted' : '';
$tweet_classes = ' class="' . $tweet_classes . '" ';
if( ctf_doing_customizer($feed_options) ){
$tweet_classes .= ' :class="!$parent.valueIsEnabled($parent.customizerFeedData.settings.include_avatar) ? \'ctf-hide-avatar\' : \'\'" ';
* Get Tweet Retweet Attribute
public static function get_retweet_attr( $post, $check_duplicates ) {
if( isset( $post['retweeted_status'] ) && $check_duplicates ) {
return ' data-ctfretweetid="'.$post['retweeted_status']['id_str'].'"';
* Get Tweet Quoted Media Text
public static function get_quoted_media_text( $post, $feed_options ) {
if(!$feed_options['is_legacy'] || ($feed_options['is_legacy'] && ctf_show( 'placeholder', $feed_options ))){
if ( isset( $post['quoted_status'] ) ) {
$quoted = $post['quoted_status'];
if ( ( isset( $quoted['extended_entities']['media'][0] ) || isset( $quoted['entities']['media'][0] ) ) && ctf_show( 'placeholder', $feed_options ) ) {
$quoted_media = isset( $quoted['extended_entities']['media'] ) ? $quoted['extended_entities']['media'] : $quoted['entities']['media'];
$quoted_media_count = count( $quoted_media );
switch ( $quoted_media[0]['type'] ) {
$quoted_media_text .= '<span class="ctf-quoted-tweet-text-media-wrap">' . ctf_get_fa_el( 'fa-file-video-o' ) . '</span>';
if ( $quoted_media_count > 1 ) {
$quoted_media_text .= '<span class="ctf-quoted-tweet-text-media-wrap ctf-multi-media-icon">' . $quoted_media_count . ctf_get_fa_el( 'fa-picture-o' ) . '</span>';
$quoted_media_text .= '<span class="ctf-quoted-tweet-text-media-wrap">' . ctf_get_fa_el( 'fa-picture-o' ) . '</span>';
return $quoted_media_text;
* Get Tweet Post media TExt
public static function get_post_media_text( $post, $feed_options, $type = 'text' ) {
if ( ( isset( $post['extended_entities']['media'][0] ) || isset( $post['entities']['media'][0] ) ) ) {
$post_media = isset( $post['extended_entities']['media'] ) ? $post['extended_entities']['media'] : $post['entities']['media'];
$post_media_count = count( $post_media );
switch ( $post_media[0]['type'] ) {
$post_media_text .= ctf_get_fa_el( 'fa-file-video-o' );
if ( $post_media_count > 1 ) {
$post_media_text .= $post_media_count . ctf_get_fa_el( 'fa-picture-o' );
$post_media_text .= ctf_get_fa_el( 'fa-picture-o' );
$html = ($type == 'text') ? $post_media_text : $post_media_count;
$multi_class = $post_media_count > 1 ? ' ctf-multi-media-icon' : '';
if ( $feed_options['linktexttotwitter'] ) {
} elseif ( $feed_options['disablelinks'] ) {
$return = '<span class="ctf-tweet-text-media-wrap'.$multi_class.'">' . $html . '</span>';
$return = '</p><a href="https://twitter.com/' . $post['user']['screen_name'] . '/status/' . $post['id_str'] . '" target="_blank" rel="noopener noreferrer" class="ctf-tweet-text-media-wrap'.$multi_class.'">' . $html . '</a>';
public static function display_header( $feed_options, $tweet_set ){
if ( empty( $tweet_set ) || (isset( $tweet_set[0] ) && is_string( $tweet_set[0] ) && $tweet_set[0] === 'error') ) {
if( ctf_doing_customizer( $feed_options ) ){
$header_template = 'header-generic';
if ( $feed_options['type'] === 'usertimeline' || $feed_options['type'] === 'mentionstimeline' || $feed_options['type'] === 'hometimeline' ) {
$header_template = 'header';
include ctf_get_feed_template_part( $header_template, $feed_options );
include ctf_get_feed_template_part( 'header-text', $feed_options );
include ctf_get_feed_template_part( CTF_Display_Elements::header_type( $feed_options ), $feed_options );
public static function header_type( $feed_options ) {
$header_template = 'header-generic';
if ( $feed_options['type'] === 'usertimeline' || $feed_options['type'] === 'mentionstimeline' || $feed_options['type'] === 'hometimeline' ) {
$header_template = 'header';
if( isset( $feed_options['headerstyle'] ) && $feed_options['headerstyle'] == 'text'){
$header_template = 'header-text';
* @param string $setting_name
* @param bool $custom_condition
public static function should_show_element_vue( $settings, $setting_name, $custom_condition = false ) {
$customizer = ctf_doing_customizer( $settings );
return ' v-if="$parent.valueIsEnabled($parent.customizerFeedData.settings.' . $setting_name . ')' . ( $custom_condition != false ? $custom_condition : '' ) . '" ';
* @param bool $customizer
public static function should_print_element_vue( $customizer, $content ) {
return ' v-html="' . $content . '" ';
* @param bool $customizer
* @param string $condition
public static function create_condition_vue( $customizer, $condition ) {
return ' v-if="' . $condition . '" ';
* @param bool $customizer
* @param string $condition
public static function create_condition_show_vue( $customizer, $condition ) {
return ' v-show="' . $condition . '" ';
* Print Element HTML Attribute
* @param bool $customizer
public static function print_element_attribute( $customizer, $args ) {
return ' :' . $args['attr'] . '="' . $args['vue_content'] . '"';
if( ( isset( $args['php_condition'] ) && $args['php_condition'] ) || !isset( $args['php_condition'] ) ){
return ' ' . $args['attr'] . '="' . $args['php_content'] . '"';
* Print Element HTML Attribute
* @param bool $customizer
public static function get_element_attribute( $element, $settings ) {
$customizer = ctf_doing_customizer( $settings );
return CTF_Display_Elements::create_condition_show_vue( $customizer, '$parent.valueIsEnabled($parent.customizerFeedData.settings.include_author)');
return CTF_Display_Elements::create_condition_show_vue( $customizer, '$parent.valueIsEnabled($parent.customizerFeedData.settings.include_author) && $parent.valueIsEnabled($parent.customizerFeedData.settings.include_avatar)');
return CTF_Display_Elements::create_condition_show_vue( $customizer, '$parent.valueIsEnabled($parent.customizerFeedData.settings.include_author) && $parent.valueIsEnabled($parent.customizerFeedData.settings.include_author_text)');
return CTF_Display_Elements::create_condition_show_vue( $customizer, '$parent.valueIsEnabled($parent.customizerFeedData.settings.include_date)');
return CTF_Display_Elements::create_condition_show_vue( $customizer, '$parent.valueIsEnabled($parent.customizerFeedData.settings.include_logo)');
return CTF_Display_Elements::create_condition_vue( $customizer, '$parent.valueIsEnabled($parent.customizerFeedData.settings.include_text) && $parent.valueIsEnabled($parent.customizerFeedData.settings.linktexttotwitter)');
return CTF_Display_Elements::create_condition_vue( $customizer, '$parent.valueIsEnabled($parent.customizerFeedData.settings.include_text) && !$parent.valueIsEnabled($parent.customizerFeedData.settings.linktexttotwitter)');
return CTF_Display_Elements::create_condition_show_vue( $customizer, '$parent.valueIsEnabled($parent.customizerFeedData.settings.include_linkbox)');
return CTF_Display_Elements::create_condition_show_vue( $customizer, '$parent.valueIsEnabled($parent.customizerFeedData.settings.include_media)');
return CTF_Display_Elements::create_condition_show_vue( $customizer, '$parent.valueIsEnabled($parent.customizerFeedData.settings.include_replied_to)');
return CTF_Display_Elements::create_condition_show_vue( $customizer, '$parent.valueIsEnabled($parent.customizerFeedData.settings.include_retweeter)');
return CTF_Display_Elements::create_condition_show_vue( $customizer, '$parent.valueIsEnabled($parent.customizerFeedData.settings.showbutton) && $parent.customizerFeedData.settings.layout !== \'carousel\' ') . ' ' . CTF_Display_Elements::should_print_element_vue( $customizer, '$parent.customizerFeedData.settings.buttontext' );
return CTF_Display_Elements::create_condition_show_vue( $customizer, '$parent.valueIsEnabled($parent.customizerFeedData.settings.showbio)');
return CTF_Display_Elements::create_condition_show_vue( $customizer, '$parent.valueIsEnabled($parent.customizerFeedData.settings.showheader) && $parent.customizerFeedData.settings.headerstyle === \'standard\' ');
return CTF_Display_Elements::create_condition_show_vue( $customizer, '$parent.valueIsEnabled($parent.customizerFeedData.settings.showheader) && $parent.customizerFeedData.settings.headerstyle === \'text\' ') . ' ' . CTF_Display_Elements::should_print_element_vue( $customizer, '$parent.customizerFeedData.settings.customheadertext' );
return CTF_Display_Elements::create_condition_show_vue( $customizer, '$parent.valueIsEnabled($parent.customizerFeedData.settings.include_actions)');
return CTF_Display_Elements::create_condition_show_vue( $customizer, '$parent.valueIsEnabled($parent.customizerFeedData.settings.viewtwitterlink)');
case 'viewtwitterlink_text':
return CTF_Display_Elements::should_print_element_vue( $customizer, '$parent.customizerFeedData.settings.twitterlinktext' );
return CTF_Display_Elements::create_condition_show_vue( $customizer, '$parent.customizerFeedData.settings.include_twittercards' );
return CTF_Display_Elements::create_condition_show_vue( $customizer, '$parent.customizerFeedData.settings.linktexttotwitter' );
* @param string $setting_name
* @param bool $custom_condition
public static function get_feed_container_data_attributes( $settings, $feed_id, $twitter_feed_id ) {
$customizer = ctf_doing_customizer( $settings );
$atts = CTF_Display_Elements::print_element_attribute(
'attr' => 'data-ctfdisablelinks',
'vue_content' => '$parent.customizerFeedData.settings.disablelinks',
'php_content' => self::cast_boolean($settings['disablelinks']) ? 'true' : 'false',
$atts .= CTF_Display_Elements::print_element_attribute(
'attr' => 'data-ctflinktextcolor',
'vue_content' => '$parent.customizerFeedData.settings.linktextcolor',
'php_content' => $settings['linktextcolor'],
$atts .= CTF_Display_Elements::print_element_attribute(
'attr' => 'data-ctfscrolloffset',
'vue_content' => '$parent.valueIsEnabled($parent.customizerFeedData.settings.autoscroll) ? $parent.customizerFeedData.settings.autoscrolldistance : false',
'php_condition' => CTF_Feed_Builder::check_if_on( $settings['autoscroll'] ),
'php_content' => $settings['autoscrolldistance'],
$atts .= CTF_Display_Elements::print_element_attribute(
'attr' => 'data-boxshadow',
'vue_content' => ' $parent.customizerFeedData.settings.tweetpoststyle === \'boxed\' && $parent.valueIsEnabled($parent.customizerFeedData.settings.tweetboxshadow) ? \'true\' : \'false\' ',
'php_condition' => $settings['tweetpoststyle'] === 'boxed' && CTF_Feed_Builder::check_if_on( $settings['tweetboxshadow'] ),
$atts .= CTF_Display_Elements::print_element_attribute(
'attr' => 'data-header-size',
'vue_content' => '$parent.customizerFeedData.settings.customheadersize',
'php_content' => $settings['customheadersize'],
$atts .= ' data-feedid="' . esc_attr($feed_id) . '" data-postid="' . esc_attr(get_the_ID()) . '" ';
if ( ! empty( $settings['feed'] ) ) {
$atts .= ' data-feed="' . esc_attr($settings['feed']) . '"';
$dbsettings = ctf_get_database_settings();
if ( CTF_GDPR_Integrations::doing_gdpr( $dbsettings ) ) {
if ( !is_admin() && CTF_Feed_Locator::should_do_ajax_locating( $twitter_feed_id , get_the_ID() ) ) {
$atts .= ' data-ctf-flags="' . implode(',', $flags) . '"';
public static function cast_boolean( $value ) {
if ( $value === 'true' || $value === true || $value === 'on' ) {
* Get Post Date TExt Attribure
public static function get_post_date_attr($created_at, $settings ) {
$customizer = ctf_doing_customizer( $settings );
return CTF_Display_Elements::should_print_element_vue( $customizer, '$parent.printDate(\''.$created_at.'\')' );
* Some characters in captions are breaking the customizer.
public static function sanitize_caption( $caption ) {
$caption = str_replace( array( "'" ), '`', $caption );
$caption = str_replace( '&', '&', $caption );
$caption = str_replace( '<', '<', $caption );
$caption = str_replace( '>', '>', $caption );
$caption = str_replace( '"', '"', $caption );
$caption = str_replace( ''', '/', $caption );
$caption = str_replace( '\', '\/', $caption );
$caption = str_replace( array( "\r", "\n" ), '<br>', $caption );
$caption = str_replace( '<br />', '<br>', nl2br( $caption ) );
* Get Post Text Attributes
public static function get_post_text_attr( $post_text, $settings, $post_id ) {
$customizer = ctf_doing_customizer( $settings );
$post_text = self::sanitize_caption( $post_text );
return ' v-html="$parent.getPostText(\'' . htmlspecialchars( $post_text ) . '\', ' . $post_id . ')"';
public static function post_text( $post, $feed_options ) {
$text = isset($post['text']) ? $post['text'] : (isset($post['full_text']) ? $post['full_text'] : '');
$post_text = apply_filters( 'ctf_tweet_text', $text, $feed_options, $post );
public static function get_post_text( $feed_options, $post_text, $post_id, $author_screen_name, $post_media_text ) {
$customizer = ctf_doing_customizer( $feed_options );
$post_text_attr = CTF_Display_Elements::get_post_text_attr( $post_text, $feed_options, $post_id );
$text_and_link_attr = CTF_Display_Elements::get_element_attribute( 'text_and_link', $feed_options );
$text_no_link_attr = CTF_Display_Elements::get_element_attribute( 'text_no_link', $feed_options );