]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/customize/class-wp-customize-selective-refresh.php
WordPress 4.7.1
[autoinstalls/wordpress.git] / wp-includes / customize / class-wp-customize-selective-refresh.php
index f90f0f988b3908ead0bb823b4685aec6ef0dc230..af0c74d67b7fac53a5164f36447595f01fc5f87d 100644 (file)
@@ -179,14 +179,24 @@ final class WP_Customize_Selective_Refresh {
                        }
                }
 
+               $switched_locale = switch_to_locale( get_user_locale() );
+               $l10n = array(
+                       'shiftClickToEdit' => __( 'Shift-click to edit this element.' ),
+                       'clickEditMenu' => __( 'Click to edit this menu.' ),
+                       'clickEditWidget' => __( 'Click to edit this widget.' ),
+                       'clickEditTitle' => __( 'Click to edit the site title.' ),
+                       'clickEditMisc' => __( 'Click to edit this element.' ),
+                       /* translators: %s: document.write() */
+                       'badDocumentWrite' => sprintf( __( '%s is forbidden' ), 'document.write()' ),
+               );
+               if ( $switched_locale ) {
+                       restore_previous_locale();
+               }
+
                $exports = array(
                        'partials'       => $partials,
                        'renderQueryVar' => self::RENDER_QUERY_VAR,
-                       'l10n'           => array(
-                               'shiftClickToEdit' => __( 'Shift-click to edit this element.' ),
-                               /* translators: %s: document.write() */
-                               'badDocumentWrite' => sprintf( __( '%s is forbidden' ), 'document.write()' ),
-                       ),
+                       'l10n'           => $l10n,
                );
 
                // Export data to JS.
@@ -307,19 +317,15 @@ final class WP_Customize_Selective_Refresh {
                        return;
                }
 
-               $this->manager->remove_preview_signature();
-
                /*
                 * Note that is_customize_preview() returning true will entail that the
                 * user passed the 'customize' capability check and the nonce check, since
                 * WP_Customize_Manager::setup_theme() is where the previewing flag is set.
                 */
                if ( ! is_customize_preview() ) {
-                       status_header( 403 );
-                       wp_send_json_error( 'expected_customize_preview' );
+                       wp_send_json_error( 'expected_customize_preview', 403 );
                } else if ( ! isset( $_POST['partials'] ) ) {
-                       status_header( 400 );
-                       wp_send_json_error( 'missing_partials' );
+                       wp_send_json_error( 'missing_partials', 400 );
                }
 
                $partials = json_decode( wp_unslash( $_POST['partials'] ), true );
@@ -402,6 +408,10 @@ final class WP_Customize_Selective_Refresh {
                        $response['errors'] = $this->triggered_errors;
                }
 
+               $setting_validities = $this->manager->validate_setting_values( $this->manager->unsanitized_post_values() );
+               $exported_setting_validities = array_map( array( $this->manager, 'prepare_setting_validity_for_js' ), $setting_validities );
+               $response['setting_validities'] = $exported_setting_validities;
+
                /**
                 * Filters the response from rendering the partials.
                 *