| @@ -41,12 +41,12 @@ | ||
| 41 | 41 | * 'title' => 'hello world' |
| 42 | 42 | * ) |
| 43 | 43 | * ) |
| 44 | 44 | * |
| 45 | - * @param string|integer $position The position of the widget in its sidebar. | |
| 46 | - * @param string $widget_id The widget's id (eg: 'text-3'). | |
| 47 | - * @param string $sidebar The widget's sidebar id (eg: 'sidebar-1'). | |
| 48 | - * @param array (Optional) $settings The settings for the widget. | |
| 45 | + * @param string|integer $position The position of the widget in its sidebar. | |
| 46 | + * @param string $widget_id The widget's id (eg: 'text-3'). | |
| 47 | + * @param string $sidebar The widget's sidebar id (eg: 'sidebar-1'). | |
| 48 | + * @param array|null $settings The settings for the widget. | |
| 49 | 49 | * |
| 50 | 50 | * @return array A normalized array representing this widget. |
| 51 | 51 | */ |
| 52 | 52 | public static function format_widget( $position, $widget_id, $sidebar, $settings = null ) { |
| @@ -361,9 +361,9 @@ | ||
| 361 | 361 | } |
| 362 | 362 | $last_position = 0; |
| 363 | 363 | foreach ( $widgets as $widget_id ) { |
| 364 | 364 | $widget = self::get_widget_by_id( $widget_id ); |
| 365 | - if ( (int) $widget['position'] > (int) $last_position ) { | |
| 365 | + if ( (int) $widget['position'] > $last_position ) { | |
| 366 | 366 | $last_position = (int) $widget['position']; |
| 367 | 367 | } |
| 368 | 368 | } |
| 369 | 369 | return $last_position; |
| @@ -382,9 +382,9 @@ | ||
| 382 | 382 | public static function set_widget_settings( $widget_id, $settings ) { |
| 383 | 383 | $widget_option_name = self::get_widget_option_name( $widget_id ); |
| 384 | 384 | $widget_settings = get_option( $widget_option_name ); |
| 385 | 385 | $instance_key = self::get_widget_instance_key( $widget_id ); |
| 386 | - $old_settings = $widget_settings[ $instance_key ]; | |
| 386 | + $old_settings = $widget_settings[ $instance_key ] ?? array(); | |
| 387 | 387 | $settings = self::sanitize_widget_settings( $widget_id, $settings, $old_settings ); |
| 388 | 388 | |
| 389 | 389 | if ( ! $settings ) { |
| 390 | 390 | return new WP_Error( 'invalid_data', 'Update failed.', 500 ); |
| @@ -575,9 +575,9 @@ | ||
| 575 | 575 | wp_get_current_user(), |
| 576 | 576 | 'wpcom_widgets_activate_widget', |
| 577 | 577 | array( |
| 578 | 578 | 'widget' => $id_base, |
| 579 | - 'settings' => wp_json_encode( $settings ), | |
| 579 | + 'settings' => wp_json_encode( $settings, JSON_UNESCAPED_SLASHES ), | |
| 580 | 580 | ) |
| 581 | 581 | ); |
| 582 | 582 | } |
| 583 | 583 | |