PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 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 All 507 releases
← All changes | modules/widgets/image-widget.php +17 -13 13.2.4 → 16.3-beta View file →
@@ -5,8 +5,12 @@
5 5 * Sort Order: 20
6 6 * First Introduced: 1.2
7 7 */
8 8
9 +if ( ! defined( 'ABSPATH' ) ) {
10 + exit( 0 );
11 +}
12 +
9 13 // phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.
10 14
11 15 add_action( 'widgets_init', 'jetpack_image_widget_init', 11 );
12 16 /**
@@ -36,12 +40,8 @@
36 40 'description' => __( 'Display an image in your sidebar', 'jetpack' ),
37 41 'customize_selective_refresh' => true,
38 42 )
39 43 );
40 -
41 - if ( is_active_widget( false, false, $this->id_base ) || is_active_widget( false, false, 'monster' ) || is_customize_preview() ) {
42 - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ) );
43 - }
44 44 }
45 45
46 46 /**
47 47 * Loads file for front-end widget style.
@@ -78,8 +78,11 @@
78 78 }
79 79
80 80 if ( $instance['img_url'] ) {
81 81
82 + // Enqueue front end assets.
83 + $this->enqueue_style();
84 +
82 85 $output = '<img src="' . esc_url( $instance['img_url'] ) . '" ';
83 86
84 87 if ( '' !== (string) $instance['alt_text'] ) {
85 88 $output .= 'alt="' . esc_attr( $instance['alt_text'] ) . '" ';
@@ -161,19 +164,19 @@
161 164 );
162 165
163 166 $instance = $old_instance;
164 167
165 - $instance['title'] = wp_strip_all_tags( $new_instance['title'] );
166 - $instance['img_url'] = esc_url( trim( $new_instance['img_url'] ) );
167 - $instance['alt_text'] = wp_strip_all_tags( $new_instance['alt_text'] );
168 - $instance['img_title'] = wp_strip_all_tags( $new_instance['img_title'] );
169 - $instance['caption'] = wp_kses( stripslashes( $new_instance['caption'] ), $allowed_caption_html );
170 - $instance['align'] = $new_instance['align'];
171 - $instance['link'] = esc_url( trim( $new_instance['link'] ) );
168 + $instance['title'] = wp_strip_all_tags( $new_instance['title'] ?? '' );
169 + $instance['img_url'] = esc_url( trim( $new_instance['img_url'] ?? '' ) );
170 + $instance['alt_text'] = wp_strip_all_tags( $new_instance['alt_text'] ?? '' );
171 + $instance['img_title'] = wp_strip_all_tags( $new_instance['img_title'] ?? '' );
172 + $instance['caption'] = wp_kses( stripslashes( $new_instance['caption'] ?? '' ), $allowed_caption_html );
173 + $instance['align'] = $new_instance['align'] ?? 'none';
174 + $instance['link'] = esc_url( trim( $new_instance['link'] ?? '' ) );
172 175 $instance['link_target_blank'] = isset( $new_instance['link_target_blank'] ) ? (bool) $new_instance['link_target_blank'] : false;
173 176
174 - $new_img_width = absint( $new_instance['img_width'] );
175 - $new_img_height = absint( $new_instance['img_height'] );
177 + $new_img_width = absint( $new_instance['img_width'] ?? 0 );
178 + $new_img_height = absint( $new_instance['img_height'] ?? 0 );
176 179
177 180 if ( ! empty( $instance['img_url'] ) && 0 === $new_img_width && 0 === $new_img_height ) {
178 181 // Download the url to a local temp file and then process it with getimagesize so we can optimize browser layout.
179 182 $tmp_file = download_url( $instance['img_url'], 10 );
@@ -204,8 +207,9 @@
204 207 *
205 208 * @see WP_Widget::form()
206 209 *
207 210 * @param array $instance Previously saved values from database.
211 + * @return string|void
208 212 */
209 213 public function form( $instance ) {
210 214 // Defaults.
211 215 $instance = wp_parse_args(