function feed_them_twitter_options_page()
    {
        $fts_functions = new feed_them_social_functions();
        ?>
		<div class="feed-them-social-admin-wrap">
		<h1>
		<?php 
        _e('Twitter Feed Options', 'feed-them-social');
        ?>
		</h1>
		<div class="use-of-plugin">
		<?php 
        _e('Change the color of your twitter feed and more using the options below.', 'feed-them-social');
        ?>
		</div>
		<!-- custom option for padding -->
		<form method="post" class="fts-twitter-feed-options-form" action="options.php">
		<br/>
		<?php 
        // get our registered settings from the fts functions
        settings_fields('fts-twitter-feed-style-options');
        $twitter_full_width = get_option('twitter_full_width');
        $twitter_allow_videos = get_option('twitter_allow_videos');
        $twitter_allow_shortlink_conversion = get_option('twitter_allow_shortlink_conversion');
        $twitter_show_follow_btn = get_option('twitter_show_follow_btn');
        $twitter_show_follow_count = get_option('twitter_show_follow_count');
        $twitter_show_follow_btn_where = get_option('twitter_show_follow_btn_where');
        ?>
		<div class="feed-them-social-admin-input-wrap">
		<div class="fts-title-description-settings-page" style="border:none; padding-top:0px">
		<h3>
		<?php 
        _e('Follow Button Options', 'feed-them-social');
        ?>
		</h3>
		</div>
		<div class="feed-them-social-admin-input-label fts-twitter-text-color-label">
		<?php 
        _e('Show Follow Count', 'feed-them-social');
        ?>
		</div>
		<select name="twitter_show_follow_count" id="twitter-show-follow-count" class="feed-them-social-admin-input">
		<option '<?php 
        echo selected($twitter_show_follow_count, 'no', false);
        ?>
' value="no">
		<?php 
        _e('No', 'feed-them-social');
        ?>
		</option>
		<option '<?php 
        echo selected($twitter_show_follow_count, 'yes', false);
        ?>
' value="yes">
		<?php 
        _e('Yes', 'feed-them-social');
        ?>
		</option>
		</select>
		<div class="clear"></div>
		</div>
		<!--/fts-twitter-feed-styles-input-wrap-->
		
		<div class="feed-them-social-admin-input-wrap">
		<div class="feed-them-social-admin-input-label fts-twitter-text-color-label">
		<?php 
        _e('Show Follow Button', 'feed-them-social');
        ?>
		</div>
		<select name="twitter_show_follow_btn" id="twitter-show-follow-btn" class="feed-them-social-admin-input">
		<option '<?php 
        echo selected($twitter_show_follow_btn, 'no', false);
        ?>
' value="no">
		<?php 
        _e('No', 'feed-them-social');
        ?>
		</option>
		<option '<?php 
        echo selected($twitter_show_follow_btn, 'yes', false);
        ?>
' value="yes">
		<?php 
        _e('Yes', 'feed-them-social');
        ?>
		</option>
		</select>
		<div class="clear"></div>
		</div>
		<!--/fts-twitter-feed-styles-input-wrap-->
		
		<div class="feed-them-social-admin-input-wrap">
		<div class="feed-them-social-admin-input-label fts-twitter-text-color-label">
		<?php 
        _e('Placement of Follow Button', 'feed-them-social');
        ?>
		</div>
		<select name="twitter_show_follow_btn_where" id="twitter-show-follow-btn-where" class="feed-them-social-admin-input">
		<option >
		<?php 
        _e('Please Select Option', 'feed-them-social');
        ?>
		</option>
		<option '<?php 
        echo selected($twitter_show_follow_btn_where, 'twitter-follow-above', false);
        ?>
' value="twitter-follow-above">
		<?php 
        _e('Show Above Feed', 'feed-them-social');
        ?>
		</option>
		<option '<?php 
        echo selected($twitter_show_follow_btn_where, 'twitter-follow-below', false);
        ?>
' value="twitter-follow-below">
		<?php 
        _e('Show Below Feed', 'feed-them-social');
        ?>
		</option>
		</select>
		<div class="clear"></div>
		</div>
		<!--/fts-twitter-feed-styles-input-wrap-->
		
		<div class="feed-them-social-admin-input-wrap">
		<div class="fts-title-description-settings-page">
		<h3>
		<?php 
        _e('Video Player Options', 'feed-them-social');
        ?>
		</h3>
		</div>
		<div class="feed-them-social-admin-input-label fts-twitter-text-color-label">
		<?php 
        _e('Show Media button for videos<br/><small>Video shows upon clicking</small>', 'feed-them-social');
        ?>
		</div>
		<select name="twitter_allow_videos" id="twitter-allow-videos" class="feed-them-social-admin-input">
		<option '<?php 
        echo selected($twitter_allow_videos, 'no', false);
        ?>
' value="no">
		<?php 
        _e('No', 'feed-them-social');
        ?>
		</option>
		<option '<?php 
        echo selected($twitter_allow_videos, 'yes', false);
        ?>
' value="yes">
		<?php 
        _e('Yes', 'feed-them-social');
        ?>
		</option>
		</select>
		<div class="clear"></div>
		</div>
		<!--/fts-twitter-feed-styles-input-wrap-->
		
		<div class="feed-them-social-admin-input-wrap">
		<div class="feed-them-social-admin-input-label fts-twitter-text-color-label">
		<?php 
        _e('Convert shortlinks for video<br/><small>Like bitly etc. May slow load time slightly</small>', 'feed-them-social');
        ?>
		</div>
		<select name="twitter_allow_shortlink_conversion" id="twitter-allow-shortlink-conversion" class="feed-them-social-admin-input">
		<option '<?php 
        echo selected($twitter_allow_shortlink_conversion, 'no', false);
        ?>
' value="no">
		<?php 
        _e('No', 'feed-them-social');
        ?>
		</option>
		<option '<?php 
        echo selected($twitter_allow_shortlink_conversion, 'yes', false);
        ?>
' value="yes">
		<?php 
        _e('Yes', 'feed-them-social');
        ?>
		</option>
		</select>
		<div class="clear"></div>
		</div>
		<!--/fts-twitter-feed-styles-input-wrap-->
		
		<div class="feed-them-social-admin-input-wrap">
		<div class="fts-title-description-settings-page">
		<h3>
		<?php 
        _e('Profile Photo Option', 'feed-them-social');
        ?>
		</h3>
		</div>
		<div class="feed-them-social-admin-input-label fts-twitter-text-color-label">
		<?php 
        _e('Hide Profile Photo', 'feed-them-social');
        ?>
		</div>
		<select name="twitter_full_width" id="twitter-full-width" class="feed-them-social-admin-input">
		<option '<?php 
        echo selected($twitter_full_width, 'no', false);
        ?>
' value="no">
		<?php 
        _e('No', 'feed-them-social');
        ?>
		</option>
		<option '<?php 
        echo selected($twitter_full_width, 'yes', false);
        ?>
' value="yes">
		<?php 
        _e('Yes', 'feed-them-social');
        ?>
		</option>
		</select>
		<div class="clear"></div>
		</div>
		<!--/fts-twitter-feed-styles-input-wrap-->
		
		<div class="feed-them-social-admin-input-wrap">
		<div class="fts-title-description-settings-page">
		<h3>
		<?php 
        _e('Style Options', 'feed-them-social');
        ?>
		</h3>
		</div>
		<div class="feed-them-social-admin-input-label fts-twitter-text-color-label">
		<?php 
        _e('Feed Text Color', 'feed-them-social');
        ?>
		</div>
		<input type="text" name="twitter_text_color" class="feed-them-social-admin-input twitter-text-color-input color {hash:true,caps:false,required:false,adjust:false,pickerFaceColor:'#eee',pickerFace:3,pickerBorder:0,pickerInsetColor:'white'}"  id="twitter-text-color-input" placeholder="#222" value="<?php 
        echo get_option('twitter_text_color');
        ?>
"/>
		<div class="clear"></div>
		</div>
		<!--/fts-twitter-feed-styles-input-wrap-->
		
		<div class="feed-them-social-admin-input-wrap">
		<div class="feed-them-social-admin-input-label fts-twitter-link-color-label">
		<?php 
        _e('Feed Link Color', 'feed-them-social');
        ?>
		</div>
		<input type="text" name="twitter_link_color" class="feed-them-social-admin-input twitter-link-color-input color {hash:true,caps:false,required:false,adjust:false,pickerFaceColor:'#eee',pickerFace:3,pickerBorder:0,pickerInsetColor:'white'}"  id="twitter-link-color-input" placeholder="#222" value="<?php 
        echo get_option('twitter_link_color');
        ?>
"/>
		<div class="clear"></div>
		</div>
		<!--/fts-twitter-feed-styles-input-wrap-->
		
		<div class="feed-them-social-admin-input-wrap">
		<div class="feed-them-social-admin-input-label fts-twitter-link-color-hover-label">
		<?php 
        _e('Feed Link Color Hover', 'feed-them-social');
        ?>
		</div>
		<input type="text" name="twitter_link_color_hover" class="feed-them-social-admin-input twitter-link-color-hover-input color {hash:true,caps:false,required:false,adjust:false,pickerFaceColor:'#eee',pickerFace:3,pickerBorder:0,pickerInsetColor:'white'}"  id="twitter-link-color-hover-input" placeholder="#ddd" value="<?php 
        echo get_option('twitter_link_color_hover');
        ?>
"/>
		<div class="clear"></div>
		</div>
		<!--/fts-twitter-feed-styles-input-wrap-->
		
		<div class="feed-them-social-admin-input-wrap">
		<div class="feed-them-social-admin-input-label fts-twitter-feed-width-label">
		<?php 
        _e('Feed Width', 'feed-them-social');
        ?>
		</div>
		<input type="text" name="twitter_feed_width" class="feed-them-social-admin-input twitter-feed-width-input"  id="twitter-feed-width-input" placeholder="500px" value="<?php 
        echo get_option('twitter_feed_width');
        ?>
"/>
		<div class="clear"></div>
		</div>
		<!--/fts-twitter-feed-styles-input-wrap-->
		
		<div class="feed-them-social-admin-input-wrap">
		<div class="feed-them-social-admin-input-label fts-twitter-feed-margin-label">
		<?php 
        _e('Feed Margin <br/><small>To center feed type auto</small>', 'feed-them-social');
        ?>
		</div>
		<input type="text" name="twitter_feed_margin" class="feed-them-social-admin-input twitter-feed-margin-input"  id="twitter-feed-margin-input" placeholder="10px" value="<?php 
        echo get_option('twitter_feed_margin');
        ?>
"/>
		<div class="clear"></div>
		</div>
		<!--/fts-twitter-feed-styles-input-wrap-->
		
		<div class="feed-them-social-admin-input-wrap">
		<div class="feed-them-social-admin-input-label fts-twitter-feed-padding-label">
		<?php 
        _e('Feed Padding', 'feed-them-social');
        ?>
		</div>
		<input type="text" name="twitter_feed_padding" class="feed-them-social-admin-input twitter-feed-padding-input"  id="twitter-feed-padding-input" placeholder="10px" value="<?php 
        echo get_option('twitter_feed_padding');
        ?>
"/>
		<div class="clear"></div>
		</div>
		<!--/fts-twitter-feed-styles-input-wrap-->
		
		<div class="feed-them-social-admin-input-wrap">
		<div class="feed-them-social-admin-input-label fts-twitter-feed-background-color-label">
		<?php 
        _e('Feed Background Color', 'feed-them-social');
        ?>
		</div>
		<input type="text" name="twitter_feed_background_color" class="feed-them-social-admin-input twitter-feed-background-color-input color {hash:true,caps:false,required:false,adjust:false,pickerFaceColor:'#eee',pickerFace:3,pickerBorder:0,pickerInsetColor:'white'}"  id="twitter-feed-background-color-input" placeholder="#ddd" value="<?php 
        echo get_option('twitter_feed_background_color');
        ?>
"/>
		<div class="clear"></div>
		</div>
		<!--/fts-twitter-feed-styles-input-wrap-->
		
		<div class="feed-them-social-admin-input-wrap">
		<div class="feed-them-social-admin-input-label fts-twitter-border-bottom-color-label">
		<?php 
        _e('Feed Border Bottom Color', 'feed-them-social');
        ?>
		</div>
		<input type="text" name="twitter_border_bottom_color" class="feed-them-social-admin-input twitter-border-bottom-color-input color {hash:true,caps:false,required:false,adjust:false,pickerFaceColor:'#eee',pickerFace:3,pickerBorder:0,pickerInsetColor:'white'}"  id="twitter-border-bottom-color-input" placeholder="#ddd" value="<?php 
        echo get_option('twitter_border_bottom_color');
        ?>
"/>
		<div class="clear"></div>
		</div>
		<!--/fts-twitter-feed-styles-input-wrap-->
		
		<?php 
        $test_fts_twitter_custom_consumer_key = get_option('fts_twitter_custom_consumer_key');
        $test_fts_twitter_custom_consumer_secret = get_option('fts_twitter_custom_consumer_secret');
        $test_fts_twitter_custom_access_token = get_option('fts_twitter_custom_access_token');
        $test_fts_twitter_custom_access_token_secret = get_option('fts_twitter_custom_access_token_secret');
        if (isset($_GET['page']) && $_GET['page'] == 'fts-twitter-feed-styles-submenu-page') {
            include WP_CONTENT_DIR . '/plugins/feed-them-social/feeds/twitter/twitteroauth/twitteroauth.php';
            $test_connection = new TwitterOAuthFTS($test_fts_twitter_custom_consumer_key, $test_fts_twitter_custom_consumer_secret, $test_fts_twitter_custom_access_token, $test_fts_twitter_custom_access_token_secret);
            $fetchedTweets = $test_connection->get('statuses/user_timeline', array('screen_name' => 'twitter', 'count' => '1'));
        }
        ?>
		<div class="feed-them-social-admin-input-wrap">
		<div class="fts-title-description-settings-page">
		<h3>
		<?php 
        _e('Twitter API Token', 'feed-them-social');
        ?>
		</h3>
		<?php 
        _e('If you keep seeing the message \'sorry twitter is down and will be right back\', it may be a good idea to add your own tokens below. See how to <a href="http://www.slickremix.com/docs/how-to-get-api-keys-and-tokens-for-twitter/" target="_blank">get API Keys and Tokens for Twitter</a>. Leave the fields below empty to use our Default API access tokens. If you do add your own tokens, after Saving all Changes make sure and <a href="admin.php?page=feed-them-settings-page&cache=clearcache">click here to delete cache</a>.', 'feed-them-social');
        ?>
		</div>
		</div>
		<div class="twitter-api-wrap">
		<div class="feed-them-social-admin-input-wrap">
		<div class="feed-them-social-admin-input-label fts-twitter-border-bottom-color-label">
		<?php 
        _e('Consumer Key (API Key)', 'feed-them-social');
        ?>
		</div>
		<input type="text" name="fts_twitter_custom_consumer_key" class="feed-them-social-admin-input"  id="fts_facebook_custom_api_token" value="<?php 
        echo get_option('fts_twitter_custom_consumer_key');
        ?>
"/>
		<div class="clear"></div>
		</div>
		<div class="feed-them-social-admin-input-wrap">
		<div class="feed-them-social-admin-input-label fts-twitter-border-bottom-color-label">
		<?php 
        _e('Consumer Secret (API Secret)', 'feed-them-social');
        ?>
		</div>
		<input type="text" name="fts_twitter_custom_consumer_secret" class="feed-them-social-admin-input"  id="fts_facebook_custom_api_token" value="<?php 
        echo get_option('fts_twitter_custom_consumer_secret');
        ?>
"/>
		<div class="clear"></div>
		</div>
		<div class="feed-them-social-admin-input-wrap">
		<div class="feed-them-social-admin-input-label fts-twitter-border-bottom-color-label">
		<?php 
        _e('Access Token', 'feed-them-social');
        ?>
		</div>
		<input type="text" name="fts_twitter_custom_access_token" class="feed-them-social-admin-input"  id="fts_facebook_custom_api_token" value="<?php 
        echo get_option('fts_twitter_custom_access_token');
        ?>
"/>
		<div class="clear"></div>
		</div>
		<div class="feed-them-social-admin-input-wrap">
		<div class="feed-them-social-admin-input-label fts-twitter-border-bottom-color-label">
		<?php 
        _e('Access Token Secret', 'feed-them-social');
        ?>
		</div>
		<input type="text" name="fts_twitter_custom_access_token_secret" class="feed-them-social-admin-input"  id="fts_facebook_custom_api_token" value="<?php 
        echo get_option('fts_twitter_custom_access_token_secret');
        ?>
"/>
		<div class="clear"></div>
		</div>
		</div>
		<!--twitter-api-wrap-->
		<div class="feed-them-social-admin-input-wrap">
		<?php 
        if (!empty($test_fts_twitter_custom_consumer_key) && !empty($test_fts_twitter_custom_consumer_secret) && !empty($test_fts_twitter_custom_access_token) && !empty($test_fts_twitter_custom_access_token_secret)) {
            if ($test_connection->http_code != 200 || isset($fetchedTweets->errors)) {
                echo '<div class="fts-failed-api-token">' . __('Oh No something\'s wrong.', 'feed-them-social') . '';
                foreach ($fetchedTweets->errors as $error) {
                    echo ' <strong>' . $error->message . '. </strong> ' . __('You may have entered in the Access information incorrectly please re-enter and try again.', 'feed-them-social') . '';
                }
                echo '</div>';
            } else {
                echo '<div class="fts-successful-api-token">' . __('Your access token is working!', 'feed-them-social') . '</div>';
            }
        } else {
            echo '<div class="fts-successful-api-token">' . __('You are using our Default Access info.', 'feed-them-social') . '</div>';
        }
        ?>
		<div class="clear"></div>
		<input type="submit" class="feed-them-social-admin-submit-btn" value="<?php 
        _e('Save All Changes');
        ?>
" />
		</div>
		</form>
		<a class="feed-them-social-admin-slick-logo" href="http://www.slickremix.com" target="_blank"></a> </div>
		<!--/feed-them-social-admin-wrap-->
	
	<?php 
    }
 function fts_load_videos()
 {
     if (!wp_verify_nonce($_REQUEST['fts_security'], $_REQUEST['fts_time'] . 'load-more-nonce')) {
         exit('Sorry, You can\'t do that!');
     } else {
         $tFinal = $_REQUEST['fts_link'];
         //strip Vimeo URL then ouput Iframe
         if (strpos($tFinal, 'vimeo') > 0) {
             if (strpos($tFinal, 'staffpicks') > 0) {
                 $parsed_url = $tFinal;
                 // var_dump(parse_url($parsed_url));
                 $parsed_url = parse_url($parsed_url);
                 $vimeoURLfinal = preg_replace('/\\D/', '', $parsed_url["path"]);
             } else {
                 $vimeoURLfinal = (int) substr(parse_url($tFinal, PHP_URL_PATH), 1);
                 // echo $vimeoURLfinal;
             }
             // echo $vimeoURLfinal;
             echo '<div class="fts-fluid-videoWrapper"><iframe src="http://player.vimeo.com/video/' . $vimeoURLfinal . '?autoplay=0" class="video" height="390" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div>';
         } elseif (strpos($tFinal, 'amp.twimg.com') > 0) {
             include_once WP_CONTENT_DIR . '/plugins/feed-them-social/feeds/twitter/twitteroauth/twitteroauth.php';
             $fts_twitter_custom_consumer_key = get_option('fts_twitter_custom_consumer_key');
             $fts_twitter_custom_consumer_secret = get_option('fts_twitter_custom_consumer_secret');
             $fts_twitter_custom_access_token = get_option('fts_twitter_custom_access_token');
             $fts_twitter_custom_access_token_secret = get_option('fts_twitter_custom_access_token_secret');
             //Use custom api info
             if (!empty($fts_twitter_custom_consumer_key) && !empty($fts_twitter_custom_consumer_secret) && !empty($fts_twitter_custom_access_token) && !empty($fts_twitter_custom_access_token_secret)) {
                 $connection = new TwitterOAuthFTS($fts_twitter_custom_consumer_key, $fts_twitter_custom_consumer_secret, $fts_twitter_custom_access_token, $fts_twitter_custom_access_token_secret);
             } else {
                 $connection = new TwitterOAuthFTS('dOIIcGrhWgooKquMWWXg', 'qzAE4t4xXbsDyGIcJxabUz3n6fgqWlg8N02B6zM', '1184502104-Cjef1xpCPwPobP5X8bvgOTbwblsmeGGsmkBzwdB', 'd789TWA8uwwfBDjkU0iJNPDz1UenRPTeJXbmZZ4xjY');
             }
             if (strpos($tFinal, 'amp.twimg.com') > 0) {
                 $videosDecode = $_REQUEST['fts_post_id'];
                 $fetchedTweets2 = $connection->get('statuses/oembed', array('id' => $videosDecode, 'widget_type' => 'video', 'hide_tweet' => true, 'hide_thread' => true, 'hide_media' => false, 'omit_script' => false));
                 echo $fetchedTweets2->html;
             } else {
                 exit('That is not allowed. FTS!');
             }
         } elseif (strpos($tFinal, 'vine') > 0 && !strpos($tFinal, '-vine') > 0) {
             // $pattern = str_replace( array( 'https://vine.co/v/', '/', 'http://vine.co/v/'), '', $tFinal);
             // $vineURLfinal = $pattern;
             echo '<div class="fts-fluid-videoWrapper"><iframe height="281" class="fts-vine-embed" src="' . $tFinal . '/embed/simple" frameborder="0"></iframe></div>';
         } elseif (strpos($tFinal, 'youtube') > 0 && !strpos($tFinal, '-youtube') > 0) {
             $pattern = '#^(?:https?://)?(?:www\\.)?(?:youtu\\.be/|youtube\\.com(?:/embed/|/v/|/watch\\?v=|/watch\\?.+&v=))([\\w-]{11})(?:.+)?$#x';
             preg_match($pattern, $tFinal, $matches);
             $youtubeURLfinal = $matches[1];
             echo '<div class="fts-fluid-videoWrapper"><iframe height="281" class="video" src="http://www.youtube.com/embed/' . $youtubeURLfinal . '?autoplay=0" frameborder="0" allowfullscreen></iframe></div>';
         } elseif (strpos($tFinal, 'youtu.be') > 0) {
             $pattern = '#^(?:https?://)?(?:www\\.)?(?:youtu\\.be/|youtube\\.com(?:/embed/|/v/|/watch\\?v=|/watch\\?.+&v=))([\\w-]{11})(?:.+)?$#x';
             preg_match($pattern, $tFinal, $matches);
             $youtubeURLfinal = $matches[1];
             echo '<div class="fts-fluid-videoWrapper"><iframe height="281" class="video" src="http://www.youtube.com/embed/' . $youtubeURLfinal . '?autoplay=0" frameborder="0" allowfullscreen></iframe></div>';
         } elseif (strpos($tFinal, 'soundcloud') > 0) {
             //Get the JSON data of song details with embed code from SoundCloud oEmbed
             $getValues = file_get_contents('http://soundcloud.com/oembed?format=js&url=' . $tFinal . '&auto_play=false&iframe=true');
             //Clean the Json to decode
             $decodeiFrame = substr($getValues, 1, -2);
             //json decode to convert it as an array
             $jsonObj = json_decode($decodeiFrame);
             echo '<div class="fts-fluid-videoWrapper">' . $jsonObj->html . '</div>';
         }
     }
     // end main else
     die;
 }
Esempio n. 3
0
    function fts_twitter_func($atts)
    {
        global $connection;
        $twitter_show_follow_btn = get_option('twitter_show_follow_btn');
        $twitter_show_follow_btn_where = get_option('twitter_show_follow_btn_where');
        $twitter_show_follow_count = get_option('twitter_show_follow_count');
        include_once ABSPATH . 'wp-admin/includes/plugin.php';
        //$fts_functions = new feed_them_social_functions;
        $twitter_allow_shortlink_conversion = get_option('twitter_allow_shortlink_conversion');
        $twitter_allow_videos = get_option('twitter_allow_videos');
        if (isset($twitter_allow_shortlink_conversion) && $twitter_allow_shortlink_conversion == 'yes' && isset($twitter_allow_shortlink_conversion) && $twitter_allow_shortlink_conversion == 'yes') {
            wp_enqueue_script('fts-longurl-js', plugins_url('feed-them-social/feeds/js/jquery.longurl.js'));
        }
        // option to allow this action or not from the Twitter Options page
        if (is_plugin_active('feed-them-premium/feed-them-premium.php')) {
            include WP_CONTENT_DIR . '/plugins/feed-them-premium/feeds/twitter/twitter-feed.php';
            if ($popup == 'yes') {
                // it's ok if these styles & scripts load at the bottom of the page
                $fts_fix_magnific = get_option('fts_fix_magnific') ? get_option('fts_fix_magnific') : '';
                if (isset($fts_fix_magnific) && $fts_fix_magnific !== '1') {
                    wp_enqueue_style('fts-popup', plugins_url('feed-them-social/feeds/css/magnific-popup.css'));
                }
                wp_enqueue_script('fts-popup-js', plugins_url('feed-them-social/feeds/js/magnific-popup.js'));
            }
        } else {
            extract(shortcode_atts(array('twitter_name' => '', 'twitter_height' => '', 'description_image' => '', 'search' => ''), $atts));
            $tweets_count = '5';
        }
        ob_start();
        $numTweets = $tweets_count;
        $name = $twitter_name;
        $excludeReplies = true;
        if (!empty($search)) {
            $data_cache = 'twitter_data_cache_' . $search . '_num' . $numTweets . '';
        } else {
            $data_cache = 'twitter_data_cache_' . $name . '_num' . $numTweets . '';
        }
        //Check Cache
        if (false !== ($transient_exists = $this->fts_check_feed_cache_exists($data_cache))) {
            $fetchedTweets = $this->fts_get_feed_cache($data_cache);
            $cache_used = true;
        } else {
            include_once WP_CONTENT_DIR . '/plugins/feed-them-social/feeds/twitter/twitteroauth/twitteroauth.php';
            $fts_twitter_custom_consumer_key = get_option('fts_twitter_custom_consumer_key');
            $fts_twitter_custom_consumer_secret = get_option('fts_twitter_custom_consumer_secret');
            $fts_twitter_custom_access_token = get_option('fts_twitter_custom_access_token');
            $fts_twitter_custom_access_token_secret = get_option('fts_twitter_custom_access_token_secret');
            //Use custom api info
            if (!empty($fts_twitter_custom_consumer_key) && !empty($fts_twitter_custom_consumer_secret) && !empty($fts_twitter_custom_access_token) && !empty($fts_twitter_custom_access_token_secret)) {
                $connection = new TwitterOAuthFTS($fts_twitter_custom_consumer_key, $fts_twitter_custom_consumer_secret, $fts_twitter_custom_access_token, $fts_twitter_custom_access_token_secret);
            } else {
                $connection = new TwitterOAuthFTS('dOIIcGrhWgooKquMWWXg', 'qzAE4t4xXbsDyGIcJxabUz3n6fgqWlg8N02B6zM', '1184502104-Cjef1xpCPwPobP5X8bvgOTbwblsmeGGsmkBzwdB', 'd789TWA8uwwfBDjkU0iJNPDz1UenRPTeJXbmZZ4xjY');
            }
            // $videosDecode = 'https://api.twitter.com/1.1/statuses/oembed.json?id=507185938620219395';
            // If excluding replies, we need to fetch more than requested as the
            // total is fetched first, and then replies removed.
            $totalToFetch = $excludeReplies ? max(50, $numTweets * 3) : $numTweets;
            $description_image = !empty($description_image) ? $description_image : "";
            // $url_of_status = !empty($url_of_status) ? $url_of_status : "";
            // $widget_type_for_videos = !empty($widget_type_for_videos) ? $widget_type_for_videos : "";
            if (!empty($search)) {
                $fetchedTweets = $connection->get('search/tweets', array('q' => $search, 'count' => $totalToFetch, 'result_type' => 'recent'));
            } else {
                $fetchedTweets = $connection->get('statuses/user_timeline', array('screen_name' => $name, 'count' => $totalToFetch, 'exclude_replies' => $excludeReplies, 'images' => $description_image));
            }
            // echo'<pre>';
            // print_r($fetchedTweets);
            // echo'</pre>';
            if (!empty($search)) {
                $fetchedTweets = $fetchedTweets->statuses;
            } else {
                $fetchedTweets = $fetchedTweets;
            }
            // $screen_name = $q;
        }
        //END ELSE
        //Error Check
        if (isset($fetchedTweets->errors)) {
            $error_check = '<div>Oops, Somethings wrong. ' . $fetchedTweets->errors[0]->message . '.</div>';
            if ($fetchedTweets->errors[0]->code == 32) {
                $error_check .= ' Please check that you have entered your Twitter API token information correctly.';
            }
            if ($fetchedTweets->errors[0]->code == 34) {
                $error_check .= ' Please check the Twitter Username you have entered is correct.';
            }
        } elseif (empty($fetchedTweets) && !isset($fetchedTweets->errors)) {
            $error_check = '<div>This account has no tweets. Please Tweet to see this feed.</div>';
        }
        //IS RATE LIMIT REACHED?
        if (isset($fetchedTweets->errors)) {
            echo '<pre>';
            print_r($fetchedTweets->errors);
            echo 'If you are seeing Rate Limited Exceeded please go to our Twitter Options page and follow the instructions under the header Twitter API Token.';
            echo '</pre>';
        }
        // Did the fetch fail?
        if (isset($error_check)) {
            echo $error_check;
        } else {
            if (!empty($fetchedTweets)) {
                //Cache It
                if (!isset($cache_used)) {
                    $this->fts_create_feed_cache($data_cache, $fetchedTweets);
                }
                // Fetch succeeded.
                // Now update the array to store just what we need.
                // (Done here instead of PHP doing this for every page load)
                $limitToDisplay = min($numTweets, count($fetchedTweets));
                for ($i = 0; $i < $limitToDisplay; $i++) {
                    $tweet = $fetchedTweets[$i];
                    // Core info.
                    $name = isset($tweet->user->name) ? $tweet->user->name : "";
                    $screen_name = isset($tweet->user->screen_name) ? $tweet->user->screen_name : "";
                    $protocol = isset($_SERVER["HTTPS"]) ? 'https://' : 'http://';
                    $not_protocol = !isset($_SERVER["HTTPS"]) ? 'https://' : 'http://';
                    $permalink = $protocol . 'twitter.com/' . $screen_name . '/status/' . $tweet->id_str;
                    $user_permalink = $protocol . 'twitter.com/#!/' . $screen_name;
                    //Is Media Set
                    if (isset($tweet->entities->media[0]->media_url)) {
                        $media_url = $tweet->entities->media[0]->media_url;
                        $media_url = str_replace($not_protocol, $protocol, $media_url);
                    } else {
                        $media_url = '';
                    }
                    //  $widget_type_for_videos = $tweet->widget_type_for_videos;
                    /* Alternative image sizes method: http://dev.twitter.com/doc/get/users/profile_image/:screen_name */
                    $image = isset($tweet->user->profile_image_url) ? $tweet->user->profile_image_url : "";
                    $image = str_replace($not_protocol, $protocol, $image);
                    // Message. Convert links to real links.
                    $pattern = array('/http:(\\S)+/', '/https:(\\S)+/', '/([^a-zA-Z0-9-_&])@([0-9a-zA-Z_]+)/', '/([^a-zA-Z0-9-_&])#([0-9a-zA-Z_]+)/');
                    $replace = array(' <a href="${0}" target="_blank" rel="nofollow">${0}</a>', ' <a href="${0}" target="_blank" rel="nofollow">${0}</a>', ' <a href="' . $protocol . 'twitter.com/$2" target="_blank" rel="nofollow">@$2</a>', ' <a href="' . $protocol . 'twitter.com/search?q=%23$2&src=hash" target="_blank" rel="nofollow">#$2</a>');
                    $text = preg_replace($pattern, $replace, $tweet->text);
                    // Need to get time in Unix format.
                    $times = isset($tweet->created_at) ? $tweet->created_at : "";
                    $ftsCustomDate = get_option('fts-custom-date');
                    $ftsCustomTime = get_option('fts-custom-time');
                    $CustomDateCheck = get_option('fts-date-and-time-format');
                    if ($ftsCustomDate == '' && $ftsCustomTime == '') {
                        $CustomDateFormatTwitter = get_option('fts-date-and-time-format');
                    } else {
                        if ($ftsCustomDate !== '' || $ftsCustomTime !== '') {
                            $CustomDateFormatTwitter = get_option('fts-custom-date') . ' ' . get_option('fts-custom-time');
                        } else {
                            $CustomDateFormatTwitter = 'F jS, Y \\a\\t g:ia';
                        }
                    }
                    date_default_timezone_set(get_option('fts-timezone'));
                    if ($CustomDateCheck == 'one-day-ago') {
                        $times = strtotime($times) - 3 * 3600;
                        $date = date_create(date('F jS, Y g:ia', $times));
                        $timestamp = date_timestamp_get($date);
                        $getFtsAgo = new feed_them_social_functions();
                        $uTime = $getFtsAgo->fts_ago($times);
                    } else {
                        $uTime = date($CustomDateFormatTwitter, strtotime($times) - 3 * 3600);
                    }
                    $id = isset($tweet->id) ? $tweet->id : "";
                    $fts_twitter_full_width = get_option('twitter_full_width');
                    $followers_count = isset($tweet->user->followers_count) ? $tweet->user->followers_count : "";
                    // $urls string is used so we can parse out video files
                    $urls = isset($tweet->entities->urls[0]->expanded_url) ? $tweet->entities->urls[0]->expanded_url : "";
                    // Now make the new array.
                    $tweets[] = array('text' => $text, 'name' => $name, 'screen_name' => $screen_name, 'user_permalink' => $user_permalink, 'permalink' => $permalink, 'image' => $image, 'time' => $uTime, 'media_url' => $media_url, 'id' => $id, 'urls' => $urls);
                }
                //End FOR fts-twitter-full-width
                // echo '<pre>';
                //  print_r($tweets);
                // echo '</pre>';
                $twitter_allow_shortlink_conversion = get_option('twitter_allow_shortlink_conversion');
                ?>
<div id="twitter-feed-<?php 
                print $twitter_name;
                ?>
" class="fts-twitter-div<?php 
                if ($twitter_height !== 'auto' && empty($twitter_height) == NULL) {
                    ?>
 fts-twitter-scrollable<?php 
                }
                if (isset($popup) && $popup == 'yes') {
                    ?>
 popup-gallery-twitter<?php 
                }
                ?>
" <?php 
                if ($twitter_height !== 'auto' && empty($twitter_height) == NULL) {
                    ?>
style="height:<?php 
                    echo $twitter_height;
                    ?>
"<?php 
                }
                ?>
>
 <?php 
                //******************
                // SOCIAL BUTTON
                //******************
                if (!empty($search)) {
                    $screen_name = $twitter_name;
                }
                if (isset($twitter_show_follow_btn) && $twitter_show_follow_btn == 'yes' && $twitter_show_follow_btn_where == 'twitter-follow-above' && $twitter_name !== '') {
                    echo '<div class="twitter-social-btn-top">';
                    $this->social_follow_button('twitter', $screen_name);
                    echo '</div>';
                }
                // option to allow the followers plus count to show
                if (isset($twitter_show_follow_count) && $twitter_show_follow_count == 'yes' && $search == '') {
                    print '<div class="twitter-followers-fts"><a href="' . $user_permalink . '" target="_blank" class="black">' . __('Followers:', 'feed-them-social') . '</a> ' . number_format($followers_count) . '</div>';
                }
                ?>
  <?php 
                foreach ($tweets as $t) {
                    $twitter_allow_videos = get_option('twitter_allow_videos');
                    if (!empty($t['urls']) && $twitter_allow_videos !== 'no') {
                        $type = 'twitterFeed';
                        $fts_dynamic_vid_name_string = trim($this->rand_string_twitter(10) . '_' . $type);
                        $fts_dynamic_name = '';
                        if (isset($fts_dynamic_vid_name_string)) {
                            $fts_dynamic_name = 'feed_dynamic_class' . $fts_dynamic_vid_name_string;
                        }
                        // ajax part
                        $time = time();
                        $nonce = wp_create_nonce($time . "load-more-nonce");
                        ?>
<script type="text/javascript">
	jQuery(document).ready(function () {
	 <?php 
                        // option to allow this action or not from the Twitter Options page
                        if (isset($twitter_allow_shortlink_conversion) && $twitter_allow_shortlink_conversion == 'yes') {
                            // API that converts shortlinks. longurlplease.com
                            print 'jQuery.longurlplease();';
                        }
                        ?>
	  jQuery('.<?php 
                        echo $fts_dynamic_name;
                        ?>
 a.fts-twitter-load-video').click(function(){
		  var fts_link = jQuery(this).attr('href');
		  var fts_security = "<?php 
                        echo $nonce;
                        ?>
";
		  var fts_post_id = "<?php 
                        echo $t['id'];
                        ?>
";
		  var fts_time = "<?php 
                        echo $time;
                        ?>
";
		  console.log('Submit Function');
		  jQuery.ajax({
				  data: {action: "fts_load_videos", fts_link: fts_link, fts_security: fts_security, fts_time: fts_time, fts_post_id: fts_post_id},
				  type: 'GET',
				  url: myAjaxFTS,
				  beforeSend: function() {
				  	jQuery('.<?php 
                        echo $fts_dynamic_name;
                        ?>
 .fts-video-loading-notice').fadeIn();
           		   },
				  success: function(data) {
				  jQuery('.<?php 
                        echo $fts_dynamic_name;
                        ?>
 .fts-video-loading-notice').hide();
				  jQuery('.<?php 
                        echo $fts_dynamic_name;
                        ?>
 .fts-video-wrapper').append(data).filter('.<?php 
                        echo $fts_dynamic_name;
                        ?>
 .fts-video-wrapper').html();
				  jQuery('a.<?php 
                        echo $fts_dynamic_name;
                        ?>
 .twitter-video').hide();
				  jQuery('a.<?php 
                        echo $fts_dynamic_name;
                        ?>
').hide();
				  jQuery('a.<?php 
                        echo $fts_dynamic_name;
                        ?>
.fts-close-media').show();
				  jQuery('.<?php 
                        echo $fts_dynamic_name;
                        ?>
 .fts-video-wrapper-padding').slideDown();
				  console.log('Well Done and got this from sever: ' + data);
			  }
		  }); // end of ajax()
		  return false;
	  })
	   jQuery('.<?php 
                        echo $fts_dynamic_name;
                        ?>
 .fts-close-media').click(function(){
				  jQuery('a.<?php 
                        echo $fts_dynamic_name;
                        ?>
.fts-close-media span.fts-show-media-text').toggle();
				  jQuery('a.<?php 
                        echo $fts_dynamic_name;
                        ?>
.fts-close-media span.fts-hide-media-text').toggle();
				  jQuery('.<?php 
                        echo $fts_dynamic_name;
                        ?>
 .fts-video-wrapper-padding').slideToggle();
	    return false;
	  })
	});
</script>
<?php 
                    }
                    // END if not empty $t['urls']
                    $fts_dynamic_name = isset($fts_dynamic_name) ? $fts_dynamic_name : '';
                    ?>
  <div class="fts-tweeter-wrap <?php 
                    echo $fts_dynamic_name;
                    ?>
">
    <div class="tweeter-info">
      <?php 
                    if ($fts_twitter_full_width !== 'yes') {
                        ?>
      <div class="fts-twitter-image"><a href="<?php 
                        print $t['user_permalink'];
                        ?>
" target="_blank" class="black"><img class="twitter-image" src="<?php 
                        print $t['image'];
                        ?>
" alt="<?php 
                        print $t['screen_name'];
                        ?>
"/></a></div>
      <?php 
                    }
                    ?>
      <div class="<?php 
                    if ($fts_twitter_full_width == 'yes') {
                        ?>
fts-twitter-full-width<?php 
                    } else {
                        ?>
right<?php 
                    }
                    ?>
">
        <div class="uppercase bold"><a href="<?php 
                    print $t['user_permalink'];
                    ?>
" target="_blank" class="black">@<?php 
                    print $t['screen_name'];
                    ?>
</a></div>
        <span class="time"><a href="<?php 
                    print $t['permalink'];
                    ?>
" target="_blank"><?php 
                    print $t['time'];
                    ?>
</a></span><br/>
        <span class="fts-twitter-text"><?php 
                    print nl2br($t['text']);
                    ?>
        <div class="fts-twitter-caption"><a href="<?php 
                    print $t['permalink'];
                    ?>
" class="fts-view-on-twitter-link" target="_blank"><?php 
                    echo _e('View on Twitter', 'feed-them-social');
                    ?>
</a></div>
        </span>
        <?php 
                    if ($t['media_url'] !== '') {
                        ?>
										<a href="<?php 
                        if (isset($popup) && $popup == 'yes') {
                            print $t['media_url'];
                        } else {
                            print $t['permalink'];
                        }
                        ?>
" class="fts-twitter-link-image" target="_blank"><img class="fts-twitter-description-image" src="<?php 
                        print $t['media_url'];
                        ?>
" alt="<?php 
                        print $t['screen_name'];
                        ?>
 photo" /></a> <?php 
                    }
                    $tFinal = $t['urls'];
                    $twitter_allow_videos = get_option('twitter_allow_videos');
                    if ($twitter_allow_videos !== 'no') {
                        if (!empty($tFinal)) {
                            // && strpos($tFinal, 'vimeo') > 0 || strpos($tFinal, 'amp.twimg.com') > 0 || strpos($tFinal, 'youtube') > 0 || strpos($tFinal, 'youtu.be') > 0
                            print '<div class="fts-video-wrapper-padding"><div class="fts-video-wrapper"></div></div>';
                            print '<div class="fts-video-show-hide-btns-wrap ' . $fts_dynamic_name . '_bts_wrap" style="display:none">';
                            print '<a href="' . $tFinal . '" class="fts-twitter-load-video-wrapper fts-twitter-load-video ' . $fts_dynamic_name . '" onclick="return false;">' . __('Show Media', 'feed-them-social') . '<span class="fts-video-loading-notice" style="display:none; ">' . __(', Loading...', 'feed-them-social') . '</span></a>';
                            print '<a href="' . $tFinal . '" class="fts-twitter-load-video-wrapper fts-close-media ' . $fts_dynamic_name . '" onclick="return false;"><span class="fts-hide-media-text">' . __('Hide Media', 'feed-them-social') . '</span><span class="fts-show-media-text">' . __('Show Media', 'feed-them-social') . '</span></a>';
                            print '</div>';
                            ?>
<script type="text/javascript">
setTimeout(function() {
	  var url = jQuery("a.fts-twitter-load-video-wrapper.<?php 
                            echo $fts_dynamic_name;
                            ?>
").attr("href");
			if (url.indexOf("soundcloud") >= 0 || url.indexOf("vine") >= 0 || url.indexOf("vimeo") >= 0 ||  url.indexOf("youtube") >= 0 || url.indexOf("youtu.be") >= 0 || url.indexOf("amp.twimg.com") >= 0 || url.indexOf("vine") >= 0 ) {
				if(url.indexOf("vimeo.com/blog/") >= 0 || url.indexOf("vimeo.com/ondemand/") >= 0 || url.indexOf("-youtube") >= 0 || url.indexOf("-vine") >= 0 || url.indexOf("-soundcloud") >= 0){
					jQuery('.fts-video-show-hide-btns-wrap.<?php 
                            echo $fts_dynamic_name;
                            ?>
_bts_wrap').hide();
				}
				else {
					jQuery('.fts-video-show-hide-btns-wrap.<?php 
                            echo $fts_dynamic_name;
                            ?>
_bts_wrap').show();
				}
			}
}, 1000);
</script>
<?php 
                        }
                    }
                    ?>
        </div>
      <div class="fts-twitter-reply-wrap">
      <a href="<?php 
                    print $t['permalink'];
                    ?>
" target="_blank">
      <div class="fts-twitter-reply"></div>
      </a></div>
      <div class="clear"></div>
    </div>
  </div>
  <?php 
                }
                ?>
  <div class="clear"></div>
</div>
<?php 
                if ($twitter_height !== 'auto' && empty($twitter_height) == NULL) {
                    ?>
<script>
  // this makes it so the page does not scroll if you reach the end of scroll bar or go back to top
  jQuery.fn.isolatedScrollTwitter = function() {
		this.bind('mousewheel DOMMouseScroll', function (e) {
		var delta = e.wheelDelta || (e.originalEvent && e.originalEvent.wheelDelta) || -e.detail,
			bottomOverflow = this.scrollTop + jQuery(this).outerHeight() - this.scrollHeight >= 0,
			topOverflow = this.scrollTop <= 0;
		if ((delta < 0 && bottomOverflow) || (delta > 0 && topOverflow)) {
			e.preventDefault();
		}
	});
	return this;
  };
  jQuery('.fts-twitter-scrollable').isolatedScrollTwitter();
</script>
<?php 
                }
            }
            // END IF $fetchedTweets
        }
        //END ELSE
        //******************
        // SOCIAL BUTTON
        //******************
        if (isset($twitter_show_follow_btn) && $twitter_show_follow_btn == 'yes' && $twitter_show_follow_btn_where == 'twitter-follow-below' && $twitter_name !== '') {
            echo '<div class="twitter-social-btn-bottom">';
            $this->social_follow_button('twitter', $screen_name);
            echo '</div>';
        }
        return ob_get_clean();
    }
Esempio n. 4
0
function fts_twitter_func($atts)
{
    include_once ABSPATH . 'wp-admin/includes/plugin.php';
    $fts_functions = new feed_them_social_functions();
    if (is_plugin_active('feed-them-premium/feed-them-premium.php')) {
        include WP_CONTENT_DIR . '/plugins/feed-them-premium/feeds/twitter/twitter-feed.php';
    } else {
        extract(shortcode_atts(array('twitter_name' => '', 'twitter_height' => '', 'description_image' => ''), $atts));
        $tweets_count = '5';
    }
    ob_start();
    $numTweets = $tweets_count;
    $name = $twitter_name;
    $excludeReplies = true;
    $data_cache = WP_CONTENT_DIR . '/plugins/feed-them-social/feeds/twitter/cache/twitter_data_cache-' . $name . '-num' . $numTweets . '.cache';
    //Check Cache
    if (file_exists($data_cache) && !filesize($data_cache) == 0 && filemtime($data_cache) > time() - 1800 && false !== strpos($data_cache, '-num' . $numTweets . '')) {
        $fetchedTweets = $fts_functions->fts_get_feed_cache($data_cache);
        $cache_used = true;
    } else {
        include WP_CONTENT_DIR . '/plugins/feed-them-social/feeds/twitter/twitteroauth/twitteroauth.php';
        $fts_twitter_custom_consumer_key = get_option('fts_twitter_custom_consumer_key');
        $fts_twitter_custom_consumer_secret = get_option('fts_twitter_custom_consumer_secret');
        $fts_twitter_custom_access_token = get_option('fts_twitter_custom_access_token');
        $fts_twitter_custom_access_token_secret = get_option('fts_twitter_custom_access_token_secret');
        //Use custom api info
        if (!empty($fts_twitter_custom_consumer_key) && !empty($fts_twitter_custom_consumer_secret) && !empty($fts_twitter_custom_access_token) && !empty($fts_twitter_custom_access_token_secret)) {
            $connection = new TwitterOAuthFTS($fts_twitter_custom_consumer_key, $fts_twitter_custom_consumer_secret, $fts_twitter_custom_access_token, $fts_twitter_custom_access_token_secret);
        } else {
            $connection = new TwitterOAuthFTS('dOIIcGrhWgooKquMWWXg', 'qzAE4t4xXbsDyGIcJxabUz3n6fgqWlg8N02B6zM', '1184502104-Cjef1xpCPwPobP5X8bvgOTbwblsmeGGsmkBzwdB', 'd789TWA8uwwfBDjkU0iJNPDz1UenRPTeJXbmZZ4xjY');
        }
        // If excluding replies, we need to fetch more than requested as the
        // total is fetched first, and then replies removed.
        $totalToFetch = $excludeReplies ? max(50, $numTweets * 3) : $numTweets;
        $fetchedTweets = $connection->get('statuses/user_timeline', array('screen_name' => $name, 'count' => $totalToFetch, 'exclude_replies' => $excludeReplies, 'images' => $description_image));
    }
    //END ELSE
    //Error Check
    if (isset($fetchedTweets->errors)) {
        $error_check = '<div>Oops, Somethings wrong. ' . $fetchedTweets->errors[0]->message . '.</div>';
        if ($fetchedTweets->errors[0]->code == 32) {
            $error_check .= ' Please check that you have entered your Twitter API token information correctly.';
        }
        if ($fetchedTweets->errors[0]->code == 34) {
            $error_check .= ' Please check the Twitter Username you have entered is correct.';
        }
    } elseif (empty($fetchedTweets) && !isset($fetchedTweets->errors)) {
        $error_check = '<div>This account has no tweets. Please Tweet to see this feed.</div>';
    }
    //Does Cache folder exists? If not make it!
    //IS RATE LIMIT REACHED?
    if (isset($fetchedTweets->errors)) {
        echo '<pre>';
        print_r($fetchedTweets->errors);
        echo '</pre>';
    }
    // Did the fetch fail?
    if (isset($error_check)) {
        echo $error_check;
    } else {
        if (!empty($fetchedTweets)) {
            //Cache It
            if (!isset($cache_used)) {
                $fts_functions->fts_create_feed_cache($data_cache, $fetchedTweets);
            }
            // Fetch succeeded.
            // Now update the array to store just what we need.
            // (Done here instead of PHP doing this for every page load)
            $limitToDisplay = min($numTweets, count($fetchedTweets));
            for ($i = 0; $i < $limitToDisplay; $i++) {
                $tweet = $fetchedTweets[$i];
                // Core info.
                $name = isset($tweet->user->name) ? $tweet->user->name : "";
                $screen_name = isset($tweet->user->screen_name) ? $tweet->user->screen_name : "";
                $protocol = isset($_SERVER["HTTPS"]) ? 'https://' : 'http://';
                $not_protocol = !isset($_SERVER["HTTPS"]) ? 'https://' : 'http://';
                $permalink = $protocol . 'twitter.com/' . $screen_name . '/status/' . $tweet->id_str;
                $user_permalink = $protocol . 'twitter.com/#!/' . $screen_name;
                //Is Media Set
                if (isset($tweet->entities->media[0]->media_url)) {
                    $media_url = $tweet->entities->media[0]->media_url;
                    $media_url = str_replace($not_protocol, $protocol, $media_url);
                } else {
                    $media_url = '';
                }
                // leaving this for another update, trying to get videos, and I know this ain't right! $url = $tweet->entities->media[0]->expanded_url;
                /* Alternative image sizes method: http://dev.twitter.com/doc/get/users/profile_image/:screen_name */
                $image = isset($tweet->user->profile_image_url) ? $tweet->user->profile_image_url : "";
                $image = str_replace($not_protocol, $protocol, $image);
                // Message. Convert links to real links.
                $pattern = array('/http:(\\S)+/', '/https:(\\S)+/', '/([^a-zA-Z0-9-_&])@([0-9a-zA-Z_]+)/', '/([^a-zA-Z0-9-_&])#([0-9a-zA-Z_]+)/');
                $replace = array(' <a href="${0}" target="_blank" rel="nofollow">${0}</a>', ' <a href="${0}" target="_blank" rel="nofollow">${0}</a>', ' <a href="' . $protocol . 'twitter.com/$2" target="_blank" rel="nofollow">@$2</a>', ' <a href="' . $protocol . 'twitter.com/search?q=%23$2&src=hash" target="_blank" rel="nofollow">#$2</a>');
                $text = preg_replace($pattern, $replace, $tweet->text);
                // Need to get time in Unix format.
                $times = isset($tweet->created_at) ? $tweet->created_at : "";
                $CustomDateCheck = get_option('fts-date-and-time-format');
                if ($CustomDateCheck) {
                    $CustomDateFormatTwitter = get_option('fts-date-and-time-format');
                } else {
                    $CustomDateFormatTwitter = 'F jS, Y \\a\\t g:ia';
                }
                date_default_timezone_set(get_option('fts-timezone'));
                $uTime = date($CustomDateFormatTwitter, strtotime($times) - 3 * 3600);
                $twitter_id = isset($tweet->id_str) ? $tweet->id_str : "";
                $fts_twitter_full_width = get_option('twitter_full_width');
                // Now make the new array.
                $tweets[] = array('text' => $text, 'name' => $name, 'screen_name' => $screen_name, 'user_permalink' => $user_permalink, 'permalink' => $permalink, 'image' => $image, 'time' => $uTime, 'media_url' => $media_url, 'id' => $twitter_id);
            }
            //End FOR fts-twitter-full-width
            ?>
   
<div id="twitter-feed-<?php 
            print $twitter_name;
            ?>
" class="fts-twitter-div<?php 
            if ($twitter_height !== 'auto' && empty($twitter_height) == NULL) {
                ?>
 fts-twitter-scrollable<?php 
            }
            if ($popup == 'yes') {
                ?>
 popup-gallery-twitter<?php 
            }
            ?>
" <?php 
            if ($twitter_height !== 'auto' && empty($twitter_height) == NULL) {
                ?>
style="height:<?php 
                echo $twitter_height;
                ?>
"<?php 
            }
            ?>
>
  <?php 
            foreach ($tweets as $t) {
                ?>
  <div class="fts-tweeter-wrap">
    <div class="tweeter-info">
      <?php 
                if ($fts_twitter_full_width !== 'yes') {
                    ?>
      <div class="fts-twitter-image"><a href="<?php 
                    print $t['user_permalink'];
                    ?>
" target="_blank" class="black"><img class="twitter-image" src="<?php 
                    print $t['image'];
                    ?>
" /></a></div>
      <?php 
                }
                ?>
      <div class="<?php 
                if ($fts_twitter_full_width == 'yes') {
                    ?>
fts-twitter-full-width<?php 
                } else {
                    ?>
right<?php 
                }
                ?>
">
        <div class="uppercase bold"><a href="<?php 
                print $t['user_permalink'];
                ?>
" target="_blank" class="black">@<?php 
                print $t['screen_name'];
                ?>
</a></div>
        <span class="time"><a href="<?php 
                print $t['permalink'];
                ?>
"><?php 
                print $t['time'];
                ?>
</a></span><br/>
        <span class="fts-twitter-text"><?php 
                print $t['text'];
                ?>
        <div class="fts-fb-caption"><a href="<?php 
                print $t['permalink'];
                ?>
" class="fts-view-on-twitter-link" target="_blank">View on Twitter</a></div>
        </span>
        <?php 
                if ($t['media_url']) {
                    ?>
        <a href="<?php 
                    if ($popup == 'yes') {
                        print $t['media_url'];
                    } else {
                        print $t['permalink'];
                    }
                    ?>
" class="fts-twitter-link-image" target="_blank"><img class="fts-twitter-description-image" src="<?php 
                    print $t['media_url'];
                    ?>
" /></a>
		<?php 
                }
                ?>
        </div>
      <div class="fts-twitter-reply-wrap">
      <a href="<?php 
                print $t['permalink'];
                ?>
">
      <div class="fts-twitter-reply"></div>
      </a></div> 
      <div class="clear"></div>
    </div>
  </div>
  <?php 
            }
            ?>
  <div class="clear"></div>
</div>
<?php 
            if ($twitter_height !== 'auto' && empty($twitter_height) == NULL) {
                ?>
<script>
  // this makes it so the page does not scroll if you reach the end of scroll bar or go back to top
  jQuery.fn.isolatedScrollTwitter = function() {
		this.bind('mousewheel DOMMouseScroll', function (e) {
		var delta = e.wheelDelta || (e.originalEvent && e.originalEvent.wheelDelta) || -e.detail,
			bottomOverflow = this.scrollTop + jQuery(this).outerHeight() - this.scrollHeight >= 0,
			topOverflow = this.scrollTop <= 0;
	
		if ((delta < 0 && bottomOverflow) || (delta > 0 && topOverflow)) {
			e.preventDefault();
		}
	});
	return this;
  };
  jQuery('.fts-twitter-scrollable').isolatedScrollTwitter();
</script>
<?php 
            }
            ?>
  
<?php 
        }
        // END IF $fetchedTweets
    }
    //END ELSE
    return ob_get_clean();
}