[animated-twitter-slideshow] shortcode in your content section.
To add directly to your php template code add echo do_shortcode(\'[animated-twitter-slideshow]\'); directly to the portion of the template you wish to display in.', 'animated-twitter-slideshow' ), 'update-nag' ); ?>

'ats-api-key', 'type'=>'text', 'instructions'=>'Enter the Consumer Key for your registered Twitter application. Go to Apps.Twitter.com and follow the instructions from the readme.txt to setup your API Key and Secret below.') ); add_settings_field( 'ats-api-secret', __( 'Twitter Consumer Secret (API Secret)', 'textdomain' ), array( $this, 'atsPlugInFieldCreate' ), 'ats-settings', 'ats-twitter-display-section', $args=array('name'=>'ats-api-secret', 'type'=>'text', 'instructions'=>'Enter the Consumer Secret for your registered Twitter application (see readme.txt).') ); add_settings_field( 'ats-twitter-users-field', __( 'Twitter User', 'textdomain' ), array( $this, 'atsPlugInFieldCreate' ), 'ats-settings', 'ats-twitter-display-section', $args=array('name'=>'ats-twitter-users-field', 'type'=>'text', 'instructions'=>'Enter the Twitter User Screen Name to display. Example: @wholahoopmedia.') ); add_settings_field( 'ats-tweet-count', __( 'Max Tweets to Display', 'textdomain' ), array( $this, 'atsPlugInFieldCreate' ), 'ats-settings', 'ats-twitter-display-section', $args=array('name'=>'ats-tweet-count', 'type'=>'select', 'items'=>array("1","2","3","4","5","6","7","8","9","10"), 'instructions'=>'Enter the maximum number of tweets (slides) to display.
The actual number displayed may be lower due to Twitters calculations, and retweets.') ); add_settings_field( 'ats-slideshow-delay', __( 'Slideshow Delay', 'textdomain' ), array( $this, 'atsPlugInFieldCreate' ), 'ats-settings', 'ats-twitter-display-section', $args=array('name'=>'ats-slideshow-delay', 'type'=>'select', 'items'=>array("4","5","6","7","8","9","10"), 'instructions' =>'Select the slideshow delay in seconds.' ) ); add_settings_field( 'ats-cache-timer', __( 'Set Twitter API Cache', 'textdomain' ), array( $this, 'atsPlugInFieldCreate' ), 'ats-settings', 'ats-twitter-display-section', $args=array('name'=>'ats-cache-timer', 'type'=>'select', 'items'=>array("15","30","45","60"), 'instructions' =>'Select the cache hold for the Twitter API in minutes. This value ensures that you will not make too many calls to the Twitter API server.' ) ); add_settings_field( 'ats-clear-cache', __( 'Clear Twitter API Cache', 'textdomain' ), array( $this, 'atsPlugInFieldCreate' ), 'ats-settings', 'ats-twitter-display-section', $args=array('name'=>'ats-clear-cache', 'type'=>'clear-cache', 'instructions' =>'Clear the current cache of Twitter tweet responses. Do this when you change/add/remove twiiter users to follow.' ) ); } /** * function atsDisplaySectionCallback */ public function atsDisplaySectionCallback() { _e( 'Enter all fields below.', 'textdomain' ); } /** * function atsPlugInFieldCreate * params: array( string $name, string $type, (opt) array $items, (opt) string $instructions ) * */ public function atsPlugInFieldCreate( $args ) { $settings = (array) get_option( 'ats-settings' ); $field = $args['name']; $value = esc_attr( $settings[$field] ); if( isset( $args['items'] ) ) { $items = $args['items']; } //switch on field input type switch ($args['type']) { case 'text' : echo ""; break; case 'select' : echo ""; break; case 'clear-cache' : echo(''); break; } //add instructions if needed if( isset( $args['instructions'] ) ) { $instructions = $args['instructions']; echo "

$instructions

"; } } /*******************************************/ /* Shortcode Related Methods etc. /*******************************************/ /** * function atsShortCodeInit */ public function atsShortCodeInit() { add_action('init', array( $this,'atsRegisterShortCode' )); } /** * function atsRegisterShortCode */ public function atsRegisterShortCode() { add_shortcode('animated-twitter-slideshow', array( $this,'atsSlideshowShortCode' )); } /** * function atsSlideshowShortCode */ public function atsSlideshowShortCode() { //get slideshow settings $twitterDisplayOptions = get_option( 'ats-settings' ); $tweet_count = trim($twitterDisplayOptions['ats-tweet-count']); $slideshow_delay = trim($twitterDisplayOptions['ats-slideshow-delay']); $twitter_user = trim(str_replace('@','',$twitterDisplayOptions['ats-twitter-users-field'])); //check cache $cache_timer = trim($twitterDisplayOptions['ats-cache-timer']); $cached_data = get_option( 'ats-cached-tweets' ); $cached_time = get_option( 'ats-cached-tweets-timestamp' ); $current_time = time(); $expire_time = $cache_timer*60; if( $cached_data && ($current_time - $expire_time < $cached_time) ) { $tweets = $cached_data; }else{ //call twitterAPI $tweets = array(); $response = $this->atsAPIUserCall( $twitter_user,$tweet_count ); if( $response === 'bad-auth' ) { $content = '
There is an error with your Twitter API Key/Secret. Please check these in the Plugin admin and re-try.
'; return $content; }else{ $tweets[] = $response; } //cache to wp cache object update_option( 'ats-cached-tweets', $tweets ); update_option( 'ats-cached-tweets-timestamp', $current_time ); } /** * Build Tweets Array */ if( is_array($tweets) && $twitterDisplayOptions!=''||null ) { $i = 0; foreach( $tweets as $tweet_group) { foreach( $tweet_group as $tweet ) { $tweetsArray[$i]['date'] = strtotime($tweet['created_at']); $tweetsArray[$i]['id'] = $tweet['id_str']; $tweetsArray[$i]['text'] = $tweet['full_text']; $tweetsArray[$i]['media'] = $tweet['extended_entities']['media'][0]['media_url']; $tweetsArray[$i]['tweet_link'] = $tweet['extended_entities']['media'][0]['url']; $tweetsArray[$i]['urls'] = $tweet['entities']['urls']; $tweetsArray[$i]['user_mentions'] = $tweet['entities']['user_mentions']; $tweetsArray[$i]['hashtags'] = $tweet['entities']['hashtags']; $tweetsArray[$i]['user_screen_name'] = $tweet['user']['screen_name']; $tweetsArray[$i]['user_name'] = $tweet['user']['name']; $tweetsArray[$i]['user_verified'] = $tweet['user']['verified']; $tweetsArray[$i]['profile_banner'] = $tweet['user']['profile_banner_url']; $tweetsArray[$i]['user_avatar'] = str_replace('normal','bigger',$tweet['user']['profile_image_url']); $tweetsArray[$i]['background-image'] = ''; /** * Check if Tweet link is enbedded if not use User Timeline link */ if( $tweetsArray[$i]['tweet_link'] !=''||null ) { //do nothing }else{ $tweetsArray[$i]['tweet_link'] =' https://twitter.com/'.$tweetsArray[$i]['user_screen_name'].'/status/'.$tweetsArray[$i]['id']; } /** * Check media if image -> set as background */ $media_check= explode( '.',$tweetsArray[$i]['media'] ); $media_check_extention = end( $media_check ); if( in_array( strtolower( $media_check_extention ), array('jpeg','jpg','png','gif') ) ) { $tweetsArray[$i]['background-image'] = "style=\"background-image:url('".$tweetsArray[$i]['media'] ."');\""; }else if( $tweetsArray[$i]['profile_banner'] !=''||null){ $tweetsArray[$i]['background-image'] = "style=\"background-image:url('".$tweetsArray[$i]['profile_banner'] ."');\""; } /** * Get tweet links, hashtags, user-mentions, remove in-line tweet perma-link, and build html */ unset($tweetTextArray); $tweetTextArray = explode( ' ', $tweetsArray[$i]['text'] ); if( is_array( $tweetTextArray ) ) { foreach( $tweetTextArray as $key => $field ) { //remove permalink text if( $field == $tweetsArray[$i]['tweet_link'] ) { $tweet_new_text = ''; $tweetTextArray[$key] = ''; } //add embedded urls html if( is_array($tweetsArray[$i]['urls']) ) { foreach( $tweetsArray[$i]['urls'] as $url ) { if( strpos( $field, $url['url'] ) !==false ) { $tweet_new_text = ''. $url['display_url'] .''; $tweetTextArray[$key] = $tweet_new_text; } } } //build hashtag links if( is_array($tweetsArray[$i]['hashtags']) ) { foreach( $tweetsArray[$i]['hashtags'] as $hashtag ) { if( strpos( $field, $hashtag['text'] ) !==false ) { $tweet_new_text = ''.$field .''; $tweetTextArray[$key] = $tweet_new_text; } } } //build user-mention links if( is_array($tweetsArray[$i]['user_mentions']) ) { unset($twitter_user_mention,$twitter_user_link,$twitter_user_title,$user_mention_replace_text ); foreach( $tweet['entities']['user_mentions'] as $user_mention ) { $twitter_user_mention = '@'.$user_mention['screen_name']; $twitter_user_link = 'https://twitter.com/' . str_replace('@','',$twitter_user_mention); $tweet_new_text = ''.$field.''; if( strpos( strtolower($field), $twitter_user_mention ) !==false ) { $tweetTextArray[$key] = $tweet_new_text; break; } } //catch ill-formed usermentions (ie: plural, capitalized etc) if( strpos( $field, '@' ) !==false && strpos( strtolower($field), $user_mention['screen_name'] ) ==false ) { $firstFieldArray = explode('@',$field); if( count( $firstFieldArray ) > 1 ) { $junk = array_shift( $firstFieldArray ); $new_field = implode('',$firstFieldArray); }elseif( count( $firstFieldArray ) == 1 ) { $junk = ''; $new_field = implode('',$firstFieldArray); } $fieldArray = explode('\'',$new_field); $twitter_user_link = 'https://twitter.com/' . strtolower(str_replace('@','',$fieldArray[0])); $tweet_new_text = $junk.''.$field.''; $tweetTextArray[$key] = $tweet_new_text; } } } } $tweetsArray[$i]['text'] = implode( ' ', $tweetTextArray ); $i++; } } } /** * sort TweetsArray by date desc */ function atsSortTweetsByDate($a,$b) { if ( $a['date'] == $b['date'] ) return 0; return ( $a['date'] < $b['date'] ) ? -1 : 1; } if( is_array($tweetsArray) ) { usort( $tweetsArray, atsSortTweetsByDate ); $tweetsArray = array_reverse( $tweetsArray ); } /** * Build Tweet Slideshow HTML */ $content =''; if( is_array( $tweetsArray ) ) { $num_slides = count( $tweetsArray ); $content = '
'; $i=1; foreach( $tweetsArray as $tweetItem ) { /** * Check if user is verified for icon */ if( $tweetItem['user_verified'] ){ $user_verified = 'verified';}else{ $user_verified = '';} $content .= '
'; $content .= '
'; $content .= '

'.$tweetItem['text'].''.date( 'h:iA - M d, Y',$tweetItem['date']).'

'; $content .= '
'; $i++; } //Add Nav-controls $content .= '
'; $content .= ''; $content .= '
'; } return $content; } /** * function atsAPIUserCall */ public function atsAPIUserCall( $twitter_user, $tweet_count ) { $tcr = new atsCurlRequest(); $tweets = $tcr->atsGetUserTweets( $twitter_user, $tweet_count ); if( $tweets !== 'bad-auth' ) { return json_decode($tweets,true); }else{ return 'bad-auth'; } } } //Install/Uninstall register_activation_hook( __FILE__, array('animatedTwitterSlideshow','atsInstall') ); register_deactivation_hook( __FILE__, array('animatedTwitterSlideshow','atsUninstall') ); //Init $ats = new animatedTwitterSlideshow; $ats->atsShortCodeInit(); //Admin if( is_admin() ) { $ats->atsCreateAdmin(); }