Changeset 31062
- Timestamp:
- 01/06/2015 09:46:54 PM (8 years ago)
- Location:
- trunk/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/customize-controls.js
r30991 r31062 1946 1946 var self = this, 1947 1947 query = $.extend( this.query(), { 1948 action: 'customize_save',1949 1948 nonce: this.nonce.save 1950 1949 } ), … … 1956 1955 1957 1956 submit = function () { 1958 var request = $.post( api.settings.url.ajax, query );1957 var request = wp.ajax.post( 'customize_save', query ); 1959 1958 1960 1959 api.trigger( 'save', request ); … … 1964 1963 } ); 1965 1964 1966 request.done( function( response ) { 1967 // Check if the user is logged out. 1965 request.fail( function ( response ) { 1968 1966 if ( '0' === response ) { 1967 response = 'not_logged_in'; 1968 } else if ( '-1' === response ) { 1969 // Back-compat in case any other check_ajax_referer() call is dying 1970 response = 'invalid_nonce'; 1971 } 1972 1973 if ( 'invalid_nonce' === response ) { 1974 self.cheatin(); 1975 } else if ( 'not_logged_in' === response ) { 1969 1976 self.preview.iframe.hide(); 1970 1977 self.login().done( function() { … … 1972 1979 self.preview.iframe.show(); 1973 1980 } ); 1974 return;1975 1981 } 1976 1977 // Check for cheaters. 1978 if ( '-1' === response ) { 1979 self.cheatin(); 1980 return; 1981 } 1982 1982 api.trigger( 'error', response ); 1983 } ); 1984 1985 request.done( function( response ) { 1983 1986 // Clear setting dirty states 1984 1987 api.each( function ( value ) { 1985 1988 value._dirty = false; 1986 1989 } ); 1987 api.trigger( 'saved' ); 1990 1991 api.trigger( 'saved', response ); 1988 1992 } ); 1989 1993 }; -
trunk/src/wp-includes/class-wp-customize-manager.php
r30885 r31062 629 629 */ 630 630 public function save() { 631 if ( ! $this->is_preview() ) 632 die; 633 634 check_ajax_referer( 'save-customize_' . $this->get_stylesheet(), 'nonce' ); 631 if ( ! $this->is_preview() ) { 632 wp_send_json_error( 'not_preview' ); 633 } 634 635 $action = 'save-customize_' . $this->get_stylesheet(); 636 if ( ! check_ajax_referer( $action, 'nonce', false ) ) { 637 wp_send_json_error( 'invalid_nonce' ); 638 } 635 639 636 640 // Do we have to switch themes? … … 667 671 do_action( 'customize_save_after', $this ); 668 672 669 die; 673 /** 674 * Filter response data for a successful customize_save Ajax request. 675 * 676 * This filter does not apply if there was a nonce or authentication failure. 677 * 678 * @since 4.2.0 679 * 680 * @param array $data 681 * @param WP_Customize_Manager $this WP_Customize_Manager instance. 682 */ 683 $response = apply_filters( 'customize_save_response', array(), $this ); 684 wp_send_json_success( $response ); 670 685 } 671 686
Note: See TracChangeset
for help on using the changeset viewer.