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/wordpress-post-widget/class.jetpack-display-posts-widget-base.php +19 -13 12.0.3 → 16.3-a.1 View file →
@@ -1,6 +1,12 @@
1 1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 2
3 +use Automattic\Jetpack\Image_CDN\Image_CDN_Core;
4 +
5 +if ( ! defined( 'ABSPATH' ) ) {
6 + exit( 0 );
7 +}
8 +
3 9 /**
4 10 * For back-compat, the final widget class must be named
5 11 * Jetpack_Display_Posts_Widget.
6 12 *
@@ -103,9 +109,9 @@
103 109 if ( empty( $instance['url'] ) ) {
104 110 if ( current_user_can( 'manage_options' ) ) {
105 111 $content .= '<p>';
106 112 /* Translators: the "Blog URL" field mentioned is the input field labeled as such in the widget form. */
107 - $content .= esc_html__( 'The Blog URL is not properly setup in the widget.', 'jetpack' );
113 + $content .= esc_html__( 'The Blog URL is not properly set up in the widget.', 'jetpack' );
108 114 $content .= '</p>';
109 115 }
110 116 $content .= $args['after_widget'];
111 117
@@ -127,9 +133,9 @@
127 133
128 134 if ( ! empty( $instance['title'] ) ) {
129 135 /** This filter is documented in core/src/wp-includes/default-widgets.php */
130 136 $instance['title'] = apply_filters( 'widget_title', $instance['title'] );
131 - $content .= $args['before_title'] . $instance['title'] . ': ' . $site_info->name . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
137 + $content .= $args['before_title'] . $instance['title'] . ': ' . esc_html( $site_info->name ) . $args['after_title'];
132 138 } else {
133 139 $content .= $args['before_title'] . esc_html( $site_info->name ) . $args['after_title'];
134 140 }
135 141
@@ -149,9 +155,9 @@
149 155 /**
150 156 * Show only as much posts as we need. If we have less than configured amount,
151 157 * we must show only that much posts.
152 158 */
153 - $number_of_posts = min( $instance['number_of_posts'], count( $posts_list ) );
159 + $number_of_posts = min( $instance['number_of_posts'], is_countable( $posts_list ) ? count( $posts_list ) : 0 );
154 160
155 161 for ( $i = 0; $i < $number_of_posts; $i++ ) {
156 162 $single_post = $posts_list[ $i ];
157 163 $post_title = ( $single_post['title'] ) ? $single_post['title'] : '( No Title )';
@@ -174,13 +180,13 @@
174 180 *
175 181 * @param array $args Array of Photon Parameters.
176 182 */
177 183 $image_params = apply_filters( 'jetpack_display_posts_widget_image_params', array() );
178 - $content .= '<a title="' . esc_attr( $post_title ) . '" href="' . esc_url( $single_post['url'] ) . '"' . $target . '><img src="' . jetpack_photon_url( $featured_image, $image_params ) . '" alt="' . esc_attr( $post_title ) . '"/></a>';
184 + $content .= '<a title="' . esc_attr( $post_title ) . '" href="' . esc_url( $single_post['url'] ) . '"' . $target . '><img src="' . esc_url( Image_CDN_Core::cdn_url( $featured_image, $image_params ) ) . '" alt="' . esc_attr( $post_title ) . '"/></a>';
179 185 }
180 186
181 187 if ( true === $instance['show_excerpts'] ) {
182 - $content .= $single_post['excerpt'];
188 + $content .= wp_kses_post( $single_post['excerpt'] );
183 189 }
184 190 }
185 191
186 192 $content .= '</div><!-- .jetpack-display-remote-posts -->';
@@ -209,14 +215,14 @@
209 215
210 216 /**
211 217 * Initialize widget configuration variables.
212 218 */
213 - $title = ( isset( $instance['title'] ) ) ? $instance['title'] : __( 'Recent Posts', 'jetpack' );
214 - $url = ( isset( $instance['url'] ) ) ? $instance['url'] : '';
215 - $number_of_posts = ( isset( $instance['number_of_posts'] ) ) ? $instance['number_of_posts'] : 5;
216 - $open_in_new_window = ( isset( $instance['open_in_new_window'] ) ) ? $instance['open_in_new_window'] : false;
217 - $featured_image = ( isset( $instance['featured_image'] ) ) ? $instance['featured_image'] : false;
218 - $show_excerpts = ( isset( $instance['show_excerpts'] ) ) ? $instance['show_excerpts'] : false;
219 + $title = $instance['title'] ?? __( 'Recent Posts', 'jetpack' );
220 + $url = $instance['url'] ?? '';
221 + $number_of_posts = $instance['number_of_posts'] ?? 5;
222 + $open_in_new_window = $instance['open_in_new_window'] ?? false;
223 + $featured_image = $instance['featured_image'] ?? false;
224 + $show_excerpts = $instance['show_excerpts'] ?? false;
219 225
220 226 /**
221 227 * Check if the widget instance has errors available.
222 228 *
@@ -352,9 +358,9 @@
352 358 */
353 359 if ( ! empty( $instance['url'] ) ) {
354 360 $blog_data = $this->fetch_blog_data( $instance['url'], array(), true );
355 361
356 - if ( is_wp_error( $blog_data['site_info']['error'] ) && 'www.' === substr( $instance['url'], 0, 4 ) ) {
362 + if ( is_wp_error( $blog_data['site_info']['error'] ) && str_starts_with( $instance['url'], 'www.' ) ) {
357 363 $blog_data = $this->fetch_blog_data( substr( $instance['url'], 4 ), array(), true );
358 364
359 365 if ( ! is_wp_error( $blog_data['site_info']['error'] ) ) {
360 366 $instance['url'] = substr( $instance['url'], 4 );
@@ -668,9 +674,9 @@
668 674
669 675 /**
670 676 * If no optional data is supplied, initialize a new structure
671 677 */
672 - if ( ! empty( $original_data ) ) {
678 + if ( ! empty( $original_data ) && is_array( $original_data ) ) {
673 679 $widget_data = $original_data;
674 680 } else {
675 681 $widget_data = array(
676 682 'site_info' => array(