Ticket #27767: 27767-05.patch
File 27767-05.patch, 5.8 KB (added by , 11 years ago) |
---|
-
src/wp-admin/js/customize-widgets.js
diff --git src/wp-admin/js/customize-widgets.js src/wp-admin/js/customize-widgets.js index 48ba335..448b13d 100644
1614 1614 widgetNumber = widget.get( 'multi_number' ); 1615 1615 } 1616 1616 1617 controlHtml = $ ( '#widget-tpl-' + widget.get( 'id' ) ).html();1617 controlHtml = $.trim( $( '#widget-tpl-' + widget.get( 'id' ) ).html() ); 1618 1618 if ( widget.get( 'is_multi' ) ) { 1619 1619 controlHtml = controlHtml.replace( /<[^<>]+>/g, function( m ) { 1620 1620 return m.replace( /__i__|%i%/g, widgetNumber ); -
src/wp-includes/class-wp-customize-manager.php
diff --git src/wp-includes/class-wp-customize-manager.php src/wp-includes/class-wp-customize-manager.php index 18a1d76..8ed4e69 100644
final class WP_Customize_Manager { 575 575 // to operate properly. 576 576 $this->stop_previewing_theme(); 577 577 switch_theme( $this->get_stylesheet() ); 578 update_option( 'theme_switched_via_customizer', true ); 578 579 $this->start_previewing_theme(); 579 580 } 580 581 -
src/wp-includes/class-wp-customize-widgets.php
diff --git src/wp-includes/class-wp-customize-widgets.php src/wp-includes/class-wp-customize-widgets.php index 72ff397..ed8e03a 100644
final class WP_Customize_Widgets { 316 316 } 317 317 318 318 /** 319 * Get sidebar configuration 320 * 321 * Fetch the sidebar configuration directly from the option so that any preview filters are applied and 322 * when the customizer is loaded with a theme that is not active override the initial sidebar in the configuration 323 * that would be applied if the theme was activated instead of being previewed. 324 * 325 * @since 3.9 326 * @access public 327 */ 328 public function get_sidebars_widgets() { 329 global $sidebars_widgets; 330 331 $sidebars_widgets = get_option( 'sidebars_widgets', array() ); 332 333 if ( ! $this->manager->is_theme_active() && 334 ( ( is_admin() && ! defined( 'DOING_AJAX' ) ) || 335 // Only override with widgets from theme_mods when loading the initial iframe 336 ( isset( $_POST['customize_messenger_channel'] ) && $_POST['customize_messenger_channel'] === 'preview-0' ) ) ) { 337 338 if ( ! isset( $this->sidebars_widgets ) ) { 339 $temporary_preview = false; 340 if ( ! $this->manager->is_preview() ) { 341 $temporary_preview = true; 342 $this->manager->start_previewing_theme(); 343 } 344 // Cache the modified version to avoid manipulating the set of widgets a second time 345 $this->sidebars_widgets = retrieve_widgets( true, false ); 346 if ( $temporary_preview ) { 347 $this->manager->stop_previewing_theme(); 348 } 349 } 350 351 // Override the widgets as fetched from the option 352 $sidebars_widgets = $this->sidebars_widgets; 353 } 354 355 unset( $sidebars_widgets['array_version'] ); 356 357 return $sidebars_widgets; 358 } 359 360 /** 319 361 * Register customizer settings and controls for all sidebars and widgets. 320 362 * 321 363 * @since 3.9.0 … … final class WP_Customize_Widgets { 327 369 $sidebars_widgets = array_merge( 328 370 array( 'wp_inactive_widgets' => array() ), 329 371 array_fill_keys( array_keys( $GLOBALS['wp_registered_sidebars'] ), array() ), 330 wp_get_sidebars_widgets()372 $this->get_sidebars_widgets() 331 373 ); 332 374 333 375 $new_setting_ids = array(); … … final class WP_Customize_Widgets { 891 933 * @param array $sidebars_widgets List of widgets for the current sidebar. 892 934 */ 893 935 public function preview_sidebars_widgets( $sidebars_widgets ) { 894 $sidebars_widgets = get_option( 'sidebars_widgets');936 $sidebars_widgets = $this->get_sidebars_widgets(); 895 937 896 unset( $sidebars_widgets['array_version'] );897 938 return $sidebars_widgets; 898 939 } 899 940 -
src/wp-includes/theme.php
diff --git src/wp-includes/theme.php src/wp-includes/theme.php index f66fd95..9bb1a1f 100644
function check_theme_switched() { 1791 1791 if ( $stylesheet = get_option( 'theme_switched' ) ) { 1792 1792 $old_theme = wp_get_theme( $stylesheet ); 1793 1793 1794 if ( get_option( 'theme_switched_via_customizer' ) ) { 1795 remove_filter( 'after_switch_theme', '_wp_sidebars_changed' ); 1796 update_option( 'theme_switched_via_customizer', false ); 1797 } 1798 1794 1799 if ( $old_theme->exists() ) { 1795 1800 /** 1796 1801 * Fires on the first WP load after a theme switch if the old theme still exists. … … function wp_customize_support_script() { 1918 1923 }()); 1919 1924 </script> 1920 1925 <?php 1921 } 1922 No newline at end of file 1926 } -
src/wp-includes/widgets.php
diff --git src/wp-includes/widgets.php src/wp-includes/widgets.php index b911fde..1f60a55 100644
function _wp_sidebars_changed() { 1402 1402 } 1403 1403 1404 1404 // look for "lost" widgets, this has to run at least on each theme change 1405 function retrieve_widgets($theme_changed = false ) {1405 function retrieve_widgets($theme_changed = false, $update = true ) { 1406 1406 global $wp_registered_sidebars, $sidebars_widgets, $wp_registered_widgets; 1407 1407 1408 1408 $registered_sidebar_keys = array_keys( $wp_registered_sidebars ); … … function retrieve_widgets($theme_changed = false) { 1412 1412 if ( is_array( $old_sidebars_widgets ) ) { 1413 1413 // time() that sidebars were stored is in $old_sidebars_widgets['time'] 1414 1414 $_sidebars_widgets = $old_sidebars_widgets['data']; 1415 remove_theme_mod( 'sidebars_widgets' ); 1415 1416 if ( $update ) { 1417 remove_theme_mod( 'sidebars_widgets' ); 1418 } 1416 1419 1417 1420 foreach ( $_sidebars_widgets as $sidebar => $widgets ) { 1418 1421 if ( 'wp_inactive_widgets' == $sidebar || 'orphaned_widgets' == substr( $sidebar, 0, 16 ) ) … … function retrieve_widgets($theme_changed = false) { 1495 1498 } 1496 1499 1497 1500 $sidebars_widgets['wp_inactive_widgets'] = array_merge($lost_widgets, (array) $sidebars_widgets['wp_inactive_widgets']); 1498 wp_set_sidebars_widgets($sidebars_widgets); 1501 if ( $update ) { 1502 wp_set_sidebars_widgets($sidebars_widgets); 1503 } 1499 1504 1500 1505 return $sidebars_widgets; 1501 1506 }