Ticket #38342: 38342-4.diff
File 38342-4.diff, 25.1 KB (added by , 8 years ago) |
---|
-
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 { 518 518 resize: none; 519 519 } 520 520 521 #quick-press.is-saving .spinner { 522 visibility: inherit; 523 } 524 521 525 /* Dashboard Quick Draft - Drafts list */ 522 526 523 527 .js #dashboard_quick_press .drafts { … … form.initial-form.quickpress-open input#title { 541 545 margin: 0 12px; 542 546 } 543 547 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 544 577 #dashboard_quick_press .drafts li { 545 578 margin-bottom: 1em; 546 579 } 580 581 #dashboard_quick_press .drafts li.is-new { 582 background-color: #fffbe5; 583 } 584 547 585 #dashboard_quick_press .drafts li time { 548 586 color: #72777c; 549 587 } -
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 ) { 491 491 $post_ID = (int) $post->ID; 492 492 ?> 493 493 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"> 499 495 500 496 <div class="input-text-wrap" id="title-wrap"> 501 <label class=" screen-reader-textprompt" for="title" id="title-prompt-text">497 <label class="prompt" for="title" id="title-prompt-text"> 502 498 503 499 <?php 504 500 /** This filter is documented in wp-admin/edit-form-advanced.php */ 505 501 echo apply_filters( 'enter_title_here', __( 'Title' ), $post ); 506 502 ?> 507 503 </label> 508 <input type="text" name=" post_title" id="title" autocomplete="off" />504 <input type="text" name="title" id="title" autocomplete="off" /> 509 505 </div> 510 506 511 507 <div class="textarea-wrap" id="description-wrap"> 512 <label class=" screen-reader-textprompt" for="content" id="content-prompt-text"><?php _e( 'What’s on your mind?' ); ?></label>508 <label class="prompt" for="content" id="content-prompt-text"><?php _e( 'What’s on your mind?' ); ?></label> 513 509 <textarea name="content" id="content" class="mceEditor" rows="3" cols="15" autocomplete="off"></textarea> 514 510 </div> 515 516 511 <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> 521 514 <?php submit_button( __( 'Save Draft' ), 'primary', 'save', false, array( 'id' => 'save-post' ) ); ?> 522 515 <br class="clear" /> 523 516 </p> … … function wp_dashboard_quick_press( $error_msg = false ) { 531 524 * Show recent drafts of the user on the dashboard. 532 525 * 533 526 * @since 2.7.0 534 *535 * @param array $drafts536 527 */ 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 “%s”' ), $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 } 528 function 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 } 582 542 echo "</ul>\n</div>"; 583 543 } 584 544 -
src/wp-admin/js/dashboard.js
diff --git src/wp-admin/js/dashboard.js src/wp-admin/js/dashboard.js index fa100dd..7aad180 100644
1 /* global pagenow, ajaxurl, postboxes, wpActiveEditor:true */2 var ajaxWidgets, ajaxPopulateWidgets , quickPressLoad;1 /* global _, wp, quickPress, pagenow, ajaxurl, postboxes, wpActiveEditor:true */ 2 var ajaxWidgets, ajaxPopulateWidgets; 3 3 4 jQuery( document).ready( function($) {4 jQuery( document ).ready( function( $ ) { 5 5 var welcomePanel = $( '#welcome-panel' ), 6 welcomePanelHide = $( '#wp_welcome_panel-hide'),6 welcomePanelHide = $( '#wp_welcome_panel-hide' ), 7 7 updateWelcomePanel; 8 8 9 9 updateWelcomePanel = function( visible ) { … … jQuery(document).ready( function($) { 11 11 action: 'update-welcome-panel', 12 12 visible: visible, 13 13 welcomepanelnonce: $( '#welcomepanelnonce' ).val() 14 } );14 } ); 15 15 }; 16 16 17 if ( welcomePanel.hasClass( 'hidden') && welcomePanelHide.prop('checked') ) {18 welcomePanel.removeClass( 'hidden');17 if ( welcomePanel.hasClass( 'hidden' ) && welcomePanelHide.prop( 'checked' ) ) { 18 welcomePanel.removeClass( 'hidden' ); 19 19 } 20 20 21 $( '.welcome-panel-close, .welcome-panel-dismiss a', welcomePanel).click( function(e) {21 $( '.welcome-panel-close, .welcome-panel-dismiss a', welcomePanel).click( function(e) { 22 22 e.preventDefault(); 23 welcomePanel.addClass( 'hidden');23 welcomePanel.addClass( 'hidden' ); 24 24 updateWelcomePanel( 0 ); 25 $( '#wp_welcome_panel-hide').prop('checked', false);26 } );25 $( '#wp_welcome_panel-hide' ).prop( 'checked', false); 26 } ); 27 27 28 28 welcomePanelHide.click( function() { 29 welcomePanel.toggleClass( 'hidden', ! this.checked );29 welcomePanel.toggleClass( 'hidden', ! this.checked ); 30 30 updateWelcomePanel( this.checked ? 1 : 0 ); 31 } );31 } ); 32 32 33 33 // These widgets are sometimes populated via ajax 34 34 ajaxWidgets = ['dashboard_primary']; 35 35 36 36 ajaxPopulateWidgets = function(el) { 37 37 function show(i, id) { 38 var p, e = $( '#' + id + ' div.inside:visible').find('.widget-loading');38 var p, e = $( '#' + id + ' div.inside:visible' ).find( '.widget-loading' ); 39 39 if ( e.length ) { 40 40 p = e.parent(); 41 41 setTimeout( function(){ 42 42 p.load( ajaxurl + '?action=dashboard-widgets&widget=' + id + '&pagenow=' + pagenow, '', function() { 43 p.hide().slideDown( 'normal', function(){44 $(this).css( 'display', '');45 } );46 } );43 p.hide().slideDown( 'normal', function(){ 44 $(this).css( 'display', '' ); 45 } ); 46 } ); 47 47 }, i * 500 ); 48 48 } 49 49 } … … jQuery(document).ready( function($) { 61 61 62 62 postboxes.add_postbox_toggles(pagenow, { pbshow: ajaxPopulateWidgets } ); 63 63 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 126 64 $( '.meta-box-sortables' ).sortable( 'option', 'containment', '#wpwrap' ); 127 65 128 66 function autoResizeTextarea() { … … jQuery(document).ready( function($) { 131 69 } 132 70 133 71 // Add a hidden div. We'll copy over the text from the textarea to measure its height. 134 $( 'body').append( '<div class="quick-draft-textarea-clone" style="display: none;"></div>' );72 $( 'body' ).append( '<div class="quick-draft-textarea-clone" style="display: none;"></div>' ); 135 73 136 var clone = $( '.quick-draft-textarea-clone'),137 editor = $( '#content'),74 var clone = $( '.quick-draft-textarea-clone' ), 75 editor = $( '#content' ), 138 76 editorHeight = editor.height(), 139 77 // 100px roughly accounts for browser chrome and allows the 140 78 // save draft button to show on-screen at the same time. … … jQuery(document).ready( function($) { 142 80 143 81 // Match up textarea and clone div as much as possible. 144 82 // Padding cannot be reliably retrieved using shorthand in all browsers. 145 clone.css( {146 'font-family': editor.css( 'font-family'),147 'font-size': editor.css( 'font-size'),148 'line-height': editor.css( 'line-height'),149 'padding-bottom': editor.css( 'paddingBottom'),150 'padding-left': editor.css( 'paddingLeft'),151 'padding-right': editor.css( 'paddingRight'),152 'padding-top': editor.css( 'paddingTop'),83 clone.css( { 84 'font-family': editor.css( 'font-family' ), 85 'font-size': editor.css( 'font-size' ), 86 'line-height': editor.css( 'line-height' ), 87 'padding-bottom': editor.css( 'paddingBottom' ), 88 'padding-left': editor.css( 'paddingLeft' ), 89 'padding-right': editor.css( 'paddingRight' ), 90 'padding-top': editor.css( 'paddingTop' ), 153 91 'white-space': 'pre-wrap', 154 92 'word-wrap': 'break-word', 155 93 'display': 'none' 156 } );94 } ); 157 95 158 96 // propertychange is for IE < 9 159 editor.on( 'focus input propertychange', function() {97 editor.on( 'focus input propertychange', function() { 160 98 var $this = $(this), 161 99 // is to ensure that the height of a final trailing newline is included. 162 100 textareaContent = $this.val() + ' ', 163 101 // 2px is for border-top & border-bottom 164 cloneHeight = clone.css( 'width', $this.css('width')).text(textareaContent).outerHeight() + 2;102 cloneHeight = clone.css( 'width', $this.css( 'width' )).text(textareaContent).outerHeight() + 2; 165 103 166 104 // Default to having scrollbars 167 editor.css( 'overflow-y', 'auto');105 editor.css( 'overflow-y', 'auto' ); 168 106 169 107 // Only change the height if it has indeed changed and both heights are below the max. 170 108 if ( cloneHeight === editorHeight || ( cloneHeight >= editorMaxHeight && editorHeight >= editorMaxHeight ) ) { … … jQuery(document).ready( function($) { 180 118 } 181 119 182 120 // No scrollbars as we change height, not for IE < 9 183 editor.css( 'overflow', 'hidden');121 editor.css( 'overflow', 'hidden' ); 184 122 185 $this.css( 'height', editorHeight + 'px');186 } );123 $this.css( 'height', editorHeight + 'px' ); 124 } ); 187 125 } 188 126 127 autoResizeTextarea(); 128 129 } ); 130 131 wp.api.loadPromise.done( function() { 132 var $ = jQuery, 133 QuickPress = {}, 134 draftsCollection; 135 136 /** 137 * Models 138 */ 139 140 QuickPress.Models = {}; 141 142 QuickPress.Models.Draft = wp.api.models.Post.extend( { 143 initialize: function( attributes ) { 144 if ( attributes ) { 145 this.set( this.normalizeAttributes( attributes ) ); 146 } 147 }, 148 149 parse: function( response ) { 150 return this.normalizeAttributes( response ); 151 }, 152 153 normalizeAttributes: function( attributes ) { 154 var date; 155 156 if ( ! attributes ) { 157 return attributes; 158 } 159 160 // Post entities from the REST API include the content and title in 161 // nested objects, but our new form model will assign as a string, 162 // so we normalize to simplify display logic 163 164 if ( 'object' === typeof attributes.content ) { 165 attributes.content = attributes.content.rendered; 166 } 167 168 if ( 'object' === typeof attributes.title ) { 169 attributes.title = attributes.title.rendered; 170 } 171 172 attributes.formattedContent = wp.formatting.trimWords( attributes.content, 10 ); 173 174 // We can format dates using newer browser i18n features, but also 175 // provide a fallback to the not-as-nice Date#toLocaleDateString 176 date = new Date( wp.api.utils.parseISO8601( attributes.date ) ); 177 date.setTime( date.getTime() + ( date.getTimezoneOffset() * 60 * 1000 ) ); 178 if ( 'undefined' !== typeof Intl && Intl.DateTimeFormat ) { 179 attributes.formattedDate = new Intl.DateTimeFormat( undefined, { 180 month: 'long', 181 day: 'numeric', 182 year: 'numeric' 183 } ).format( date ); 184 } else { 185 attributes.formattedDate = date.toLocaleDateString(); 186 } 187 188 return attributes; 189 }, 190 191 validate: function( attributes ) { 192 if ( ! attributes.title && ! attributes.content ) { 193 return 'no-content'; 194 } 195 } 196 } ); 197 198 /** 199 * Collections 200 */ 201 202 QuickPress.Collections = {}; 203 204 QuickPress.Collections.Drafts = wp.api.collections.Posts.extend( { 205 model: QuickPress.Models.Draft, 206 207 comparator: function( a, b ) { 208 // Sort by date descending, date is an ISO8601 string and can be 209 // compared lexicographically 210 return a.get( 'date' ) < b.get( 'date' ); 211 } 212 } ); 213 214 /** 215 * Collections 216 */ 217 218 QuickPress.Views = {}; 219 220 QuickPress.Views.Form = wp.Backbone.View.extend( { 221 events: { 222 'click :input': 'hidePromptAndFocus', 223 'focus :input': 'hidePrompt', 224 'blur :input': 'showPrompt', 225 reset: 'showAllPrompts', 226 click: 'setActiveEditor', 227 focusin: 'setActiveEditor', 228 submit: 'submit' 229 }, 230 231 initialize: function() { 232 this.showAllPrompts(); 233 234 this.listenTo( this.model, 'invalid', this.render ); 235 this.listenTo( this.model, 'error', this.showSyncError ); 236 }, 237 238 togglePrompt: function( element, visible ) { 239 var $input = $( element ), 240 hasContent = $input.val().length > 0; 241 242 $( element ).siblings( '.prompt' ).toggleClass( 'screen-reader-text', ! visible || hasContent ); 243 }, 244 245 showAllPrompts: function() { 246 this.$el.find( ':input' ).each( _.bind( function( i, input ) { 247 // Prompt toggling must be deferred because the reset event is 248 // fired before the input values have been cleared 249 _.defer( _.bind( this.togglePrompt, this, input, true ) ); 250 }, this ) ); 251 }, 252 253 showPrompt: function( event ) { 254 this.togglePrompt( event.target, true ); 255 }, 256 257 hidePrompt: function( event ) { 258 this.togglePrompt( event.target, false ); 259 }, 260 261 hidePromptAndFocus: function( event ) { 262 this.togglePrompt( event.target, false ); 263 $( ':input', event.target ).focus(); 264 }, 265 266 setActiveEditor: function() { 267 wpActiveEditor = 'content'; 268 }, 269 270 showSyncError: function() { 271 this.syncError = true; 272 this.render(); 273 }, 274 275 submit: function( event ) { 276 var values; 277 278 delete this.syncError; 279 event.preventDefault(); 280 281 // jQuery's serializeArray returns an array of field tuples, which 282 // we need to transform into an object before sending to API 283 values = _.reduce( this.$el.serializeArray(), function( memo, field ) { 284 memo[ field.name ] = field.value; 285 return memo; 286 }, {} ); 287 288 // Ensure that by setting these fields on model that it is valid 289 // before proceeding with save 290 this.model.set( values ); 291 if ( ! this.model.isValid() ) { 292 return; 293 } 294 295 // Show a spinner during the callback. 296 this.$el.addClass( 'is-saving' ); 297 298 this.model.save() 299 .always( _.bind( function() { 300 this.$el.removeClass( 'is-saving' ); 301 }, this ) ) 302 .success( _.bind( function() { 303 this.collection.add( this.model ); 304 this.model = new QuickPress.Models.Draft(); 305 this.el.reset(); 306 }, this ) ); 307 }, 308 309 render: function() { 310 var $error = this.$el.find( '.error' ), 311 errorText; 312 313 if ( this.model.validationError ) { 314 // Error via submission validation 315 errorText = quickPress.l10n[ this.model.validationError ]; 316 } else if ( this.syncError ) { 317 // Error via API save failure 318 errorText = quickPress.l10n.error; 319 } 320 321 // Error notice is only visible if error text determined 322 $error.toggle( !! errorText ); 323 if ( errorText ) { 324 $error.html( $( '<p />', { text: errorText } ) ); 325 } 326 } 327 } ); 328 329 QuickPress.Views.DraftList = wp.Backbone.View.extend( { 330 initialize: function() { 331 this.listenTo( this.collection, 'sync', this.onDraftsLoaded ); 332 }, 333 334 onDraftsLoaded: function() { 335 this.listenTo( this.collection, 'add', this.renderNew ); 336 this.render(); 337 }, 338 339 renderNew: function() { 340 // Display highlight effect to first (added) item for one second 341 var $newEl = this.render().$el.find( 'li:first' ).addClass( 'is-new' ); 342 setTimeout( function() { 343 $newEl.removeClass( 'is-new' ); 344 }, 1000 ); 345 }, 346 347 render: function() { 348 // Though we request only four drafts initially, since more will be 349 // added through the form, render only the first four sorted 350 var slicedCollection = this.collection.slice( 0, 4 ); 351 352 // Hide drafts list if no drafts exist 353 this.$el.toggle( this.collection.length > 0 ); 354 355 // "View All" link is visible if 4 or more drafts, since we only 356 // show a maximum of 4 drafts in the list 357 this.$el.find( '.view-all' ).toggle( slicedCollection.length > 3 ); 358 359 // If after drafts load, this could be the first render, so remove 360 // placeholder effect and render the first four drafts 361 this.$el.find( '.drafts-list' ) 362 .removeClass( 'is-placeholder' ) 363 .html( _.map( slicedCollection, function( draft ) { 364 return new QuickPress.Views.DraftListItem( { 365 model: draft 366 } ).render().el; 367 } ) ); 368 369 return this; 370 } 371 } ); 372 373 QuickPress.Views.DraftListItem = wp.Backbone.View.extend( { 374 tagName: 'li', 375 376 template: wp.template( 'item-quick-press-draft' ), 377 378 render: function() { 379 this.$el.html( this.template( this.model.attributes ) ); 380 381 return this; 382 } 383 } ); 384 385 /** 386 * Initialize 387 */ 388 389 // Fetch drafts 390 draftsCollection = new QuickPress.Collections.Drafts(); 391 draftsCollection.fetch( { 392 data: { 393 status: 'draft', 394 author: quickPress.currentUserId, 395 per_page: 4 396 } 397 } ); 398 399 // Drafts list is initialized but not rendered until drafts load 400 new QuickPress.Views.DraftList( { 401 el: '#quick-press-drafts', 402 collection: draftsCollection 403 } ); 404 405 new QuickPress.Views.Form( { 406 el: '#quick-press', 407 model: new QuickPress.Models.Draft(), 408 collection: draftsCollection 409 } ).render(); 189 410 } ); -
src/wp-admin/post.php
diff --git src/wp-admin/post.php src/wp-admin/post.php index 437d1bd..df78352 100644
if ( ! $sendback || 60 60 } 61 61 62 62 switch($action) { 63 case 'post-quickdraft-save':64 // Check nonce and capabilities65 $nonce = $_REQUEST['_wpnonce'];66 $error_msg = false;67 68 // For output of the quickdraft dashboard widget69 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 91 63 case 'postajaxpost': 92 64 case 'post': 93 65 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 || {}; 121 121 } 122 122 }; 123 123 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 124 170 }(jQuery)); -
src/wp-includes/script-loader.php
diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php index 143bfa1..95bed93 100644
function wp_default_scripts( &$scripts ) { 333 333 'ajax' => array( 334 334 'url' => admin_url( 'admin-ajax.php', 'relative' ), 335 335 ), 336 'formatting' => array( 337 'trimWordsMore' => __( '…' ), 338 /* 339 * translators: If your word count is based on single characters (e.g. East Asian characters), 340 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'. 341 * Do not translate into your own language. 342 */ 343 'trimWordsByCharacter' => strpos( _x( 'words', 'Word count type. Do not translate!' ), 'characters' ) === 0 && preg_match( '/^utf\-?8$/i', get_option( 'blog_charset' ) ), 344 ), 336 345 ) ); 337 346 338 347 $scripts->add( 'wp-backbone', "/wp-includes/js/wp-backbone$suffix.js", array('backbone', 'wp-util'), false, 1 ); … … function wp_default_scripts( &$scripts ) { 716 725 'current' => __( 'Current Color' ), 717 726 ) ); 718 727 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 ) ); 720 736 721 737 $scripts->add( 'list-revisions', "/wp-includes/js/wp-list-revisions$suffix.js" ); 722 738