Twitter - Version 1.4.0

Version Description

Remove Tweet button options for share count. Display a Follow button by pasting a Twitter profile URL.

Download this release

Release Info

Developer niallkennedy
Plugin Icon 128x128 Twitter
Version 1.4.0
Comparing to
See all releases

Code changes from version 1.3.0 to 1.4.0

Files changed (42) hide show
  1. languages/twitter-ar.mo +0 -0
  2. languages/twitter-da_DK.mo +0 -0
  3. languages/twitter-de_DE.mo +0 -0
  4. languages/twitter-el.mo +0 -0
  5. languages/twitter-es_MX.mo +0 -0
  6. languages/twitter-fa_IR.mo +0 -0
  7. languages/twitter-fi.mo +0 -0
  8. languages/twitter-fr_FR.mo +0 -0
  9. languages/twitter-he_IL.mo +0 -0
  10. languages/twitter-hi_IN.mo +0 -0
  11. languages/twitter-hu_HU.mo +0 -0
  12. languages/twitter-id_ID.mo +0 -0
  13. languages/twitter-it_IT.mo +0 -0
  14. languages/twitter-ja.mo +0 -0
  15. languages/twitter-ko_KR.mo +0 -0
  16. languages/twitter-ms_MY.mo +0 -0
  17. languages/twitter-nb_NO.mo +0 -0
  18. languages/twitter-nl_NL.mo +0 -0
  19. languages/twitter-pl_PL.mo +0 -0
  20. languages/twitter-pt_BR.mo +0 -0
  21. languages/twitter-ru_RU.mo +0 -0
  22. languages/twitter-sv_SE.mo +0 -0
  23. languages/twitter-th.mo +0 -0
  24. languages/twitter-tl.mo +0 -0
  25. languages/twitter-tr_TR.mo +0 -0
  26. languages/twitter-zh_CN.mo +0 -0
  27. languages/twitter-zh_TW.mo +0 -0
  28. readme.txt +10 -4
  29. src/Twitter/Intents/Tweet.php +1 -1
  30. src/Twitter/Widgets/TweetButton.php +1 -143
  31. src/Twitter/WordPress/Admin/Post/TweetIntent.php +2 -2
  32. src/Twitter/WordPress/Admin/Post/TwitterCard.php +2 -2
  33. src/Twitter/WordPress/Admin/Settings/TweetButton.php +0 -34
  34. src/Twitter/WordPress/PluginLoader.php +2 -6
  35. src/Twitter/WordPress/Shortcodes/EmbeddedTweet.php +1 -1
  36. src/Twitter/WordPress/Shortcodes/Follow.php +42 -2
  37. src/Twitter/WordPress/Shortcodes/PeriscopeOnAir.php +3 -3
  38. src/Twitter/WordPress/Shortcodes/Share.php +4 -25
  39. src/Twitter/WordPress/Shortcodes/TweetGrid.php +3 -3
  40. src/Twitter/WordPress/Shortcodes/Vine.php +1 -1
  41. src/Twitter/WordPress/Widgets/PeriscopeOnAir.php +2 -2
  42. twitter.php +2 -3
languages/twitter-ar.mo DELETED
Binary file
languages/twitter-da_DK.mo DELETED
Binary file
languages/twitter-de_DE.mo DELETED
Binary file
languages/twitter-el.mo DELETED
Binary file
languages/twitter-es_MX.mo DELETED
Binary file
languages/twitter-fa_IR.mo DELETED
Binary file
languages/twitter-fi.mo DELETED
Binary file
languages/twitter-fr_FR.mo DELETED
Binary file
languages/twitter-he_IL.mo DELETED
Binary file
languages/twitter-hi_IN.mo DELETED
Binary file
languages/twitter-hu_HU.mo DELETED
Binary file
languages/twitter-id_ID.mo DELETED
Binary file
languages/twitter-it_IT.mo DELETED
Binary file
languages/twitter-ja.mo DELETED
Binary file
languages/twitter-ko_KR.mo DELETED
Binary file
languages/twitter-ms_MY.mo DELETED
Binary file
languages/twitter-nb_NO.mo DELETED
Binary file
languages/twitter-nl_NL.mo DELETED
Binary file
languages/twitter-pl_PL.mo DELETED
Binary file
languages/twitter-pt_BR.mo DELETED
Binary file
languages/twitter-ru_RU.mo DELETED
Binary file
languages/twitter-sv_SE.mo DELETED
Binary file
languages/twitter-th.mo DELETED
Binary file
languages/twitter-tl.mo DELETED
Binary file
languages/twitter-tr_TR.mo DELETED
Binary file
languages/twitter-zh_CN.mo DELETED
Binary file
languages/twitter-zh_TW.mo DELETED
Binary file
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Plugin Name ===
2
  Contributors: Twitter, niallkennedy
3
- Tags: twitter, embedded tweet, twitter moment, twitter video, twitter grid, vine, periscope, periscope on air, twitter cards, tweet button, follow button, twitter analytics, twitter ads
4
  Requires at least: 3.9
5
  Tested up to: 4.4
6
- Stable tag: 1.3.0
7
  License: MIT
8
  License URI: http://opensource.org/licenses/MIT
9
 
@@ -47,7 +47,7 @@ Provide a custom link preview title and description for each post from your site
47
 
48
  = Twitter follow button =
49
 
50
- Add a [Twitter follow button](https://dev.twitter.com/web/follow-button) with a WordPress widget or shortcode.
51
 
52
  = Periscope On Air button =
53
 
@@ -66,6 +66,8 @@ Add a Twitter audience pixel or [track advertising conversions](https://support.
66
  > View [Twitter for WordPress documentation](https://dev.twitter.com/web/wordpress) to learn more about customization through WordPress filters.
67
 
68
  == Upgrade Notice ==
 
 
69
 
70
  = 1.3.0 =
71
  Adds embedded Tweets grid template, Vine embeds, and Periscope On Air buttons.
@@ -80,6 +82,10 @@ Shortcode improvements for ajax-loaded posts. Remove photo, gallery, and product
80
  Display admin notice if current PHP version does not meet minimum requirements. Do not display Tweet button in auto-generated excerpt.
81
 
82
  == Changelog ==
 
 
 
 
83
 
84
  = 1.3.0 =
85
  * Display multiple Tweets in a [media-rich responsive grid template](https://dev.twitter.com/web/embedded-timelines/collection#template-grid) by pasting a Twitter collection URL
@@ -141,7 +147,7 @@ Twitter advertising trackers are only included on the page when invoked by the s
141
 
142
  1. Settings screen. Customize Tweet and Timeline color schemes including background, text colors, and borders. Attribute site content to a Twitter account. Automatically include Tweet buttons alongside your post content.
143
  2. Post editor meta box. Define custom Tweet text, hashtags, and Twitter Card data.
144
- 3. Twitter widgets and buttons in action.
145
 
146
  == Installation ==
147
 
1
  === Plugin Name ===
2
  Contributors: Twitter, niallkennedy
3
+ Tags: twitter, embedded tweet, twitter moment, twitter video, twitter grid, vine, periscope, twitter cards, tweet button, follow button, twitter analytics, twitter ads
4
  Requires at least: 3.9
5
  Tested up to: 4.4
6
+ Stable tag: 1.4.0
7
  License: MIT
8
  License URI: http://opensource.org/licenses/MIT
9
 
47
 
48
  = Twitter follow button =
49
 
50
+ Add a [Twitter follow button](https://dev.twitter.com/web/follow-button) with a WordPress widget, shortcode, or by pasting a Twitter profile link into a post.
51
 
52
  = Periscope On Air button =
53
 
66
  > View [Twitter for WordPress documentation](https://dev.twitter.com/web/wordpress) to learn more about customization through WordPress filters.
67
 
68
  == Upgrade Notice ==
69
+ = 1.4.0 =
70
+ Remove Tweet button options for share count. Display a Follow button by pasting a Twitter profile URL.
71
 
72
  = 1.3.0 =
73
  Adds embedded Tweets grid template, Vine embeds, and Periscope On Air buttons.
82
  Display admin notice if current PHP version does not meet minimum requirements. Do not display Tweet button in auto-generated excerpt.
83
 
84
  == Changelog ==
85
+ = 1.4.0 =
86
+ * Remove Tweet button options for share count and align display, matching Twitter's changes
87
+ * Convert Twitter profile URLs into a Follow button
88
+ * Enable language packs loaded from WordPress.org
89
 
90
  = 1.3.0 =
91
  * Display multiple Tweets in a [media-rich responsive grid template](https://dev.twitter.com/web/embedded-timelines/collection#template-grid) by pasting a Twitter collection URL
147
 
148
  1. Settings screen. Customize Tweet and Timeline color schemes including background, text colors, and borders. Attribute site content to a Twitter account. Automatically include Tweet buttons alongside your post content.
149
  2. Post editor meta box. Define custom Tweet text, hashtags, and Twitter Card data.
150
+ 3. Embed single Tweets, Tweets with video templates, multiple Tweets in a grid format, Twitter Moments, and Vines.
151
 
152
  == Installation ==
153
 
src/Twitter/Intents/Tweet.php CHANGED
@@ -382,7 +382,7 @@ class Tweet
382
  $values = array();
383
  }
384
 
385
- $class = __CLASS__;
386
  $intent = new $class;
387
  unset( $class );
388
 
382
  $values = array();
383
  }
384
 
385
+ $class = get_called_class();
386
  $intent = new $class;
387
  unset( $class );
388
 
src/Twitter/Widgets/TweetButton.php CHANGED
@@ -53,37 +53,6 @@ class TweetButton extends BaseWidget
53
  */
54
  const INTENT_CLASS = '\Twitter\Intents\Tweet';
55
 
56
- /**
57
- * Allowed values for the count variable
58
- *
59
- * @since 1.0.0
60
- *
61
- * @type array allowed values {
62
- * @type string count value
63
- * @type bool exists
64
- * }
65
- */
66
- public static $ALLOWED_COUNT_VALUES = array(
67
- '' => true, // reset to default (horizontal)
68
- 'none' => true, // hide Tweet count
69
- 'vertical' => true, // display above Tweet button
70
- );
71
-
72
- /**
73
- * Allowed values for the align variable
74
- *
75
- * @since 1.0.0
76
- *
77
- * @type array allowed values {
78
- * @type string align value
79
- * @type bool exists
80
- * }
81
- */
82
- public static $ALLOWED_ALIGN_VALUES = array(
83
- 'left' => true,
84
- 'right' => true,
85
- );
86
-
87
  /**
88
  * Tweet Web Intent
89
  *
@@ -104,35 +73,6 @@ class TweetButton extends BaseWidget
104
  */
105
  protected $size;
106
 
107
- /**
108
- * Show the number of Tweets mentioning this URL
109
- *
110
- * @since 1.0.0
111
- *
112
- * @type string
113
- */
114
- protected $count = '';
115
-
116
- /**
117
- * URL to use for Tweet count purposes
118
- *
119
- * Count should also be true for the URL used for the count to affect the button
120
- *
121
- * @since 1.0.0
122
- *
123
- * @type string
124
- */
125
- protected $counturl;
126
-
127
- /**
128
- * Force align the button to the left or right of the generated iframe
129
- *
130
- * @since 1.0.0
131
- *
132
- * @type string
133
- */
134
- protected $align;
135
-
136
  /**
137
  * Create a new button. Initialize the web intent.
138
  *
@@ -185,67 +125,6 @@ class TweetButton extends BaseWidget
185
  return $this;
186
  }
187
 
188
- /**
189
- * Show the Tweet count next to the Tweet button
190
- *
191
- * @since 1.0.0
192
- *
193
- * @param string $count a valid count value
194
- *
195
- * @return __CLASS__ support chaining
196
- */
197
- public function setCount($count)
198
- {
199
- if (is_string($count) && isset(static::$ALLOWED_COUNT_VALUES[$count])) {
200
- $this->count = $count;
201
- }
202
-
203
- return $this;
204
- }
205
-
206
- /**
207
- * Set the URL used for Tweet counts
208
- *
209
- * @since 1.0.0
210
- *
211
- * @param string $url absolute URL to be used for Tweet count
212
- *
213
- * @return __CLASS__ support chaining
214
- */
215
- public function setCountURL($url)
216
- {
217
- $url = trim($url);
218
- if ($url) {
219
- if ($this->intent->shouldValidate()) {
220
- if ($this->intent->isHTTPURL($url)) {
221
- $this->counturl = $url;
222
- }
223
- } else {
224
- $this->counturl = $url;
225
- }
226
- }
227
-
228
- return $this;
229
- }
230
-
231
- /**
232
- * Force the alignment of the button inside the iframe
233
- *
234
- * @since 1.0.0
235
- *
236
- * @param string $align left|right
237
- *
238
- * @return __CLASS__ support chaining
239
- */
240
- public function setAlign($align)
241
- {
242
- if (isset(static::$ALLOWED_ALIGN_VALUES[$align])) {
243
- $this->align = $align;
244
- }
245
-
246
- return $this;
247
- }
248
-
249
  /**
250
  * Define a parent Tweet by ID
251
  *
@@ -358,7 +237,7 @@ class TweetButton extends BaseWidget
358
  $options = array();
359
  }
360
 
361
- $class = __CLASS__;
362
  $button = new $class();
363
  unset( $class );
364
 
@@ -375,15 +254,6 @@ class TweetButton extends BaseWidget
375
  if (isset( $options['size'] )) {
376
  $button->setSize($options['size']);
377
  }
378
- if (isset( $options['count'] )) {
379
- $button->setCount($options['count']);
380
- }
381
- if (isset( $options['counturl'] )) {
382
- $button->setCountURL($options['counturl']);
383
- }
384
- if (isset( $options['align'] )) {
385
- $button->setAlign($options['align']);
386
- }
387
 
388
  return $button;
389
  }
@@ -406,18 +276,6 @@ class TweetButton extends BaseWidget
406
  $data['size'] = $this->size;
407
  }
408
 
409
- // empty string is default value
410
- if ($this->count) {
411
- $data['count'] = $this->count;
412
- }
413
- // only include counturl if a count will be shown
414
- if ('none' !== $this->count && $this->counturl) {
415
- $data['counturl'] = $this->counturl;
416
- }
417
- if ($this->align) {
418
- $data['align'] = $this->align;
419
- }
420
-
421
  return $data;
422
  }
423
 
53
  */
54
  const INTENT_CLASS = '\Twitter\Intents\Tweet';
55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  /**
57
  * Tweet Web Intent
58
  *
73
  */
74
  protected $size;
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  /**
77
  * Create a new button. Initialize the web intent.
78
  *
125
  return $this;
126
  }
127
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  /**
129
  * Define a parent Tweet by ID
130
  *
237
  $options = array();
238
  }
239
 
240
+ $class = get_called_class();
241
  $button = new $class();
242
  unset( $class );
243
 
254
  if (isset( $options['size'] )) {
255
  $button->setSize($options['size']);
256
  }
 
 
 
 
 
 
 
 
 
257
 
258
  return $button;
259
  }
276
  $data['size'] = $this->size;
277
  }
278
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  return $data;
280
  }
281
 
src/Twitter/WordPress/Admin/Post/TweetIntent.php CHANGED
@@ -151,9 +151,9 @@ class TweetIntent
151
  }
152
  }
153
 
154
- echo '<h4>' . esc_html( _x( 'Tweet', 'Tweet verb. Sharing.', 'twitter' ) ) . '</h4>';
155
  echo '<table id="tweet-intent">';
156
- echo '<thead><tr><th scope="col">' . esc_html( _x( 'Parameter', 'Customization or variable', 'twitter' ) ) . '</th><th scope="col">' . esc_html( __( 'Value' ) ) . '</th></tr></thead><tbody>';
157
 
158
  $available_characters = 140;
159
  // t.co wrapped URL length
151
  }
152
  }
153
 
154
+ echo '<h3>' . esc_html( _x( 'Tweet', 'Tweet verb. Sharing.', 'twitter' ) ) . '</h3>';
155
  echo '<table id="tweet-intent">';
156
+ echo '<thead><tr><th scope="col">' . esc_html( _x( 'Parameter', 'Customization or variable', 'twitter' ) ) . '</th><th scope="col">' . esc_html( _x( 'Value', 'Table column header: user-inputted value', 'twitter' ) ) . '</th></tr></thead><tbody>';
157
 
158
  $available_characters = 140;
159
  // t.co wrapped URL length
src/Twitter/WordPress/Admin/Post/TwitterCard.php CHANGED
@@ -135,11 +135,11 @@ class TwitterCard
135
  // separate Twitter Cards content from Intent content above
136
  echo '<hr' . \Twitter\WordPress\Helpers\HTMLBuilder::closeVoidHTMLElement() . '>';
137
 
138
- echo '<h4>' . esc_html( __( 'Twitter Card', 'twitter' ) ) . '</h4>';
139
 
140
  // set up the table
141
  echo '<table id="twitter-card">';
142
- echo '<thead><tr><th scope="col">' . esc_html( _x( 'Property', 'Object component, such as a title and description of an article', 'twitter' ) ) . '</th><th scope="col">' . esc_html( __( 'Value' ) ) . '</th></tr></thead><tbody>';
143
 
144
  if ( isset( $cards_fields_supported_by_post_type[ static::TITLE_KEY ] ) ) {
145
  echo '<tr>';
135
  // separate Twitter Cards content from Intent content above
136
  echo '<hr' . \Twitter\WordPress\Helpers\HTMLBuilder::closeVoidHTMLElement() . '>';
137
 
138
+ echo '<h3>' . esc_html( __( 'Twitter Card', 'twitter' ) ) . '</h3>';
139
 
140
  // set up the table
141
  echo '<table id="twitter-card">';
142
+ echo '<thead><tr><th scope="col">' . esc_html( _x( 'Property', 'Object component, such as a title and description of an article', 'twitter' ) ) . '</th><th scope="col">' . esc_html( _x( 'Value', 'Table column header: user-inputted value', 'twitter' ) ) . '</th></tr></thead><tbody>';
143
 
144
  if ( isset( $cards_fields_supported_by_post_type[ static::TITLE_KEY ] ) ) {
145
  echo '<tr>';
src/Twitter/WordPress/Admin/Settings/TweetButton.php CHANGED
@@ -157,13 +157,6 @@ class TweetButton implements SettingsSection
157
  $this->hook_suffix,
158
  $section
159
  );
160
- add_settings_field(
161
- 'tweet-button-count',
162
- _x( 'Count', 'Numeric sum: number of Tweets referencing this URL', 'twitter' ),
163
- array( &$this, 'displayCount' ),
164
- $this->hook_suffix,
165
- $section
166
- );
167
  add_settings_field(
168
  'tweet-button-size',
169
  __( 'Size' ),
@@ -265,27 +258,6 @@ class TweetButton implements SettingsSection
265
  echo \Twitter\WordPress\Helpers\HTMLBuilder::closeVoidHTMLElement() . '> ' . esc_html( __( 'Large button', 'twitter' ) ) . '</label>';
266
  }
267
 
268
- /**
269
- * Control display of the total number of Tweets citing the Tweet URL
270
- *
271
- * @since 1.0.0
272
- *
273
- * @return void
274
- */
275
- public function displayCount()
276
- {
277
- $key = 'count';
278
-
279
- echo '<label><input type="checkbox" name="' . esc_attr( static::OPTION_NAME . '[' . $key . ']' ) . '" value="1"';
280
- if ( ! ( isset( $this->existing_options ) && isset( $this->existing_options[ $key ] ) && 'none' === $this->existing_options[ $key ] ) ) {
281
- echo ' checked';
282
- if ( ! current_theme_supports( 'html5' ) ) {
283
- echo '="checked"';
284
- }
285
- }
286
- echo \Twitter\WordPress\Helpers\HTMLBuilder::closeVoidHTMLElement() . '> ' . esc_html( __( 'Show the number of Tweets citing the post URL', 'twitter' ) ) . '</label>';
287
- }
288
-
289
  /**
290
  * Sanitize posted option before saving
291
  *
@@ -323,12 +295,6 @@ class TweetButton implements SettingsSection
323
  $clean_options['size'] = 'large';
324
  }
325
 
326
- $key = 'count';
327
- if ( ! ( isset( $options[ $key ] ) && 1 == $options[ $key ] ) ) {
328
- $clean_options[ $key ] = 'none';
329
- }
330
- unset( $key );
331
-
332
  return $clean_options;
333
  }
334
  }
157
  $this->hook_suffix,
158
  $section
159
  );
 
 
 
 
 
 
 
160
  add_settings_field(
161
  'tweet-button-size',
162
  __( 'Size' ),
258
  echo \Twitter\WordPress\Helpers\HTMLBuilder::closeVoidHTMLElement() . '> ' . esc_html( __( 'Large button', 'twitter' ) ) . '</label>';
259
  }
260
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
  /**
262
  * Sanitize posted option before saving
263
  *
295
  $clean_options['size'] = 'large';
296
  }
297
 
 
 
 
 
 
 
298
  return $clean_options;
299
  }
300
  }
src/Twitter/WordPress/PluginLoader.php CHANGED
@@ -41,7 +41,7 @@ class PluginLoader
41
  *
42
  * @type string
43
  */
44
- const VERSION = '1.3.0';
45
 
46
  /**
47
  * Unique domain of the plugin's translated text
@@ -121,11 +121,7 @@ class PluginLoader
121
  */
122
  public static function loadTranslatedText()
123
  {
124
- load_plugin_textdomain(
125
- static::TEXT_DOMAIN,
126
- false, // deprecated parameter as of WP 2.7
127
- dirname( plugin_basename( static::getPluginMainFile() ) ) . '/languages' // directory location of MO files
128
- );
129
  }
130
 
131
  /**
41
  *
42
  * @type string
43
  */
44
+ const VERSION = '1.4.0';
45
 
46
  /**
47
  * Unique domain of the plugin's translated text
121
  */
122
  public static function loadTranslatedText()
123
  {
124
+ load_plugin_textdomain( static::TEXT_DOMAIN );
 
 
 
 
125
  }
126
 
127
  /**
src/Twitter/WordPress/Shortcodes/EmbeddedTweet.php CHANGED
@@ -79,7 +79,7 @@ class EmbeddedTweet implements ShortcodeInterface
79
  *
80
  * @type string
81
  */
82
- const TWEET_URL_REGEX = '#^https?://(www\.)?twitter\.com/.+?/status(es)?/([0-9]+)#i';
83
 
84
  /**
85
  * Base URL used to reconstruct a Tweet URL
79
  *
80
  * @type string
81
  */
82
+ const TWEET_URL_REGEX = '#^https?://(www\.)?twitter\.com/[a-z0-9_]{1,20}/status(es)?/([0-9]+)#i';
83
 
84
  /**
85
  * Base URL used to reconstruct a Tweet URL
src/Twitter/WordPress/Shortcodes/Follow.php CHANGED
@@ -42,6 +42,15 @@ class Follow implements ShortcodeInterface
42
  */
43
  const SHORTCODE_TAG = 'twitter_follow';
44
 
 
 
 
 
 
 
 
 
 
45
  /**
46
  * Accepted shortcode attributes and their default values
47
  *
@@ -60,12 +69,22 @@ class Follow implements ShortcodeInterface
60
  */
61
  public static function init()
62
  {
63
- add_shortcode( static::SHORTCODE_TAG, array( __CLASS__, 'shortcodeHandler' ) );
 
 
 
 
 
 
 
 
 
 
64
 
65
  // Shortcode UI, if supported
66
  add_action(
67
  'register_shortcode_ui',
68
- array( __CLASS__, 'shortcodeUI' ),
69
  5,
70
  0
71
  );
@@ -117,6 +136,27 @@ class Follow implements ShortcodeInterface
117
  );
118
  }
119
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  /**
121
  * Clean up provided shortcode values
122
  *
42
  */
43
  const SHORTCODE_TAG = 'twitter_follow';
44
 
45
+ /**
46
+ * Regex used to match a Twitter profile URL in text
47
+ *
48
+ * @since 1.3.0
49
+ *
50
+ * @type string
51
+ */
52
+ const URL_REGEX = '#^https://twitter\.com/([a-z0-9_]{1,20})$#i';
53
+
54
  /**
55
  * Accepted shortcode attributes and their default values
56
  *
69
  */
70
  public static function init()
71
  {
72
+ $classname = get_called_class();
73
+
74
+ add_shortcode( static::SHORTCODE_TAG, array( $classname, 'shortcodeHandler' ) );
75
+
76
+ // convert a URL into the shortcode equivalent
77
+ wp_embed_register_handler(
78
+ static::SHORTCODE_TAG,
79
+ static::URL_REGEX,
80
+ array( $classname, 'linkHandler' ),
81
+ 1
82
+ );
83
 
84
  // Shortcode UI, if supported
85
  add_action(
86
  'register_shortcode_ui',
87
+ array( $classname, 'shortcodeUI' ),
88
  5,
89
  0
90
  );
136
  );
137
  }
138
 
139
+ /**
140
+ * Handle a URL matched by a embed handler
141
+ *
142
+ * @since 1.3.1
143
+ *
144
+ * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.
145
+ * @param array $attr Embed attributes. Not used.
146
+ * @param string $url The original URL that was matched by the regex. Not used.
147
+ * @param array $rawattr The original unmodified attributes. Not used.
148
+ *
149
+ * @return string HTML markup for the follow button or an empty string if requirements not met
150
+ */
151
+ public static function linkHandler( $matches, $attr, $url, $rawattr )
152
+ {
153
+ if ( ! ( is_array( $matches ) && isset( $matches[1] ) && $matches[1] ) ) {
154
+ return '';
155
+ }
156
+
157
+ return static::shortcodeHandler( array( 'screen_name' => $matches[1] ) );
158
+ }
159
+
160
  /**
161
  * Clean up provided shortcode values
162
  *
src/Twitter/WordPress/Shortcodes/PeriscopeOnAir.php CHANGED
@@ -107,12 +107,12 @@ class PeriscopeOnAir implements ShortcodeInterface
107
  shortcode_ui_register_for_shortcode(
108
  static::SHORTCODE_TAG,
109
  array(
110
- 'label' => esc_html( __( 'Periscope On Air', 'twitter' ) ),
111
  'listItemImage' => 'dashicons-video-alt',
112
  'attrs' => array(
113
  array(
114
  'attr' => 'username',
115
- 'label' => esc_html( __( 'Periscope username', 'twitter' ) ),
116
  'type' => 'text',
117
  'meta' => array(
118
  'placeholder' => 'photomatt',
@@ -144,7 +144,7 @@ class PeriscopeOnAir implements ShortcodeInterface
144
  * @param string $url The original URL that was matched by the regex. Not used.
145
  * @param array $rawattr The original unmodified attributes. Not used.
146
  *
147
- * @return string HTML markup for the Tweet or an empty string if requirements not met
148
  */
149
  public static function linkHandler( $matches, $attr, $url, $rawattr )
150
  {
107
  shortcode_ui_register_for_shortcode(
108
  static::SHORTCODE_TAG,
109
  array(
110
+ 'label' => esc_html( __( 'Periscope On Air Button', 'twitter' ) ),
111
  'listItemImage' => 'dashicons-video-alt',
112
  'attrs' => array(
113
  array(
114
  'attr' => 'username',
115
+ 'label' => esc_html( _x( 'Periscope username', 'Prompt requesting entry of a Periscope username', 'twitter' ) ),
116
  'type' => 'text',
117
  'meta' => array(
118
  'placeholder' => 'photomatt',
144
  * @param string $url The original URL that was matched by the regex. Not used.
145
  * @param array $rawattr The original unmodified attributes. Not used.
146
  *
147
+ * @return string HTML markup for the Periscope On Air button or an empty string if requirements not met
148
  */
149
  public static function linkHandler( $matches, $attr, $url, $rawattr )
150
  {
src/Twitter/WordPress/Shortcodes/Share.php CHANGED
@@ -49,7 +49,7 @@ class Share implements ShortcodeInterface
49
  *
50
  * @type array
51
  */
52
- public static $SHORTCODE_DEFAULTS = array( 'in_reply_to' => '', 'text' => '', 'url' => '', 'hashtags' => array(), 'via' => '', 'related' => array(), 'size' => '', 'align' => '', 'count' => '', 'counturl' => '' );
53
 
54
  /**
55
  * Attach handlers for Tweet button
@@ -228,15 +228,10 @@ class Share implements ShortcodeInterface
228
  $options['text'] = $attributes['text'];
229
  }
230
 
231
- foreach ( array( 'url', 'counturl' ) as $url_param ) {
232
- if ( ! ( isset( $attributes[ $url_param ] ) && $attributes[ $url_param ] ) ) {
233
- continue;
234
- }
235
-
236
- // filter the URL
237
- $url = esc_url_raw( trim( $attributes[ $url_param ] ), array( 'http', 'https' ) );
238
  if ( $url ) {
239
- $options[ $url_param ] = $url;
240
  }
241
  unset( $url );
242
  }
@@ -273,22 +268,6 @@ class Share implements ShortcodeInterface
273
  unset( $intent );
274
  }
275
 
276
- if ( isset( $attributes['align'] ) && is_string( $attributes['align'] ) && $attributes['align'] ) {
277
- $align = strtolower( trim( $attributes['align'] ) );
278
- if ( array_key_exists( $align, \Twitter\Widgets\TweetButton::$ALLOWED_ALIGN_VALUES ) ) {
279
- $options['align'] = $align;
280
- }
281
- unset( $align );
282
- }
283
-
284
- if ( isset( $attributes['count'] ) && is_string( $attributes['count'] ) ) {
285
- $count = strtolower( trim( $attributes['count'] ) );
286
- if ( array_key_exists( $count, \Twitter\Widgets\TweetButton::$ALLOWED_COUNT_VALUES ) ) {
287
- $options['count'] = $count;
288
- }
289
- unset( $count );
290
- }
291
-
292
  // large is the only option
293
  if ( isset( $attributes['size'] ) ) {
294
  if ( is_string( $attributes['size'] ) && in_array( strtolower( $attributes['size'] ), array( 'large', 'l' ) ) ) {
49
  *
50
  * @type array
51
  */
52
+ public static $SHORTCODE_DEFAULTS = array( 'in_reply_to' => '', 'text' => '', 'url' => '', 'hashtags' => array(), 'via' => '', 'related' => array(), 'size' => '' );
53
 
54
  /**
55
  * Attach handlers for Tweet button
228
  $options['text'] = $attributes['text'];
229
  }
230
 
231
+ if ( isset( $attributes['url'] ) && $attributes['url'] ) {
232
+ $url = esc_url_raw( trim( $attributes['url'] ), array( 'http', 'https' ) );
 
 
 
 
 
233
  if ( $url ) {
234
+ $options['url'] = $url;
235
  }
236
  unset( $url );
237
  }
268
  unset( $intent );
269
  }
270
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  // large is the only option
272
  if ( isset( $attributes['size'] ) ) {
273
  if ( is_string( $attributes['size'] ) && in_array( strtolower( $attributes['size'] ), array( 'large', 'l' ) ) ) {
src/Twitter/WordPress/Shortcodes/TweetGrid.php CHANGED
@@ -59,7 +59,7 @@ class TweetGrid implements ShortcodeInterface
59
  *
60
  * @type string
61
  */
62
- const URL_REGEX = '#^https://twitter\.com/.+?/timelines/([0-9]+)#i';
63
 
64
  /**
65
  * Base URL used to reconstruct a Collection URL
@@ -137,7 +137,7 @@ class TweetGrid implements ShortcodeInterface
137
  */
138
  public static function featureName()
139
  {
140
- return __( 'Tweet Grid', 'twitter' );
141
  }
142
 
143
  /**
@@ -197,7 +197,7 @@ class TweetGrid implements ShortcodeInterface
197
  * @param string $url The original URL that was matched by the regex. Not used.
198
  * @param array $rawattr The original unmodified attributes. Not used.
199
  *
200
- * @return string HTML markup for the Tweet or an empty string if requirements not met
201
  */
202
  public static function linkHandler( $matches, $attr, $url, $rawattr )
203
  {
59
  *
60
  * @type string
61
  */
62
+ const URL_REGEX = '#^https://twitter\.com/[a-z0-9_]{1,20}/timelines/([0-9]+)#i';
63
 
64
  /**
65
  * Base URL used to reconstruct a Collection URL
137
  */
138
  public static function featureName()
139
  {
140
+ return _x( 'Tweet Grid', 'Tweets displayed in a grid layout', 'twitter' );
141
  }
142
 
143
  /**
197
  * @param string $url The original URL that was matched by the regex. Not used.
198
  * @param array $rawattr The original unmodified attributes. Not used.
199
  *
200
+ * @return string HTML markup for the Tweet grid or an empty string if requirements not met
201
  */
202
  public static function linkHandler( $matches, $attr, $url, $rawattr )
203
  {
src/Twitter/WordPress/Shortcodes/Vine.php CHANGED
@@ -198,7 +198,7 @@ class Vine implements ShortcodeInterface
198
  * @param string $url The original URL that was matched by the regex. Not used.
199
  * @param array $rawattr The original unmodified attributes. Not used.
200
  *
201
- * @return string HTML markup for the Tweet or an empty string if requirements not met
202
  */
203
  public static function linkHandler( $matches, $attr, $url, $rawattr )
204
  {
198
  * @param string $url The original URL that was matched by the regex. Not used.
199
  * @param array $rawattr The original unmodified attributes. Not used.
200
  *
201
+ * @return string HTML markup for the Vine or an empty string if requirements not met
202
  */
203
  public static function linkHandler( $matches, $attr, $url, $rawattr )
204
  {
src/Twitter/WordPress/Widgets/PeriscopeOnAir.php CHANGED
@@ -57,7 +57,7 @@ class PeriscopeOnAir extends \WP_Widget
57
  {
58
  parent::__construct(
59
  static::BASE_ID, // Base ID
60
- __( 'Periscope On Air', 'twitter' ), // name
61
  array(
62
  'description' => __( 'Lets a viewer discover your Periscope account and on air status', 'twitter' ) // args
63
  )
@@ -128,7 +128,7 @@ class PeriscopeOnAir extends \WP_Widget
128
  <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php echo esc_html( __( 'Title:', 'twitter' ) ); ?></label>
129
  <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( trim( strip_tags( $instance['title'] ) ) ); ?>"<?php echo $close_void_element; ?>></p>
130
 
131
- <p><label for="<?php echo esc_attr( $this->get_field_id( 'username' ) ); ?>"><?php echo esc_html( __( 'Periscope username', 'twitter' ) ); ?></label>
132
  <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'username' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'username' ) ); ?>" type="text" pattern="[a-zA-Z0-9_]{1,20}" value="<?php echo esc_attr( $instance['username'] ); ?>"<?php echo $close_void_element; ?>></p>
133
 
134
  <p><label for="<?php echo esc_attr( $this->get_field_id( 'size' ) ); ?>"><?php echo esc_html( __( 'Button size:', 'twitter' ) ); ?></label>
57
  {
58
  parent::__construct(
59
  static::BASE_ID, // Base ID
60
+ __( 'Periscope On Air Button', 'twitter' ), // name
61
  array(
62
  'description' => __( 'Lets a viewer discover your Periscope account and on air status', 'twitter' ) // args
63
  )
128
  <p><label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php echo esc_html( __( 'Title:', 'twitter' ) ); ?></label>
129
  <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( trim( strip_tags( $instance['title'] ) ) ); ?>"<?php echo $close_void_element; ?>></p>
130
 
131
+ <p><label for="<?php echo esc_attr( $this->get_field_id( 'username' ) ); ?>"><?php echo esc_html( _x( 'Periscope username', 'Prompt requesting entry of a Periscope username', 'twitter' ) ); ?></label>
132
  <input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'username' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'username' ) ); ?>" type="text" pattern="[a-zA-Z0-9_]{1,20}" value="<?php echo esc_attr( $instance['username'] ); ?>"<?php echo $close_void_element; ?>></p>
133
 
134
  <p><label for="<?php echo esc_attr( $this->get_field_id( 'size' ) ); ?>"><?php echo esc_html( __( 'Button size:', 'twitter' ) ); ?></label>
twitter.php CHANGED
@@ -24,18 +24,17 @@ THE SOFTWARE.
24
  */
25
  /**
26
  * @package twitter
27
- * @version 1.3.0
28
  */
29
  /*
30
  Plugin Name: Twitter
31
  Plugin URI: http://wordpress.org/plugins/twitter/
32
  Description: Official Twitter plugin for WordPress. Embed Twitter content and grow your audience on Twitter. Requires PHP 5.4 or greater.
33
- Version: 1.3.0
34
  Author: Twitter
35
  Author URI: https://dev.twitter.com/
36
  License: MIT
37
  Text Domain: twitter
38
- Domain Path: /languages/
39
  */
40
 
41
  // make sure the plugin does not expose any info if called directly
24
  */
25
  /**
26
  * @package twitter
27
+ * @version 1.4.0
28
  */
29
  /*
30
  Plugin Name: Twitter
31
  Plugin URI: http://wordpress.org/plugins/twitter/
32
  Description: Official Twitter plugin for WordPress. Embed Twitter content and grow your audience on Twitter. Requires PHP 5.4 or greater.
33
+ Version: 1.4.0
34
  Author: Twitter
35
  Author URI: https://dev.twitter.com/
36
  License: MIT
37
  Text Domain: twitter
 
38
  */
39
 
40
  // make sure the plugin does not expose any info if called directly