Changeset 41667 for trunk/src/wp-includes/class-wp-customize-manager.php
- Timestamp:
- 10/02/2017 03:36:18 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-customize-manager.php
r41648 r41667 375 375 remove_action( 'admin_init', '_maybe_update_themes' ); 376 376 377 add_action( 'wp_ajax_customize_save', array( $this, 'save' ) ); 378 add_action( 'wp_ajax_customize_refresh_nonces', array( $this, 'refresh_nonces' ) ); 379 add_action( 'wp_ajax_customize-load-themes', array( $this, 'load_themes_ajax' ) ); 380 add_action( 'wp_ajax_dismiss_customize_changeset_autosave', array( $this, 'handle_dismiss_changeset_autosave_request' ) ); 377 add_action( 'wp_ajax_customize_save', array( $this, 'save' ) ); 378 add_action( 'wp_ajax_customize_trash', array( $this, 'handle_changeset_trash_request' ) ); 379 add_action( 'wp_ajax_customize_refresh_nonces', array( $this, 'refresh_nonces' ) ); 380 add_action( 'wp_ajax_customize_load_themes', array( $this, 'handle_load_themes_request' ) ); 381 add_action( 'wp_ajax_customize_dismiss_autosave', array( $this, 'handle_dismiss_autosave_request' ) ); 381 382 382 383 add_action( 'customize_register', array( $this, 'register_controls' ) ); … … 2831 2832 2832 2833 /** 2834 * Handle request to trash a changeset. 2835 * 2836 * @since 4.9.0 2837 */ 2838 public function handle_changeset_trash_request() { 2839 if ( ! is_user_logged_in() ) { 2840 wp_send_json_error( 'unauthenticated' ); 2841 } 2842 2843 if ( ! $this->is_preview() ) { 2844 wp_send_json_error( 'not_preview' ); 2845 } 2846 2847 if ( ! check_ajax_referer( 'trash_customize_changeset', 'nonce', false ) ) { 2848 wp_send_json_error( array( 2849 'code' => 'invalid_nonce', 2850 'message' => __( 'There was an authentication problem. Please reload and try again.' ), 2851 ) ); 2852 } 2853 2854 $changeset_post_id = $this->changeset_post_id(); 2855 2856 if ( ! $changeset_post_id ) { 2857 wp_send_json_error( array( 2858 'message' => __( 'No changes saved yet, so there is nothing to trash.' ), 2859 'code' => 'non_existent_changeset', 2860 ) ); 2861 return; 2862 } 2863 2864 if ( $changeset_post_id && ! current_user_can( get_post_type_object( 'customize_changeset' )->cap->delete_post, $changeset_post_id ) ) { 2865 wp_send_json_error( array( 2866 'code' => 'changeset_trash_unauthorized', 2867 'message' => __( 'Unable to trash changes.' ), 2868 ) ); 2869 } 2870 2871 if ( 'trash' === get_post_status( $changeset_post_id ) ) { 2872 wp_send_json_error( array( 2873 'message' => __( 'Changes have already been trashed.' ), 2874 'code' => 'changeset_already_trashed', 2875 ) ); 2876 return; 2877 } 2878 2879 $r = wp_trash_post( $changeset_post_id ); 2880 if ( ! ( $r instanceof WP_Post ) ) { 2881 wp_send_json_error( array( 2882 'code' => 'changeset_trash_failure', 2883 'message' => __( 'Unable to trash changes.' ), 2884 ) ); 2885 } 2886 2887 wp_send_json_success( array( 2888 'message' => __( 'Changes trashed successfully.' ), 2889 ) ); 2890 } 2891 2892 /** 2833 2893 * Re-map 'edit_post' meta cap for a customize_changeset post to be the same as 'customize' maps. 2834 2894 * … … 3103 3163 * @since 4.9.0 3104 3164 */ 3105 public function handle_dismiss_ changeset_autosave_request() {3165 public function handle_dismiss_autosave_request() { 3106 3166 if ( ! $this->is_preview() ) { 3107 3167 wp_send_json_error( 'not_preview', 400 ); 3108 3168 } 3109 3169 3110 if ( ! check_ajax_referer( ' dismiss_customize_changeset_autosave', 'nonce', false ) ) {3170 if ( ! check_ajax_referer( 'customize_dismiss_autosave', 'nonce', false ) ) { 3111 3171 wp_send_json_error( 'invalid_nonce', 403 ); 3112 3172 } … … 3544 3604 ?> 3545 3605 <script type="text/html" id="tmpl-customize-notification"> 3546 <li class="notice notice-{{ data.type || 'info' }} {{ data.alt ? 'notice-alt' : '' }} {{ data.dismissible ? 'is-dismissible' : '' }} " data-code="{{ data.code }}" data-type="{{ data.type }}">3547 {{{ data.message || data.code }}}3606 <li class="notice notice-{{ data.type || 'info' }} {{ data.alt ? 'notice-alt' : '' }} {{ data.dismissible ? 'is-dismissible' : '' }} {{ data.classes || '' }}" data-code="{{ data.code }}" data-type="{{ data.type }}"> 3607 <div class="notification-message">{{{ data.message || data.code }}}</div> 3548 3608 <# if ( data.dismissible ) { #> 3549 3609 <button type="button" class="notice-dismiss"><span class="screen-reader-text"><?php _e( 'Dismiss' ); ?></span></button> … … 3577 3637 </div> 3578 3638 </script> 3639 <script type="text/html" id="tmpl-customize-trash-changeset-control"> 3640 <button type="button" class="button-link button-link-delete"><?php _e( 'Trash unpublished changes' ); ?></button> 3641 </script> 3579 3642 <?php 3580 3643 } … … 3902 3965 'save' => wp_create_nonce( 'save-customize_' . $this->get_stylesheet() ), 3903 3966 'preview' => wp_create_nonce( 'preview-customize_' . $this->get_stylesheet() ), 3904 'switch-themes' => wp_create_nonce( 'switch-themes' ), 3905 'dismiss_autosave' => wp_create_nonce( 'dismiss_customize_changeset_autosave' ), 3967 'switch_themes' => wp_create_nonce( 'switch_themes' ), 3968 'dismiss_autosave' => wp_create_nonce( 'customize_dismiss_autosave' ), 3969 'trash' => wp_create_nonce( 'trash_customize_changeset' ), 3906 3970 ); 3907 3971 … … 4160 4224 $this->add_control( 'changeset_status', array( 4161 4225 'section' => 'publish_settings', 4226 'priority' => 10, 4162 4227 'settings' => array(), 4163 4228 'type' => 'radio', … … 4174 4239 $this->add_control( new WP_Customize_Date_Time_Control( $this, 'changeset_scheduled_date', array( 4175 4240 'section' => 'publish_settings', 4241 'priority' => 20, 4176 4242 'settings' => array(), 4177 4243 'type' => 'date_time', … … 4724 4790 * @since 4.9.0 4725 4791 */ 4726 public function load_themes_ajax() {4727 check_ajax_referer( 'switch -themes', 'switch-themes-nonce' );4792 public function handle_load_themes_request() { 4793 check_ajax_referer( 'switch_themes', 'nonce' ); 4728 4794 4729 4795 if ( ! current_user_can( 'switch_themes' ) ) {
Note: See TracChangeset
for help on using the changeset viewer.