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/gallery.php +17 -11 12.0.3 → 16.3-a.1 View file →
@@ -7,9 +7,14 @@
7 7
8 8 // phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.
9 9
10 10 use Automattic\Jetpack\Assets;
11 +use Automattic\Jetpack\Image_CDN\Image_CDN_Core;
11 12
13 +if ( ! defined( 'ABSPATH' ) ) {
14 + exit( 0 );
15 +}
16 +
12 17 /**
13 18 * Jetpack_Gallery_Widget main class.
14 19 */
15 20 class Jetpack_Gallery_Widget extends WP_Widget {
@@ -72,12 +77,12 @@
72 77 $instance = wp_parse_args( (array) $instance, $this->defaults() );
73 78
74 79 $this->enqueue_frontend_scripts();
75 80
76 - $before_widget = isset( $args['before_widget'] ) ? $args['before_widget'] : '';
77 - $before_title = isset( $args['before_title'] ) ? $args['before_title'] : '';
78 - $after_title = isset( $args['after_title'] ) ? $args['after_title'] : '';
79 - $after_widget = isset( $args['after_widget'] ) ? $args['after_widget'] : '';
81 + $before_widget = $args['before_widget'] ?? '';
82 + $before_title = $args['before_title'] ?? '';
83 + $after_title = $args['after_title'] ?? '';
84 + $after_widget = $args['after_widget'] ?? '';
80 85
81 86 $instance['attachments'] = $this->get_attachments( $instance );
82 87
83 88 $classes = array();
@@ -106,10 +111,9 @@
106 111 // Create new carousel so we can use the enqueue_assets() method. Not ideal, but there is a decent amount
107 112 // of logic in that method that shouldn't be duplicated.
108 113 $carousel = new Jetpack_Carousel();
109 114
110 - // First parameter is $output, which comes from filters, and causes bypass of the asset enqueuing. Passing null is correct.
111 - $carousel->enqueue_assets( null );
115 + $carousel->enqueue_assets();
112 116 }
113 117 }
114 118
115 119 echo $before_widget . "\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@@ -279,9 +283,9 @@
279 283 $gallery = array();
280 284
281 285 foreach ( $instance['attachments'] as $attachment ) {
282 286 $attachment_image_src = wp_get_attachment_image_src( $attachment->ID, 'full' );
283 - $attachment_image_src = jetpack_photon_url( $attachment_image_src[0], array( 'w' => $this->instance_width ) ); /** [url, width, height] */
287 + $attachment_image_src = Image_CDN_Core::cdn_url( $attachment_image_src[0], array( 'w' => $this->instance_width ) ); /** [url, width, height] */
284 288
285 289 $caption = wptexturize( wp_strip_all_tags( $attachment->post_excerpt ) );
286 290
287 291 $gallery[] = (object) array(
@@ -297,11 +301,9 @@
297 301 if ( (int) $content_width > 0 ) {
298 302 $max_width = min( (int) $content_width, $max_width );
299 303 }
300 304
301 - $color = Jetpack_Options::get_option( 'slideshow_background_color', 'black' );
302 - $autostart = isset( $attr['autostart'] ) ? $attr['autostart'] : true; // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UndefinedVariable -- Todo: should read off the $instance? Also not sure if slideshow_widget() is used still.
303 -
305 + $color = Jetpack_Options::get_option( 'slideshow_background_color', 'black' );
304 306 $js_attr = array(
305 307 'gallery' => $gallery,
306 308 'selector' => $gallery_instance,
307 309 'width' => $max_width,
@@ -307,9 +309,9 @@
307 309 'width' => $max_width,
308 310 'height' => $max_height,
309 311 'trans' => 'fade',
310 312 'color' => $color,
311 - 'autostart' => $autostart,
313 + 'autostart' => true,
312 314 );
313 315
314 316 $html = $slideshow->slideshow_js( $js_attr );
315 317
@@ -329,9 +331,13 @@
329 331
330 332 /**
331 333 * Outputs the widget settings form.
332 334 *
335 + * @html-template-var array $instance
336 + * @html-template-var array<string,array<string|int,string|int>> $allowed_values
337 + *
333 338 * @param array $instance Current settings.
339 + * @return string|void
334 340 */
335 341 public function form( $instance ) {
336 342 $defaults = $this->defaults();
337 343 $allowed_values = $this->allowed_values(); // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable -- Used in included form template.