Make WordPress Core

Ticket #38342: 38342-5.diff

File 38342-5.diff, 20.3 KB (added by aduth, 8 years ago)

Remove unrelated style updates to dashboard.js, adhere to spacing exceptions from JS guidelines

  • src/wp-admin/css/dashboard.css

    diff --git src/wp-admin/css/dashboard.css src/wp-admin/css/dashboard.css
    index 72b0230..3ef5d82 100644
    form.initial-form.quickpress-open input#title { 
    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 {
    form.initial-form.quickpress-open input#title { 
    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@keyframes loading-fade {
     554        0% { opacity: .5; }
     555        50% { opacity: 1; }
     556        100% { opacity: .5; }
     557}
     558
     559#dashboard_quick_press .drafts ul.is-placeholder li:before,
     560#dashboard_quick_press .drafts ul.is-placeholder li:after {
     561        content: '';
     562        display: block;
     563        height: 13px;
     564        background: #eee;
     565        animation: loading-fade 1.6s ease-in-out infinite;
     566}
     567
     568#dashboard_quick_press .drafts ul.is-placeholder li:before {
     569        margin-bottom: 5px;
     570        width: 40%;
     571}
     572
     573#dashboard_quick_press .drafts ul.is-placeholder li:after {
     574        width: 80%;
     575}
     576
    544577#dashboard_quick_press .drafts li {
    545578        margin-bottom: 1em;
    546579}
     580
     581#dashboard_quick_press .drafts li.is-new {
     582        background-color: #fffbe5;
     583}
     584
    547585#dashboard_quick_press .drafts li time {
    548586        color: #72777c;
    549587}
  • src/wp-admin/includes/dashboard.php

    diff --git src/wp-admin/includes/dashboard.php src/wp-admin/includes/dashboard.php
    index aab5976..b472072 100644
    function wp_dashboard_quick_press( $error_msg = false ) { 
    491491        $post_ID = (int) $post->ID;
    492492?>
    493493
    494         <form name="post" action="<?php echo esc_url( admin_url( 'post.php' ) ); ?>" method="post" id="quick-press" class="initial-form hide-if-no-js">
    495 
    496                 <?php if ( $error_msg ) : ?>
    497                 <div class="error"><?php echo $error_msg; ?></div>
    498                 <?php endif; ?>
     494        <form name="post" method="post" id="quick-press" class="initial-form hide-if-no-js">
    499495
    500496                <div class="input-text-wrap" id="title-wrap">
    501                         <label class="screen-reader-text prompt" for="title" id="title-prompt-text">
     497                        <label class="prompt" for="title" id="title-prompt-text">
    502498
    503499                                <?php
    504500                                /** This filter is documented in wp-admin/edit-form-advanced.php */
    505501                                echo apply_filters( 'enter_title_here', __( 'Title' ), $post );
    506502                                ?>
    507503                        </label>
    508                         <input type="text" name="post_title" id="title" autocomplete="off" />
     504                        <input type="text" name="title" id="title" autocomplete="off" />
    509505                </div>
    510506
    511507                <div class="textarea-wrap" id="description-wrap">
    512                         <label class="screen-reader-text prompt" for="content" id="content-prompt-text"><?php _e( 'What&#8217;s on your mind?' ); ?></label>
     508                        <label class="prompt" for="content" id="content-prompt-text"><?php _e( 'What&#8217;s on your mind?' ); ?></label>
    513509                        <textarea name="content" id="content" class="mceEditor" rows="3" cols="15" autocomplete="off"></textarea>
    514510                </div>
    515 
    516511                <p class="submit">
    517                         <input type="hidden" name="action" id="quickpost-action" value="post-quickdraft-save" />
    518                         <input type="hidden" name="post_ID" value="<?php echo $post_ID; ?>" />
    519                         <input type="hidden" name="post_type" value="post" />
    520                         <?php wp_nonce_field( 'add-post' ); ?>
     512                        <div class="error inline" style="display: none;"><p></p></div>
     513                        <div class="spinner no-float"></div>
    521514                        <?php submit_button( __( 'Save Draft' ), 'primary', 'save', false, array( 'id' => 'save-post' ) ); ?>
    522515                        <br class="clear" />
    523516                </p>
    function wp_dashboard_quick_press( $error_msg = false ) { 
    531524 * Show recent drafts of the user on the dashboard.
    532525 *
    533526 * @since 2.7.0
    534  *
    535  * @param array $drafts
    536527 */
    537 function wp_dashboard_recent_drafts( $drafts = false ) {
    538         if ( ! $drafts ) {
    539                 $query_args = array(
    540                         'post_type'      => 'post',
    541                         'post_status'    => 'draft',
    542                         'author'         => get_current_user_id(),
    543                         'posts_per_page' => 4,
    544                         'orderby'        => 'modified',
    545                         'order'          => 'DESC'
    546                 );
    547 
    548                 /**
    549                  * Filters the post query arguments for the 'Recent Drafts' dashboard widget.
    550                  *
    551                  * @since 4.4.0
    552                  *
    553                  * @param array $query_args The query arguments for the 'Recent Drafts' dashboard widget.
    554                  */
    555                 $query_args = apply_filters( 'dashboard_recent_drafts_query_args', $query_args );
    556 
    557                 $drafts = get_posts( $query_args );
    558                 if ( ! $drafts ) {
    559                         return;
    560                 }
    561         }
    562 
    563         echo '<div class="drafts">';
    564         if ( count( $drafts ) > 3 ) {
    565                 echo '<p class="view-all"><a href="' . esc_url( admin_url( 'edit.php?post_status=draft' ) ) . '" aria-label="' . __( 'View all drafts' ) . '">' . _x( 'View all', 'drafts' ) . "</a></p>\n";
    566         }
    567         echo '<h2 class="hide-if-no-js">' . __( 'Drafts' ) . "</h2>\n<ul>";
    568 
    569         $drafts = array_slice( $drafts, 0, 3 );
    570         foreach ( $drafts as $draft ) {
    571                 $url = get_edit_post_link( $draft->ID );
    572                 $title = _draft_or_post_title( $draft->ID );
    573                 echo "<li>\n";
    574                 /* translators: %s: post title */
    575                 echo '<div class="draft-title"><a href="' . esc_url( $url ) . '" aria-label="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ) . '">' . esc_html( $title ) . '</a>';
    576                 echo '<time datetime="' . get_the_time( 'c', $draft ) . '">' . get_the_time( __( 'F j, Y' ), $draft ) . '</time></div>';
    577                 if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) {
    578                         echo '<p>' . $the_content . '</p>';
    579                 }
    580                 echo "</li>\n";
    581         }
     528function wp_dashboard_recent_drafts() {
     529        echo '<div id="quick-press-drafts" class="drafts">';
     530        echo '<p class="view-all" style="display: none;"><a href="' . esc_url( admin_url( 'edit.php?post_status=draft' ) ) . '" aria-label="' . __( 'View all drafts' ) . '">' . _x( 'View all', 'drafts' ) . "</a></p>\n";
     531        echo '<h2 class="hide-if-no-js">' . __( 'Drafts' ) . "</h2>\n";
     532        echo '<script id="tmpl-item-quick-press-draft" type="text/template">';
     533        /* translators: %s: post title */
     534        echo '<div class="draft-title"><a href="post.php?post={{ data.id }}&action=edit" aria-label="' . esc_attr( __( 'Edit Post' ) ) . '">{{ data.title }}</a>';
     535        echo '<time datetime="{{ data.date }}">{{ data.formattedDate }}</time></div>';
     536        echo '{{{ data.formattedContent }}}';
     537        echo '</script>';
     538        echo '<ul class="drafts-list is-placeholder">';
     539        for ( $i = 0; $i < 4; $i++ ) {
     540                echo '<li><span class="screen-reader-text">' . esc_html( __( 'Loading…' ) ) . '</span></li>';
     541        }
    582542        echo "</ul>\n</div>";
    583543}
    584544
  • src/wp-admin/js/dashboard.js

    diff --git src/wp-admin/js/dashboard.js src/wp-admin/js/dashboard.js
    index fa100dd..6379b9b 100644
     
    1 /* global pagenow, ajaxurl, postboxes, wpActiveEditor:true */
    2 var ajaxWidgets, ajaxPopulateWidgets, quickPressLoad;
     1/* global _, wp, quickPress, pagenow, ajaxurl, postboxes, wpActiveEditor:true */
     2var ajaxWidgets, ajaxPopulateWidgets;
    33
    44jQuery(document).ready( function($) {
    55        var welcomePanel = $( '#welcome-panel' ),
    jQuery(document).ready( function($) { 
    6161
    6262        postboxes.add_postbox_toggles(pagenow, { pbshow: ajaxPopulateWidgets } );
    6363
    64         /* QuickPress */
    65         quickPressLoad = function() {
    66                 var act = $('#quickpost-action'), t;
    67 
    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 
    12664        $( '.meta-box-sortables' ).sortable( 'option', 'containment', '#wpwrap' );
    12765
    12866        function autoResizeTextarea() {
    jQuery(document).ready( function($) { 
    186124                });
    187125        }
    188126
     127        autoResizeTextarea();
    189128} );
     129
     130wp.api.loadPromise.done(function() {
     131        var $ = jQuery,
     132                QuickPress = {},
     133                draftsCollection;
     134
     135        /**
     136         * Models
     137         */
     138
     139        QuickPress.Models = {};
     140
     141        QuickPress.Models.Draft = wp.api.models.Post.extend({
     142                initialize: function( attributes ) {
     143                        if ( attributes ) {
     144                                this.set( this.normalizeAttributes( attributes ) );
     145                        }
     146                },
     147
     148                parse: function( response ) {
     149                        return this.normalizeAttributes( response );
     150                },
     151
     152                normalizeAttributes: function( attributes ) {
     153                        var date;
     154
     155                        if ( ! attributes ) {
     156                                return attributes;
     157                        }
     158
     159                        // Post entities from the REST API include the content and title in
     160                        // nested objects, but our new form model will assign as a string,
     161                        // so we normalize to simplify display logic
     162
     163                        if ( 'object' === typeof attributes.content ) {
     164                                attributes.content = attributes.content.rendered;
     165                        }
     166
     167                        if ( 'object' === typeof attributes.title ) {
     168                                attributes.title = attributes.title.rendered;
     169                        }
     170
     171                        attributes.formattedContent = wp.formatting.trimWords( attributes.content, 10 );
     172
     173                        // We can format dates using newer browser i18n features, but also
     174                        // provide a fallback to the not-as-nice Date#toLocaleDateString
     175                        date = new Date( wp.api.utils.parseISO8601( attributes.date ) );
     176                        date.setTime( date.getTime() + ( date.getTimezoneOffset() * 60 * 1000 ) );
     177                        if ( 'undefined' !== typeof Intl && Intl.DateTimeFormat ) {
     178                                attributes.formattedDate = new Intl.DateTimeFormat( undefined, {
     179                                        month: 'long',
     180                                        day: 'numeric',
     181                                        year: 'numeric'
     182                                }).format( date );
     183                        } else {
     184                                attributes.formattedDate = date.toLocaleDateString();
     185                        }
     186
     187                        return attributes;
     188                },
     189
     190                validate: function( attributes ) {
     191                        if ( ! attributes.title && ! attributes.content ) {
     192                                return 'no-content';
     193                        }
     194                }
     195        });
     196
     197        /**
     198         * Collections
     199         */
     200
     201        QuickPress.Collections = {};
     202
     203        QuickPress.Collections.Drafts = wp.api.collections.Posts.extend({
     204                model: QuickPress.Models.Draft,
     205
     206                comparator: function( a, b ) {
     207                        // Sort by date descending, date is an ISO8601 string and can be
     208                        // compared lexicographically
     209                        return a.get( 'date' ) < b.get( 'date' );
     210                }
     211        });
     212
     213        /**
     214         * Collections
     215         */
     216
     217        QuickPress.Views = {};
     218
     219        QuickPress.Views.Form = wp.Backbone.View.extend({
     220                events: {
     221                        'click :input': 'hidePromptAndFocus',
     222                        'focus :input': 'hidePrompt',
     223                        'blur :input': 'showPrompt',
     224                        reset: 'showAllPrompts',
     225                        click: 'setActiveEditor',
     226                        focusin: 'setActiveEditor',
     227                        submit: 'submit'
     228                },
     229
     230                initialize: function() {
     231                        this.showAllPrompts();
     232
     233                        this.listenTo( this.model, 'invalid', this.render );
     234                        this.listenTo( this.model, 'error', this.showSyncError );
     235                },
     236
     237                togglePrompt: function( element, visible ) {
     238                        var $input = $( element ),
     239                                hasContent = $input.val().length > 0;
     240
     241                        $( element ).siblings( '.prompt' ).toggleClass( 'screen-reader-text', ! visible || hasContent );
     242                },
     243
     244                showAllPrompts: function() {
     245                        this.$el.find( ':input' ).each( _.bind(function( i, input ) {
     246                                // Prompt toggling must be deferred because the reset event is
     247                                // fired before the input values have been cleared
     248                                _.defer( _.bind( this.togglePrompt, this, input, true ) );
     249                        }, this ) );
     250                },
     251
     252                showPrompt: function( event ) {
     253                        this.togglePrompt( event.target, true );
     254                },
     255
     256                hidePrompt: function( event ) {
     257                        this.togglePrompt( event.target, false );
     258                },
     259
     260                hidePromptAndFocus: function( event ) {
     261                        this.togglePrompt( event.target, false );
     262                        $( ':input', event.target ).focus();
     263                },
     264
     265                setActiveEditor: function() {
     266                        wpActiveEditor = 'content';
     267                },
     268
     269                showSyncError: function() {
     270                        this.syncError = true;
     271                        this.render();
     272                },
     273
     274                submit: function( event ) {
     275                        var values;
     276
     277                        delete this.syncError;
     278                        event.preventDefault();
     279
     280                        // jQuery's serializeArray returns an array of field tuples, which
     281                        // we need to transform into an object before sending to API
     282                        values = _.reduce( this.$el.serializeArray(), function( memo, field ) {
     283                                memo[ field.name ] = field.value;
     284                                return memo;
     285                        }, {});
     286
     287                        // Ensure that by setting these fields on model that it is valid
     288                        // before proceeding with save
     289                        this.model.set( values );
     290                        if ( ! this.model.isValid() ) {
     291                                return;
     292                        }
     293
     294                        // Show a spinner during the callback.
     295                        this.$el.addClass( 'is-saving' );
     296
     297                        this.model.save()
     298                                .always( _.bind(function() {
     299                                        this.$el.removeClass( 'is-saving' );
     300                                }, this ) )
     301                                .success( _.bind(function() {
     302                                        this.collection.add( this.model );
     303                                        this.model = new QuickPress.Models.Draft();
     304                                        this.el.reset();
     305                                }, this ) );
     306                },
     307
     308                render: function() {
     309                        var $error = this.$el.find( '.error' ),
     310                                errorText;
     311
     312                        if ( this.model.validationError ) {
     313                                // Error via submission validation
     314                                errorText = quickPress.l10n[ this.model.validationError ];
     315                        } else if ( this.syncError ) {
     316                                // Error via API save failure
     317                                errorText = quickPress.l10n.error;
     318                        }
     319
     320                        // Error notice is only visible if error text determined
     321                        $error.toggle( !! errorText );
     322                        if ( errorText ) {
     323                                $error.html( $( '<p />', { text: errorText }) );
     324                        }
     325                }
     326        });
     327
     328        QuickPress.Views.DraftList = wp.Backbone.View.extend({
     329                initialize: function() {
     330                        this.listenTo( this.collection, 'sync', this.onDraftsLoaded );
     331                },
     332
     333                onDraftsLoaded: function() {
     334                        this.listenTo( this.collection, 'add', this.renderNew );
     335                        this.render();
     336                },
     337
     338                renderNew: function() {
     339                        // Display highlight effect to first (added) item for one second
     340                        var $newEl = this.render().$el.find( 'li:first' ).addClass( 'is-new' );
     341                        setTimeout(function() {
     342                                $newEl.removeClass( 'is-new' );
     343                        }, 1000 );
     344                },
     345
     346                render: function() {
     347                        // Though we request only four drafts initially, since more will be
     348                        // added through the form, render only the first four sorted
     349                        var slicedCollection = this.collection.slice( 0, 4 );
     350
     351                        // Hide drafts list if no drafts exist
     352                        this.$el.toggle( this.collection.length > 0 );
     353
     354                        // "View All" link is visible if 4 or more drafts, since we only
     355                        // show a maximum of 4 drafts in the list
     356                        this.$el.find( '.view-all' ).toggle( slicedCollection.length > 3 );
     357
     358                        // If after drafts load, this could be the first render, so remove
     359                        // placeholder effect and render the first four drafts
     360                        this.$el.find( '.drafts-list' )
     361                                .removeClass( 'is-placeholder' )
     362                                .html( _.map( slicedCollection, function( draft ) {
     363                                        return new QuickPress.Views.DraftListItem({
     364                                                model: draft
     365                                        }).render().el;
     366                                }) );
     367
     368                        return this;
     369                }
     370        });
     371
     372        QuickPress.Views.DraftListItem = wp.Backbone.View.extend({
     373                tagName: 'li',
     374
     375                template: wp.template( 'item-quick-press-draft' ),
     376
     377                render: function() {
     378                        this.$el.html( this.template( this.model.attributes ) );
     379
     380                        return this;
     381                }
     382        });
     383
     384        /**
     385         * Initialize
     386         */
     387
     388        // Fetch drafts
     389        draftsCollection = new QuickPress.Collections.Drafts();
     390        draftsCollection.fetch({
     391                data: {
     392                        status: 'draft',
     393                        author: quickPress.currentUserId,
     394                        per_page: 4
     395                }
     396        });
     397
     398        // Drafts list is initialized but not rendered until drafts load
     399        new QuickPress.Views.DraftList({
     400                el: '#quick-press-drafts',
     401                collection: draftsCollection
     402        });
     403
     404        new QuickPress.Views.Form({
     405                el: '#quick-press',
     406                model: new QuickPress.Models.Draft(),
     407                collection: draftsCollection
     408        }).render();
     409});
  • src/wp-admin/post.php

    diff --git src/wp-admin/post.php src/wp-admin/post.php
    index 437d1bd..df78352 100644
    if ( ! $sendback || 
    6060}
    6161
    6262switch($action) {
    63 case 'post-quickdraft-save':
    64         // Check nonce and capabilities
    65         $nonce = $_REQUEST['_wpnonce'];
    66         $error_msg = false;
    67 
    68         // For output of the quickdraft dashboard widget
    69         require_once ABSPATH . 'wp-admin/includes/dashboard.php';
    70 
    71         if ( ! wp_verify_nonce( $nonce, 'add-post' ) )
    72                 $error_msg = __( 'Unable to submit this form, please refresh and try again.' );
    73 
    74         if ( ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {
    75                 exit;
    76         }
    77 
    78         if ( $error_msg )
    79                 return wp_dashboard_quick_press( $error_msg );
    80 
    81         $post = get_post( $_REQUEST['post_ID'] );
    82         check_admin_referer( 'add-' . $post->post_type );
    83 
    84         $_POST['comment_status'] = get_default_comment_status( $post->post_type );
    85         $_POST['ping_status']    = get_default_comment_status( $post->post_type, 'pingback' );
    86 
    87         edit_post();
    88         wp_dashboard_quick_press();
    89         exit;
    90 
    9163case 'postajaxpost':
    9264case 'post':
    9365        check_admin_referer( 'add-' . $post_type );
  • src/wp-includes/js/wp-util.js

    diff --git src/wp-includes/js/wp-util.js src/wp-includes/js/wp-util.js
    index 527441d..79ab07e 100644
    window.wp = window.wp || {}; 
    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 (default: 55).
     138                 * @param  {?string} more     What to append if text needs to be trimmed (default: '…').
     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/script-loader.php

    diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php
    index 143bfa1..f1aab74 100644
    function wp_default_scripts( &$scripts ) { 
    333333                'ajax' => array(
    334334                        'url' => admin_url( 'admin-ajax.php', 'relative' ),
    335335                ),
     336                'formatting' => array(
     337                        /*
     338                         * translators: If your word count is based on single characters (e.g. East Asian characters),
     339                         * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
     340                         * Do not translate into your own language.
     341                         */
     342                        'trimWordsByCharacter' => strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ),
     343                        'trimWordsMore'        => __( '&hellip;' ),
     344                ),
    336345        ) );
    337346
    338347        $scripts->add( 'wp-backbone', "/wp-includes/js/wp-backbone$suffix.js", array('backbone', 'wp-util'), false, 1 );
    function wp_default_scripts( &$scripts ) { 
    716725                        'current' => __( 'Current Color' ),
    717726                ) );
    718727
    719                 $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox' ), false, 1 );
     728                $scripts->add( 'dashboard', "/wp-admin/js/dashboard$suffix.js", array( 'jquery', 'admin-comments', 'postbox', 'wp-api', 'wp-backbone' ), false, 1 );
     729                did_action( 'init' ) && $scripts->localize( 'dashboard', 'quickPress', array(
     730                        'currentUserId' => get_current_user_id(),
     731                        'l10n' => array(
     732                                'no-content' => __( 'Post content cannot be empty.' ),
     733                                'error'      => __( 'An error has occurred. Please reload the page and try again.' )
     734                        )
     735                ) );
    720736
    721737                $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" );
    722738