X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/dc1231b7312fbdca99e9e887cc2bb35a28f85cdc..refs/tags/wordpress-4.4:/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 8569228e..7639d509 100644 --- a/wp-includes/class-wp-customize-widgets.php +++ b/wp-includes/class-wp-customize-widgets.php @@ -164,8 +164,8 @@ final class WP_Customize_Widgets { * @since 4.2.0 * @access public * - * @param false|array $setting_args The arguments to the WP_Customize_Setting constructor. - * @param string $setting_id ID for dynamic setting, usually coming from `$_POST['customized']`. + * @param false|array $args The arguments to the WP_Customize_Setting constructor. + * @param string $setting_id ID for dynamic setting, usually coming from `$_POST['customized']`. * @return false|array Setting arguments, false otherwise. */ public function filter_customize_dynamic_setting_args( $args, $setting_id ) { @@ -355,9 +355,11 @@ final class WP_Customize_Widgets { } $this->manager->add_panel( 'widgets', array( - 'title' => __( 'Widgets' ), - 'description' => __( 'Widgets are independent sections of content that can be placed into widgetized areas provided by your theme (commonly called sidebars).' ), - 'priority' => 110, + 'type' => 'widgets', + 'title' => __( 'Widgets' ), + 'description' => __( 'Widgets are independent sections of content that can be placed into widgetized areas provided by your theme (commonly called sidebars).' ), + 'priority' => 110, + 'active_callback' => array( $this, 'is_panel_active' ), ) ); foreach ( $sidebars_widgets as $sidebar_id => $sidebar_widget_ids ) { @@ -365,7 +367,7 @@ final class WP_Customize_Widgets { $sidebar_widget_ids = array(); } - $is_registered_sidebar = isset( $wp_registered_sidebars[ $sidebar_id ] ); + $is_registered_sidebar = is_registered_sidebar( $sidebar_id ); $is_inactive_widgets = ( 'wp_inactive_widgets' === $sidebar_id ); $is_active_sidebar = ( $is_registered_sidebar && ! $is_inactive_widgets ); @@ -454,6 +456,22 @@ final class WP_Customize_Widgets { add_filter( 'sidebars_widgets', array( $this, 'preview_sidebars_widgets' ), 1 ); } + /** + * Return whether the widgets panel is active, based on whether there are sidebars registered. + * + * @since 4.4.0 + * @access public + * + * @see WP_Customize_Panel::$active_callback + * + * @global array $wp_registered_sidebars + * @return bool Active. + */ + public function is_panel_active() { + global $wp_registered_sidebars; + return ! empty( $wp_registered_sidebars ); + } + /** * Covert a widget_id into its corresponding Customizer setting ID (option name). * @@ -655,6 +673,11 @@ 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.' ), + 'reorderModeOn' => __( 'Reorder mode enabled' ), + 'reorderModeOff' => __( 'Reorder mode closed' ), + 'reorderLabelOn' => esc_attr__( 'Reorder widgets' ), + 'reorderLabelOff' => esc_attr__( 'Close reorder mode' ), ), 'tpl' => array( 'widgetReorderNav' => $widget_reorder_nav_tpl, @@ -898,19 +921,45 @@ final class WP_Customize_Widgets { * @return string Widget control form HTML markup. */ public function get_widget_control( $args ) { + $args[0]['before_form'] = '