Make WordPress Core

Ticket #38342: 38342.17.diff

File 38342.17.diff, 22.4 KB (added by adamsilverstein, 8 years ago)
  • src/wp-admin/css/dashboard.css

     
    518518        resize: none;
    519519}
    520520
     521#quick-press.is-saving .spinner {
     522        visibility: inherit;
     523}
     524
    521525/* Dashboard Quick Draft - Drafts list */
    522526
    523527.js #dashboard_quick_press .drafts {
     
    541545        margin: 0 12px;
    542546}
    543547
     548#dashboard_quick_press .drafts ul.is-placeholder li {
     549        padding: 3px 0;
     550        color: transparent;
     551}
     552
     553@-webkit-keyframes loading-fade {
     554
     555        0% {
     556                opacity: 0.5;
     557        }
     558
     559        50% {
     560                opacity: 1;
     561        }
     562
     563        100% {
     564                opacity: 0.5;
     565        }
     566}
     567
     568@keyframes loading-fade {
     569
     570        0% {
     571                opacity: 0.5;
     572        }
     573
     574        50% {
     575                opacity: 1;
     576        }
     577
     578        100% {
     579                opacity: 0.5;
     580        }
     581}
     582
     583#dashboard_quick_press .drafts ul.is-placeholder li:before,
     584#dashboard_quick_press .drafts ul.is-placeholder li:after {
     585        content: "";
     586        display: block;
     587        height: 13px;
     588        background: #eee;
     589        -webkit-animation: loading-fade 1.6s ease-in-out infinite;
     590        animation: loading-fade 1.6s ease-in-out infinite;
     591}
     592
     593#dashboard_quick_press .drafts ul.is-placeholder li:before {
     594        margin-bottom: 5px;
     595        width: 40%;
     596}
     597
     598#dashboard_quick_press .drafts ul.is-placeholder li:after {
     599        width: 80%;
     600}
     601
    544602#dashboard_quick_press .drafts li {
    545603        margin-bottom: 1em;
    546604}
     605
     606#dashboard_quick_press .drafts li.is-new {
     607        background-color: #fffbe5;
     608}
     609
    547610#dashboard_quick_press .drafts li time {
    548611        color: #72777c;
    549612}
  • src/wp-admin/includes/dashboard.php

     
    5050        if ( is_blog_admin() && current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
    5151                $quick_draft_title = sprintf( '<span class="hide-if-no-js">%1$s</span> <span class="hide-if-js">%2$s</span>', __( 'Quick Draft' ), __( 'Drafts' ) );
    5252                wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' );
     53                add_action( 'admin_footer', 'wp_dashboard_print_recent_drafts_template' );
    5354        }
    5455
    5556        // WordPress News
     
    494495        $post_ID = (int) $post->ID;
    495496?>
    496497
    497         <form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press" class="initial-form hide-if-no-js">
    498 
    499                 <?php if ( $error_msg ) : ?>
    500                 <div class="error"><?php echo $error_msg; ?></div>
    501                 <?php endif; ?>
    502 
     498        <form name="post" method="post" id="quick-press" class="initial-form hide-if-no-js">
     499                <div class="notice notice-info notice-alt inline" style="display: none;"><p></p></div>
    503500                <div class="input-text-wrap" id="title-wrap">
    504                         <label class="screen-reader-text prompt" for="title" id="title-prompt-text">
     501                        <label class="prompt" for="title" id="title-prompt-text">
    505502
    506503                                <?php
    507504                                /** This filter is documented in wp-admin/edit-form-advanced.php */
     
    508505                                echo apply_filters( 'enter_title_here', __( 'Title' ), $post );
    509506                                ?>
    510507                        </label>
    511                         <input type="text" name="post_title" id="title" autocomplete="off" />
     508                        <input type="text" name="title" id="title" autocomplete="off" />
    512509                </div>
    513510
    514511                <div class="textarea-wrap" id="description-wrap">
    515                         <label class="screen-reader-text prompt" for="content" id="content-prompt-text"><?php _e( 'What&#8217;s on your mind?' ); ?></label>
     512                        <label class="prompt" for="content" id="content-prompt-text"><?php _e( 'What&#8217;s on your mind?' ); ?></label>
    516513                        <textarea name="content" id="content" class="mceEditor" rows="3" cols="15" autocomplete="off"></textarea>
    517514                </div>
    518 
    519515                <p class="submit">
    520                         <input type="hidden" name="action" id="quickpost-action" value="post-quickdraft-save" />
    521                         <input type="hidden" name="post_ID" value="<?php echo $post_ID; ?>" />
    522                         <input type="hidden" name="post_type" value="post" />
    523                         <?php wp_nonce_field( 'add-post' ); ?>
     516                        <div class="spinner no-float"></div>
    524517                        <?php submit_button( __( 'Save Draft' ), 'primary', 'save', false, array( 'id' => 'save-post' ) ); ?>
    525518                        <br class="clear" />
    526519                </p>
    527520
    528521        </form>
     522        <div id="quick-press-drafts" class="drafts">
     523                <p class="view-all" style="display: none;">
     524                        <a href="<?php echo esc_url( admin_url( 'edit.php?post_status=draft' ) ) ?>" aria-label="<?php esc_attr_e( 'View all drafts' ) ?>"><?php _ex( 'View all', 'drafts' ) ?></a>
     525                </p>
     526                <h2 class="hide-if-no-js"><?php _e( 'Drafts' ) ?></h2>
     527                <ul class="drafts-list is-placeholder">
     528                        <li><span class="screen-reader-text"><?php _e( 'Loading&hellip;' ) ?></span></li>
     529                </ul>
     530        </div>
    529531        <?php
    530         wp_dashboard_recent_drafts();
    531532}
    532533
    533534/**
     
    534535 * Show recent drafts of the user on the dashboard.
    535536 *
    536537 * @since 2.7.0
     538 * @deprecated 4.7
    537539 *
    538540 * @param array $drafts
    539541 */
     
    548550                        'order'          => 'DESC'
    549551                );
    550552
    551                 /**
    552                  * Filters the post query arguments for the 'Recent Drafts' dashboard widget.
    553                  *
    554                  * @since 4.4.0
    555                  *
    556                  * @param array $query_args The query arguments for the 'Recent Drafts' dashboard widget.
    557                  */
     553                /** This filter is documented in wp-includes/rest-api.php */
    558554                $query_args = apply_filters( 'dashboard_recent_drafts_query_args', $query_args );
    559555
    560556                $drafts = get_posts( $query_args );
     
    586582}
    587583
    588584/**
     585 * Get the HTML template for the Quick Draft recent posts.
     586 *
     587 * @since 4.7.0
     588 *
     589 * @return string The template HTML.
     590 */
     591function wp_dashboard_print_recent_drafts_template() {
     592        ?>
     593        <script id="tmpl-item-quick-press-draft" type="text/template">
     594                <div class="draft-title">
     595                        <a href="post.php?post={{ data.id }}&action=edit" aria-label="<?php esc_attr_e( 'Edit Post' ) ?>">{{ data.formattedTitle }}</a>
     596                        <time datetime="{{ data.date }}">{{ data.formattedDate }}</time>
     597                </div>
     598                {{{ data.formattedContent }}}
     599        </script>
     600        <?php
     601}
     602
     603/**
    589604 * Outputs a row for the Recent Comments widget.
    590605 *
    591606 * @access private
  • src/wp-admin/js/dashboard.js

     
    1 /* global pagenow, ajaxurl, postboxes, wpActiveEditor:true */
    2 var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad;
     1/* global _, wp, quickPress, pagenow, ajaxurl, postboxes, wpActiveEditor:true */
     2var ajaxWidgets, ajaxPopulateWidgets, QuickDraft = {};
    33
    44jQuery(document).ready( function($) {
    55        var welcomePanel = $( '#welcome-panel' ),
     
    5959        };
    6060        ajaxPopulateWidgets();
    6161
    62         postboxes.add_postbox_toggles(pagenow, { pbshow: ajaxPopulateWidgets } );
     62        postboxes.add_postbox_toggles(pagenow, { pbshow: function( id ) {
     63                ajaxPopulateWidgets();
    6364
    64         /* QuickPress */
    65         quickPressLoad = function() {
    66                 var act = $('#quickpost-action'), t;
     65                if ( 'dashboard_quick_press' === id ) {
     66                        QuickDraft.init();
     67                }
     68        } } );
    6769
    68                 $( '#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]' ).prop( 'disabled' , false );
    69 
    70                 t = $('#quick-press').submit( function( e ) {
    71                         e.preventDefault();
    72                         $('#dashboard_quick_press #publishing-action .spinner').show();
    73                         $('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').prop('disabled', true);
    74 
    75                         $.post( t.attr( 'action' ), t.serializeArray(), function( data ) {
    76                                 // Replace the form, and prepend the published post.
    77                                 $('#dashboard_quick_press .inside').html( data );
    78                                 $('#quick-press').removeClass('initial-form');
    79                                 quickPressLoad();
    80                                 highlightLatestPost();
    81                                 $('#title').focus();
    82                         });
    83 
    84                         function highlightLatestPost () {
    85                                 var latestPost = $('.drafts ul li').first();
    86                                 latestPost.css('background', '#fffbe5');
    87                                 setTimeout(function () {
    88                                         latestPost.css('background', 'none');
    89                                 }, 1000);
    90                         }
    91                 } );
    92 
    93                 $('#publish').click( function() { act.val( 'post-quickpress-publish' ); } );
    94 
    95                 $('#title, #tags-input, #content').each( function() {
    96                         var input = $(this), prompt = $('#' + this.id + '-prompt-text');
    97 
    98                         if ( '' === this.value ) {
    99                                 prompt.removeClass('screen-reader-text');
    100                         }
    101 
    102                         prompt.click( function() {
    103                                 $(this).addClass('screen-reader-text');
    104                                 input.focus();
    105                         });
    106 
    107                         input.blur( function() {
    108                                 if ( '' === this.value ) {
    109                                         prompt.removeClass('screen-reader-text');
    110                                 }
    111                         });
    112 
    113                         input.focus( function() {
    114                                 prompt.addClass('screen-reader-text');
    115                         });
    116                 });
    117 
    118                 $('#quick-press').on( 'click focusin', function() {
    119                         wpActiveEditor = 'content';
    120                 });
    121 
    122                 autoResizeTextarea();
    123         };
    124         quickPressLoad();
    125 
    12670        $( '.meta-box-sortables' ).sortable( 'option', 'containment', '#wpwrap' );
    12771
    12872        function autoResizeTextarea() {
     
    186130                });
    187131        }
    188132
     133        autoResizeTextarea();
     134
     135        if ( jQuery( '#dashboard_quick_press' ).is( ':visible' ) ) {
     136                QuickDraft.init();
     137        }
     138});
     139
     140// Set up the QuickDraft views.
     141QuickDraft.Views = {};
     142
     143/**
     144 * Set up a view object for the quick draft form.
     145 *
     146 * @since 4.7.0
     147 *
     148 * @augments wp.Backbone.View
     149 */
     150QuickDraft.Views.Form = wp.Backbone.View.extend( {
     151
     152        // Set up our default action handlers.
     153        events: {
     154
     155                // Hide the prompt whena field receives focus.
     156                'focus :input': 'hidePrompt',
     157
     158                // Possibly re-display the prompt when a field looses focus.
     159                'blur :input':  'showPrompt',
     160
     161                // Listen for a reset event, showing all prompts.
     162                'reset':        'showAllPrompts',
     163
     164                // Listed for and handle form submissions.
     165                'submit':       'handleFormSubmission'
     166        },
     167
     168        // Initialize the QuickDraft Form view.
     169        initialize: function() {
     170
     171                // Show all prompts n the form to begin.
     172                this.showAllPrompts();
     173
     174                // Add some listeners to handle events on the underlying model containing the form data.
     175                this.model.on( 'invalid', _.bind( this.render, this ) );
     176                this.model.on( 'error',   _.bind( this.showSyncError, this ) );
     177        },
     178
     179        /**
     180         * Handle toggling of the helper prompts shown inside each field.
     181         *
     182         * Will only show the prompt if the field is empty.
     183         *
     184         * @param  {object}  element Field element containing the helper prompt.
     185         * @param  {boolean} visible Should the prompt be visible?
     186         */
     187        togglePrompt: function( element, visible ) {
     188                var $input = jQuery( element ),
     189                        hasContent = $input.val().length > 0;
     190
     191                jQuery( element ).siblings( '.prompt' ).toggleClass( 'screen-reader-text', ! visible || hasContent );
     192        },
     193
     194        // Show all of the field promts.
     195        showAllPrompts: function() {
     196                this.$el.find( ':input' ).each( _.bind( function( i, input ) {
     197
     198                        // Prompt toggling must be deferred because the reset event is
     199                        // fired before the input values have been cleared
     200                        _.defer( _.bind( this.togglePrompt, this, input, true ) );
     201                }, this ) );
     202        },
     203
     204        /**
     205         * Show the prompt inside a field.
     206         *
     207         * @param {object} event The event triggering this show request.
     208         */
     209        showPrompt: function( event ) {
     210                this.togglePrompt( event.target, true );
     211        },
     212
     213        /**
     214         * Hide the prompt inside a field.
     215         *
     216         * @param {object} event The event triggering this hide request.
     217         */
     218        hidePrompt: function( event ) {
     219                this.togglePrompt( event.target, false );
     220        },
     221
     222        /**
     223         * When the model fires an error, show and speak the error.
     224         *
     225         * @param  {object} model The underlying Backbone model containing the form data.
     226         * @param  {object} error The error object.
     227         */
     228        showSyncError: function( model, error ) {
     229                try {
     230                        this.syncError = JSON.parse( error.responseText ).message;
     231                } catch( e ) {
     232                        this.syncError = quickPress.l10n.error;
     233                }
     234
     235                // Alert screen readers that an error occurred.
     236                wp.a11y.speak( quickPress.l10n.error );
     237
     238                // Re-render the form.
     239                this.render();
     240        },
     241
     242        /**
     243         * Handle the form submission event.
     244         *
     245         * @param {object} event The form submission event.
     246         */
     247        handleFormSubmission: function( event ) {
     248                var values;
     249
     250                // remove any previous error condition.
     251                delete this.syncError;
     252
     253                // Prevent the browser's default form submission handling.
     254                event.preventDefault();
     255
     256                // Extract the form field values.
     257                values = _.reduce( this.$el.serializeArray(), function( memo, field ) {
     258                        memo[ field.name ] = field.value;
     259                        return memo;
     260                }, {} );
     261
     262                // Save the new values to the model and confirm they are valid.
     263                this.model.set( values );
     264                if ( ! this.model.isValid() ) {
     265                        return;
     266                }
     267
     268                // Show a spinner during the callback.
     269                this.$el.addClass( 'is-saving' );
     270
     271                // Trigger the model save.
     272                this.model.save()
     273
     274                        // Always remove the spinner.
     275                        .always(
     276                                _.bind( function() {
     277                                        this.$el.removeClass( 'is-saving' );
     278                                }, this )
     279                        )
     280
     281                        // Handle save success.
     282                        .success(
     283                                _.bind( function() {
     284
     285                                        // Add the post model to the head of our collection.
     286                                        this.collection.add( this.model, { at: 0 } );
     287
     288                                        // Create a new post model to contain the form data and reset the form.
     289                                        this.model = new wp.api.models.Post();
     290                                        this.el.reset();
     291                                }, this )
     292                        );
     293        },
     294
     295        // Render the form view.
     296        render: function() {
     297                var $error = this.$el.find( '.notice-alt' ),
     298                        errorText;
     299
     300                if ( this.syncError ) {
     301
     302                        // Set the error text to the syncError.
     303                        errorText = this.syncError;
     304                }
     305
     306                // Error notice is only visible if error text is set.
     307                $error.toggle( !! errorText );
     308                if ( errorText ) {
     309
     310                        // Note: The inner text transform prevents XSS via html().
     311                        $error.html( jQuery( '<p />', { text: errorText } ) );
     312                }
     313        }
    189314} );
     315
     316/**
     317 * Set up a view object for the Quick Draft list of drafts.
     318 *
     319 * @since 4.7.0
     320 *
     321 * @augments wp.Backbone.View
     322 */
     323QuickDraft.Views.DraftList = wp.Backbone.View.extend( {
     324
     325        // Initialize the draft list view.
     326        initialize: function() {
     327
     328                // Render the view once the drafts have loaded.
     329                this.listenTo( this.collection, 'sync', this.onDraftsLoaded );
     330        },
     331
     332        // Once the drafts have loaded, complete the setup.
     333        onDraftsLoaded: function() {
     334
     335                // Add a listener for new items added to the underlying (draft) post collection.
     336                this.listenTo( this.collection, 'add', this.renderNew );
     337
     338                // Render the view!
     339                this.render();
     340        },
     341
     342        // Handle a new item being added to the collection.
     343        renderNew: function() {
     344
     345                // Display highlight effect to first (added) item for one second.
     346                var $newEl = this.render().$el.find( 'li:first' ).addClass( 'is-new' );
     347                setTimeout( function() {
     348                        $newEl.removeClass( 'is-new' );
     349                }, 1000 );
     350
     351                // Alert screen readers that a new draft has been added.
     352                wp.a11y.speak( quickPress.l10n.newDraftCreated );
     353        },
     354
     355        // Render the draft post list view.
     356        render: function() {
     357
     358                // Hide drafts list entirely if no drafts exist.
     359                this.$el.toggle( this.collection.length > 0 );
     360
     361                // Display a 'View All' link if there are more drafts available.
     362                this.$el.find( '.view-all' ).toggle( this.collection.hasMore() );
     363
     364                // Remove the placeholder class and render the models.
     365                this.$el.find( '.drafts-list' )
     366                        .removeClass( 'is-placeholder' )
     367                        .html(
     368                                _.map( this.collection.models, function( draft ) {
     369                                        return new QuickDraft.Views.DraftListItem( {
     370                                                model: draft
     371                                        } ).render().el;
     372                                } )
     373                        );
     374
     375                return this;
     376        }
     377} );
     378
     379/**
     380 * Set up a view object an individual draft in the draft list.
     381 *
     382 * @since 4.7.0
     383 *
     384 * @augments wp.Backbone.View
     385 */
     386QuickDraft.Views.DraftListItem = wp.Backbone.View.extend( {
     387        tagName: 'li',
     388
     389        // Render beased on the passed template.
     390        template: wp.template( 'item-quick-press-draft' ),
     391
     392        // Render a single draft list item.
     393        render: function() {
     394
     395                // Clone the original model attributes, so we can leave the model untouched.
     396                var attributes = _.clone( this.model.attributes );
     397
     398                // Trim the content to 10 words.
     399                attributes.formattedContent = wp.formatting.trimWords( attributes.content.rendered, 10 );
     400
     401                // If the title is missing entirely, add a no title placeholder.
     402                attributes.formattedTitle = attributes.title.rendered.length > 0 ? attributes.title.rendered : quickPress.l10n.noTitle;
     403
     404                // Format the data using Intl.DateTimeFormat with a fallback to date.toLocaleDateString.
     405                var date = new Date( wp.api.utils.parseISO8601( attributes.date + quickPress.timezoneOffset ) );
     406                if ( 'undefined' !== typeof Intl && Intl.DateTimeFormat ) {
     407                        attributes.formattedDate = new Intl.DateTimeFormat( undefined, {
     408                                month: 'long',
     409                                day: 'numeric',
     410                                year: 'numeric'
     411                        } ).format( date );
     412                } else {
     413                        attributes.formattedDate = date.toLocaleDateString();
     414                }
     415
     416                // Output the rendered template.
     417                this.$el.html( this.template( attributes ) );
     418
     419                // Continue the rendering chain.
     420                return this;
     421        }
     422} );
     423
     424
     425/**
     426 * Initialize the Quick Draft feature.
     427 *
     428 * @since 4.7.0
     429 *
     430 */
     431QuickDraft.init = function() {
     432
     433        // Wait for the wp-api client to initialize.
     434        wp.api.loadPromise.done( function() {
     435
     436                // Fetch up to 4 of the current user's recent drafts by extending wp.api.collections.Posts.
     437                var draftsCollection = new wp.api.collections.Posts();
     438                draftsCollection.fetch( {
     439                        data: {
     440                                status: 'draft',
     441                                author: quickPress.currentUserId,
     442                                per_page: 4,
     443                                order_by: 'date',
     444                                'quick-draft-post-list': true /* flag passed for back end filters */
     445                        }
     446                } );
     447
     448                // Drafts list is initialized but not rendered until drafts load.
     449                new QuickDraft.Views.DraftList( {
     450                        el: '#quick-press-drafts',
     451                        collection: draftsCollection
     452                } );
     453
     454                new QuickDraft.Views.Form( {
     455                        el: '#quick-press',
     456                        model: new wp.api.models.Post(),
     457                        collection: draftsCollection
     458                } ).render();
     459        });
     460};
  • src/wp-includes/js/wp-util.js

     
    121121                }
    122122        };
    123123
     124        // wp.formatting
     125        // ------
     126        //
     127        // Tools for formatting strings
     128        wp.formatting = {
     129                settings: settings.formatting || {},
     130
     131                /**
     132                 * Trims text to a certain number of words.
     133                 *
     134                 * @see wp_trim_words
     135                 *
     136                 * @param  {string} text     Text to trim.
     137                 * @param  {number} numWords Number of words. Optional, default is 55.
     138                 * @param  {string} more     What to append if text needs to be trimmed. Optional, default is '…'.
     139                 * @return {string}          Trimmed text.
     140                 */
     141                trimWords: function( text, numWords, more ) {
     142                        var words, separator;
     143
     144                        if ( 'undefined' === typeof numWords ) {
     145                                numWords = 55;
     146                        }
     147
     148                        if ( 'undefined' === typeof more ) {
     149                                more = wp.formatting.settings.trimWordsMore;
     150                        }
     151
     152                        text = text.replace( /[\n\r\t ]+/g, ' ' ).replace( /^ | $/g, '' );
     153
     154                        if ( wp.formatting.settings.trimWordsByCharacter ) {
     155                                separator = '';
     156                        } else {
     157                                separator = ' ';
     158                        }
     159
     160                        words = text.split( separator );
     161
     162                        if ( words.length <= numWords ) {
     163                                return words.join( separator );
     164                        }
     165
     166                        return words.slice( 0, numWords ).join( separator ) + more;
     167                }
     168        };
     169
    124170}(jQuery));
  • src/wp-includes/rest-api.php

     
    164164        add_filter( 'rest_post_dispatch', 'rest_send_allow_header', 10, 3 );
    165165
    166166        add_filter( 'rest_pre_dispatch', 'rest_handle_options_request', 10, 3 );
     167
     168        // Legacy filter for Quick Draft recent posts.
     169        add_filter( 'rest_post_query', 'rest_filter_quick_draft_query', 10, 2 );
    167170}
    168171
    169172/**
     173 * Filter query args used by he Quick Draft recent posts list.
     174 *
     175 * @param array           $args    Key value array of query var to query value.
     176 * @param WP_REST_Request $request The request used.
     177 */
     178function rest_filter_quick_draft_query( $query_args, $request ) {
     179
     180        // Only modify Quick Draft queries.
     181        $params = $request->get_query_params();
     182
     183        if ( ! isset( $params['quick-draft-post-list'] ) ) {
     184                return $query_args;
     185        }
     186
     187        /**
     188         * Filters the post query arguments for the 'Recent Drafts' dashboard widget.
     189         *
     190         * @since 4.4.0
     191         *
     192         * @param array $query_args The query arguments for the 'Recent Drafts' dashboard widget.
     193         */
     194        $query_args = apply_filters( 'dashboard_recent_drafts_query_args', $query_args );
     195
     196        return $query_args;
     197
     198}
     199
     200/**
    170201 * Registers default REST API routes.
    171202 *
    172203 * @since 4.7.0
  • src/wp-includes/script-loader.php

     
    336336                'ajax' => array(
    337337                        'url' => admin_url( 'admin-ajax.php', 'relative' ),
    338338                ),
     339                'formatting' => array(
     340                        'trimWordsMore'  => __( '&hellip;' ),
     341                        /*
     342                         * translators: If your word count is based on single characters (e.g. East Asian characters),
     343                         * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
     344                         * Do not translate into your own language.
     345                         */
     346                        'trimWordsByCharacter' => strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ),
     347                ),
    339348        ) );
    340349
    341350        $scripts->add( 'wp-backbone', "/wp-includes/js/wp-backbone$suffix.js", array('backbone', 'wp-util'), false, 1 );
     
    721730                        'current' => __( 'Current Color' ),
    722731                ) );
    723732
    724                 $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), false, 1 );
     733                $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox', 'wp-api', 'wp-backbone', 'wp-a11y', 'wp-util' ), false, 1 );
     734                did_action( 'init' ) && $scripts->localize( 'dashboard', 'quickPress', array(
     735                        'currentUserId'  => get_current_user_id(),
     736                        'l10n' => array(
     737                                'error'           => __( 'An error has occurred. Please reload the page and try again.' ),
     738                                'newDraftCreated' => __( 'Success. A new draft was created.' ),
     739                                'noTitle'         => __( '(no title)' ),
     740                        ),
     741                        'timezoneOffset' => ( get_option( 'gmt_offset' ) >= 0 ? '+' : '-' ) . date( 'H:i', abs( get_option( 'gmt_offset' ) * 3600 ) ),
     742                ) );
    725743
    726744                $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" );
    727745
  • tests/qunit/index.html

     
    6161                <script src="wp-admin/js/customize-base.js"></script>
    6262                <script src="wp-admin/js/customize-header.js"></script>
    6363                <script src="wp-includes/js/shortcode.js"></script>
     64                <script src="wp-includes/js/wp-util.js"></script>
    6465                <script src="wp-admin/js/customize-controls.js"></script>
    6566                <script src="wp-admin/js/customize-controls-utils.js"></script>
    6667                <script src="wp-admin/js/customize-nav-menus.js"></script>