Rotating Tweets (Twitter widget and shortcode) - Version 1.4.4

Version Description

  • Adds an option to switch off verification of SSL connections to Twitter. Adds an option to switch off rotation.
Download this release

Release Info

Developer mpntod
Plugin Icon wp plugin Rotating Tweets (Twitter widget and shortcode)
Version 1.4.4
Comparing to
See all releases

Code changes from version 1.4.3 to 1.4.4

Files changed (3) hide show
  1. css/style.css +7 -1
  2. readme.txt +8 -3
  3. rotatingtweets.php +51 -7
css/style.css CHANGED
@@ -74,8 +74,14 @@ div.rtw_intents {
74
  clear: none;
75
  }
76
 
 
 
 
 
 
77
  /* This sets the style for tweets in articles or posts */
78
- #content .rotatingtweets {
 
79
  border-top: 1px solid #DDD;
80
  border-bottom: 1px solid #DDD;
81
  margin-bottom: 3%;
74
  clear: none;
75
  }
76
 
77
+ .norotatingtweets .rotatingtweet {
78
+ border-bottom: 1px solid #DDD;
79
+ }
80
+
81
+
82
  /* This sets the style for tweets in articles or posts */
83
+ #content .rotatingtweets,
84
+ #content .norotatingtweets {
85
  border-top: 1px solid #DDD;
86
  border-bottom: 1px solid #DDD;
87
  margin-bottom: 3%;
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: shortcode,widget,twitter,rotating,rotate,rotator,tweet,tweets,animation,jquery,jquery cycle,cycle,multilingual,responsive
5
  Requires at least: 2.6
6
  Tested up to: 3.5.1
7
- Stable tag: 1.4.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -77,6 +77,7 @@ Possible variables for the shortcode include:
77
  * `show_meta_screen_name` = `'0'` or `'1'` - show who posted each tweet - optional - default is `'1'`
78
  * `show_meta_via` = `'0'` or `'1'` - show how each tweet was posted - optional - default is `'1'`
79
  * `show_meta_reply_retweet_favorite` = `'0'` or `'1'` - show 'reply', 'retweet' and 'favorite' buttons - optional - default is `'0'`
 
80
  * `show_meta_prev_next` = `'0'` or `'1'` - show 'next', 'prev' links - optional - default is `'0'`
81
  * `prev` = content for the prev button (default `'prev'`)
82
  * `next` = content for the next button (default `'next'`)
@@ -141,13 +142,17 @@ If there is only one copy of `jquery` and of `jquery.cycle` on your page, the be
141
  1. Read the diagnostics and look for any problems that relate to JavaScript. This will normally tell you which JavaScript (if any) is having problems.
142
 
143
  == Upgrade notice ==
144
- = 1.4.3 =
145
- * Works with responsive templates. Fixes some styling problems.
146
 
147
  = 0.700 (1.3.0) =
148
  * Upgrade needed for Rotating Tweets to keep working after May 2013. Supports version 1.1 of the Twitter API.
149
 
150
  == Changelog ==
 
 
 
 
151
  = 1.4.3 =
152
  * Removes two lines of CSS causing formatting problems
153
  * Improves responsiveness going from narrow to wider layouts
4
  Tags: shortcode,widget,twitter,rotating,rotate,rotator,tweet,tweets,animation,jquery,jquery cycle,cycle,multilingual,responsive
5
  Requires at least: 2.6
6
  Tested up to: 3.5.1
7
+ Stable tag: 1.4.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
77
  * `show_meta_screen_name` = `'0'` or `'1'` - show who posted each tweet - optional - default is `'1'`
78
  * `show_meta_via` = `'0'` or `'1'` - show how each tweet was posted - optional - default is `'1'`
79
  * `show_meta_reply_retweet_favorite` = `'0'` or `'1'` - show 'reply', 'retweet' and 'favorite' buttons - optional - default is `'0'`
80
+ * `no_rotate` = `'0'` or `'1'` - switch off rotation - default is `'0'`
81
  * `show_meta_prev_next` = `'0'` or `'1'` - show 'next', 'prev' links - optional - default is `'0'`
82
  * `prev` = content for the prev button (default `'prev'`)
83
  * `next` = content for the next button (default `'next'`)
142
  1. Read the diagnostics and look for any problems that relate to JavaScript. This will normally tell you which JavaScript (if any) is having problems.
143
 
144
  == Upgrade notice ==
145
+ = 1.4.4 =
146
+ * Adds an option to switch off verification of SSL connections to Twitter. Adds an option to switch off rotation.
147
 
148
  = 0.700 (1.3.0) =
149
  * Upgrade needed for Rotating Tweets to keep working after May 2013. Supports version 1.1 of the Twitter API.
150
 
151
  == Changelog ==
152
+ = 1.4.4 =
153
+ * Adds an option to switch off verification of SSL connections to Twitter
154
+ * Adds a short code option (`no_rotate`) to switch off rotation
155
+
156
  = 1.4.3 =
157
  * Removes two lines of CSS causing formatting problems
158
  * Improves responsiveness going from narrow to wider layouts
rotatingtweets.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Rotating Tweets (Twitter widget & shortcode)
4
  Description: Replaces a shortcode such as [rotatingtweets screen_name='your_twitter_name'], or a widget, with a rotating tweets display
5
- Version: 1.4.3
6
  Text Domain: rotatingtweets
7
  Author: Martin Tod
8
  Author URI: http://www.martintod.org.uk
@@ -476,7 +476,8 @@ function rotatingtweets_display_shortcode( $atts, $content=null, $code="", $prin
476
  'next' => __('next','rotatingtweets'),
477
  'prev' => __('prev','rotatingtweets'),
478
  'middot' => ' · ',
479
- 'np_pos' => 'top'
 
480
  ), $atts ) ;
481
  extract($args);
482
  if(empty($screen_name) && empty($search) && !empty($url)):
@@ -540,8 +541,11 @@ function rotatingtweets_call_twitter_API_options() {
540
  echo sprintf(__('<h3>Step 2:</h3><p>If you don\'t already have a suitable \'application\' that you can use for your website, set one up on the <a href="%s">Create an Application page</a>.</p> <p>It\'s normally best to use the name, description and website URL of the website where you plan to use Rotating Tweets.</p><p>You don\'t need a Callback URL.</p>','rotatingtweets'),'https://dev.twitter.com/apps/new');
541
  _e('<h3>Step 3:</h3><p>After clicking <strong>Create your Twitter application</strong>, on the following page, click on <strong>Create my access token</strong>.</p>','rotatingtweets');
542
  _e('<h3>Step 4:</h3><p>Copy the <strong>Consumer key</strong>, <strong>Consumer secret</strong>, <strong>Access token</strong> and <strong>Access token secret</strong> from your Twitter application page into the settings below.</p>','rotatingtweets');
543
- _e('<h3>Step 5:</h3><p>Click on <strong>Save Changes</strong>. If there are any problems, you will get an error message from Twitter which should help diagnose the problem.</p>','rotatingtweets');
544
- _e('<p><em>Even though you are only entering one set of Twitter API data, Rotating Tweets will continue to support multiple widgets and shortcodes pulling from a variety of different Twitter accounts.</em></p>','rotatingtweets');
 
 
 
545
  echo '<form method="post" action="options.php">';
546
  settings_fields( 'rotatingtweets_options' );
547
  do_settings_sections('rotatingtweets_api_settings');
@@ -557,6 +561,7 @@ function rotatingtweets_admin_init(){
557
  add_settings_field('rotatingtweets_secret', __('Twitter API Consumer Secret','rotatingtweets'), 'rotatingtweets_option_show_secret', 'rotatingtweets_api_settings', 'rotatingtweets_api_main');
558
  add_settings_field('rotatingtweets_token', __('Twitter API Access Token','rotatingtweets'), 'rotatingtweets_option_show_token', 'rotatingtweets_api_settings', 'rotatingtweets_api_main');
559
  add_settings_field('rotatingtweets_token_secret', __('Twitter API Access Token Secret','rotatingtweets'), 'rotatingtweets_option_show_token_secret', 'rotatingtweets_api_settings', 'rotatingtweets_api_main');
 
560
  }
561
  function rotatingtweets_option_show_key() {
562
  $options = get_option('rotatingtweets-api-settings');
@@ -574,6 +579,23 @@ function rotatingtweets_option_show_token_secret() {
574
  $options = get_option('rotatingtweets-api-settings');
575
  echo "<input id='rotatingtweets_api_token_secret_input' name='rotatingtweets-api-settings[token_secret]' size='70' type='text' value='{$options['token_secret']}' />";
576
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
577
  // Explanatory text
578
  function rotatingtweets_api_explanation() {
579
 
@@ -610,6 +632,12 @@ function rotatingtweets_api_validate($input) {
610
  $error = 1;
611
  add_settings_error( 'rotatingtweets', esc_attr('rotatingtweets-api-token-secret'), __('Error: Twitter API Access Token Secret not correctly formatted.','rotatingtweets'));
612
  }
 
 
 
 
 
 
613
  // Now a proper test
614
  if(empty($error)):
615
  $test = rotatingtweets_call_twitter_API('statuses/user_timeline',NULL,$options);
@@ -632,6 +660,17 @@ function rotatingtweets_call_twitter_API($command,$options = NULL,$api = NULL )
632
  if(WP_DEBUG):
633
  echo "\n<!-- Using OAuth - version 1.1 of API -- ".esc_attr($command)." -->\n";
634
  endif;
 
 
 
 
 
 
 
 
 
 
 
635
  $result = $connection->get($command , $options);
636
  else:
637
  // Construct old style API command
@@ -923,10 +962,15 @@ function rotating_tweets_display($json,$args,$print=TRUE) {
923
  $result .= '<div class="rotatingtweets_nextprev">'.$nextprev.'</div>';
924
  endif;
925
  endif;
 
 
 
 
 
926
  if(WP_DEBUG):
927
- $result .= "\n<div class='rotatingtweets wp_debug rotatingtweets_format_".+intval($args['official_format'])."' id='$id'>";
928
  else:
929
- $result .= "\n<div class='rotatingtweets rotatingtweets_format_".+intval($args['official_format'])."' id='$id'>";
930
  endif;
931
  $error = get_option('rotatingtweets_api_error');
932
  if(!empty($error)):
@@ -991,7 +1035,7 @@ function rotating_tweets_display($json,$args,$print=TRUE) {
991
  foreach($json as $twitter_object):
992
  $tweet_counter++;
993
  if($tweet_counter <= $tweet_count):
994
- if($tweet_counter == 1 ):
995
  $result .= "\n\t<div class = 'rotatingtweet'>";
996
  else:
997
  $result .= "\n\t<div class = 'rotatingtweet' style='display:none'>";
2
  /*
3
  Plugin Name: Rotating Tweets (Twitter widget & shortcode)
4
  Description: Replaces a shortcode such as [rotatingtweets screen_name='your_twitter_name'], or a widget, with a rotating tweets display
5
+ Version: 1.4.4
6
  Text Domain: rotatingtweets
7
  Author: Martin Tod
8
  Author URI: http://www.martintod.org.uk
476
  'next' => __('next','rotatingtweets'),
477
  'prev' => __('prev','rotatingtweets'),
478
  'middot' => ' &middot; ',
479
+ 'np_pos' => 'top',
480
+ 'no_rotate' => FALSE
481
  ), $atts ) ;
482
  extract($args);
483
  if(empty($screen_name) && empty($search) && !empty($url)):
541
  echo sprintf(__('<h3>Step 2:</h3><p>If you don\'t already have a suitable \'application\' that you can use for your website, set one up on the <a href="%s">Create an Application page</a>.</p> <p>It\'s normally best to use the name, description and website URL of the website where you plan to use Rotating Tweets.</p><p>You don\'t need a Callback URL.</p>','rotatingtweets'),'https://dev.twitter.com/apps/new');
542
  _e('<h3>Step 3:</h3><p>After clicking <strong>Create your Twitter application</strong>, on the following page, click on <strong>Create my access token</strong>.</p>','rotatingtweets');
543
  _e('<h3>Step 4:</h3><p>Copy the <strong>Consumer key</strong>, <strong>Consumer secret</strong>, <strong>Access token</strong> and <strong>Access token secret</strong> from your Twitter application page into the settings below.</p>','rotatingtweets');
544
+ _e('<h3>Step 5:</h3><p>Click on <strong>Save Changes</strong>.');
545
+ _e('<h3>If there are any problems:</h3><p>If there are any problems, you should get an error message from Twitter displayed as a "rotating tweet" which should help diagnose the problem.</p>','rotatingtweets');
546
+ _e('<p>If the error message references SSL, try changing the "Verify SSL connection to Twitter" below to "No".</p>','rotatingtweets');
547
+ _e('<h3>Multiple Twitter Accounts</h3>');
548
+ _e('<p>Even though you are only entering one set of Twitter API data, Rotating Tweets will continue to support multiple widgets and shortcodes pulling from a variety of different Twitter accounts.</p>','rotatingtweets');
549
  echo '<form method="post" action="options.php">';
550
  settings_fields( 'rotatingtweets_options' );
551
  do_settings_sections('rotatingtweets_api_settings');
561
  add_settings_field('rotatingtweets_secret', __('Twitter API Consumer Secret','rotatingtweets'), 'rotatingtweets_option_show_secret', 'rotatingtweets_api_settings', 'rotatingtweets_api_main');
562
  add_settings_field('rotatingtweets_token', __('Twitter API Access Token','rotatingtweets'), 'rotatingtweets_option_show_token', 'rotatingtweets_api_settings', 'rotatingtweets_api_main');
563
  add_settings_field('rotatingtweets_token_secret', __('Twitter API Access Token Secret','rotatingtweets'), 'rotatingtweets_option_show_token_secret', 'rotatingtweets_api_settings', 'rotatingtweets_api_main');
564
+ add_settings_field('rotatingtweets_ssl_verify', __('Verify SSL connection to Twitter','rotatingtweets'), 'rotatingtweets_option_show_ssl_verify','rotatingtweets_api_settings','rotatingtweets_api_main');
565
  }
566
  function rotatingtweets_option_show_key() {
567
  $options = get_option('rotatingtweets-api-settings');
579
  $options = get_option('rotatingtweets-api-settings');
580
  echo "<input id='rotatingtweets_api_token_secret_input' name='rotatingtweets-api-settings[token_secret]' size='70' type='text' value='{$options['token_secret']}' />";
581
  }
582
+ function rotatingtweets_option_show_ssl_verify() {
583
+ $options = get_option('rotatingtweets-api-settings');
584
+ $choice = array(
585
+ 1 => _x('Yes','Verify SSL connection to Twitter','rotatingtweets'),
586
+ 0 => _x('No','Verify SSL connection to Twitter','rotatingtweets')
587
+ );
588
+ echo "\n<select id='rotatingtweets_api_ssl_verify_input' name='rotatingtweets-api-settings[ssl_verify]'>";
589
+ foreach($choice as $value => $text) {
590
+ if($options['ssl_verify_off'] != $value ) {
591
+ $selected = 'selected = "selected"';
592
+ } else {
593
+ $selected = '';
594
+ }
595
+ echo "\n\t<option value='".$value."'".$selected.">".$text."</option>";
596
+ }
597
+ echo "\n</select>";
598
+ }
599
  // Explanatory text
600
  function rotatingtweets_api_explanation() {
601
 
632
  $error = 1;
633
  add_settings_error( 'rotatingtweets', esc_attr('rotatingtweets-api-token-secret'), __('Error: Twitter API Access Token Secret not correctly formatted.','rotatingtweets'));
634
  }
635
+ // Check 'ssl_verify'
636
+ if(isset($input['ssl_verify']) && $input['ssl_verify']==0):
637
+ $options['ssl_verify_off']=true;
638
+ else:
639
+ $options['ssl_verify_off']=false;
640
+ endif;
641
  // Now a proper test
642
  if(empty($error)):
643
  $test = rotatingtweets_call_twitter_API('statuses/user_timeline',NULL,$options);
660
  if(WP_DEBUG):
661
  echo "\n<!-- Using OAuth - version 1.1 of API -- ".esc_attr($command)." -->\n";
662
  endif;
663
+ if(isset($api['ssl_verify_off']) && $api['ssl_verify_off']):
664
+ if(WP_DEBUG):
665
+ echo "\n<!-- NOT verifying SSL peer -->\n";
666
+ endif;
667
+ $connection->ssl_verifypeer = FALSE;
668
+ else:
669
+ if(WP_DEBUG):
670
+ echo "\n<!-- Verifying SSL peer -->\n";
671
+ endif;
672
+ $connection->ssl_verifypeer = TRUE;
673
+ endif;
674
  $result = $connection->get($command , $options);
675
  else:
676
  // Construct old style API command
962
  $result .= '<div class="rotatingtweets_nextprev">'.$nextprev.'</div>';
963
  endif;
964
  endif;
965
+ if(isset($args['no_rotate']) && $args['no_rotate']):
966
+ $rotclass = 'norotatingtweets';
967
+ else:
968
+ $rotclass = 'rotatingtweets';
969
+ endif;
970
  if(WP_DEBUG):
971
+ $result .= "\n<div class='$rotclass wp_debug rotatingtweets_format_".+intval($args['official_format'])."' id='$id'>";
972
  else:
973
+ $result .= "\n<div class='$rotclass rotatingtweets_format_".+intval($args['official_format'])."' id='$id'>";
974
  endif;
975
  $error = get_option('rotatingtweets_api_error');
976
  if(!empty($error)):
1035
  foreach($json as $twitter_object):
1036
  $tweet_counter++;
1037
  if($tweet_counter <= $tweet_count):
1038
+ if($tweet_counter == 1 || ( isset($args['no_rotate']) && $args['no_rotate'] ) ):
1039
  $result .= "\n\t<div class = 'rotatingtweet'>";
1040
  else:
1041
  $result .= "\n\t<div class = 'rotatingtweet' style='display:none'>";