diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-includes/class-wp-widget.php --- a/wp/wp-includes/class-wp-widget.php Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-includes/class-wp-widget.php Fri Sep 05 18:40:08 2025 +0200 @@ -17,6 +17,7 @@ * @since 2.8.0 * @since 4.4.0 Moved to its own file from wp-includes/widgets.php */ +#[AllowDynamicProperties] class WP_Widget { /** @@ -151,7 +152,7 @@ * * @since 2.8.0 * - * @param string $id_base Optional. Base ID for the widget, lowercase and unique. If left empty, + * @param string $id_base Base ID for the widget, lowercase and unique. If left empty, * a portion of the widget's PHP class name will be used. Has to be unique. * @param string $name Name for the widget displayed on the configuration page. * @param array $widget_options Optional. Widget options. See wp_register_sidebar_widget() for @@ -187,7 +188,7 @@ * * @see WP_Widget::__construct() * - * @param string $id_base Optional. Base ID for the widget, lowercase and unique. If left empty, + * @param string $id_base Base ID for the widget, lowercase and unique. If left empty, * a portion of the widget's PHP class name will be used. Has to be unique. * @param string $name Name for the widget displayed on the configuration page. * @param array $widget_options Optional. Widget options. See wp_register_sidebar_widget() for @@ -428,14 +429,14 @@ if ( isset( $wp_registered_widgets[ $del_id ]['params'][0]['number'] ) ) { $number = $wp_registered_widgets[ $del_id ]['params'][0]['number']; - if ( $this->id_base . '-' . $number == $del_id ) { + if ( $this->id_base . '-' . $number === $del_id ) { unset( $all_instances[ $number ] ); } } } else { if ( isset( $_POST[ 'widget-' . $this->id_base ] ) && is_array( $_POST[ 'widget-' . $this->id_base ] ) ) { $settings = $_POST[ 'widget-' . $this->id_base ]; - } elseif ( isset( $_POST['id_base'] ) && $_POST['id_base'] == $this->id_base ) { + } elseif ( isset( $_POST['id_base'] ) && $_POST['id_base'] === $this->id_base ) { $num = $_POST['multi_number'] ? (int) $_POST['multi_number'] : (int) $_POST['widget_number']; $settings = array( $num => array() ); } else { @@ -507,7 +508,7 @@ $widget_args = wp_parse_args( $widget_args, array( 'number' => -1 ) ); $all_instances = $this->get_settings(); - if ( -1 == $widget_args['number'] ) { + if ( -1 === $widget_args['number'] ) { // We echo out a form where 'number' can be set later. $this->_set( '__i__' ); $instance = array(); @@ -612,12 +613,16 @@ $settings = get_option( $this->option_name ); if ( false === $settings ) { + $settings = array(); if ( isset( $this->alt_option_name ) ) { - $settings = get_option( $this->alt_option_name ); - } else { - // Save an option so it can be autoloaded next time. - $this->save_settings( array() ); + // Get settings from alternative (legacy) option. + $settings = get_option( $this->alt_option_name, array() ); + + // Delete the alternative (legacy) option as the new option will be created using `$this->option_name`. + delete_option( $this->alt_option_name ); } + // Save an option so it can be autoloaded next time. + $this->save_settings( $settings ); } if ( ! is_array( $settings ) && ! ( $settings instanceof ArrayObject || $settings instanceof ArrayIterator ) ) {