mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-05 02:10:45 +01:00
Customize: Ignore invalid customization sessions.
Merge of [40704] to the 4.2 branch. Built from https://develop.svn.wordpress.org/branches/4.2@40710 git-svn-id: http://core.svn.wordpress.org/branches/4.2@40573 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
92f3fdb956
commit
8f47014af6
@ -148,7 +148,7 @@ do_action( 'customize_controls_print_scripts' );
|
|||||||
<div id="customize-info" class="accordion-section">
|
<div id="customize-info" class="accordion-section">
|
||||||
<div class="accordion-section-title" aria-label="<?php esc_attr_e( 'Customizer Options' ); ?>" tabindex="0">
|
<div class="accordion-section-title" aria-label="<?php esc_attr_e( 'Customizer Options' ); ?>" tabindex="0">
|
||||||
<span class="preview-notice"><?php
|
<span class="preview-notice"><?php
|
||||||
echo sprintf( __( 'You are customizing %s' ), '<strong class="theme-name site-title">' . get_bloginfo( 'name' ) . '</strong>' );
|
echo sprintf( __( 'You are customizing %s' ), '<strong class="theme-name site-title">' . get_bloginfo( 'name', 'display' ) . '</strong>' );
|
||||||
?></span>
|
?></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="accordion-section-content"><?php
|
<div class="accordion-section-content"><?php
|
||||||
|
@ -2703,6 +2703,16 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Ensure preview nonce is included with every customized request, to allow post data to be read.
|
||||||
|
$.ajaxPrefilter( function injectPreviewNonce( options ) {
|
||||||
|
if ( ! /wp_customize=on/.test( options.data ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
options.data += '&' + $.param({
|
||||||
|
customize_preview_nonce: api.settings.nonce.preview
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Refresh the nonces if the preview sends updated nonces over.
|
// Refresh the nonces if the preview sends updated nonces over.
|
||||||
api.previewer.bind( 'nonce', function( nonce ) {
|
api.previewer.bind( 'nonce', function( nonce ) {
|
||||||
$.extend( this.nonce, nonce );
|
$.extend( this.nonce, nonce );
|
||||||
|
4
wp-admin/js/customize-controls.min.js
vendored
4
wp-admin/js/customize-controls.min.js
vendored
File diff suppressed because one or more lines are too long
@ -196,6 +196,24 @@ final class WP_Customize_Manager {
|
|||||||
|
|
||||||
show_admin_bar( false );
|
show_admin_bar( false );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Clear incoming post data if the user lacks a CSRF token (nonce). Note that the customizer
|
||||||
|
* application will inject the customize_preview_nonce query parameter into all Ajax requests.
|
||||||
|
* For similar behavior elsewhere in WordPress, see rest_cookie_check_errors() which logs out
|
||||||
|
* a user when a valid nonce isn't present.
|
||||||
|
*/
|
||||||
|
$has_post_data_nonce = (
|
||||||
|
check_ajax_referer( 'preview-customize_' . $this->get_stylesheet(), 'nonce', false )
|
||||||
|
||
|
||||||
|
check_ajax_referer( 'save-customize_' . $this->get_stylesheet(), 'nonce', false )
|
||||||
|
||
|
||||||
|
check_ajax_referer( 'preview-customize_' . $this->get_stylesheet(), 'customize_preview_nonce', false )
|
||||||
|
);
|
||||||
|
if ( ! $has_post_data_nonce ) {
|
||||||
|
unset( $_POST['customized'] );
|
||||||
|
unset( $_REQUEST['customized'] );
|
||||||
|
}
|
||||||
|
|
||||||
if ( ! current_user_can( 'customize' ) ) {
|
if ( ! current_user_can( 'customize' ) ) {
|
||||||
$this->wp_die( -1 );
|
$this->wp_die( -1 );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user