Make WordPress Core

Ticket #37890: 37890.3.diff

File 37890.3.diff, 4.0 KB (added by westonruter, 7 years ago)
  • src/wp-admin/js/customize-controls.js

    diff --git src/wp-admin/js/customize-controls.js src/wp-admin/js/customize-controls.js
    index 320f892..631df0b 100644
     
    34613461                                // Add notifications for invalidities.
    34623462                                if ( _.isObject( validity ) ) {
    34633463                                        _.each( validity, function( params, code ) {
    3464                                                 var notification = new api.Notification( code, params ), existingNotification, needsReplacement = false;
     3464                                                var notification, existingNotification, needsReplacement = false;
     3465                                                notification = new api.Notification( code, _.extend( { fromServer: true }, params ) );
    34653466
    34663467                                                // Remove existing notification if already exists for code but differs in parameters.
    34673468                                                existingNotification = setting.notifications( notification.code );
    34683469                                                if ( existingNotification ) {
    3469                                                         needsReplacement = ( notification.type !== existingNotification.type ) || ! _.isEqual( notification.data, existingNotification.data );
     3470                                                        needsReplacement = notification.type !== existingNotification.type || notification.message !== existingNotification.message || ! _.isEqual( notification.data, existingNotification.data );
    34703471                                                }
    34713472                                                if ( needsReplacement ) {
    34723473                                                        setting.notifications.remove( code );
     
    37153716                                         */
    37163717                                        api.each( function( setting ) {
    37173718                                                setting.notifications.each( function( notification ) {
    3718                                                         if ( 'error' === notification.type && ( ! notification.data || ! notification.data.from_server ) ) {
     3719                                                        if ( 'error' === notification.type && ! notification.fromServer ) {
    37193720                                                                invalidSettings.push( setting.id );
    37203721                                                        }
    37213722                                                } );
  • src/wp-includes/class-wp-customize-manager.php

    diff --git src/wp-includes/class-wp-customize-manager.php src/wp-includes/class-wp-customize-manager.php
    index 5ee3b6d..668989b 100644
    final class WP_Customize_Manager { 
    10461046                if ( is_wp_error( $validity ) ) {
    10471047                        $notification = array();
    10481048                        foreach ( $validity->errors as $error_code => $error_messages ) {
    1049                                 $error_data = $validity->get_error_data( $error_code );
    1050                                 if ( is_null( $error_data ) ) {
    1051                                         $error_data = array();
    1052                                 }
    1053                                 $error_data = array_merge(
    1054                                         $error_data,
    1055                                         array( 'from_server' => true )
    1056                                 );
    10571049                                $notification[ $error_code ] = array(
    10581050                                        'message' => join( ' ', $error_messages ),
    1059                                         'data' => $error_data,
     1051                                        'data' => $validity->get_error_data( $error_code ),
    10601052                                );
    10611053                        }
    10621054                        return $notification;
  • src/wp-includes/js/customize-base.js

    diff --git src/wp-includes/js/customize-base.js src/wp-includes/js/customize-base.js
    index e59f926..20bb74a 100644
    window.wp = window.wp || {}; 
    762762         * @augments wp.customize.Class
    763763         * @since 4.6.0
    764764         *
    765          * @param {string} code                The error code.
    766          * @param {object} params              Params.
    767          * @param {string} params.message      The error message.
    768          * @param {string} [params.type=error] The notification type.
    769          * @param {*}      [params.data]       Any additional data.
     765         * @param {string}  code - The error code.
     766         * @param {object}  params - Params.
     767         * @param {string}  params.message=null - The error message.
     768         * @param {string}  [params.type=error] - The notification type.
     769         * @param {boolean} [params.fromServer=false] - Whether the notification was server-sent.
     770         * @param {string}  [params.setting=null] - The setting ID that the notification is related to.
     771         * @param {*}       [params.data=null] - Any additional data.
    770772         */
    771773        api.Notification = api.Class.extend({
    772774                initialize: function( code, params ) {
     775                        var _params;
    773776                        this.code = code;
    774                         this.message = params.message;
    775                         this.type = params.type || 'error';
    776                         this.data = params.data || null;
     777                        _params = _.extend(
     778                                {
     779                                        message: null,
     780                                        type: 'error',
     781                                        fromServer: false,
     782                                        data: null,
     783                                        setting: null
     784                                },
     785                                params
     786                        );
     787                        delete _params.code;
     788                        _.extend( this, _params );
    777789                }
    778790        });
    779791