X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/d3947bc013df7edd54b46deed8230d2eeafc5ecb..e3ff8f35458a959c1879c0a4976701ed8dcfe651:/wp-includes/class-wp-customize-widgets.php diff --git a/wp-includes/class-wp-customize-widgets.php b/wp-includes/class-wp-customize-widgets.php index 0a739531..4be73e4d 100644 --- a/wp-includes/class-wp-customize-widgets.php +++ b/wp-includes/class-wp-customize-widgets.php @@ -93,16 +93,18 @@ final class WP_Customize_Widgets { public function __construct( $manager ) { $this->manager = $manager; - // Skip useless hooks when the user can't manage widgets anyway. + // See https://github.com/xwp/wp-customize-snapshots/blob/962586659688a5b1fd9ae93618b7ce2d4e7a421c/php/class-customize-snapshot-manager.php#L420-L449 + add_filter( 'customize_dynamic_setting_args', array( $this, 'filter_customize_dynamic_setting_args' ), 10, 2 ); + add_action( 'widgets_init', array( $this, 'register_settings' ), 95 ); + add_action( 'customize_register', array( $this, 'schedule_customize_register' ), 1 ); + + // Skip remaining hooks when the user can't manage widgets anyway. if ( ! current_user_can( 'edit_theme_options' ) ) { return; } - add_filter( 'customize_dynamic_setting_args', array( $this, 'filter_customize_dynamic_setting_args' ), 10, 2 ); - add_action( 'widgets_init', array( $this, 'register_settings' ), 95 ); add_action( 'wp_loaded', array( $this, 'override_sidebars_widgets_for_theme_switch' ) ); add_action( 'customize_controls_init', array( $this, 'customize_controls_init' ) ); - add_action( 'customize_register', array( $this, 'schedule_customize_register' ), 1 ); add_action( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); add_action( 'customize_controls_print_styles', array( $this, 'print_styles' ) ); add_action( 'customize_controls_print_scripts', array( $this, 'print_scripts' ) ); @@ -276,6 +278,7 @@ final class WP_Customize_Widgets { $this->old_sidebars_widgets = wp_get_sidebars_widgets(); add_filter( 'customize_value_old_sidebars_widgets_data', array( $this, 'filter_customize_value_old_sidebars_widgets_data' ) ); + $this->manager->set_post_value( 'old_sidebars_widgets_data', $this->old_sidebars_widgets ); // Override any value cached in changeset. // retrieve_widgets() looks at the global $sidebars_widgets $sidebars_widgets = $this->old_sidebars_widgets; @@ -349,7 +352,7 @@ final class WP_Customize_Widgets { /** * Ensures widgets are available for all types of previews. * - * When in preview, hook to 'customize_register' for settings after WordPress is loaded + * When in preview, hook to {@see 'customize_register'} for settings after WordPress is loaded * so that all filters have been initialized (e.g. Widget Visibility). * * @since 3.9.0 @@ -455,7 +458,7 @@ final class WP_Customize_Widgets { ); /** - * Filter Customizer widget section arguments for a given sidebar. + * Filters Customizer widget section arguments for a given sidebar. * * @since 3.9.0 * @@ -556,7 +559,7 @@ final class WP_Customize_Widgets { * have widths of 400 and yet they still render fine in the Customizer panel. * * This method will return all Core widgets as being not wide, but this can be - * overridden with the is_wide_widget_in_customizer filter. + * overridden with the {@see 'is_wide_widget_in_customizer'} filter. * * @since 3.9.0 * @access public @@ -575,7 +578,7 @@ final class WP_Customize_Widgets { $is_wide = ( $width > 250 && ! $is_core ); /** - * Filter whether the given widget is considered "wide". + * Filters whether the given widget is considered "wide". * * @since 3.9.0 * @@ -712,7 +715,7 @@ final class WP_Customize_Widgets { <% }); %>
- +
' ); @@ -729,11 +732,12 @@ final class WP_Customize_Widgets { 'error' => __( 'An error has occurred. Please reload the page and try again.' ), 'widgetMovedUp' => __( 'Widget moved up' ), 'widgetMovedDown' => __( 'Widget moved down' ), - 'noAreasRendered' => __( 'There are no widget areas currently rendered in the preview. Navigate in the preview to a template that makes use of a widget area in order to access its widgets here.' ), + 'noAreasRendered' => __( 'There are no widget areas on the page shown, however other pages in this theme do have them.' ), 'reorderModeOn' => __( 'Reorder mode enabled' ), 'reorderModeOff' => __( 'Reorder mode closed' ), 'reorderLabelOn' => esc_attr__( 'Reorder widgets' ), - 'reorderLabelOff' => esc_attr__( 'Close reorder mode' ), + 'widgetsFound' => __( 'Number of widgets found: %d' ), + 'noWidgetsFound' => __( 'No widgets found.' ), ), 'tpl' => array( 'widgetReorderNav' => $widget_reorder_nav_tpl, @@ -777,7 +781,10 @@ final class WP_Customize_Widgets {
- + + + +

get_available_widgets() as $available_widget ): ?> @@ -785,6 +792,7 @@ final class WP_Customize_Widgets {
+

@@ -799,6 +807,9 @@ final class WP_Customize_Widgets { * @access public */ public function print_footer_scripts() { + /** This action is documented in wp-admin/admin-footer.php */ + do_action( 'admin_print_footer_scripts-widgets.php' ); + /** This action is documented in wp-admin/admin-footer.php */ do_action( 'admin_print_footer_scripts' ); @@ -836,7 +847,7 @@ final class WP_Customize_Widgets { $args = array_merge( $args, $overrides ); /** - * Filter the common arguments supplied when constructing a Customizer setting. + * Filters the common arguments supplied when constructing a Customizer setting. * * @since 3.9.0 * @@ -1061,7 +1072,7 @@ final class WP_Customize_Widgets { * @return array */ public function preview_sidebars_widgets( $sidebars_widgets ) { - $sidebars_widgets = get_option( 'sidebars_widgets' ); + $sidebars_widgets = get_option( 'sidebars_widgets', array() ); unset( $sidebars_widgets['array_version'] ); return $sidebars_widgets; @@ -1112,15 +1123,21 @@ final class WP_Customize_Widgets { public function export_preview_data() { global $wp_registered_sidebars, $wp_registered_widgets; + $switched_locale = switch_to_locale( get_user_locale() ); + $l10n = array( + 'widgetTooltip' => __( 'Shift-click to edit this widget.' ), + ); + if ( $switched_locale ) { + restore_previous_locale(); + } + // Prepare Customizer settings to pass to JavaScript. $settings = array( 'renderedSidebars' => array_fill_keys( array_unique( $this->rendered_sidebars ), true ), 'renderedWidgets' => array_fill_keys( array_keys( $this->rendered_widgets ), true ), 'registeredSidebars' => array_values( $wp_registered_sidebars ), 'registeredWidgets' => $wp_registered_widgets, - 'l10n' => array( - 'widgetTooltip' => __( 'Shift-click to edit this widget.' ), - ), + 'l10n' => $l10n, 'selectiveRefreshableWidgets' => $this->get_selective_refreshable_widgets(), ); foreach ( $settings['registeredWidgets'] as &$registered_widget ) { @@ -1986,32 +2003,48 @@ final class WP_Customize_Widgets { } /** + * {@internal Missing Summary} + * + * See the {@see 'customize_dynamic_setting_args'} filter. + * * @since 3.9.0 - * @deprecated 4.2.0 Deprecated in favor of customize_dynamic_setting_args filter. + * @deprecated 4.2.0 Deprecated in favor of the {@see 'customize_dynamic_setting_args'} filter. */ public function setup_widget_addition_previews() { _deprecated_function( __METHOD__, '4.2.0' ); } /** + * {@internal Missing Summary} + * + * See the {@see 'customize_dynamic_setting_args'} filter. + * * @since 3.9.0 - * @deprecated 4.2.0 Deprecated in favor of customize_dynamic_setting_args filter. + * @deprecated 4.2.0 Deprecated in favor of the {@see 'customize_dynamic_setting_args'} filter. */ public function prepreview_added_sidebars_widgets() { _deprecated_function( __METHOD__, '4.2.0' ); } /** + * {@internal Missing Summary} + * + * See the {@see 'customize_dynamic_setting_args'} filter. + * * @since 3.9.0 - * @deprecated 4.2.0 Deprecated in favor of customize_dynamic_setting_args filter. + * @deprecated 4.2.0 Deprecated in favor of the {@see 'customize_dynamic_setting_args'} filter. */ public function prepreview_added_widget_instance() { _deprecated_function( __METHOD__, '4.2.0' ); } /** + * {@internal Missing Summary} + * + * See the {@see 'customize_dynamic_setting_args'} filter. + * * @since 3.9.0 - * @deprecated 4.2.0 Deprecated in favor of customize_dynamic_setting_args filter. + * @deprecated 4.2.0 Deprecated in favor of the {@see 'customize_dynamic_setting_args'} filter. */ public function remove_prepreview_filters() { _deprecated_function( __METHOD__, '4.2.0' );