| @@ -4,8 +4,12 @@ | ||
| 4 | 4 | * |
| 5 | 5 | * @package automattic/jetpack |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 9 | + exit( 0 ); | |
| 10 | +} | |
| 11 | + | |
| 8 | 12 | // phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files. |
| 9 | 13 | |
| 10 | 14 | /** |
| 11 | 15 | * Register the widget. |
| @@ -44,12 +48,12 @@ | ||
| 44 | 48 | */ |
| 45 | 49 | public function widget( $args, $instance ) { |
| 46 | 50 | $instance = wp_parse_args( (array) $instance, $this->defaults() ); |
| 47 | 51 | |
| 48 | - $before_widget = isset( $args['before_widget'] ) ? $args['before_widget'] : ''; | |
| 49 | - $before_title = isset( $args['before_title'] ) ? $args['before_title'] : ''; | |
| 50 | - $after_title = isset( $args['after_title'] ) ? $args['after_title'] : ''; | |
| 51 | - $after_widget = isset( $args['after_widget'] ) ? $args['after_widget'] : ''; | |
| 52 | + $before_widget = $args['before_widget'] ?? ''; | |
| 53 | + $before_title = $args['before_title'] ?? ''; | |
| 54 | + $after_title = $args['after_title'] ?? ''; | |
| 55 | + $after_widget = $args['after_widget'] ?? ''; | |
| 52 | 56 | |
| 53 | 57 | /** This filter is documented in core/src/wp-includes/default-widgets.php */ |
| 54 | 58 | $title = apply_filters( 'widget_title', $instance['title'] ); |
| 55 | 59 | echo $before_widget; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| @@ -104,9 +108,9 @@ | ||
| 104 | 108 | * @param array $old_instance Previously saved values from database. |
| 105 | 109 | * |
| 106 | 110 | * @return array Updated safe values to be saved. |
| 107 | 111 | */ |
| 108 | - public function update( $new_instance, $old_instance ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable | |
| 112 | + public function update( $new_instance, $old_instance ) { | |
| 109 | 113 | $instance = $old_instance; |
| 110 | 114 | |
| 111 | 115 | $instance['title'] = wp_filter_nohtml_kses( $new_instance['title'] ); |
| 112 | 116 | $instance['display'] = $new_instance['display']; |
| @@ -131,10 +135,10 @@ | ||
| 131 | 135 | |
| 132 | 136 | $title = stripslashes( $instance['title'] ); |
| 133 | 137 | $display = $instance['display']; |
| 134 | 138 | $format = $instance['format']; |
| 135 | - $image_size = isset( $instance['imagesize'] ) ? $instance['imagesize'] : 0; | |
| 136 | - $image_color = isset( $instance['imagecolor'] ) ? $instance['imagecolor'] : 'red'; | |
| 139 | + $image_size = $instance['imagesize'] ?? 0; | |
| 140 | + $image_color = $instance['imagecolor'] ?? 'red'; | |
| 137 | 141 | |
| 138 | 142 | echo '<p><label for="' . esc_attr( $this->get_field_id( 'title' ) ) . '">' . esc_html__( 'Title:', 'jetpack' ) . ' |
| 139 | 143 | <input class="widefat" id="' . esc_attr( $this->get_field_id( 'title' ) ) . '" name="' . esc_attr( $this->get_field_name( 'title' ) ) . '" type="text" value="' . esc_attr( $title ) . '" /> |
| 140 | 144 | </label></p>'; |
| @@ -160,9 +164,9 @@ | ||
| 160 | 164 | 'image' => __( 'Image Link', 'jetpack' ), |
| 161 | 165 | 'text-image' => __( 'Text & Image Links', 'jetpack' ), |
| 162 | 166 | ); |
| 163 | 167 | echo '<p><label for="' . esc_attr( $this->get_field_id( 'format' ) ) . '">' . esc_html_x( 'Format:', 'Noun', 'jetpack' ) . ' |
| 164 | - <select class="widefat" id="' . esc_attr( $this->get_field_id( 'format' ) ) . '" name="' . esc_attr( $this->get_field_name( 'format' ) ) . '" onchange="if ( this.value == \'text\' ) jQuery( \'#' . esc_js( $this->get_field_id( 'image-settings' ) ) . '\' ).fadeOut(); else jQuery( \'#' . esc_js( $this->get_field_id( 'image-settings' ) ) . '\' ).fadeIn();">'; | |
| 168 | + <select class="widefat" id="' . esc_attr( $this->get_field_id( 'format' ) ) . '" name="' . esc_attr( $this->get_field_name( 'format' ) ) . '" onchange="if ( this.value == \'text\' ) jQuery( ' . esc_attr( wp_json_encode( '#' . $this->get_field_id( 'image-settings' ), JSON_UNESCAPED_SLASHES | JSON_HEX_AMP ) ) . ' ).fadeOut(); else jQuery( ' . esc_attr( wp_json_encode( '#' . $this->get_field_id( 'image-settings' ), JSON_UNESCAPED_SLASHES | JSON_HEX_AMP ) ) . ' ).fadeIn();">'; | |
| 165 | 169 | foreach ( $formats as $format_option => $label ) { |
| 166 | 170 | echo '<option value="' . esc_attr( $format_option ) . '"'; |
| 167 | 171 | if ( $format_option === $format ) { |
| 168 | 172 | echo ' selected="selected"'; |
| @@ -265,10 +269,10 @@ | ||
| 265 | 269 | } |
| 266 | 270 | |
| 267 | 271 | printf( |
| 268 | 272 | '%1$s<a target="%3$s" href="%4$s" title="%5$s">%6$s</a>%2$s', |
| 269 | - 'text' === $format ? '<li>' : '<p>', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 270 | - 'text' === $format ? '</li>' : '</p>', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 273 | + 'text' === $format ? '<li>' : '<p>', | |
| 274 | + 'text' === $format ? '</li>' : '</p>', | |
| 271 | 275 | esc_attr( $link_target ), |
| 272 | 276 | esc_url( get_bloginfo( $rss_type ) ), |
| 273 | 277 | esc_attr( $subscribe_to ), |
| 274 | 278 | $link_contents // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- we are escaping this above. |