Advertisements

wp_dashboard_recent_drafts

Definition:
function wp_dashboard_recent_drafts( $drafts = false ) {}

Parameters

  • $drafts

Source code

function wp_dashboard_recent_drafts( $drafts = false ) {

	if ( !$drafts ) {

		$drafts_query = new WP_Query( array(

			'post_type' => 'post',

			'post_status' => 'draft',

			'author' => $GLOBALS['current_user']->ID,

			'posts_per_page' => 5,

			'orderby' => 'modified',

			'order' => 'DESC'

		) );

		$drafts =& $drafts_query->posts;

	}



	if ( $drafts && is_array( $drafts ) ) {

		$list = array();

		foreach ( $drafts as $draft ) {

			$url = get_edit_post_link( $draft->ID );

			$title = _draft_or_post_title( $draft->ID );

			$item = "<h4><a href='$url' title='" . sprintf( __( 'Edit “%s”' ), esc_attr( $title ) ) . "'>" . esc_html($title) . "</a> <abbr title='" . get_the_time(__('Y/m/d g:i:s A'), $draft) . "'>" . get_the_time( get_option( 'date_format' ), $draft ) . '</abbr></h4>';

			if ( $the_content = preg_split( '#\s#', strip_tags( $draft->post_content ), 11, PREG_SPLIT_NO_EMPTY ) )

				$item .= '<p>' . join( ' ', array_slice( $the_content, 0, 10 ) ) . ( 10 < count( $the_content ) ? '&hellip;' : '' ) . '</p>';

			$list[] = $item;

		}

?>

	<ul>

		<li><?php echo join( "</li>\n<li>", $list ); ?></li>

	</ul>

	<p class="textright"><a href="edit.php?post_status=draft" ><?php _e('View all'); ?></a></p>

<?php

	} else {

		_e('There are no drafts at the moment');

	}

}

3555

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: