'; echo '
'; echo ''. $item['user']['name'] .''; echo '
'; echo ''; } // Render User Account public function render_post_user_profile_name( $settings, $class, $item ) { echo '
'; echo '
'; echo ''; echo '@'. $item['user']['screen_name'] .''; echo ''; echo '
'; echo '
'; } // Render User Account public function render_post_user_profile_picture( $settings, $class, $item ) { echo '
'; echo '
'; ?>
Image
'; echo '
'; } public function render_post_caption($settings, $class, $item) { if ( !isset($item['full_text']) || '' === $item['full_text'] ) { return; } echo '
'; echo '
'; echo '

'; $string = preg_replace("~[[:alpha:]]+://[^

[:space:]]+[[:alnum:]/]~", "\\0", $item['full_text']); $new_string = preg_replace('/\#([a-z0-9]+)/i', '#$1', $string); echo preg_replace('/\@([a-z0-9]+)/i', '@$1' ,$new_string); echo '

'; echo '
'; echo '
'; } public function render_post_date($settings, $class, $item) { echo '
'; echo '
'; echo ''; // Text: Before // if ( 'before' === $settings['element_extra_text_pos'] ) { // echo ''. esc_html( $settings['element_extra_text'] ) .''; // } // Icon: Before // if ( 'before' === $settings['element_extra_icon_pos'] ) { // echo ''; // } // echo wp_date(get_option( 'date_format' ), strtotime($item['created_at'])) echo human_time_diff(strtotime($item['created_at'])) .' '. esc_html__('ago', 'wpr-addons'); // Icon: After // if ( 'after' === $settings['element_extra_icon_pos'] ) { // echo ''; // } // Text: After // if ( 'after' === $settings['element_extra_text_pos'] ) { // echo ''. esc_html( $settings['element_extra_text'] ) .''; // } echo ''; echo '
'; echo '
'; } public function render_post_lightbox( $settings, $class, $item ) { echo '
'; echo '
'; $lightbox_source = $item['']; // Lightbox Button echo ''; // Text: Before if ( 'before' === $settings['element_extra_text_pos'] ) { echo ''. esc_html( $settings['element_extra_text'] ) .''; } // Lightbox Icon echo ''; // Text: After if ( 'after' === $settings['element_extra_text_pos'] ) { echo ''. esc_html( $settings['element_extra_text'] ) .''; } echo ''; // Media Overlay if ( 'yes' === $settings['element_lightbox_overlay'] ) { echo '
'; } echo '
'; echo '
'; } public function render_post_likes($settings, $class, $item) { echo '
'; echo '
'; ?> '; echo '
'; } public function render_post_comment($settings, $class, $item) { echo '
'; echo '
'; ?> '; echo '
'; } public function render_post_retweets($settings, $class, $item) { echo '
'; echo '
'; ?> '; echo '
'; } // Render Post Element Separator public function render_post_element_separator( $settings, $class ) { echo '
'; echo '
'; echo '
'; } public function render_post_media($settings, $class, $item) { if ( isset($item['extended_entities']) && null !== $item['extended_entities'] ) { if ( $item['extended_entities']['media'] ) { $media = $item['extended_entities']['media']; } else if ( isset( $item['retweeted_status']['entities']['media'] ) ) { $media = $item['retweeted_status']['entities']['media']; } else if ( isset( $item['quoted_status']['entities']['media'] ) ) { $media = $item['quoted_status']['entities']['media']; } else { $media = []; } } if ( !empty($media) ) { echo '
'; echo '
'; // && $media[0]['type'] == 'photo' echo (isset( $media[0] )) ? '' : ''; echo '
'; echo '
'; } } // Get Elements public function get_elements( $type, $settings, $class, $item ) { if ( 'pro-lk' == $type || 'pro-shr' == $type || 'pro-cf' == $type ) { $type = 'title'; } switch ( $type ) { case 'username': $this->render_post_username( $settings, $class, $item ); break; case 'profile-name': $this->render_post_user_profile_name( $settings, $class, $item ); break; case 'twit': $this->render_post_caption( $settings, $class, $item ); break; case 'date': $this->render_post_date( $settings, $class, $item ); break; case 'likes': $this->render_post_likes( $settings, $class, $item ); break; case 'comment': $this->render_post_comment( $settings, $class, $item ); break; case 'retweets': $this->render_post_retweets( $settings, $class, $item ); break; case 'media': $this->render_post_media( $settings, $class, $item ); break; case 'profile-picture': $this->render_post_user_profile_picture( $settings, $class, $item ); break; // case 'read-more': // $this->render_post_account_name( $settings, $class ); // break; // case 'lightbox': // $this->render_post_lightbox( $settings, $class, $item ); // break; case 'separator': $this->render_post_element_separator( $settings, $class ); break; } } // Get Elements by Location public function get_elements_by_location( $location, $settings, $item ) { $locations = []; foreach ( $settings['twitter_feed_elements'] as $data ) { $place = $data['element_location']; $align_vr = $data['element_align_vr']; if ( !defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code() ) { $align_vr = 'middle'; } if ( ! isset($locations[$place]) ) { $locations[$place] = []; } if ( 'over' === $place ) { if ( ! isset($locations[$place][$align_vr]) ) { $locations[$place][$align_vr] = []; } array_push( $locations[$place][$align_vr], $data ); } else { array_push( $locations[$place], $data ); } } if ( ! empty( $locations[$location] ) ) { if ( 'over' === $location ) { foreach ( $locations[$location] as $align => $thiss ) { if ( 'middle' === $align ) { echo '
'; } echo '
'; foreach ( $thiss as $data ) { // Get Class $class = 'wpr-twitter-feed-item-'. $data['element_select']; $class .= ' elementor-repeater-item-'. $data['_id']; $class .= ' wpr-twitter-feed-item-display-'. $data['element_display']; $class .= ' wpr-twitter-feed-item-align-'. $data['element_align_hr']; $class .= $this->get_animation_class( $data, 'element' ); // Element $this->get_elements( $data['element_select'], $data, $class, $item ); } echo '
'; if ( 'middle' === $align ) { echo '
'; } } } else { echo '
'; foreach ( $locations[$location] as $data ) { // Get Class $class = 'wpr-twitter-feed-item-'. $data['element_select']; $class .= ' elementor-repeater-item-'. $data['_id']; $class .= ' wpr-twitter-feed-item-display-'. $data['element_display']; $class .= ' wpr-twitter-feed-item-align-'. $data['element_align_hr']; // Element $this->get_elements( $data['element_select'], $data, $class, $item ); } echo '
'; } } } public function wpr_load_more_tweets_function() { $settings = $_POST['wpr_load_more_settings']; $credentials = base64_encode($settings['twitter_feed_consumer_key'] . ':' . $settings['twitter_feed_consumer_secret']); add_filter('https_ssl_verify', '__return_false'); $response = wp_remote_post('https://api.twitter.com/oauth2/token', [ 'method' => 'POST', 'httpversion' => '1.1', 'blocking' => true, 'headers' => [ 'Authorization' => 'Basic ' . $credentials, 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8', ], 'body' => ['grant_type' => 'client_credentials'], ]); $body = json_decode(wp_remote_retrieve_body($response)); if ($body) { $token = $body->access_token; } add_filter('https_ssl_verify', '__return_false'); $response = []; $items_array = []; foreach ($settings['twitter_accounts'] as $key=>$value) { $response[$key] = wp_remote_get('https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=' . $value['twitter_feed_account_name'] . '&count='. ($settings['number_of_posts'] + $_POST['next_post_index']) .'&tweet_mode=extended', [ 'httpversion' => '1.1', 'blocking' => true, 'headers' => [ 'Authorization' => "Bearer $token", ], ]); if ( is_wp_error( $response[$key] ) ) { return $response[$key]; } if ( ! empty( $response[$key]['response'] ) && $response[$key]['response']['code'] == 200 ) { $items_array[] = json_decode( wp_remote_retrieve_body( $response[$key] ), true ); } } foreach ( $items_array as $key=>$items ) : if ($settings['twitter_feed_hashtag_name']) { $hashtag_names = explode(',', str_replace(' ', '', $settings['twitter_feed_hashtag_name'])); foreach ($items as $key => $item) { $match = false; if ($item['entities']['hashtags']) { foreach ($item['entities']['hashtags'] as $tag) { if (in_array($tag['text'], $hashtag_names)) { $match = true; } } } if ($match == false) { unset($items[$key]); } } } foreach ( $items as $key=>$item) : if ( $key >= 6 && (!defined('WPR_ADDONS_PRO_VERSION') || !wpr_fs()->can_use_premium_code()) ) { break; } if ($key < $_POST['next_post_index']) : continue; endif; $banner_placeholder = WPR_ADDONS_ASSETS_URL . 'img/placeholder.png'; $banner = $item['user']['profile_banner_url'] ? $item['user']['profile_banner_url'] : $banner_placeholder; ?>
get_elements_by_location( 'above', $settings, $item ); ?>