Make WordPress Core

Changeset 42171 for trunk


Ignore:
Timestamp:
11/13/2017 09:18:49 PM (7 years ago)
Author:
westonruter
Message:

Customize: Allow notifications for linting errors in code editor control (for Additional CSS) to be overridden to allow saving.

Implements the same override that was implemented in [41721] for the theme/plugin editors.

See #41897, #41887.
Fixes #42528.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/customize-controls.js

    r42144 r42171  
    52815281            } );
    52825282            api.Control.prototype.initialize.call( control, id, options );
     5283
     5284            // Note that rendering is debounced so the props will be used when rendering happens after add event.
     5285            control.notifications.bind( 'add', function( notification ) {
     5286
     5287                // Skip if control notification is not from setting csslint_error notification.
     5288                if ( notification.code !== control.setting.id + ':csslint_error' ) {
     5289                    return;
     5290                }
     5291
     5292                // Customize the template and behavior of csslint_error notifications.
     5293                notification.templateId = 'customize-code-editor-lint-error-notification';
     5294                notification.render = (function( render ) {
     5295                    return function() {
     5296                        var li = render.call( this );
     5297                        li.find( 'input[type=checkbox]' ).on( 'click', function() {
     5298                            control.setting.notifications.remove( 'csslint_error' );
     5299                        } );
     5300                        return li;
     5301                    };
     5302                })( notification.render );
     5303            } );
    52835304        },
    52845305
  • trunk/src/wp-includes/class-wp-customize-manager.php

    r42122 r42171  
    41264126        </script>
    41274127
     4128        <script type="text/html" id="tmpl-customize-code-editor-lint-error-notification">
     4129            <li class="notice notice-{{ data.type || 'info' }} {{ data.alt ? 'notice-alt' : '' }} {{ data.dismissible ? 'is-dismissible' : '' }} {{ data.containerClasses || '' }}" data-code="{{ data.code }}" data-type="{{ data.type }}">
     4130                <div class="notification-message">{{{ data.message || data.code }}}</div>
     4131
     4132                <p>
     4133                    <# var elementId = 'el-' + String( Math.random() ); #>
     4134                    <input id="{{ elementId }}" type="checkbox">
     4135                    <label for="{{ elementId }}"><?php _e( 'Update anyway, even though it might break your site?' ); ?></label>
     4136                </p>
     4137            </li>
     4138        </script>
     4139
    41284140        <?php
    41294141        /* The following template is obsolete in core but retained for plugins. */
Note: See TracChangeset for help on using the changeset viewer.