Make WordPress Core


Ignore:
Timestamp:
03/28/2014 05:08:05 PM (10 years ago)
Author:
SergeyBiryukov
Message:

Widget Customizer: Simplify conditions in setup_widget_addition_previews().

see #27534.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-widgets.php

    r27819 r27820  
    119119     */
    120120    public function setup_widget_addition_previews() {
    121         $is_customize_preview = (
    122             ( ! empty( $this->manager ) )
    123             &&
    124             ( ! is_admin() )
    125             &&
    126             ( 'on' === $this->get_post_value( 'wp_customize' ) )
    127             &&
    128             check_ajax_referer( 'preview-customize_' . $this->manager->get_stylesheet(), 'nonce', false )
    129         );
    130 
    131         $is_ajax_widget_update = (
    132             ( defined( 'DOING_AJAX' ) && DOING_AJAX )
    133             &&
    134             $this->get_post_value( 'action' ) === 'update-widget'
    135             &&
    136             check_ajax_referer( 'update-widget', 'nonce', false )
    137         );
    138 
    139         $is_ajax_customize_save = (
    140             ( defined( 'DOING_AJAX' ) && DOING_AJAX )
    141             &&
    142             $this->get_post_value( 'action' ) === 'customize_save'
    143             &&
    144             check_ajax_referer( 'save-customize_' . $this->manager->get_stylesheet(), 'nonce', false )
    145         );
     121        $is_customize_preview = false;
     122        if ( ! empty( $this->manager ) && ! is_admin() && 'on' === $this->get_post_value( 'wp_customize' ) ) {
     123            $is_customize_preview = check_ajax_referer( 'preview-customize_' . $this->manager->get_stylesheet(), 'nonce', false );
     124        }
     125
     126        $is_ajax_widget_update = false;
     127        if ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'update-widget' === $this->get_post_value( 'action' ) ) {
     128            $is_ajax_widget_update = check_ajax_referer( 'update-widget', 'nonce', false );
     129        }
     130
     131        $is_ajax_customize_save = false;
     132        if ( defined( 'DOING_AJAX' ) && DOING_AJAX && 'customize_save' === $this->get_post_value( 'action' ) ) {
     133            $is_ajax_customize_save = check_ajax_referer( 'save-customize_' . $this->manager->get_stylesheet(), 'nonce', false );
     134        }
    146135
    147136        $is_valid_request = ( $is_ajax_widget_update || $is_customize_preview || $is_ajax_customize_save );
Note: See TracChangeset for help on using the changeset viewer.