PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 All 504 releases
← All changes | modules/widgets/twitter-timeline.php +17 -8 13.2.416.3-a.1 View file →
@@ -15,8 +15,12 @@
15 15
16 16 use Automattic\Jetpack\Assets;
17 17 use Automattic\Jetpack\Redirect;
18 18
19 +if ( ! defined( 'ABSPATH' ) ) {
20 + exit( 0 );
21 +}
22 +
19 23 /**
20 24 * Register the widget for use in Appearance -> Widgets
21 25 */
22 26 function jetpack_twitter_timeline_widget_init() {
@@ -42,9 +46,9 @@
42 46 'customize_selective_refresh' => true,
43 47 )
44 48 );
45 49
46 - if ( is_active_widget( false, false, $this->id_base ) || is_active_widget( false, false, 'monster' ) || is_customize_preview() ) {
50 + if ( is_customize_preview() ) {
47 51 add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
48 52 }
49 53
50 54 add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
@@ -104,9 +108,11 @@
104 108 $output = '';
105 109
106 110 // Twitter deprecated `data-widget-id` on 2018-05-25,
107 111 // with cease support deadline on 2018-07-27.
108 - if ( isset( $instance['type'] ) && 'widget-id' === $instance['type'] ) {
112 + $explicit_widget_id = isset( $instance['type'] ) && 'widget-id' === $instance['type'];
113 + $implicit_widget_id = empty( $instance['type'] ) && ! empty( $instance['widget-id'] ) && is_numeric( $instance['widget-id'] );
114 + if ( $explicit_widget_id || $implicit_widget_id ) {
109 115 if ( current_user_can( 'edit_theme_options' ) ) {
110 116 $output .= $args['before_widget']
111 117 . $args['before_title'] . esc_html__( 'Twitter Timeline', 'jetpack' ) . $args['after_title']
112 118 . '<p>' . esc_html__( "The Twitter Timeline widget can't display tweets based on searches or hashtags. To display a simple list of tweets instead, change the Widget ID to a Twitter username. Otherwise, delete this widget.", 'jetpack' ) . '</p>'
@@ -117,13 +123,15 @@
117 123 echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
118 124 return;
119 125 }
120 126
127 + $this->enqueue_scripts();
128 +
121 129 $instance['lang'] = substr( strtoupper( get_locale() ), 0, 2 );
122 130
123 131 $output .= $args['before_widget'];
124 132
125 - $title = isset( $instance['title'] ) ? $instance['title'] : '';
133 + $title = $instance['title'] ?? '';
126 134
127 135 /** This filter is documented in core/src/wp-includes/default-widgets.php */
128 136 $title = apply_filters( 'widget_title', $title );
129 137 if ( ! empty( $title ) ) {
@@ -183,15 +191,15 @@
183 191 * @param string $timeline_placeholder Timeline placeholder text.
184 192 */
185 193 $timeline_placeholder = apply_filters( 'jetpack_twitter_timeline_placeholder', $timeline_placeholder );
186 194
187 - $type = ( isset( $instance['type'] ) ? $instance['type'] : '' );
188 - $widget_id = ( isset( $instance['widget-id'] ) ? $instance['widget-id'] : '' );
195 + $type = ( $instance['type'] ?? '' );
196 + $widget_id = ( $instance['widget-id'] ?? '' );
189 197
190 198 if ( class_exists( 'Jetpack_AMP_Support' ) && Jetpack_AMP_Support::is_amp_request() ) {
191 199 $width = ! empty( $instance['width'] ) ? $instance['width'] : 600;
192 200 $height = ! empty( $instance['height'] ) ? $instance['height'] : 480;
193 - $output .= '<amp-twitter' . $data_attrs . ' layout="responsive" data-timeline-source-type="profile" data-timeline-screen-name="' . esc_attr( $widget_id ) . '" width="' . absint( $width ) . '" height="' . absint( $height ) . '">'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
201 + $output .= '<amp-twitter' . $data_attrs . ' layout="responsive" data-timeline-source-type="profile" data-timeline-screen-name="' . esc_attr( $widget_id ) . '" width="' . absint( $width ) . '" height="' . absint( $height ) . '">';
194 202 $output .= esc_html( $timeline_placeholder ) . '</amp-twitter>';
195 203
196 204 echo $output . $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
197 205 return;
@@ -199,9 +207,9 @@
199 207
200 208 // Start tag output
201 209 // This tag is transformed into the widget markup by Twitter's
202 210 // widgets.js code.
203 - $output .= '<a class="twitter-timeline"' . $data_attrs; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
211 + $output .= '<a class="twitter-timeline"' . $data_attrs;
204 212 switch ( $type ) {
205 213 case 'profile':
206 214 $output .= ' href="https://twitter.com/' . esc_attr( $widget_id ) . '"';
207 215 break;
@@ -248,9 +256,9 @@
248 256 // Set default width value to minimum.
249 257 $instance['width'] = 220;
250 258 }
251 259
252 - $tweet_display = sanitize_text_field( $new_instance['tweet-display'] );
260 + $tweet_display = sanitize_text_field( $new_instance['tweet-display'] ?? 'dynamic' );
253 261 $instance['tweet-display'] = $tweet_display;
254 262 /**
255 263 * A timeline with a specified limit is expanded to the height of those Tweets.
256 264 * The specified height value no longer applies, so reject the height value
@@ -352,8 +360,9 @@
352 360 *
353 361 * @see WP_Widget::form()
354 362 *
355 363 * @param array $instance Previously saved values from database.
364 + * @return string|void
356 365 */
357 366 public function form( $instance ) {
358 367 $defaults = array(
359 368 'title' => esc_html__( 'Follow me on Twitter', 'jetpack' ),