|
|
|
@ -203,6 +203,9 @@ final class WP_Customize_Widgets {
|
|
|
|
|
*
|
|
|
|
|
* @since 3.9.0
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @global array $sidebars_widgets
|
|
|
|
|
* @global array $_wp_sidebars_widgets
|
|
|
|
|
*/
|
|
|
|
|
public function override_sidebars_widgets_for_theme_switch() {
|
|
|
|
|
global $sidebars_widgets;
|
|
|
|
@ -218,7 +221,8 @@ final class WP_Customize_Widgets {
|
|
|
|
|
$sidebars_widgets = $this->old_sidebars_widgets;
|
|
|
|
|
$sidebars_widgets = retrieve_widgets( 'customize' );
|
|
|
|
|
add_filter( 'option_sidebars_widgets', array( $this, 'filter_option_sidebars_widgets_for_theme_switch' ), 1 );
|
|
|
|
|
unset( $GLOBALS['_wp_sidebars_widgets'] ); // reset global cache var used by wp_get_sidebars_widgets()
|
|
|
|
|
// reset global cache var used by wp_get_sidebars_widgets()
|
|
|
|
|
unset( $GLOBALS['_wp_sidebars_widgets'] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -252,6 +256,8 @@ final class WP_Customize_Widgets {
|
|
|
|
|
* @since 3.9.0
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @global array $sidebars_widgets
|
|
|
|
|
*
|
|
|
|
|
* @param array $sidebars_widgets
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
@ -303,13 +309,17 @@ final class WP_Customize_Widgets {
|
|
|
|
|
*
|
|
|
|
|
* @since 3.9.0
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @global array $wp_registered_widgets
|
|
|
|
|
* @global array $wp_registered_widget_controls
|
|
|
|
|
* @global array $wp_registered_sidebars
|
|
|
|
|
*/
|
|
|
|
|
public function customize_register() {
|
|
|
|
|
global $wp_registered_widgets, $wp_registered_widget_controls, $wp_registered_sidebars;
|
|
|
|
|
|
|
|
|
|
$sidebars_widgets = array_merge(
|
|
|
|
|
array( 'wp_inactive_widgets' => array() ),
|
|
|
|
|
array_fill_keys( array_keys( $GLOBALS['wp_registered_sidebars'] ), array() ),
|
|
|
|
|
array_fill_keys( array_keys( $wp_registered_sidebars ), array() ),
|
|
|
|
|
wp_get_sidebars_widgets()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
@ -353,7 +363,7 @@ final class WP_Customize_Widgets {
|
|
|
|
|
$sidebar_widget_ids = array();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$is_registered_sidebar = isset( $GLOBALS['wp_registered_sidebars'][$sidebar_id] );
|
|
|
|
|
$is_registered_sidebar = isset( $wp_registered_sidebars[ $sidebar_id ] );
|
|
|
|
|
$is_inactive_widgets = ( 'wp_inactive_widgets' === $sidebar_id );
|
|
|
|
|
$is_active_sidebar = ( $is_registered_sidebar && ! $is_inactive_widgets );
|
|
|
|
|
|
|
|
|
@ -374,8 +384,8 @@ final class WP_Customize_Widgets {
|
|
|
|
|
if ( $is_active_sidebar ) {
|
|
|
|
|
|
|
|
|
|
$section_args = array(
|
|
|
|
|
'title' => $GLOBALS['wp_registered_sidebars'][ $sidebar_id ]['name'],
|
|
|
|
|
'description' => $GLOBALS['wp_registered_sidebars'][ $sidebar_id ]['description'],
|
|
|
|
|
'title' => $wp_registered_sidebars[ $sidebar_id ]['name'],
|
|
|
|
|
'description' => $wp_registered_sidebars[ $sidebar_id ]['description'],
|
|
|
|
|
'priority' => array_search( $sidebar_id, array_keys( $wp_registered_sidebars ) ),
|
|
|
|
|
'panel' => 'widgets',
|
|
|
|
|
'sidebar_id' => $sidebar_id,
|
|
|
|
@ -410,13 +420,13 @@ final class WP_Customize_Widgets {
|
|
|
|
|
foreach ( $sidebar_widget_ids as $i => $widget_id ) {
|
|
|
|
|
|
|
|
|
|
// Skip widgets that may have gone away due to a plugin being deactivated.
|
|
|
|
|
if ( ! $is_active_sidebar || ! isset( $GLOBALS['wp_registered_widgets'][$widget_id] ) ) {
|
|
|
|
|
if ( ! $is_active_sidebar || ! isset( $wp_registered_widgets[$widget_id] ) ) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$registered_widget = $GLOBALS['wp_registered_widgets'][$widget_id];
|
|
|
|
|
$registered_widget = $wp_registered_widgets[$widget_id];
|
|
|
|
|
$setting_id = $this->get_setting_id( $widget_id );
|
|
|
|
|
$id_base = $GLOBALS['wp_registered_widget_controls'][$widget_id]['id_base'];
|
|
|
|
|
$id_base = $wp_registered_widget_controls[$widget_id]['id_base'];
|
|
|
|
|
|
|
|
|
|
$control = new WP_Widget_Form_Customize_Control( $this->manager, $setting_id, array(
|
|
|
|
|
'label' => $registered_widget['name'],
|
|
|
|
@ -474,6 +484,8 @@ final class WP_Customize_Widgets {
|
|
|
|
|
* @since 3.9.0
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @global $wp_registered_widget_controls
|
|
|
|
|
*
|
|
|
|
|
* @param string $widget_id Widget ID.
|
|
|
|
|
* @return bool Whether or not the widget is a "wide" widget.
|
|
|
|
|
*/
|
|
|
|
@ -577,8 +589,14 @@ final class WP_Customize_Widgets {
|
|
|
|
|
*
|
|
|
|
|
* @since 3.9.0
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @global WP_Scripts $wp_scripts
|
|
|
|
|
* @global array $wp_registered_sidebars
|
|
|
|
|
* @global array $wp_registered_widgets
|
|
|
|
|
*/
|
|
|
|
|
public function enqueue_scripts() {
|
|
|
|
|
global $wp_scripts, $wp_registered_sidebars, $wp_registered_widgets;
|
|
|
|
|
|
|
|
|
|
wp_enqueue_style( 'customize-widgets' );
|
|
|
|
|
wp_enqueue_script( 'customize-widgets' );
|
|
|
|
|
|
|
|
|
@ -622,12 +640,10 @@ final class WP_Customize_Widgets {
|
|
|
|
|
</div>'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
global $wp_scripts;
|
|
|
|
|
|
|
|
|
|
$settings = array(
|
|
|
|
|
'nonce' => wp_create_nonce( 'update-widget' ),
|
|
|
|
|
'registeredSidebars' => array_values( $GLOBALS['wp_registered_sidebars'] ),
|
|
|
|
|
'registeredWidgets' => $GLOBALS['wp_registered_widgets'],
|
|
|
|
|
'registeredSidebars' => array_values( $wp_registered_sidebars ),
|
|
|
|
|
'registeredWidgets' => $wp_registered_widgets,
|
|
|
|
|
'availableWidgets' => $available_widgets, // @todo Merge this with registered_widgets
|
|
|
|
|
'l10n' => array(
|
|
|
|
|
'saveBtnLabel' => __( 'Apply' ),
|
|
|
|
@ -763,6 +779,10 @@ final class WP_Customize_Widgets {
|
|
|
|
|
* @since 3.9.0
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @global array $wp_registered_widgets
|
|
|
|
|
* @global array $wp_registered_widget_controls
|
|
|
|
|
* @staticvar array $available_widgets
|
|
|
|
|
*
|
|
|
|
|
* @see wp_list_widgets()
|
|
|
|
|
*
|
|
|
|
|
* @return array List of available widgets.
|
|
|
|
@ -967,15 +987,18 @@ final class WP_Customize_Widgets {
|
|
|
|
|
*
|
|
|
|
|
* @since 3.9.0
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @global array $wp_registered_sidebars
|
|
|
|
|
* @global array $wp_registered_widgets
|
|
|
|
|
*/
|
|
|
|
|
public function export_preview_data() {
|
|
|
|
|
|
|
|
|
|
global $wp_registered_sidebars, $wp_registered_widgets;
|
|
|
|
|
// 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( $GLOBALS['wp_registered_sidebars'] ),
|
|
|
|
|
'registeredWidgets' => $GLOBALS['wp_registered_widgets'],
|
|
|
|
|
'registeredSidebars' => array_values( $wp_registered_sidebars ),
|
|
|
|
|
'registeredWidgets' => $wp_registered_widgets,
|
|
|
|
|
'l10n' => array(
|
|
|
|
|
'widgetTooltip' => __( 'Shift-click to edit this widget.' ),
|
|
|
|
|
),
|
|
|
|
@ -1040,6 +1063,8 @@ final class WP_Customize_Widgets {
|
|
|
|
|
* @since 3.9.0
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @global array $wp_registered_sidebars
|
|
|
|
|
*
|
|
|
|
|
* @param bool $is_active Whether the sidebar is active.
|
|
|
|
|
* @param string $sidebar_id Sidebar ID.
|
|
|
|
|
* @return bool
|
|
|
|
@ -1066,6 +1091,8 @@ final class WP_Customize_Widgets {
|
|
|
|
|
* @since 3.9.0
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @global array $wp_registered_sidebars
|
|
|
|
|
*
|
|
|
|
|
* @param bool $has_widgets Whether the current sidebar has widgets.
|
|
|
|
|
* @param string $sidebar_id Sidebar ID.
|
|
|
|
|
* @return bool
|
|
|
|
@ -1172,6 +1199,8 @@ final class WP_Customize_Widgets {
|
|
|
|
|
* @since 3.9.0
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @global array $wp_registered_widgets
|
|
|
|
|
*
|
|
|
|
|
* @param array $widget_ids List of widget IDs.
|
|
|
|
|
* @return array Parsed list of widget IDs.
|
|
|
|
|
*/
|
|
|
|
@ -1189,6 +1218,9 @@ final class WP_Customize_Widgets {
|
|
|
|
|
* @since 3.9.0
|
|
|
|
|
* @access public
|
|
|
|
|
*
|
|
|
|
|
* @global array $wp_registered_widget_updates
|
|
|
|
|
* @global array $wp_registered_widget_controls
|
|
|
|
|
*
|
|
|
|
|
* @param string $widget_id Widget ID.
|
|
|
|
|
* @return WP_Error|array Array containing the updated widget information.
|
|
|
|
|
* A WP_Error object, otherwise.
|
|
|
|
|