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

Built from https://develop.svn.wordpress.org/trunk@26221


git-svn-id: http://core.svn.wordpress.org/trunk@26129 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-11-15 20:40:15 +00:00
parent 2cc8ed1594
commit 963b2aa574
5 changed files with 42 additions and 66 deletions

View File

@ -3093,27 +3093,27 @@ form.initial-form.quickpress-open input#title {
font-weight: normal; font-weight: normal;
} }
#draft-list { #dashboard_quick_press .drafts ul {
margin: 0; margin: 0;
} }
#draft-list li { #dashboard_quick_press .drafts li {
margin-bottom: 1em; margin-bottom: 1em;
} }
#draft-list li time { #dashboard_quick_press .drafts li time {
color: #bbb; color: #bbb;
} }
#draft-list p { #dashboard_quick_press .drafts p {
margin: 0; margin: 0;
} }
#draft-list .draft-title { #dashboard_quick_press .draft-title {
overflow: hidden; overflow: hidden;
} }
#draft-list .draft-title a, #dashboard_quick_press .draft-title a,
#draft-list .draft-title time { #dashboard_quick_press .draft-title time {
float: right; float: right;
margin: 0 0 0 5px; margin: 0 0 0 5px;
} }

File diff suppressed because one or more lines are too long

View File

@ -3093,27 +3093,27 @@ form.initial-form.quickpress-open input#title {
font-weight: normal; font-weight: normal;
} }
#draft-list { #dashboard_quick_press .drafts ul {
margin: 0; margin: 0;
} }
#draft-list li { #dashboard_quick_press .drafts li {
margin-bottom: 1em; margin-bottom: 1em;
} }
#draft-list li time { #dashboard_quick_press .drafts li time {
color: #bbb; color: #bbb;
} }
#draft-list p { #dashboard_quick_press .drafts p {
margin: 0; margin: 0;
} }
#draft-list .draft-title { #dashboard_quick_press .draft-title {
overflow: hidden; overflow: hidden;
} }
#draft-list .draft-title a, #dashboard_quick_press .draft-title a,
#draft-list .draft-title time { #dashboard_quick_press .draft-title time {
float: left; float: left;
margin: 0 5px 0 0; margin: 0 5px 0 0;
} }

File diff suppressed because one or more lines are too long

View File

@ -337,63 +337,39 @@ function wp_dashboard_quick_press( $error_msg=false ) {
</p> </p>
</form> </form>
<?php
<?php
wp_dashboard_recent_quickdrafts();
}
/**
* Show `Recent Drafts` below Quick Draft form
*
*
*
* @since 3.8.0
*
*/
function wp_dashboard_recent_quickdrafts() {
$query_args = array( $query_args = array(
'post_type' => 'post', 'post_type' => 'post',
'post_status' => 'draft', 'post_status' => 'draft',
'author' => $GLOBALS['current_user']->ID, 'author' => get_current_user_id(),
'posts_per_page' => 4, 'posts_per_page' => 4,
'orderby' => 'modified', 'orderby' => 'modified',
'order' => 'DESC' 'order' => 'DESC'
); );
$query_args = apply_filters( 'dash_recent_quickdrafts_query_args', $query_args ); $drafts = get_posts( $query_args );
$drafts_query = new WP_Query( $query_args ); if ( ! $drafts ) {
$drafts =& $drafts_query->posts; return;
}
if ( $drafts && is_array( $drafts ) ) { echo '<div class="drafts">';
$list = array(); if ( count( $drafts ) > 3 ) {
$draft_count = 0; echo '<p class="view-all"><a href="' . esc_url( admin_url( 'edit.php?post_status=draft' ) ) . '">' . _x( 'View all', 'drafts' ) . "</a></p>\n";
foreach ( $drafts as $draft ) { }
if ( 3 == $draft_count ) echo '<h4>' . __( 'Drafts' ) . "</h4>\n<ul>";
break;
$drafts = array_slice( $drafts, 0, 3 );
$draft_count++; foreach ( $drafts as $draft ) {
$url = get_edit_post_link( $draft->ID );
$url = get_edit_post_link( $draft->ID ); $title = _draft_or_post_title( $draft->ID );
$title = _draft_or_post_title( $draft->ID ); echo "<li>\n";
$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>'; echo '<div class="draft-title"><a href="' . esc_url( $url ) . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ) . '">' . esc_html( $title ) . '</a>';
if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) echo '<time datetime="' . get_the_time( 'c', $draft ) . '">' . get_the_time( get_option( 'date_format' ), $draft ) . '</time></div>';
$item .= '<p>' . $the_content . '</p>'; if ( $the_content = wp_trim_words( $draft->post_content, 10 ) ) {
$list[] = $item; echo '<p>' . $the_content . '</p>';
} }
echo "</li>\n";
do_action( 'dashboard_quickdraft_drafts_list', $drafts ); }
?> echo "</ul>\n</div>";
<div class="drafts">
<?php if ( 3 < count($drafts) ) { ?>
<p class="view-all"><a href="edit.php?post_status=draft" ><?php _e( 'View all' ); ?></a></p>
<?php } ?>
<h4><?php _e('Drafts'); ?></h4>
<ul id="draft-list">
<li><?php echo join( "</li>\n<li>", $list ); ?></li>
</ul>
</div>
<?php }
} }
function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) {