Twitter - Version 1.1.0

Version Description

Shortcode improvements for ajax-loaded posts. Remove photo, gallery, and product Twitter Cards no longer supported by Twitter.

Download this release

Release Info

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

Code changes from version 1.0.1 to 1.1.0

compatibility-notice.php CHANGED
@@ -201,7 +201,7 @@ class Twitter_CompatibilityNotice {
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;
201
  */
202
  public static function adminNotice()
203
  {
204
+ echo '<div class="notice error is-dismissible">';
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;
readme.txt CHANGED
@@ -2,8 +2,8 @@
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
 
@@ -27,12 +27,20 @@ Contribute to the plugin, submit pull requests, or run test suites through the [
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
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.3
6
+ Stable tag: 1.1.0
7
  License: MIT
8
  License URI: http://opensource.org/licenses/MIT
9
 
27
 
28
  == Upgrade Notice ==
29
 
30
+ = 1.1.0 =
31
+ Shortcode improvements for ajax-loaded posts. Remove photo, gallery, and product Twitter Cards no longer supported by Twitter.
32
 
33
+ = 1.0.1 =
34
  Display admin notice if current PHP version does not meet minimum requirements. Do not display Tweet button in auto-generated excerpt.
35
 
36
  == Changelog ==
37
 
38
+ = 1.1.0 =
39
+ * Shortcodes now include inline asynchronous JavaScript loaders for improved compatibility with ajax-loaded content
40
+ * Twitter announced photo, gallery, and product Twitter Cards are [no longer supported](https://twittercommunity.com/t/deprecating-the-photo-gallery-and-product-cards/38961 "Twitter announcement: deprecation of photo, gallery, product cards"). Removed from plugin
41
+ * Add [Shortcake plugin](https://wordpress.org/plugins/shortcode-ui/ "Shortcake WordPress plugin") compatibility for form-based shortcode construction and previews
42
+ * Improved Twitter Card image compatibility
43
+
44
  = 1.0.1 =
45
  * Display admin notice if plugin is installed on a site not meeting minimum PHP requirement
46
  * Disable Tweet button the_content wrapper when called during excerpt generation
src/Twitter/Cards/Card.php CHANGED
@@ -34,7 +34,7 @@ class Card
34
  {
35
 
36
  /**
37
- * Twitter Card type. summary, photo, etc.
38
  *
39
  * @since 1.0.0
40
  *
34
  {
35
 
36
  /**
37
+ * Twitter Card type. summary, summary_large_image, etc.
38
  *
39
  * @since 1.0.0
40
  *
src/Twitter/Cards/Components/MultipleImages.php DELETED
@@ -1,158 +0,0 @@
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
- namespace Twitter\Cards\Components;
27
-
28
- /**
29
- * A card with multiple images
30
- *
31
- * @since 1.0.0
32
- */
33
- trait MultipleImages
34
- {
35
-
36
- /**
37
- * Images representing the content of the page
38
- *
39
- * @since 1.0.0
40
- *
41
- * @type array {
42
- * Images stored for the card
43
- *
44
- * @type string image uri
45
- * @type \Twitter\Cards\Components\Image card image
46
- * }
47
- */
48
- protected $images = array();
49
-
50
- /**
51
- * Keep track of the total number of images stored for the card
52
- *
53
- * @since 1.0.0
54
- *
55
- * @type int
56
- */
57
- protected $image_count = 0;
58
-
59
- /**
60
- * Get the images array
61
- *
62
- * @since 1.0.0
63
- *
64
- * @return array {
65
- * Images stored for the card
66
- *
67
- * @type string image uri
68
- * @type \Twitter\Cards\Components\Image card image
69
- * }
70
- */
71
- public function getImages()
72
- {
73
- return $this->images;
74
- }
75
-
76
- /**
77
- * Add an image representing the content of the page
78
- *
79
- * @since 1.0.0
80
- *
81
- * @param string|\Twitter\Cards\Components\Image $url absolute URL of an image file
82
- * @param int $width width of the image in whole pixels
83
- * @param int $height height of the image in whole pixels
84
- *
85
- * @return __CLASS__ support chaining
86
- */
87
- public function addImage($url, $width = 0, $height = 0)
88
- {
89
- // URL required
90
- if (! $url) {
91
- return $this;
92
- }
93
- if (! ( is_int($width) && $width >= 0 )) {
94
- $width = 0;
95
- }
96
- if (! ( is_int($height) && $height >= 0 )) {
97
- $height = 0;
98
- }
99
-
100
- // have we already filled the image allotment?
101
- if (defined(__CLASS__ . '::MAX_IMAGES') && $this->image_count === self::MAX_IMAGES) {
102
- return $this;
103
- }
104
-
105
- $image = null;
106
- $preset = false;
107
- if (is_a($url, '\Twitter\Cards\Components\Image')) {
108
- // support overloading the function
109
- $image = $url;
110
- $url = $url->getURL();
111
- if (isset( $this->images[ $url ] )) {
112
- return $this;
113
- }
114
- $preset = true;
115
- $width = $image->getWidth();
116
- $height = $image->getHeight();
117
- } elseif (is_string($url)) {
118
- if (isset( $this->images[ $url ] )) {
119
- return $this;
120
- }
121
- try {
122
- $image = new \Twitter\Cards\Components\Image($url);
123
- } catch (Exception $e) {
124
- return $this;
125
- }
126
- }
127
-
128
- if (! $image) {
129
- return $this;
130
- }
131
-
132
- // only set dimensions if both width and height exist
133
- if (is_int($width) && $width && is_int($height) && $height) {
134
- // test if minimum width and height requirements are met for the card type
135
- if (defined(__CLASS__ . '::MIN_IMAGE_WIDTH') && defined(__CLASS__ . '::MIN_IMAGE_HEIGHT')) {
136
- if ($width >= self::MIN_IMAGE_WIDTH && $height >= self::MIN_IMAGE_HEIGHT) {
137
- if (! $preset) {
138
- $image->setWidth($width);
139
- $image->setHeight($height);
140
- }
141
- } else {
142
- // do not store image if minimum requirements not met
143
- return $this;
144
- }
145
- } else {
146
- if (! $preset) {
147
- $image->setWidth($width);
148
- $image->setHeight($height);
149
- }
150
- }
151
- }
152
-
153
- $this->images[ $url ] = $image;
154
- $this->image_count = count($this->images);
155
-
156
- return $this;
157
- }
158
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/Twitter/Cards/Gallery.php DELETED
@@ -1,125 +0,0 @@
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
- namespace Twitter\Cards;
27
-
28
- /**
29
- * Gallery card
30
- *
31
- * @since 1.0.0
32
- *
33
- * @link https://dev.twitter.com/cards/types/gallery
34
- */
35
- class Gallery extends Card
36
- {
37
- use \Twitter\Cards\Components\Creator;
38
- use \Twitter\Cards\Components\Description;
39
- use \Twitter\Cards\Components\MultipleImages;
40
-
41
- /**
42
- * Twitter Card type value
43
- *
44
- * @since 1.0.0
45
- *
46
- * @type string
47
- */
48
- const TYPE = 'gallery';
49
-
50
- /**
51
- * Minimum width of an image in whole pixels
52
- *
53
- * @since 1.0.0
54
- *
55
- * @type int
56
- */
57
- const MIN_IMAGE_WIDTH = 280;
58
-
59
- /**
60
- * Minimum height of an image in whole pixels
61
- *
62
- * @since 1.0.0
63
- *
64
- * @type int
65
- */
66
- const MIN_IMAGE_HEIGHT = 150;
67
-
68
- /**
69
- * Maximum number of images used in a gallery card template
70
- *
71
- * @since 1.0.0
72
- *
73
- * @type int
74
- */
75
- const MAX_IMAGES = 4;
76
-
77
- /**
78
- * Set the card type
79
- *
80
- * @since 1.0.0
81
- *
82
- * @return void
83
- */
84
- public function __construct()
85
- {
86
- parent::__construct(static::TYPE);
87
- }
88
-
89
- /**
90
- * Convert to an array suitable for use as Twitter Card structured properties
91
- *
92
- * @since 1.0.0
93
- *
94
- * @return array {
95
- * @type string Twitter card property
96
- * @type mixed property value
97
- * }
98
- */
99
- public function toArray()
100
- {
101
- $card = parent::toArray();
102
-
103
- $images = $this->getImages();
104
- if (! empty( $images )) {
105
- $image_count = count($images);
106
- // flatten to just \Twitter\Cards\Components\Image
107
- $images = array_values($images);
108
- for ($i = 0; $i < $image_count; $i++) {
109
- $card[ 'image' . $i ] = $images[ $i ]->asCardProperties();
110
- }
111
- unset( $image_count );
112
- }
113
- unset( $images );
114
-
115
- if (isset( $this->creator ) && $this->creator) {
116
- $creator = $this->creator->asCardProperties();
117
- if ($creator) {
118
- $card['creator'] = $creator;
119
- }
120
- unset( $creator );
121
- }
122
-
123
- return $card;
124
- }
125
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/Twitter/Cards/Photo.php DELETED
@@ -1,109 +0,0 @@
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
- namespace Twitter\Cards;
27
-
28
- /**
29
- * Photo card
30
- *
31
- * @since 1.0.0
32
- *
33
- * @link https://dev.twitter.com/cards/types/photo
34
- */
35
- class Photo extends Card
36
- {
37
- use \Twitter\Cards\Components\Creator;
38
- use \Twitter\Cards\Components\SingleImage;
39
-
40
- /**
41
- * Twitter Card type value
42
- *
43
- * @since 1.0.0
44
- *
45
- * @type string
46
- */
47
- const TYPE = 'photo';
48
-
49
- /**
50
- * Minimum width of the image in whole pixels
51
- *
52
- * @since 1.0.0
53
- *
54
- * @type int
55
- */
56
- const MIN_IMAGE_WIDTH = 280;
57
-
58
- /**
59
- * Minimum height of the image in whole pixels
60
- *
61
- * @since 1.0.0
62
- *
63
- * @type int
64
- */
65
- const MIN_IMAGE_HEIGHT = 150;
66
-
67
- /**
68
- * Set the card type
69
- *
70
- * @since 1.0.0
71
- *
72
- * @return void
73
- */
74
- public function __construct()
75
- {
76
- parent::__construct(static::TYPE);
77
- }
78
-
79
- /**
80
- * Convert to an array suitable for use as Twitter Card structured properties
81
- *
82
- * @since 1.0.0
83
- *
84
- * @return array {
85
- * @type string Twitter card property
86
- * @type mixed property value
87
- * }
88
- */
89
- public function toArray()
90
- {
91
- $card = parent::toArray();
92
-
93
- $image_properties = $this->imageCardProperties();
94
- if (! empty( $image_properties )) {
95
- $card['image'] = $image_properties;
96
- }
97
- unset( $image_properties );
98
-
99
- if (isset( $this->creator ) && $this->creator) {
100
- $creator = $this->creator->asCardProperties();
101
- if ($creator) {
102
- $card['creator'] = $creator;
103
- }
104
- unset( $creator );
105
- }
106
-
107
- return $card;
108
- }
109
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/Twitter/Cards/Product.php DELETED
@@ -1,187 +0,0 @@
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
- namespace Twitter\Cards;
27
-
28
- /**
29
- * Product card
30
- *
31
- * @since 1.0.0
32
- *
33
- * @link https://dev.twitter.com/cards/types/product
34
- */
35
- class Product extends Card
36
- {
37
- use \Twitter\Cards\Components\Creator;
38
- use \Twitter\Cards\Components\Description;
39
- use \Twitter\Cards\Components\SingleImage;
40
-
41
- /**
42
- * Twitter Card type value
43
- *
44
- * @since 1.0.0
45
- *
46
- * @type string
47
- */
48
- const TYPE = 'product';
49
-
50
- /**
51
- * Minimum width of the image in whole pixels
52
- *
53
- * @since 1.0.0
54
- *
55
- * @type int
56
- */
57
- const MIN_IMAGE_WIDTH = 160;
58
-
59
- /**
60
- * Minimum height of the image in whole pixels
61
- *
62
- * @since 1.0.0
63
- *
64
- * @type int
65
- */
66
- const MIN_IMAGE_HEIGHT = 160;
67
-
68
- /**
69
- * Maximum number of displayed product details
70
- *
71
- * @since 1.0.0
72
- *
73
- * @type int
74
- */
75
- const MAX_DETAILS = 2;
76
-
77
- /**
78
- * Tabular data for display in the card template
79
- *
80
- * @since 1.0.0
81
- *
82
- * @type array label value pairs {
83
- * @type string label
84
- * @type string data
85
- * }
86
- */
87
- protected $details = array();
88
-
89
- /**
90
- * Number of stored details for the product
91
- *
92
- * @since 1.0.0
93
- *
94
- * @type int
95
- */
96
- protected $details_count = 0;
97
-
98
- /**
99
- * Set the card type
100
- *
101
- * @since 1.0.0
102
- *
103
- * @return void
104
- */
105
- public function __construct()
106
- {
107
- parent::__construct(static::TYPE);
108
- }
109
-
110
- /**
111
- * Add a detail
112
- *
113
- * @since 1.0.0
114
- *
115
- * @param string $label product detail label
116
- * @param string $value product detail value
117
- *
118
- * @return __CLASS__ support chaining
119
- */
120
- public function addDetail($label, $value)
121
- {
122
- // maximum allowed details already reached
123
- if ($this->details_count === static::MAX_DETAILS) {
124
- return $this;
125
- }
126
-
127
- try {
128
- $label = trim((string) $label);
129
- $value = trim((string) $value);
130
- } catch (Exception $e) {
131
- return $this;
132
- }
133
-
134
- if ($label && $value && ! isset( $this->details[ $label ] )) {
135
- $this->details[ $label ] = $value;
136
- $this->details_count = count($this->details);
137
- }
138
-
139
- return $this;
140
- }
141
-
142
- /**
143
- * Convert to an array suitable for use as Twitter Card structured properties
144
- *
145
- * @since 1.0.0
146
- *
147
- * @return array {
148
- * @type string Twitter card property
149
- * @type string|array property value
150
- * }
151
- */
152
- public function toArray()
153
- {
154
- $card = parent::toArray();
155
-
156
- if (isset( $this->description ) && $this->description) {
157
- $card['description'] = $this->description;
158
- }
159
-
160
- $image_properties = $this->imageCardProperties();
161
- if (! empty( $image_properties )) {
162
- $card['image'] = $image_properties;
163
- }
164
- unset( $image_properties );
165
-
166
- if (! empty( $this->details )) {
167
- // product card table is 1-based
168
- $details_position = 1;
169
- foreach ($this->details as $label => $data) {
170
- $card[ 'label' . $details_position ] = $label;
171
- $card[ 'data' . $details_position ] = $data;
172
- $details_position++;
173
- }
174
- unset( $details_position );
175
- }
176
-
177
- if (isset( $this->creator ) && $this->creator) {
178
- $creator = $this->creator->asCardProperties();
179
- if ($creator) {
180
- $card['creator'] = $creator;
181
- }
182
- unset( $creator );
183
- }
184
-
185
- return $card;
186
- }
187
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
src/Twitter/WordPress/Cards/Generator.php CHANGED
@@ -47,9 +47,6 @@ class Generator
47
  public static $SUPPORTED_CARDS = array(
48
  'summary' => '\Twitter\Cards\Summary',
49
  'summary_large_image' => '\Twitter\Cards\SummaryLargeImage',
50
- 'photo' => '\Twitter\Cards\Photo',
51
- 'gallery' => '\Twitter\Cards\Gallery',
52
- 'product' => '\Twitter\Cards\Product',
53
  );
54
 
55
  /**
@@ -349,15 +346,8 @@ class Generator
349
  return;
350
  }
351
 
352
- $card_type = 'summary';
353
- if ( has_post_format( 'image', $post->ID ) ) {
354
- $card_type = 'photo';
355
- } else if ( has_post_format( 'gallery', $post->ID ) ) {
356
- $card_type = 'gallery';
357
- }
358
-
359
  $query_type = 'post';
360
- $card = static::getCardObject( $query_type, $post->ID, $card_type );
361
  if ( ! $card ) {
362
  return;
363
  }
@@ -427,24 +417,7 @@ class Generator
427
 
428
  $images = $cards_image_handler->getTwitterCardImages();
429
  if ( ! empty( $images ) ) {
430
- $card->setImage( array_shift( $images ) );
431
- }
432
- unset( $images );
433
-
434
- unset( $cards_image_handler );
435
- } else if ( defined( $card_class . '::MAX_IMAGES' ) && method_exists( $card, 'addImage' ) ) {
436
- // multiple image card type
437
-
438
- $cards_image_handler = new \Twitter\WordPress\Cards\ImageHandler();
439
- $cards_image_handler->setLimit( $card::MAX_IMAGES );
440
- $cards_image_handler->setMinWidth( $card::MIN_IMAGE_WIDTH );
441
- $cards_image_handler->setMinHeight( $card::MIN_IMAGE_HEIGHT );
442
-
443
- // discover images associated with the post
444
- $cards_image_handler->addPostImages( $post );
445
- $images = $cards_image_handler->getTwitterCardImages();
446
- if ( ! empty( $images ) ) {
447
- array_walk( $images, array( $card, 'addImage' ) );
448
  }
449
  unset( $images );
450
 
47
  public static $SUPPORTED_CARDS = array(
48
  'summary' => '\Twitter\Cards\Summary',
49
  'summary_large_image' => '\Twitter\Cards\SummaryLargeImage',
 
 
 
50
  );
51
 
52
  /**
346
  return;
347
  }
348
 
 
 
 
 
 
 
 
349
  $query_type = 'post';
350
+ $card = static::getCardObject( $query_type, $post->ID, 'summary' );
351
  if ( ! $card ) {
352
  return;
353
  }
417
 
418
  $images = $cards_image_handler->getTwitterCardImages();
419
  if ( ! empty( $images ) ) {
420
+ $card->setImage( reset( $images ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
  }
422
  unset( $images );
423
 
src/Twitter/WordPress/Head/CardsMetaElements.php CHANGED
@@ -70,7 +70,7 @@ class CardsMetaElements
70
  foreach ( $card_properties as $name => $content ) {
71
  if ( is_array( $content ) && $name ) {
72
  foreach ( $content as $structured_name => $structured_value ) {
73
- $html .= \Twitter\WordPress\Head\MetaElement::fromNameContentPair( $name . ':' . $structured_name, $structured_value );
74
  }
75
  } else {
76
  $html .= \Twitter\WordPress\Head\MetaElement::fromNameContentPair( $name, $content );
70
  foreach ( $card_properties as $name => $content ) {
71
  if ( is_array( $content ) && $name ) {
72
  foreach ( $content as $structured_name => $structured_value ) {
73
+ $html .= \Twitter\WordPress\Head\MetaElement::fromNameContentPair( ( $structured_name === 'src' ) ? $name : $name . ':' . $structured_name, $structured_value );
74
  }
75
  } else {
76
  $html .= \Twitter\WordPress\Head\MetaElement::fromNameContentPair( $name, $content );
src/Twitter/WordPress/JavaScriptLoaders/Widgets.php CHANGED
@@ -34,6 +34,7 @@ class Widgets
34
  {
35
  /**
36
  * Twitter widget JavaScript handle
 
37
  * Used in WordPress JavaScript queue
38
  *
39
  * @since 1.0.0
@@ -42,6 +43,26 @@ class Widgets
42
  */
43
  const QUEUE_HANDLE = 'twitter-wjs';
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  /**
46
  * Proactively resolve Twitter widget JS FQDN asynchronously before later use
47
  *
@@ -54,7 +75,7 @@ class Widgets
54
  */
55
  public static function dnsPrefetch()
56
  {
57
- echo '<link rel="dns-prefetch" href="//platform.twitter.com"';
58
  echo \Twitter\WordPress\Helpers\HTMLBuilder::closeVoidHTMLElement();
59
  echo '>' . "\n";
60
  }
@@ -64,30 +85,41 @@ class Widgets
64
  *
65
  * @since 1.0.0
66
  *
67
- * @return void
68
  */
69
  public static function register()
70
  {
71
  global $wp_scripts;
72
 
73
- wp_register_script(
74
  self::QUEUE_HANDLE,
75
- static::getAbsoluteURI(), // should be overridden during queue output by asyncScriptLoaderSrc
76
  array(), // no dependencies
77
  null, // no not add extra query parameters for cache busting
78
  true // in footer
79
  );
80
 
 
 
 
 
 
 
 
 
81
  // initialize the twttr variable to attach ready events before JS loaded
82
  $script = 'window.twttr=(function(w){t=w.twttr||{};t._e=[];t.ready=function(f){t._e.push(f);};return t;}(window));';
83
  $data = $wp_scripts->get_data( self::QUEUE_HANDLE, 'data' );
84
  if ( $data ) {
85
- $script = $data . "\n" . $script;
 
 
 
 
86
  }
87
  $wp_scripts->add_data( self::QUEUE_HANDLE, 'data', $script );
88
 
89
- // replace standard script element with async script element
90
- add_filter( 'script_loader_src', array( __CLASS__, 'asyncScriptLoaderSrc' ), 1, 2 );
91
  }
92
 
93
  /**
@@ -97,7 +129,7 @@ class Widgets
97
  *
98
  * @uses wp_enqueue_script()
99
  *
100
- * @return void
101
  */
102
  public static function enqueue()
103
  {
@@ -105,21 +137,13 @@ class Widgets
105
  static::register();
106
  }
107
 
 
 
 
 
108
  wp_enqueue_script( self::QUEUE_HANDLE );
109
- }
110
 
111
- /**
112
- * The absolute URI of the Twitter widgets JavaScript file
113
- *
114
- * Prefer absolute URI over scheme-relative URI
115
- *
116
- * @since 1.0.0
117
- *
118
- * @return string absolute URI for the Twitter widgets JavaScript file
119
- */
120
- public static function getAbsoluteURI()
121
- {
122
- return 'http' . ( is_ssl() ? 's' : '' ) . '://platform.twitter.com/widgets.js';
123
  }
124
 
125
  /**
@@ -134,7 +158,7 @@ class Widgets
134
  // type = text/javascript to match default WP_Scripts output
135
  // async property to unlock page load, preload scanner discoverable in modern browsers
136
  // defer property for IE 9 and older
137
- return '<script type="text/javascript" id="' . esc_attr( self::QUEUE_HANDLE ) . '" async defer src="' . esc_url( static::getAbsoluteURI(), array( 'http', 'https' ) ) . '" charset="utf-8"></script>' . "\n";
138
  }
139
 
140
  /**
@@ -191,4 +215,24 @@ class Widgets
191
  // empty out the src response to avoid extra <script>
192
  return '';
193
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  }
34
  {
35
  /**
36
  * Twitter widget JavaScript handle
37
+ *
38
  * Used in WordPress JavaScript queue
39
  *
40
  * @since 1.0.0
43
  */
44
  const QUEUE_HANDLE = 'twitter-wjs';
45
 
46
+ /**
47
+ * Twitter widget JavaScript fully-qualified domain name
48
+ *
49
+ * Used to prefetch DNS lookup
50
+ *
51
+ * @since 1.1.0
52
+ *
53
+ * @type string
54
+ */
55
+ const FQDN = 'platform.twitter.com';
56
+
57
+ /**
58
+ * Twitter widgets JavaScript absolute URI
59
+ *
60
+ * @since 1.1.0
61
+ *
62
+ * @type string
63
+ */
64
+ const URI = 'https://platform.twitter.com/widgets.js';
65
+
66
  /**
67
  * Proactively resolve Twitter widget JS FQDN asynchronously before later use
68
  *
75
  */
76
  public static function dnsPrefetch()
77
  {
78
+ echo '<link rel="dns-prefetch" href="//' . esc_attr( self::FQDN ) . '"';
79
  echo \Twitter\WordPress\Helpers\HTMLBuilder::closeVoidHTMLElement();
80
  echo '>' . "\n";
81
  }
85
  *
86
  * @since 1.0.0
87
  *
88
+ * @return bool true on a successful wp_register_script response
89
  */
90
  public static function register()
91
  {
92
  global $wp_scripts;
93
 
94
+ $registered = wp_register_script(
95
  self::QUEUE_HANDLE,
96
+ self::URI, // should be overridden during queue output by asyncScriptLoaderSrc
97
  array(), // no dependencies
98
  null, // no not add extra query parameters for cache busting
99
  true // in footer
100
  );
101
 
102
+ // treat null response as true
103
+ if ( ! is_bool( $registered ) ) {
104
+ $registered = true;
105
+ }
106
+
107
+ // replace standard script element with async script element
108
+ add_filter( 'script_loader_src', array( __CLASS__, 'asyncScriptLoaderSrc' ), 1, 2 );
109
+
110
  // initialize the twttr variable to attach ready events before JS loaded
111
  $script = 'window.twttr=(function(w){t=w.twttr||{};t._e=[];t.ready=function(f){t._e.push(f);};return t;}(window));';
112
  $data = $wp_scripts->get_data( self::QUEUE_HANDLE, 'data' );
113
  if ( $data ) {
114
+ // WP 4.3+
115
+ // do not add script data if data was possibly previously added
116
+ if ( $registered ) {
117
+ $script = $data . "\n" . $script;
118
+ }
119
  }
120
  $wp_scripts->add_data( self::QUEUE_HANDLE, 'data', $script );
121
 
122
+ return $registered;
 
123
  }
124
 
125
  /**
129
  *
130
  * @uses wp_enqueue_script()
131
  *
132
+ * @return string async JavaScript loading snippet if script queue may not be supported. empty string if enqueued
133
  */
134
  public static function enqueue()
135
  {
137
  static::register();
138
  }
139
 
140
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
141
+ return static::asyncScriptLoaderInline();
142
+ }
143
+
144
  wp_enqueue_script( self::QUEUE_HANDLE );
 
145
 
146
+ return '';
 
 
 
 
 
 
 
 
 
 
 
147
  }
148
 
149
  /**
158
  // type = text/javascript to match default WP_Scripts output
159
  // async property to unlock page load, preload scanner discoverable in modern browsers
160
  // defer property for IE 9 and older
161
+ return '<script type="text/javascript" id="' . esc_attr( self::QUEUE_HANDLE ) . '" async defer src="' . esc_url( self::URI, array( 'http', 'https' ) ) . '" charset="utf-8"></script>' . "\n";
162
  }
163
 
164
  /**
215
  // empty out the src response to avoid extra <script>
216
  return '';
217
  }
218
+
219
+ /**
220
+ * Load Twitter widget JS using an inline script block
221
+ *
222
+ * Suitable for unknown render environments where a script block may not be included in a standard enqueue output such as the wp_print_footer_scripts action.
223
+ *
224
+ * @since 1.1.0
225
+ *
226
+ * @param bool $include_script_element_wrapper wrap the returned JavaScript string in a script element wrapper
227
+ *
228
+ * @return string HTML script element containing loader script
229
+ */
230
+ public static function asyncScriptLoaderInline( $include_script_element_wrapper = true ) {
231
+ $script = 'window.twttr=(function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],t=window.twttr||{};if(d.getElementById(id))return t;js=d.createElement(s);js.id=id;js.src=' . json_encode( self::URI ) . ';fjs.parentNode.insertBefore(js,fjs);t._e=[];t.ready=function(f){t._e.push(f);};return t;}(document,"script",' . json_encode( self::QUEUE_HANDLE ) . '));';
232
+
233
+ if ( $include_script_element_wrapper ) {
234
+ return '<script>' . $script . '</script>';
235
+ }
236
+ return $script;
237
+ }
238
  }
src/Twitter/WordPress/PluginLoader.php CHANGED
@@ -41,7 +41,7 @@ class PluginLoader
41
  *
42
  * @type string
43
  */
44
- const VERSION = '1.0.1';
45
 
46
  /**
47
  * Unique domain of the plugin's translated text
@@ -78,10 +78,12 @@ class PluginLoader
78
  add_action( 'init', array( __CLASS__, 'adminInit' ) );
79
  } else {
80
  // hooks to be executed on general execution of WordPress such as public pageviews
81
- static::registerShortcodeHandlers();
82
  add_action( 'init', array( __CLASS__, 'publicInit' ) );
83
  add_action( 'wp_head', array( __CLASS__, 'wpHead' ), 1, 0 );
84
  }
 
 
 
85
  }
86
 
87
  /**
41
  *
42
  * @type string
43
  */
44
+ const VERSION = '1.1.0';
45
 
46
  /**
47
  * Unique domain of the plugin's translated text
78
  add_action( 'init', array( __CLASS__, 'adminInit' ) );
79
  } else {
80
  // hooks to be executed on general execution of WordPress such as public pageviews
 
81
  add_action( 'init', array( __CLASS__, 'publicInit' ) );
82
  add_action( 'wp_head', array( __CLASS__, 'wpHead' ), 1, 0 );
83
  }
84
+
85
+ // shortcodes
86
+ static::registerShortcodeHandlers();
87
  }
88
 
89
  /**
src/Twitter/WordPress/Shortcodes/EmbeddedTweet.php CHANGED
@@ -101,14 +101,65 @@ class EmbeddedTweet
101
  // register our shortcode and its handler
102
  add_shortcode( self::SHORTCODE_TAG, array( __CLASS__, 'shortcodeHandler' ) );
103
 
104
- // unhook the WordPress Core oEmbed handler
105
- wp_oembed_remove_provider( static::OEMBED_CORE_REGEX );
106
- // pass a Tweet detail URL through the Tweet shortcode handler
107
- wp_embed_register_handler(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  self::SHORTCODE_TAG,
109
- static::TWEET_URL_REGEX,
110
- array( __CLASS__, 'linkHandler' ),
111
- 1
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  );
113
  }
114
 
@@ -273,8 +324,14 @@ class EmbeddedTweet
273
  return '';
274
  }
275
 
276
- \Twitter\WordPress\JavaScriptLoaders\Widgets::enqueue();
277
- return '<div class="twitter-tweet">' . $html . '</div>';
 
 
 
 
 
 
278
  }
279
 
280
  /**
101
  // register our shortcode and its handler
102
  add_shortcode( self::SHORTCODE_TAG, array( __CLASS__, 'shortcodeHandler' ) );
103
 
104
+ if ( is_admin() ) {
105
+ // Shortcake UI
106
+ if ( function_exists( 'shortcode_ui_register_for_shortcode' ) ) {
107
+ add_action(
108
+ 'admin_init',
109
+ array( __CLASS__, 'shortcodeUI' ),
110
+ 5,
111
+ 0
112
+ );
113
+ }
114
+ } else {
115
+ // unhook the WordPress Core oEmbed handler
116
+ wp_oembed_remove_provider( static::OEMBED_CORE_REGEX );
117
+ // pass a Tweet detail URL through the Tweet shortcode handler
118
+ wp_embed_register_handler(
119
+ self::SHORTCODE_TAG,
120
+ static::TWEET_URL_REGEX,
121
+ array( __CLASS__, 'linkHandler' ),
122
+ 1
123
+ );
124
+ }
125
+ }
126
+
127
+ /**
128
+ * Describe shortcode for Shortcake UI
129
+ *
130
+ * @since 1.1.0
131
+ *
132
+ * @link https://github.com/fusioneng/Shortcake Shortcake UI
133
+ *
134
+ * @return void
135
+ */
136
+ public static function shortcodeUI()
137
+ {
138
+ // Shortcake required
139
+ if ( ! function_exists( 'shortcode_ui_register_for_shortcode' ) ) {
140
+ return;
141
+ }
142
+
143
+ // id only
144
+ // avoids an unchecked Shortcake input checkbox requiring a shortcode output
145
+ shortcode_ui_register_for_shortcode(
146
  self::SHORTCODE_TAG,
147
+ array(
148
+ 'label' => __( 'Embedded Tweet', 'twitter' ),
149
+ 'listItemImage' => 'dashicons-twitter',
150
+ 'attrs' => array(
151
+ array(
152
+ 'attr' => 'id',
153
+ 'label' => 'ID',
154
+ 'type' => 'text',
155
+ 'meta' => array(
156
+ 'required' => true,
157
+ 'pattern' => '[0-9]+',
158
+ 'placeholder' => '560070183650213889',
159
+ ),
160
+ ),
161
+ ),
162
+ )
163
  );
164
  }
165
 
324
  return '';
325
  }
326
 
327
+ $html = '<div class="twitter-tweet">' . $html . '</div>';
328
+
329
+ $inline_js = \Twitter\WordPress\JavaScriptLoaders\Widgets::enqueue();
330
+ if ( $inline_js ) {
331
+ return $html . $inline_js;
332
+ }
333
+
334
+ return $html;
335
  }
336
 
337
  /**
src/Twitter/WordPress/Shortcodes/EmbeddedTweetVideo.php CHANGED
@@ -62,6 +62,55 @@ class EmbeddedTweetVideo extends EmbeddedTweet
62
  {
63
  // register our shortcode and its handler
64
  add_shortcode( self::SHORTCODE_TAG, array( __CLASS__, 'shortcodeHandler' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  }
66
 
67
  /**
@@ -152,8 +201,14 @@ class EmbeddedTweetVideo extends EmbeddedTweet
152
  return '';
153
  }
154
 
155
- \Twitter\WordPress\JavaScriptLoaders\Widgets::enqueue();
156
- return '<div class="twitter-video">' . $html . '</div>';
 
 
 
 
 
 
157
  }
158
 
159
  /**
62
  {
63
  // register our shortcode and its handler
64
  add_shortcode( self::SHORTCODE_TAG, array( __CLASS__, 'shortcodeHandler' ) );
65
+
66
+ // Shortcake UI
67
+ if ( function_exists( 'shortcode_ui_register_for_shortcode' ) ) {
68
+ add_action(
69
+ 'admin_init',
70
+ array( __CLASS__, 'shortcodeUI' ),
71
+ 5,
72
+ 0
73
+ );
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Describe shortcode for Shortcake UI
79
+ *
80
+ * @since 1.1.0
81
+ *
82
+ * @link https://github.com/fusioneng/Shortcake Shortcake UI
83
+ *
84
+ * @return void
85
+ */
86
+ public static function shortcodeUI()
87
+ {
88
+ // Shortcake required
89
+ if ( ! function_exists( 'shortcode_ui_register_for_shortcode' ) ) {
90
+ return;
91
+ }
92
+
93
+ // id only
94
+ // avoids an unchecked Shortcake input checkbox requiring a shortcode output
95
+ shortcode_ui_register_for_shortcode(
96
+ self::SHORTCODE_TAG,
97
+ array(
98
+ 'label' => __( 'Embedded Tweet Video', 'twitter' ),
99
+ 'listItemImage' => 'dashicons-twitter',
100
+ 'attrs' => array(
101
+ array(
102
+ 'attr' => 'id',
103
+ 'label' => 'ID',
104
+ 'type' => 'text',
105
+ 'meta' => array(
106
+ 'required' => true,
107
+ 'pattern' => '[0-9]+',
108
+ 'placeholder' => '560070183650213889',
109
+ ),
110
+ ),
111
+ ),
112
+ )
113
+ );
114
  }
115
 
116
  /**
201
  return '';
202
  }
203
 
204
+ $html = '<div class="twitter-video">' . $html . '</div>';
205
+
206
+ $inline_js = \Twitter\WordPress\JavaScriptLoaders\Widgets::enqueue();
207
+ if ( $inline_js ) {
208
+ return $html . $inline_js;
209
+ }
210
+
211
+ return $html;
212
  }
213
 
214
  /**
src/Twitter/WordPress/Shortcodes/Follow.php CHANGED
@@ -61,6 +61,62 @@ class Follow
61
  public static function init()
62
  {
63
  add_shortcode( static::SHORTCODE_TAG, array( __CLASS__, 'shortcodeHandler' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  }
65
 
66
  /**
@@ -187,7 +243,13 @@ class Follow
187
  return '';
188
  }
189
 
190
- \Twitter\WordPress\JavaScriptLoaders\Widgets::enqueue();
191
- return '<div class="twitter-follow">' . $html . '</div>';
 
 
 
 
 
 
192
  }
193
  }
61
  public static function init()
62
  {
63
  add_shortcode( static::SHORTCODE_TAG, array( __CLASS__, 'shortcodeHandler' ) );
64
+
65
+ // Shortcake UI
66
+ if ( function_exists( 'shortcode_ui_register_for_shortcode' ) ) {
67
+ add_action(
68
+ 'admin_init',
69
+ array( __CLASS__, 'shortcodeUI' ),
70
+ 5,
71
+ 0
72
+ );
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Describe shortcode for Shortcake UI
78
+ *
79
+ * @since 1.1.0
80
+ *
81
+ * @link https://github.com/fusioneng/Shortcake Shortcake UI
82
+ *
83
+ * @return void
84
+ */
85
+ public static function shortcodeUI()
86
+ {
87
+ // Shortcake required
88
+ if ( ! function_exists( 'shortcode_ui_register_for_shortcode' ) ) {
89
+ return;
90
+ }
91
+
92
+ shortcode_ui_register_for_shortcode(
93
+ static::SHORTCODE_TAG,
94
+ array(
95
+ 'label' => __( 'Follow Button', 'twitter' ),
96
+ 'listItemImage' => 'dashicons-twitter',
97
+ 'attrs' => array(
98
+ array(
99
+ 'attr' => 'screen_name',
100
+ 'label' => __( 'Twitter @username', 'twitter' ),
101
+ 'type' => 'text',
102
+ 'meta' => array(
103
+ 'placeholder' => 'WordPress',
104
+ 'pattern' => '[A-Za-z0-9_]{1,20}',
105
+ ),
106
+ ),
107
+ array(
108
+ 'attr' => 'size',
109
+ 'label' => __( 'Button size:', 'twitter' ),
110
+ 'type' => 'radio',
111
+ 'value' => 'medium',
112
+ 'options' => array(
113
+ '' => _x( 'medium', 'medium size button', 'twitter' ),
114
+ 'large' => _x( 'large', 'large size button', 'twitter' ),
115
+ ),
116
+ ),
117
+ ),
118
+ )
119
+ );
120
  }
121
 
122
  /**
243
  return '';
244
  }
245
 
246
+ $html = '<div class="twitter-follow">' . $html . '</div>';
247
+
248
+ $inline_js = \Twitter\WordPress\JavaScriptLoaders\Widgets::enqueue();
249
+ if ( $inline_js ) {
250
+ return $html . $inline_js;
251
+ }
252
+
253
+ return $html;
254
  }
255
  }
src/Twitter/WordPress/Shortcodes/Share.php CHANGED
@@ -61,6 +61,63 @@ class Share
61
  public static function init()
62
  {
63
  add_shortcode( static::SHORTCODE_TAG, array( __CLASS__, 'shortcodeHandler' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  }
65
 
66
  /**
@@ -374,7 +431,13 @@ class Share
374
  return '';
375
  }
376
 
377
- \Twitter\WordPress\JavaScriptLoaders\Widgets::enqueue();
378
- return '<div class="twitter-share">' . $html . '</div>';
 
 
 
 
 
 
379
  }
380
  }
61
  public static function init()
62
  {
63
  add_shortcode( static::SHORTCODE_TAG, array( __CLASS__, 'shortcodeHandler' ) );
64
+
65
+ // Shortcake UI
66
+ if ( function_exists( 'shortcode_ui_register_for_shortcode' ) ) {
67
+ add_action(
68
+ 'admin_init',
69
+ array( __CLASS__, 'shortcodeUI' ),
70
+ 5,
71
+ 0
72
+ );
73
+ }
74
+ }
75
+
76
+ /**
77
+ * Describe shortcode for Shortcake UI
78
+ *
79
+ * @since 1.1.0
80
+ *
81
+ * @link https://github.com/fusioneng/Shortcake Shortcake UI
82
+ *
83
+ * @return void
84
+ */
85
+ public static function shortcodeUI()
86
+ {
87
+ // Shortcake required
88
+ if ( ! function_exists( 'shortcode_ui_register_for_shortcode' ) ) {
89
+ return;
90
+ }
91
+
92
+ shortcode_ui_register_for_shortcode(
93
+ static::SHORTCODE_TAG,
94
+ array(
95
+ 'label' => __( 'Tweet Button', 'twitter' ),
96
+ 'listItemImage' => 'dashicons-twitter',
97
+ 'attrs' => array(
98
+ array(
99
+ 'attr' => 'text',
100
+ 'label' => _x( 'Text', 'Share / Tweet text', 'twitter' ),
101
+ 'type' => 'text',
102
+ ),
103
+ array(
104
+ 'attr' => 'url',
105
+ 'label' => 'URL',
106
+ 'type' => 'url',
107
+ ),
108
+ array(
109
+ 'attr' => 'size',
110
+ 'label' => __( 'Button size:', 'twitter' ),
111
+ 'type' => 'radio',
112
+ 'value' => 'medium',
113
+ 'options' => array(
114
+ '' => _x( 'medium', 'medium size button', 'twitter' ),
115
+ 'large' => _x( 'large', 'large size button', 'twitter' ),
116
+ ),
117
+ ),
118
+ ),
119
+ )
120
+ );
121
  }
122
 
123
  /**
431
  return '';
432
  }
433
 
434
+ $html = '<div class="twitter-share">' . $html . '</div>';
435
+
436
+ $inline_js = \Twitter\WordPress\JavaScriptLoaders\Widgets::enqueue();
437
+ if ( $inline_js ) {
438
+ return $html . $inline_js;
439
+ }
440
+
441
+ return $html;
442
  }
443
  }
src/Twitter/WordPress/Shortcodes/Tracking.php CHANGED
@@ -70,6 +70,52 @@ class Tracking
70
  public static function init()
71
  {
72
  add_shortcode( static::SHORTCODE_TAG, array( __CLASS__, 'shortcodeHandler' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  }
74
 
75
  /**
70
  public static function init()
71
  {
72
  add_shortcode( static::SHORTCODE_TAG, array( __CLASS__, 'shortcodeHandler' ) );
73
+
74
+ // Shortcake UI
75
+ if ( function_exists( 'shortcode_ui_register_for_shortcode' ) ) {
76
+ add_action(
77
+ 'admin_init',
78
+ array( __CLASS__, 'shortcodeUI' ),
79
+ 5,
80
+ 0
81
+ );
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Describe shortcode for Shortcake UI
87
+ *
88
+ * @since 1.1.0
89
+ *
90
+ * @link https://github.com/fusioneng/Shortcake Shortcake UI
91
+ *
92
+ * @return void
93
+ */
94
+ public static function shortcodeUI()
95
+ {
96
+ // Shortcake required
97
+ if ( ! function_exists( 'shortcode_ui_register_for_shortcode' ) ) {
98
+ return;
99
+ }
100
+
101
+ shortcode_ui_register_for_shortcode(
102
+ static::SHORTCODE_TAG,
103
+ array(
104
+ 'label' => __( 'Twitter Advertising Tracker', 'twitter' ),
105
+ 'listItemImage' => 'dashicons-twitter',
106
+ 'attrs' => array(
107
+ array(
108
+ 'attr' => 'id',
109
+ 'label' => 'ID',
110
+ 'description' => __( 'Twitter conversion or remarketing audience tracking identifier', 'twitter' ),
111
+ 'type' => 'text',
112
+ 'meta' => array(
113
+ 'required' => true,
114
+ ),
115
+ ),
116
+ ),
117
+ )
118
+ );
119
  }
120
 
121
  /**
twitter.php CHANGED
@@ -24,13 +24,13 @@ 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
24
  */
25
  /**
26
  * @package twitter
27
+ * @version 1.1.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.1.0
34
  Author: Twitter
35
  Author URI: https://dev.twitter.com/
36
  License: MIT