Make WordPress Core

Ticket #42849: 42849.diff

File 42849.diff, 3.6 KB (added by iCaleb, 8 years ago)

Incomplete patch for 42849

  • src/wp-admin/js/widgets/custom-html-widgets.js

    diff --git a/src/wp-admin/js/widgets/custom-html-widgets.js b/src/wp-admin/js/widgets/custom-html-widgets.js
    index 6fd6421..61dabe7 100644
    a b wp.customHtmlWidgets = ( function( $ ) { 
    116116                 * Show linting error notice.
    117117                 *
    118118                 * @param {Array} errorAnnotations - Error annotations.
     119                 * @param {Object} onChangeLintingErrors - codeEditorSettings.onChangeLintingErrors
    119120                 * @returns {void}
    120121                 */
    121                 updateErrorNotice: function( errorAnnotations ) {
     122                updateErrorNotice: function( errorAnnotations, onChangeLintingErrors ) {
    122123                        var control = this, errorNotice, message = '', customizeSetting;
    123124
    124125                        if ( 1 === errorAnnotations.length ) {
    wp.customHtmlWidgets = ( function( $ ) { 
    142143                                }
    143144                        } else if ( 0 !== errorAnnotations.length ) {
    144145                                errorNotice = $( '<div class="inline notice notice-error notice-alt"></div>' );
    145                                 errorNotice.append( $( '<p></p>', {
    146                                         text: message
    147                                 } ) );
     146                                errorNotice.append(
     147                                        $( '<p>', { text: message } ),
     148                                        $( '<p><input type="checkbox"></p>' ).append(
     149                                                $( '<label>', { text: component.l10n.dismissError } )
     150                                        )
     151                                );
    148152                                control.errorNoticeContainer.empty();
    149153                                control.errorNoticeContainer.append( errorNotice );
    150154                                control.errorNoticeContainer.slideDown( 'fast' );
    151155                                wp.a11y.speak( message );
     156
     157                                control.errorNoticeContainer.find( 'input[type=checkbox]' ).on( 'click', function() {
     158                                        control.errorNoticeContainer.slideUp( 'fast' );
     159                                        control.errorNoticeContainer.empty();
     160                                        onChangeLintingErrors( [] );
     161                                        if ( control.fields.content[0].setCustomValidity ) {
     162                                                control.fields.content[0].setCustomValidity( '' );
     163                                        }
     164                                } );
    152165                        } else {
    153166                                control.errorNoticeContainer.slideUp( 'fast' );
    154167                        }
    wp.customHtmlWidgets = ( function( $ ) { 
    195208                                 */
    196209                                onChangeLintingErrors: function onChangeLintingErrors( errorAnnotations ) {
    197210                                        control.currentErrorAnnotations = errorAnnotations;
     211
     212                                        if ( 0 === errorAnnotations.length ) {
     213                                                control.saveButton.toggleClass( 'validation-blocked disabled', false );
     214                                        }
    198215                                },
    199216
    200217                                /**
    wp.customHtmlWidgets = ( function( $ ) { 
    204221                                 * @returns {void}
    205222                                 */
    206223                                onUpdateErrorNotice: function onUpdateErrorNotice( errorAnnotations ) {
    207                                         control.saveButton.toggleClass( 'validation-blocked disabled', errorAnnotations.length );
    208                                         control.updateErrorNotice( errorAnnotations );
     224                                        control.saveButton.toggleClass( 'validation-blocked disabled', errorAnnotations.length > 0 );
     225
     226                                        // TODO: find a way to not pass down settings.onChangeLintingErrors
     227                                        control.updateErrorNotice( errorAnnotations, settings.onChangeLintingErrors );
    209228                                }
    210229                        });
    211230
  • src/wp-includes/widgets/class-wp-widget-custom-html.php

    diff --git a/src/wp-includes/widgets/class-wp-widget-custom-html.php b/src/wp-includes/widgets/class-wp-widget-custom-html.php
    index 068d6f7..6a42eec 100644
    a b class WP_Widget_Custom_HTML extends WP_Widget { 
    222222                                /* translators: %d: error count */
    223223                                'plural'   => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491.
    224224                        ),
     225                        'dismissError' => _( 'Update anyway, even though it might break your site?' ),
    225226                );
    226227                wp_add_inline_script( 'custom-html-widgets', sprintf( 'jQuery.extend( wp.customHtmlWidgets.l10n, %s );', wp_json_encode( $l10n ) ), 'after' );
    227228        }