Ticket #31294: 31294.4.diff
File 31294.4.diff, 5.2 KB (added by , 10 years ago) |
---|
-
src/wp-admin/js/customize-controls.js
2358 2358 2359 2359 messenger.targetWindow( iframe[0].contentWindow ); 2360 2360 2361 messenger.bind( 'login', function() { 2362 iframe.remove(); 2363 messenger.destroy(); 2364 delete previewer._login; 2365 deferred.resolve(); 2361 messenger.bind( 'login', function () { 2362 previewer.refreshNonces().done( function() { 2363 iframe.remove(); 2364 messenger.destroy(); 2365 delete previewer._login; 2366 deferred.resolve(); 2367 }); 2366 2368 }); 2367 2369 2368 2370 return this._login; … … 2370 2372 2371 2373 cheatin: function() { 2372 2374 $( document.body ).empty().addClass('cheatin').append( '<p>' + api.l10n.cheatin + '</p>' ); 2375 }, 2376 2377 refreshNonces: function() { 2378 var self = this, request, deferred = $.Deferred(); 2379 2380 deferred.promise(); 2381 2382 request = wp.ajax.post( 'customize_refresh_nonces', { 2383 wp_customize: 'on', 2384 theme: api.settings.theme.stylesheet 2385 } ); 2386 2387 request.fail( function() { 2388 self.cheatin(); 2389 deferred.reject(); 2390 } ); 2391 2392 request.done( function( response ) { 2393 api.trigger( 'nonce-refresh', response ); 2394 deferred.resolve(); 2395 } ); 2396 2397 return deferred; 2373 2398 } 2374 2399 }); 2375 2400 … … 2538 2563 $.extend( this.nonce, nonce ); 2539 2564 }); 2540 2565 2566 // Refresh the nonces if login sends updated nonces over. 2567 api.bind( 'nonce-refresh', function( nonce ) { 2568 $.extend( api.settings.nonce, nonce ); 2569 $.extend( api.previewer.nonce, nonce ); 2570 }); 2571 2541 2572 // Create Settings 2542 2573 $.each( api.settings.settings, function( id, data ) { 2543 2574 api.create( id, id, data.value, { -
src/wp-admin/js/customize-widgets.js
1898 1898 sidebar_widgets: api.Widgets.SidebarControl 1899 1899 }); 1900 1900 1901 // Refresh the nonces if login sends updated nonces over. 1902 api.bind( 'nonce-refresh', function( nonce ) { 1903 api.Widgets.data.nonce = nonce['update-widget']; 1904 }); 1905 1901 1906 /** 1902 1907 * Init Customizer for widgets. 1903 1908 */ -
src/wp-includes/class-wp-customize-manager.php
106 106 remove_action( 'admin_init', '_maybe_update_themes' ); 107 107 108 108 add_action( 'wp_ajax_customize_save', array( $this, 'save' ) ); 109 add_action( 'wp_ajax_customize_refresh_nonces', array( $this, 'refresh_nonces' ) ); 109 110 110 111 add_action( 'customize_register', array( $this, 'register_controls' ) ); 111 112 add_action( 'customize_register', array( $this, 'register_dynamic_settings' ), 11 ); // allow code to create settings first … … 778 779 } 779 780 780 781 /** 782 * Refresh nonces for the current preview. 783 * 784 * @since 4.2.0 785 */ 786 public function refresh_nonces() { 787 if ( ! $this->is_preview() ) { 788 wp_send_json_error( 'not_preview' ); 789 } 790 791 $nonces = array( 792 'save' => wp_create_nonce( 'save-customize_' . $this->get_stylesheet() ), 793 'preview' => wp_create_nonce( 'preview-customize_' . $this->get_stylesheet() ), 794 ); 795 796 /** 797 * Filter response data for a successful customize_refresh_nonces Ajax request. 798 * 799 * @since 4.2.0 800 * 801 * @param array $nonces Array of new nonces for save an preview actions. 802 * @param WP_Customize_Manager $this WP_Customize_Manager instance. 803 */ 804 $nonces = apply_filters( 'customize_refresh_nonces', $nonces, $this ); 805 wp_send_json_success( $nonces ); 806 } 807 808 /** 781 809 * Add a customize setting. 782 810 * 783 811 * @since 3.4.0 -
src/wp-includes/class-wp-customize-widgets.php
95 95 add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_footer_scripts' ) ); 96 96 add_action( 'customize_controls_print_footer_scripts', array( $this, 'output_widget_control_templates' ) ); 97 97 add_action( 'customize_preview_init', array( $this, 'customize_preview_init' ) ); 98 add_filter( 'customize_refresh_nonces', array( $this, 'refresh_nonces' ) ); 98 99 99 100 add_action( 'dynamic_sidebar', array( $this, 'tally_rendered_widgets' ) ); 100 101 add_filter( 'is_active_sidebar', array( $this, 'tally_sidebars_via_is_active_sidebar_calls' ), 10, 2 ); … … 887 888 } 888 889 889 890 /** 891 * Refresh nonce for widget updates. 892 * 893 * @since 4.2.0 894 * @access public 895 * 896 * @param array $nonces Array of nonces. 897 * @return array $nonces Array of nonces. 898 */ 899 public function refresh_nonces( $nonces ) { 900 $nonces['update-widget'] = wp_create_nonce( 'update-widget' ); 901 return $nonces; 902 } 903 904 /** 890 905 * When previewing, make sure the proper previewing widgets are used. 891 906 * 892 907 * Because wp_get_sidebars_widgets() gets called early at init