Twitter - Version 1.0.1

Version Description

Display admin notice if current PHP version does not meet minimum requirements. Do not display Tweet button in auto-generated excerpt.

=

Download this release

Release Info

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

Code changes from version 1.0.0 to 1.0.1

compatibility-notice.php ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ The MIT License (MIT)
4
+
5
+ Copyright (c) 2015 Twitter Inc.
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the "Software"), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in
15
+ all copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
+ THE SOFTWARE.
24
+ */
25
+
26
+ /**
27
+ * Communicate a lack of compatibilty between the Twitter plugin for WordPress and the current site's server environment
28
+ *
29
+ * @since 1.0.1
30
+ */
31
+ class Twitter_CompatibilityNotice {
32
+ /**
33
+ * Minimum version of PHP required to run the plugin
34
+ *
35
+ * Format: major.minor(.release)
36
+ *
37
+ * @since 1.0.1
38
+ *
39
+ * @type string
40
+ */
41
+ const MIN_PHP_VERSION = '5.4';
42
+
43
+ /**
44
+ * Release dates of PHP versions greater than the WordPress minimum requirement and less than the plugin minimum requirement
45
+ *
46
+ * @since 1.0.1
47
+ *
48
+ * @type array
49
+ */
50
+ public static $PHP_RELEASE_DATES = array(
51
+ '5.3.29' => '2014-08-14',
52
+ '5.3.28' => '2013-07-11',
53
+ '5.3.27' => '2013-07-11',
54
+ '5.3.26' => '2013-06-06',
55
+ '5.3.25' => '2013-05-09',
56
+ '5.3.24' => '2013-04-11',
57
+ '5.3.23' => '2013-03-14',
58
+ '5.3.22' => '2013-02-21',
59
+ '5.3.21' => '2013-01-17',
60
+ '5.3.20' => '2012-12-20',
61
+ '5.3.19' => '2012-11-22',
62
+ '5.3.18' => '2012-10-18',
63
+ '5.3.17' => '2012-09-13',
64
+ '5.3.16' => '2012-08-16',
65
+ '5.3.15' => '2012-07-19',
66
+ '5.3.14' => '2012-06-14',
67
+ '5.3.13' => '2012-05-08',
68
+ '5.3.12' => '2012-05-03',
69
+ '5.3.11' => '2012-04-26',
70
+ '5.3.10' => '2012-02-02',
71
+ '5.3.9' => '2012-01-10',
72
+ '5.3.8' => '2011-08-23',
73
+ '5.3.7' => '2011-08-18',
74
+ '5.3.6' => '2011-03-19',
75
+ '5.3.5' => '2011-01-06',
76
+ '5.3.4' => '2010-12-09',
77
+ '5.3.3' => '2010-07-22',
78
+ '5.3.2' => '2010-03-04',
79
+ '5.3.1' => '2009-11-19',
80
+ '5.3.0' => '2009-06-30',
81
+ '5.2.17' => '2011-01-06',
82
+ '5.2.16' => '2010-12-16',
83
+ '5.2.15' => '2010-12-09',
84
+ '5.2.14' => '2010-07-22',
85
+ '5.2.13' => '2010-02-25',
86
+ '5.2.12' => '2009-12-17',
87
+ '5.2.11' => '2009-09-17',
88
+ '5.2.10' => '2009-06-18',
89
+ '5.2.9' => '2009-02-26',
90
+ '5.2.8' => '2008-12-08',
91
+ '5.2.7' => '2008-12-04',
92
+ '5.2.6' => '2008-05-01',
93
+ '5.2.5' => '2007-11-08',
94
+ '5.2.4' => '2007-08-30',
95
+ );
96
+
97
+ /**
98
+ * Admin init handler
99
+ *
100
+ * @since 1.0.1
101
+ *
102
+ * @return void
103
+ */
104
+ public static function adminInit()
105
+ {
106
+ // no action taken for ajax request
107
+ // extra non-formatted output could break a response format such as XML or JSON
108
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
109
+ return;
110
+ }
111
+
112
+ // only show notice to a user of proper capability
113
+ if ( ! Twitter_CompatibilityNotice::currentUserCanManagePlugins() ) {
114
+ return;
115
+ }
116
+
117
+ // display error messages in the site locale
118
+ Twitter_CompatibilityNotice::loadTranslatedText();
119
+
120
+ // trigger an E_USER_NOTICE for the built-in error handler
121
+ trigger_error( sprintf( __( 'The Twitter plugin for WordPress requires PHP version %s or greater.', 'twitter' ), Twitter_CompatibilityNotice::MIN_PHP_VERSION ) );
122
+
123
+ // deactivate the plugin
124
+ Twitter_CompatibilityNotice::deactivatePlugin();
125
+
126
+ // display an admin notice
127
+ add_action( 'admin_notices', array( 'Twitter_CompatibilityNotice', 'adminNotice' ) );
128
+ }
129
+
130
+ /**
131
+ * Load translated text to display an error message in the site locale
132
+ *
133
+ * @since 1.0.1
134
+ *
135
+ * @uses load_plugin_textdomain()
136
+ * @return void
137
+ */
138
+ public static function loadTranslatedText()
139
+ {
140
+ load_plugin_textdomain(
141
+ 'twitter',
142
+ false, // deprecated parameter as of WP 2.7
143
+ dirname( plugin_basename( __FILE__ ) ) . '/languages' // path to MO files
144
+ );
145
+ }
146
+
147
+ /**
148
+ * Get the plugin path relative to the plugins directory
149
+ *
150
+ * Used to identify the plugin in a list of installed and activated plugins
151
+ *
152
+ * @since 1.0.1
153
+ *
154
+ * @return string Plugin path. e.g. twitter/twitter.php
155
+ */
156
+ public static function getPluginPath()
157
+ {
158
+ return dirname( plugin_basename( __FILE__ ) ) . '/twitter.php';
159
+ }
160
+
161
+ /**
162
+ * Does the curent user have the capability to possibly fix the problem?
163
+ *
164
+ * @since 1.0.1
165
+ *
166
+ * @return bool True if the current user might be able to fix, else false
167
+ */
168
+ public static function currentUserCanManagePlugins()
169
+ {
170
+ return current_user_can( is_plugin_active_for_network( Twitter_CompatibilityNotice::getPluginPath() ) ? 'manage_network_plugins' : 'activate_plugins' );
171
+ }
172
+
173
+ /**
174
+ * Deactivate the plugin due to incompatibility
175
+ *
176
+ * @since 1.0.1
177
+ *
178
+ * @return void
179
+ */
180
+ public static function deactivatePlugin()
181
+ {
182
+ // test for plugin management capability
183
+ if ( ! Twitter_CompatibilityNotice::currentUserCanManagePlugins() ) {
184
+ return;
185
+ }
186
+
187
+ // deactivate with deactivation actions (non-silent)
188
+ deactivate_plugins( array( Twitter_CompatibilityNotice::getPluginPath() ) );
189
+
190
+ // remove activate state to prevent a "Plugin activated" notice
191
+ // notice located in wp-admin/plugins.php
192
+ unset( $_GET['activate'] );
193
+ }
194
+
195
+ /**
196
+ * Display an admin notice communicating an incompatibility
197
+ *
198
+ * @since 1.0.1
199
+ *
200
+ * @return void
201
+ */
202
+ public static function adminNotice()
203
+ {
204
+ echo '<div class="error">';
205
+ echo '<p>' . esc_html( sprintf( __( 'The Twitter plugin for WordPress requires PHP version %s or greater.', 'twitter' ), Twitter_CompatibilityNotice::MIN_PHP_VERSION ) ) . '</p>';
206
+
207
+ $version = PHP_VERSION;
208
+
209
+ $matches = array();
210
+ // isolate major.minor(.release)
211
+ preg_match('/^(5\.[2|3](\.[\d]{1,2})?).*/', $version, $matches );
212
+ if ( isset( $matches[1] ) ) {
213
+ $version = $matches[1];
214
+ // account for one possible major.minor match in range
215
+ if ( '5.3' === $version ) {
216
+ $version = '5.3.0';
217
+ }
218
+ }
219
+ unset( $matches );
220
+
221
+ $release_date = _x( 'an unknown date', 'the day the event occurred is unknown', 'twitter' );
222
+ if ( array_key_exists( $version, Twitter_CompatibilityNotice::$PHP_RELEASE_DATES ) ) {
223
+ $release_date = date_i18n(
224
+ get_option( 'date_format' ),
225
+ strtotime( Twitter_CompatibilityNotice::$PHP_RELEASE_DATES[ $version ] ),
226
+ /* GMT */ true
227
+ );
228
+ }
229
+ echo '<p>' . esc_html( sprintf( _x( 'This server is running PHP version %1$s released on %2$s.', 'The web server is running a version of the PHP software released on a locale-formatted date', 'twitter' ), $version, esc_html( $release_date ) ) ) . '</p>';
230
+
231
+ if ( is_plugin_inactive( Twitter_CompatibilityNotice::getPluginPath() ) ) {
232
+ echo '<p>' . __( 'Plugin <strong>deactivated</strong>.' ) . '</p>';
233
+ }
234
+
235
+ echo '</div>';
236
+ }
237
+ }
readme.txt CHANGED
@@ -2,18 +2,18 @@
2
  Contributors: Twitter, niallkennedy
3
  Tags: twitter, embedded tweet, twitter video, twitter cards, tweet button, follow button, twitter analytics, twitter ads
4
  Requires at least: 3.9
5
- Tested up to: 4.1
6
- Stable tag: 1.0.0
7
  License: MIT
8
  License URI: http://opensource.org/licenses/MIT
9
 
10
- Official Twitter plugin for WordPress. Embed Twitter content and grow your audience on Twitter. Requires PHP 5.4 or newer.
11
 
12
  == Description ==
13
 
14
  The Twitter plugin for WordPress optimizes your website for a Twitter audience through easy to use sharing buttons, embedded Tweets, auto-generated markup indexed by Twitter, and Follow buttons to help grow your Twitter audience. All features are deeply integrated with WordPress APIs to make building your webpages and administrative features as easy as possible with the extensibility you expect from WordPress.
15
 
16
- Requires PHP 5.4 or later.
17
 
18
  * [Embedded Tweet](https://dev.twitter.com/web/embedded-tweets) - customize backgrounds and color schemes to match your site's theme
19
  * [Embedded Twitter video](https://dev.twitter.com/web/embedded-video) - showcase video uploaded to Twitter
@@ -25,8 +25,20 @@ Requires PHP 5.4 or later.
25
 
26
  Contribute to the plugin, submit pull requests, or run test suites through the [Twitter plugin for WordPress GitHub repository](https://github.com/twitter/wordpress). View [Twitter for WordPress documentation](https://dev.twitter.com/web/wordpress) to learn more about customization through filters.
27
 
 
 
 
 
 
 
28
  == Changelog ==
29
 
 
 
 
 
 
 
30
  = 1.0.0 =
31
  * Embedded Tweets
32
  * Embedded video
@@ -37,10 +49,6 @@ Contribute to the plugin, submit pull requests, or run test suites through the [
37
 
38
  == Frequently Asked Questions ==
39
 
40
- = Twitter Cards do not appear for my shared links =
41
-
42
- Twitter Cards must be enabled for your domain before they will appear alongside a Tweet. Submit a URL to the [Twitter Cards validator](https://cards-dev.twitter.com/validator) and request Twitter add the card type for your domain.
43
-
44
  = How can I change an embedded Tweet's background and link colors to match my site's theme? =
45
 
46
  The Twitter plugin for WordPress includes a settings page with options to customize the background color, link color, and border color used in Twitter embedded Tweets and embedded timelines.
@@ -74,4 +82,4 @@ Twitter advertising trackers are only included on the page when invoked by the s
74
  == Installation ==
75
 
76
  1. Add the Twitter plugin to your WordPress installation
77
- 1. Activate the plugin through the 'Plugins' menu in WordPress
2
  Contributors: Twitter, niallkennedy
3
  Tags: twitter, embedded tweet, twitter video, twitter cards, tweet button, follow button, twitter analytics, twitter ads
4
  Requires at least: 3.9
5
+ Tested up to: 4.2
6
+ Stable tag: 1.0.1
7
  License: MIT
8
  License URI: http://opensource.org/licenses/MIT
9
 
10
+ Official Twitter plugin for WordPress. Embed Twitter content and grow your audience on Twitter. Requires PHP 5.4 or greater.
11
 
12
  == Description ==
13
 
14
  The Twitter plugin for WordPress optimizes your website for a Twitter audience through easy to use sharing buttons, embedded Tweets, auto-generated markup indexed by Twitter, and Follow buttons to help grow your Twitter audience. All features are deeply integrated with WordPress APIs to make building your webpages and administrative features as easy as possible with the extensibility you expect from WordPress.
15
 
16
+ Requires PHP version 5.4 or greater.
17
 
18
  * [Embedded Tweet](https://dev.twitter.com/web/embedded-tweets) - customize backgrounds and color schemes to match your site's theme
19
  * [Embedded Twitter video](https://dev.twitter.com/web/embedded-video) - showcase video uploaded to Twitter
25
 
26
  Contribute to the plugin, submit pull requests, or run test suites through the [Twitter plugin for WordPress GitHub repository](https://github.com/twitter/wordpress). View [Twitter for WordPress documentation](https://dev.twitter.com/web/wordpress) to learn more about customization through filters.
27
 
28
+ == Upgrade Notice ==
29
+
30
+ = 1.0.1 =
31
+
32
+ Display admin notice if current PHP version does not meet minimum requirements. Do not display Tweet button in auto-generated excerpt.
33
+
34
  == Changelog ==
35
 
36
+ = 1.0.1 =
37
+ * Display admin notice if plugin is installed on a site not meeting minimum PHP requirement
38
+ * Disable Tweet button the_content wrapper when called during excerpt generation
39
+ * Tweet button: add support for via shortcode attribute
40
+ * Fix: save Follow button widget with no overrides
41
+
42
  = 1.0.0 =
43
  * Embedded Tweets
44
  * Embedded video
49
 
50
  == Frequently Asked Questions ==
51
 
 
 
 
 
52
  = How can I change an embedded Tweet's background and link colors to match my site's theme? =
53
 
54
  The Twitter plugin for WordPress includes a settings page with options to customize the background color, link color, and border color used in Twitter embedded Tweets and embedded timelines.
82
  == Installation ==
83
 
84
  1. Add the Twitter plugin to your WordPress installation
85
+ 1. Activate the plugin through the 'Plugins' menu in WordPress
src/Twitter/Intents/Tweet.php CHANGED
@@ -282,6 +282,18 @@ class Tweet
282
  return array_values($this->hashtags);
283
  }
284
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  /**
286
  * Associate Tweet with a source account
287
  *
282
  return array_values($this->hashtags);
283
  }
284
 
285
+ /**
286
+ * Get the stored via value
287
+ *
288
+ * @since 1.0.1
289
+ *
290
+ * @return string source Twitter account username
291
+ */
292
+ public function getVia()
293
+ {
294
+ return $this->via ?: '';
295
+ }
296
+
297
  /**
298
  * Associate Tweet with a source account
299
  *
src/Twitter/WordPress/Admin/Post/MetaBox.php CHANGED
@@ -145,7 +145,7 @@ class MetaBox
145
  \Twitter\WordPress\PluginLoader::getPluginMainFile()
146
  ), // absolute URI
147
  array(), // no dependencies
148
- '1.0.0' // last chance. used for caching
149
  );
150
  }
151
 
145
  \Twitter\WordPress\PluginLoader::getPluginMainFile()
146
  ), // absolute URI
147
  array(), // no dependencies
148
+ '1.0.1' // last change. used for caching
149
  );
150
  }
151
 
src/Twitter/WordPress/Admin/Post/TweetIntent.php CHANGED
@@ -164,7 +164,7 @@ class TweetIntent
164
  }
165
 
166
  echo '<tr>';
167
- echo '<td scope="row" class="left"><label for="tweet-text">' . esc_html( _x( 'Text', 'Share / Tweet text', 'twitter' ) ) . '</label></th>';
168
  echo '<td><input id="tweet-text" name="' . esc_attr( static::META_KEY . '[' . static::TEXT_KEY . ']' ) . '" type="text" maxlength="' . $available_characters . '" autocomplete="off"';
169
  if ( isset( $stored_values[ static::TEXT_KEY ] ) ) {
170
  echo ' value="' . esc_attr( $stored_values[ static::TEXT_KEY ] ) . '"';
@@ -174,7 +174,7 @@ class TweetIntent
174
  echo \Twitter\WordPress\Helpers\HTMLBuilder::closeVoidHTMLElement() . '></td>';
175
  echo '</tr>';
176
  echo '<tr>';
177
- echo '<td scope="row" class="left"><label for"tweet-hashtags">' . esc_html( __( 'Hashtags', 'twitter' ) ) . '</label></th>';
178
  echo '<td><input id="tweet-hashtags" name="' . esc_attr( static::META_KEY . '[' . static::HASHTAGS_KEY . ']' ) . '" type="text" maxlength="' . ($available_characters - 2) . '" autocomplete="off"';
179
  if ( isset( $stored_values[ static::HASHTAGS_KEY ] ) && is_array( $stored_values[ static::HASHTAGS_KEY ] ) ) {
180
  echo ' value="' . esc_attr( implode( ',', $stored_values[ static::HASHTAGS_KEY ] ) ) . '"';
164
  }
165
 
166
  echo '<tr>';
167
+ echo '<th scope="row" class="left"><label for="tweet-text">' . esc_html( _x( 'Text', 'Share / Tweet text', 'twitter' ) ) . '</label></th>';
168
  echo '<td><input id="tweet-text" name="' . esc_attr( static::META_KEY . '[' . static::TEXT_KEY . ']' ) . '" type="text" maxlength="' . $available_characters . '" autocomplete="off"';
169
  if ( isset( $stored_values[ static::TEXT_KEY ] ) ) {
170
  echo ' value="' . esc_attr( $stored_values[ static::TEXT_KEY ] ) . '"';
174
  echo \Twitter\WordPress\Helpers\HTMLBuilder::closeVoidHTMLElement() . '></td>';
175
  echo '</tr>';
176
  echo '<tr>';
177
+ echo '<th scope="row" class="left"><label for="tweet-hashtags">' . esc_html( __( 'Hashtags', 'twitter' ) ) . '</label></th>';
178
  echo '<td><input id="tweet-hashtags" name="' . esc_attr( static::META_KEY . '[' . static::HASHTAGS_KEY . ']' ) . '" type="text" maxlength="' . ($available_characters - 2) . '" autocomplete="off"';
179
  if ( isset( $stored_values[ static::HASHTAGS_KEY ] ) && is_array( $stored_values[ static::HASHTAGS_KEY ] ) ) {
180
  echo ' value="' . esc_attr( implode( ',', $stored_values[ static::HASHTAGS_KEY ] ) ) . '"';
src/Twitter/WordPress/Admin/Post/TwitterCard.php CHANGED
@@ -142,7 +142,7 @@ class TwitterCard
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
  echo '<tr>';
145
- echo '<td scope="row" class="left"><label for="twitter-card-title">' . esc_html( __( 'Title' ) ) . '</label></th>';
146
  echo '<td><input type="text" id="twitter-card-title" name="' . esc_attr( static::META_KEY . '[' . static::TITLE_KEY . ']' ) . '" maxlength="70" autocomplete="off"';
147
  if ( isset( $stored_values[ static::TITLE_KEY ] ) ) {
148
  echo ' value="' . esc_attr( $stored_values[ static::TITLE_KEY ] ) . '"';
@@ -156,7 +156,7 @@ class TwitterCard
156
 
157
  if ( isset( $cards_fields_supported_by_post_type[ static::DESCRIPTION_KEY ] ) ) {
158
  echo '<tr>';
159
- echo '<td scope="row" class="left"><label for="twitter-card-description">' . esc_html( __( 'Description' ) ) . '</label></th>';
160
  echo '<td><input type="text" id="twitter-card-description" name="' . esc_attr( static::META_KEY . '[' . static::DESCRIPTION_KEY . ']' ) . '" maxlength="200" autocomplete="off"';
161
  if ( isset( $stored_values[ static::DESCRIPTION_KEY ] ) ) {
162
  echo ' value="' . esc_attr( $stored_values[ static::DESCRIPTION_KEY ] ) . '"';
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
  echo '<tr>';
145
+ echo '<th scope="row" class="left"><label for="twitter-card-title">' . esc_html( __( 'Title' ) ) . '</label></th>';
146
  echo '<td><input type="text" id="twitter-card-title" name="' . esc_attr( static::META_KEY . '[' . static::TITLE_KEY . ']' ) . '" maxlength="70" autocomplete="off"';
147
  if ( isset( $stored_values[ static::TITLE_KEY ] ) ) {
148
  echo ' value="' . esc_attr( $stored_values[ static::TITLE_KEY ] ) . '"';
156
 
157
  if ( isset( $cards_fields_supported_by_post_type[ static::DESCRIPTION_KEY ] ) ) {
158
  echo '<tr>';
159
+ echo '<th scope="row" class="left"><label for="twitter-card-description">' . esc_html( __( 'Description' ) ) . '</label></th>';
160
  echo '<td><input type="text" id="twitter-card-description" name="' . esc_attr( static::META_KEY . '[' . static::DESCRIPTION_KEY . ']' ) . '" maxlength="200" autocomplete="off"';
161
  if ( isset( $stored_values[ static::DESCRIPTION_KEY ] ) ) {
162
  echo ' value="' . esc_attr( $stored_values[ static::DESCRIPTION_KEY ] ) . '"';
src/Twitter/WordPress/Admin/Settings/Loader.php CHANGED
@@ -41,22 +41,10 @@ class Loader
41
  */
42
  public static function init()
43
  {
44
- add_action( 'admin_menu', array( __CLASS__, 'settingsMenuItems' ) );
45
  add_filter( 'plugin_action_links', array( __CLASS__, 'pluginActionLinks' ), 10, 2 );
46
  }
47
 
48
- /**
49
- * Add Twitter settings to the WordPress administration menu.
50
- *
51
- * @since 1.0.0
52
- *
53
- * @return void
54
- */
55
- public static function settingsMenuItems()
56
- {
57
- \Twitter\WordPress\Admin\Settings\SinglePage::menuItem();
58
- }
59
-
60
  /**
61
  * Link to settings from the plugin listing page
62
  *
41
  */
42
  public static function init()
43
  {
44
+ add_action( 'admin_menu', array( '\Twitter\WordPress\Admin\Settings\SinglePage', 'menuItem' ) );
45
  add_filter( 'plugin_action_links', array( __CLASS__, 'pluginActionLinks' ), 10, 2 );
46
  }
47
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  /**
49
  * Link to settings from the plugin listing page
50
  *
src/Twitter/WordPress/Admin/Settings/{Template.php → SettingsSection.php} RENAMED
@@ -26,42 +26,47 @@ THE SOFTWARE.
26
  namespace Twitter\WordPress\Admin\Settings;
27
 
28
  /**
29
- * Share common template functionality across Twitter setting pages
30
  *
31
- * @since 1.0.0
32
  */
33
- trait Template
34
  {
35
-
36
  /**
37
- * Load the settings page
38
  *
39
- * @since 1.0.0
40
  *
41
- * @return void
42
  */
43
- public function settingsPage()
44
- {
45
- if ( ! isset( $this->hook_suffix ) ) {
46
- return;
47
- }
48
-
49
- do_action( 'add-' . $this->hook_suffix . '-section' );
50
-
51
- echo '<div class="wrap">';
52
-
53
- echo '<header><h2>' . esc_html( static::featureName() ) . '</h2></header>';
54
- // handle general messages such as settings updated up top
55
- // place individual settings errors alongside their fields
56
- settings_errors( 'general' );
57
 
58
- echo '<form method="post" action="' . esc_url( admin_url( 'options.php' ), array( 'https', 'http' ) ) . '">';
59
- settings_fields( $this->hook_suffix );
60
- do_settings_sections( $this->hook_suffix );
61
- submit_button();
62
- echo '</form>';
 
 
 
 
 
63
 
64
- echo '</div>';
65
- }
 
 
 
 
 
 
66
 
 
 
 
 
 
 
 
 
67
  }
26
  namespace Twitter\WordPress\Admin\Settings;
27
 
28
  /**
29
+ * Expected structure of a settings section included in the Twitter settings page
30
  *
31
+ * @since 1.0.1
32
  */
33
+ interface SettingsSection
34
  {
 
35
  /**
36
+ * Reference the feature by name
37
  *
38
+ * @since 1.0.1
39
  *
40
+ * @return string translated feature name
41
  */
42
+ public static function featureName();
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
+ /**
45
+ * Register settings, hook an onload handler
46
+ *
47
+ * @since 1.0.1
48
+ *
49
+ * @param string $hook_suffix hook suffix of an existing settings page
50
+ *
51
+ * @return bool settings section loaded
52
+ */
53
+ public static function addToSettingsPage( $hook_suffix );
54
 
55
+ /**
56
+ * Set up settings section
57
+ *
58
+ * @since 1.0.1
59
+ *
60
+ * @return void
61
+ */
62
+ public function onload();
63
 
64
+ /**
65
+ * Add settings section and fields
66
+ *
67
+ * @since 1.0.1
68
+ *
69
+ * @return void
70
+ */
71
+ public function defineSection();
72
  }
src/Twitter/WordPress/Admin/Settings/SinglePage.php CHANGED
@@ -32,8 +32,6 @@ namespace Twitter\WordPress\Admin\Settings;
32
  */
33
  class SinglePage
34
  {
35
- use Template;
36
-
37
  /**
38
  * Settings page identifier.
39
  *
@@ -118,6 +116,37 @@ class SinglePage
118
  return $hook_suffix;
119
  }
120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  /**
122
  * Add contextual help content to the settings screen
123
  *
@@ -128,7 +157,8 @@ class SinglePage
128
  public function addContextualHelp()
129
  {
130
  $screen = get_current_screen();
131
- if ( ! $screen ) { // null if global not set
 
132
  return;
133
  }
134
 
32
  */
33
  class SinglePage
34
  {
 
 
35
  /**
36
  * Settings page identifier.
37
  *
116
  return $hook_suffix;
117
  }
118
 
119
+ /**
120
+ * Load the settings page
121
+ *
122
+ * @since 1.0.0
123
+ *
124
+ * @return void
125
+ */
126
+ public function settingsPage()
127
+ {
128
+ if ( ! isset( $this->hook_suffix ) ) {
129
+ return;
130
+ }
131
+
132
+ do_action( 'add-' . $this->hook_suffix . '-section' );
133
+
134
+ echo '<div class="wrap">';
135
+
136
+ echo '<header><h2>' . esc_html( static::featureName() ) . '</h2></header>';
137
+ // handle general messages such as settings updated up top
138
+ // place individual settings errors alongside their fields
139
+ settings_errors( 'general' );
140
+
141
+ echo '<form method="post" action="' . esc_url( admin_url( 'options.php' ), array( 'https', 'http' ) ) . '">';
142
+ settings_fields( $this->hook_suffix );
143
+ do_settings_sections( $this->hook_suffix );
144
+ submit_button();
145
+ echo '</form>';
146
+
147
+ echo '</div>';
148
+ }
149
+
150
  /**
151
  * Add contextual help content to the settings screen
152
  *
157
  public function addContextualHelp()
158
  {
159
  $screen = get_current_screen();
160
+ // null if global not set
161
+ if ( ! $screen ) {
162
  return;
163
  }
164
 
src/Twitter/WordPress/Admin/Settings/SiteAttribution.php CHANGED
@@ -30,7 +30,7 @@ namespace Twitter\WordPress\Admin\Settings;
30
  *
31
  * @since 1.0.0
32
  */
33
- class SiteAttribution
34
  {
35
  /**
36
  * Define our option name
30
  *
31
  * @since 1.0.0
32
  */
33
+ class SiteAttribution implements SettingsSection
34
  {
35
  /**
36
  * Define our option name
src/Twitter/WordPress/Admin/Settings/Theme.php CHANGED
@@ -30,7 +30,7 @@ namespace Twitter\WordPress\Admin\Settings;
30
  *
31
  * @since 1.0.0
32
  */
33
- class Theme
34
  {
35
  /**
36
  * Define our option array value.
@@ -157,7 +157,7 @@ class Theme
157
  // theme
158
  add_action(
159
  'add-' . $this->hook_suffix . '-section',
160
- array( &$this, 'defineThemeSection' ),
161
  static::SECTION_PRIORITY, // top of screen
162
  0 // no parameters
163
  );
@@ -187,7 +187,7 @@ class Theme
187
  *
188
  * @return void
189
  */
190
- public function defineThemeSection()
191
  {
192
  $section = 'twitter-colorscheme';
193
  add_settings_section(
30
  *
31
  * @since 1.0.0
32
  */
33
+ class Theme implements SettingsSection
34
  {
35
  /**
36
  * Define our option array value.
157
  // theme
158
  add_action(
159
  'add-' . $this->hook_suffix . '-section',
160
+ array( &$this, 'defineSection' ),
161
  static::SECTION_PRIORITY, // top of screen
162
  0 // no parameters
163
  );
187
  *
188
  * @return void
189
  */
190
+ public function defineSection()
191
  {
192
  $section = 'twitter-colorscheme';
193
  add_settings_section(
src/Twitter/WordPress/Admin/Settings/TweetButton.php CHANGED
@@ -30,7 +30,7 @@ namespace Twitter\WordPress\Admin\Settings;
30
  *
31
  * @since 1.0.0
32
  */
33
- class TweetButton
34
  {
35
  /**
36
  * Define our option name
30
  *
31
  * @since 1.0.0
32
  */
33
+ class TweetButton implements SettingsSection
34
  {
35
  /**
36
  * Define our option name
src/Twitter/WordPress/Content/TweetButton.php CHANGED
@@ -32,7 +32,6 @@ namespace Twitter\WordPress\Content;
32
  */
33
  class TweetButton
34
  {
35
-
36
  /**
37
  * Get the stored site option for Tweet button content
38
  *
@@ -59,6 +58,12 @@ class TweetButton
59
  */
60
  public static function contentFilter( $content )
61
  {
 
 
 
 
 
 
62
  $options = static::getOption();
63
  if ( isset( $options['position'] ) ) {
64
  $position = $options['position'];
32
  */
33
  class TweetButton
34
  {
 
35
  /**
36
  * Get the stored site option for Tweet button content
37
  *
58
  */
59
  public static function contentFilter( $content )
60
  {
61
+ // do not include Tweet button(s) in an autogenerated excerpt
62
+ // get_the_excerpt filter calls wp_trim_excerpt() at priority 10 which triggers the_content filter on an empty excerpt string
63
+ if ( doing_filter( 'get_the_excerpt' ) ) {
64
+ return $content;
65
+ }
66
+
67
  $options = static::getOption();
68
  if ( isset( $options['position'] ) ) {
69
  $position = $options['position'];
src/Twitter/WordPress/PluginLoader.php CHANGED
@@ -41,7 +41,7 @@ class PluginLoader
41
  *
42
  * @type string
43
  */
44
- const VERSION = '1.0.0';
45
 
46
  /**
47
  * Unique domain of the plugin's translated text
@@ -120,7 +120,7 @@ class PluginLoader
120
  load_plugin_textdomain(
121
  static::TEXT_DOMAIN,
122
  false, // deprecated parameter as of WP 2.7
123
- dirname( plugin_basename( static::getPluginMainFile() ) ) . '/languages/' // directory location of MO files
124
  );
125
  }
126
 
@@ -180,7 +180,18 @@ class PluginLoader
180
  return;
181
  }
182
 
183
- $twitter_content_priority = apply_filters( 'twitter_content_filter_priority', 10 );
 
 
 
 
 
 
 
 
 
 
 
184
  add_filter(
185
  'the_content',
186
  array( '\Twitter\WordPress\Content\TweetButton', 'contentFilter' ),
41
  *
42
  * @type string
43
  */
44
+ const VERSION = '1.0.1';
45
 
46
  /**
47
  * Unique domain of the plugin's translated text
120
  load_plugin_textdomain(
121
  static::TEXT_DOMAIN,
122
  false, // deprecated parameter as of WP 2.7
123
+ dirname( plugin_basename( static::getPluginMainFile() ) ) . '/languages' // directory location of MO files
124
  );
125
  }
126
 
180
  return;
181
  }
182
 
183
+ /**
184
+ * Set the priority to apply to Twitter elements automatically added to the_content
185
+ *
186
+ * Allow publishers to adjust the order of Twitter buttons relative to other the_content actors
187
+ *
188
+ * @since 1.0.0
189
+ *
190
+ * @param int $priority filter priority
191
+ */
192
+ $twitter_content_priority = apply_filters( 'twitter_content_filter_priority', 15 );
193
+
194
+ // possibly add Tweet button(s)
195
  add_filter(
196
  'the_content',
197
  array( '\Twitter\WordPress\Content\TweetButton', 'contentFilter' ),
src/Twitter/WordPress/Shortcodes/Share.php CHANGED
@@ -198,6 +198,14 @@ class Share
198
  unset( $intent );
199
  }
200
 
 
 
 
 
 
 
 
 
201
  if ( isset( $attributes['hashtags'] ) ) {
202
  $intent = \Twitter\Intents\Tweet::fromArray( array( 'hashtags' => $attributes['hashtags'] ) );
203
  if ( $intent ) {
198
  unset( $intent );
199
  }
200
 
201
+ if ( isset( $attributes['via'] ) ) {
202
+ $via = (new \Twitter\Intents\Tweet())->setVia( $attributes['via'] )->getVia();
203
+ if ( $via ) {
204
+ $options['via'] = $via;
205
+ }
206
+ unset( $via );
207
+ }
208
+
209
  if ( isset( $attributes['hashtags'] ) ) {
210
  $intent = \Twitter\Intents\Tweet::fromArray( array( 'hashtags' => $attributes['hashtags'] ) );
211
  if ( $intent ) {
src/Twitter/WordPress/Widgets/Follow.php CHANGED
@@ -177,9 +177,6 @@ class Follow extends \WP_Widget
177
  }
178
 
179
  $filtered_options = $follow_button->toArray( /* dashed_keys */ false );
180
- if ( empty( $filtered_options ) ) {
181
- return false;
182
- }
183
  $screen_name = $follow_button->getScreenName();
184
  if ( $screen_name ) {
185
  $filtered_options['screen_name'] = $screen_name;
177
  }
178
 
179
  $filtered_options = $follow_button->toArray( /* dashed_keys */ false );
 
 
 
180
  $screen_name = $follow_button->getScreenName();
181
  if ( $screen_name ) {
182
  $filtered_options['screen_name'] = $screen_name;
static/css/admin/post/edit.min.css CHANGED
@@ -1 +1 @@
1
- #twitter-custom table{margin:0;width:100%;border:1px solid #dfdfdf;border-spacing:0;background-color:#f9f9f9}#twitter-custom thead th{padding:5px 8px 8px;background-color:#f1f1f1}#twitter-custom input{width:96%;margin:8px}#tweet-intent{width:100%}#twitter-card{width:100%}
1
+ #twitter-custom table{margin:0;width:100%;border:1px solid #dfdfdf;border-spacing:0;background-color:#f9f9f9}#twitter-custom thead th{padding:5px 8px 8px;background-color:#f1f1f1}#twitter-custom tbody th{font-family:inherit;font-size:inherit;font-weight:inherit;line-height:inherit;text-align:inherit}#twitter-custom input{width:96%;margin:8px}#tweet-intent{width:100%}#twitter-card{width:100%}
twitter.php CHANGED
@@ -1,20 +1,4 @@
1
  <?php
2
- /**
3
- * @package twitter
4
- * @version 1.0.0
5
- */
6
- /*
7
- Plugin Name: Twitter
8
- Plugin URI: http://wordpress.org/plugins/twitter/
9
- Description: Official Twitter plugin for WordPress. Embed Twitter content and grow your audience on Twitter. Requires PHP 5.4 or newer.
10
- Version: 1.0.0
11
- Author: Twitter
12
- Author URI: https://dev.twitter.com/
13
- License: MIT
14
- Text Domain: twitter
15
- Domain Path: /languages/
16
- */
17
-
18
  /*
19
  The MIT License (MIT)
20
 
@@ -38,7 +22,21 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
38
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
39
  THE SOFTWARE.
40
  */
41
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
  // make sure the plugin does not expose any info if called directly
44
  if ( ! function_exists( 'add_action' ) ) {
@@ -52,9 +50,16 @@ if ( ! function_exists( 'add_action' ) ) {
52
  exit( 'Hi there! I am a WordPress plugin requiring functions included with WordPress. I am not meant to be addressed directly.' );
53
  }
54
 
55
- // plugin requires PHP 5.4 or newer
56
  if ( version_compare( PHP_VERSION, '5.4.0', '<' ) ) {
57
- trigger_error( 'The Twitter plugin for WordPress requires PHP version 5.4 or higher.' );
 
 
 
 
 
 
 
58
  return;
59
  }
60
 
@@ -64,7 +69,7 @@ require_once( dirname( __FILE__ ) . '/autoload.php' );
64
  // initialize on plugins loaded
65
  add_action(
66
  'plugins_loaded',
67
- array( '\\Twitter\\WordPress\\PluginLoader', 'init' ),
68
  0, // priority
69
  0 // expected arguments
70
  );
1
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  /*
3
  The MIT License (MIT)
4
 
22
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
  THE SOFTWARE.
24
  */
25
+ /**
26
+ * @package twitter
27
+ * @version 1.0.1
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.0.1
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
42
  if ( ! function_exists( 'add_action' ) ) {
50
  exit( 'Hi there! I am a WordPress plugin requiring functions included with WordPress. I am not meant to be addressed directly.' );
51
  }
52
 
53
+ // plugin requires PHP 5.4 or greater
54
  if ( version_compare( PHP_VERSION, '5.4.0', '<' ) ) {
55
+ if ( ! class_exists( 'Twitter_CompatibilityNotice' ) ) {
56
+ require_once( dirname(__FILE__) . '/compatibility-notice.php' );
57
+ }
58
+
59
+ // possibly display a notice, trigger error
60
+ add_action( 'admin_init', array( 'Twitter_CompatibilityNotice', 'adminInit' ) );
61
+
62
+ // stop execution of this file
63
  return;
64
  }
65
 
69
  // initialize on plugins loaded
70
  add_action(
71
  'plugins_loaded',
72
+ array( '\Twitter\WordPress\PluginLoader', 'init' ),
73
  0, // priority
74
  0 // expected arguments
75
  );