Make WordPress Core

Changeset 26221


Ignore:
Timestamp:
11/15/2013 08:39:37 PM (13 years ago)
Author:
nacin
Message:

Merge wp_dashboard_recent_quickdrafts() into wp_dashboard_quick_press(). see #25824.

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/wp-admin.css

    r26220 r26221  
    30943094}
    30953095
    3096 #draft-list {
     3096#dashboard_quick_press .drafts ul {
    30973097        margin: 0;
    30983098}
    30993099
    3100 #draft-list li {
     3100#dashboard_quick_press .drafts li {
    31013101        margin-bottom: 1em;
    31023102}
    3103 #draft-list li time {
     3103#dashboard_quick_press .drafts li time {
    31043104        color: #bbb;
    31053105}
    31063106
    3107 #draft-list p {
     3107#dashboard_quick_press .drafts p {
    31083108        margin: 0;
    31093109}
    31103110
    3111 #draft-list .draft-title {
     3111#dashboard_quick_press .draft-title {
    31123112        overflow: hidden;
    31133113}
    31143114
    3115 #draft-list .draft-title a,
    3116 #draft-list .draft-title time {
     3115#dashboard_quick_press .draft-title a,
     3116#dashboard_quick_press .draft-title time {
    31173117        float: left;
    31183118        margin: 0 5px 0 0;
  • trunk/src/wp-admin/includes/dashboard.php

    r26220 r26221  
    338338
    339339        </form>
    340 
    341 <?php
    342         wp_dashboard_recent_quickdrafts();
    343 }
    344 
    345 /**
    346  * Show `Recent Drafts` below Quick Draft form
    347  *
    348  *
    349  *
    350  * @since 3.8.0
    351  *
    352  */
    353 function wp_dashboard_recent_quickdrafts() {
    354 
     340        <?php
    355341        $query_args = array(
    356342                'post_type'      => 'post',
    357343                'post_status'    => 'draft',
    358                 'author'         => $GLOBALS['current_user']->ID,
     344                'author'         => get_current_user_id(),
    359345                'posts_per_page' => 4,
    360346                'orderby'        => 'modified',
    361347                'order'          => 'DESC'
    362348        );
    363         $query_args = apply_filters( 'dash_recent_quickdrafts_query_args', $query_args );
    364         $drafts_query = new WP_Query( $query_args );
    365         $drafts =& $drafts_query->posts;
    366 
    367 
    368         if ( $drafts && is_array( $drafts ) ) {
    369                 $list = array();
    370                 $draft_count = 0;
    371                 foreach ( $drafts as $draft ) {
    372                         if ( 3 == $draft_count )
    373                                 break;
    374 
    375                         $draft_count++;
    376 
    377                         $url = get_edit_post_link( $draft->ID );
    378                         $title = _draft_or_post_title( $draft->ID );
    379                         $item = '<div class="draft-title"><a href="' . $url . '" title="' . sprintf( __( 'Edit &#8220;%s&#8221;' ), esc_attr( $title ) ) . '">' . esc_html( $title ) . '</a> <time datetime="' . get_the_time( 'c', $draft) . '">' . get_the_time( get_option( 'date_format' ), $draft ) . '</time></div>';
    380                         if ( $the_content = wp_trim_words( $draft->post_content, 10 ) )
    381                                 $item .= '<p>' . $the_content . '</p>';
    382                         $list[] = $item;
    383                 }
    384 
    385                 do_action( 'dashboard_quickdraft_drafts_list', $drafts );
    386 ?>
    387         <div class="drafts">
    388                 <?php if ( 3 < count($drafts) ) { ?>
    389                 <p class="view-all"><a href="edit.php?post_status=draft" ><?php _e( 'View all' ); ?></a></p>
    390                 <?php } ?>
    391                 <h4><?php _e('Drafts'); ?></h4>
    392                 <ul id="draft-list">
    393                         <li><?php echo join( "</li>\n<li>", $list ); ?></li>
    394                 </ul>
    395         </div>
    396 <?php }
     349        $drafts = get_posts( $query_args );
     350        if ( ! $drafts ) {
     351                return;
     352        }
     353 
     354        echo '<div class="drafts">';
     355        if ( count( $drafts ) > 3 ) {
     356                echo '<p class="view-all"><a href="' . esc_url( admin_url( 'edit.php?post_status=draft' ) ) . '">' . _x( 'View all', 'drafts' ) . "</a></p>\n";
     357        }
     358        echo '<h4>' . __( 'Drafts' ) . "</h4>\n<ul>";
     359 
     360        $drafts = array_slice( $drafts, 0, 3 );
     361        foreach ( $drafts as $draft ) {
     362                $url = get_edit_post_link( $draft->ID );
     363                $title = _draft_or_post_title( $draft->ID );
     364                echo "<li>\n";
     365                echo '<div class="draft-title"><a href="' . esc_url( $url ) . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ) . '">' . esc_html( $title ) . '</a>';
     366                echo '<time datetime="' . get_the_time( 'c', $draft ) . '">' . get_the_time( get_option( 'date_format' ), $draft ) . '</time></div>';
     367                if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) {
     368                        echo '<p>' . $the_content . '</p>';
     369                }
     370                echo "</li>\n";
     371        }
     372        echo "</ul>\n</div>";
    397373}
    398374
Note: See TracChangeset for help on using the changeset viewer.