# wp_dashboard_recent_drafts()

URL: https://chugunov.pro/api-wordpress/functions/wp_dashboard_recent_drafts/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 2.7.0.

## Сигнатура

```php
wp_dashboard_recent_drafts( WP_Post[]|false $drafts = false )
```

## Описание

Показывает недавние черновики пользователя на панели управления.

## Параметры

- `$drafts` `WP_Post[]|false` — необязательный, по умолчанию `false`. Массив записей для отображения.

## Исходный код

Файл: `wp-admin/includes/dashboard.php:630`

```php
function wp_dashboard_recent_drafts( $drafts = false ) {
	if ( ! $drafts ) {
		$query_args = array(
			'post_type'      => 'post',
			'post_status'    => 'draft',
			'author'         => get_current_user_id(),
			'posts_per_page' => 4,
			'orderby'        => 'modified',
			'order'          => 'DESC',
		);

		/**
		 * Filters the post query arguments for the 'Recent Drafts' dashboard widget.
		 *
		 * @since 4.4.0
		 *
		 * @param array $query_args The query arguments for the 'Recent Drafts' dashboard widget.
		 */
		$query_args = apply_filters( 'dashboard_recent_drafts_query_args', $query_args );

		$drafts = get_posts( $query_args );
		if ( ! $drafts ) {
			return;
		}
	}

	echo '<div class="drafts">';

	if ( count( $drafts ) > 3 ) {
		printf(
			'<p class="view-all"><a href="%s">%s</a></p>' . "\n",
			esc_url( admin_url( 'edit.php?post_status=draft' ) ),
			__( 'View all drafts' )
		);
	}

	echo '<h2 class="hide-if-no-js">' . __( 'Your Recent Drafts' ) . "</h2>\n";
	echo '<ul>';

	/* translators: Maximum number of words used in a preview of a draft on the dashboard. */
	$draft_length = (int) _x( '10', 'draft_length' );

	$drafts = array_slice( $drafts, 0, 3 );
	foreach ( $drafts as $draft ) {
		$url   = get_edit_post_link( $draft->ID );
		$title = _draft_or_post_title( $draft->ID );

		echo "<li>\n";
		printf(
			'<div class="draft-title"><a href="%s" aria-label="%s">%s</a><time datetime="%s">%s</time></div>',
			esc_url( $url ),
			/* translators: %s: Post title. */
			esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ),
			esc_html( $title ),
			get_the_time( 'c', $draft ),
			get_the_time( __( 'F j, Y' ), $draft )
		);

		$the_content = wp_trim_words( $draft->post_content, $draft_length );

		if ( $the_content ) {
			echo '<p>' . $the_content . '</p>';
		}
		echo "</li>\n";
	}

	echo "</ul>\n";
	echo '</div>';
}
```

## История изменений

- 2.7.0 — Introduced.

## Связанные

Использует: [`_draft_or_post_title`](https://chugunov.pro/api-wordpress/functions/_draft_or_post_title/), [`wp_trim_words`](https://chugunov.pro/api-wordpress/functions/wp_trim_words/), [`get_the_time`](https://chugunov.pro/api-wordpress/functions/get_the_time/), [`get_edit_post_link`](https://chugunov.pro/api-wordpress/functions/get_edit_post_link/), [`get_posts`](https://chugunov.pro/api-wordpress/functions/get_posts/), [`__`](https://chugunov.pro/api-wordpress/functions/__/), [`_x`](https://chugunov.pro/api-wordpress/functions/_x/), [`esc_url`](https://chugunov.pro/api-wordpress/functions/esc_url/), [`esc_attr`](https://chugunov.pro/api-wordpress/functions/esc_attr/), [`esc_html`](https://chugunov.pro/api-wordpress/functions/esc_html/), [`admin_url`](https://chugunov.pro/api-wordpress/functions/admin_url/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/), [`get_current_user_id`](https://chugunov.pro/api-wordpress/functions/get_current_user_id/).
Используется в: [`wp_dashboard_quick_press`](https://chugunov.pro/api-wordpress/functions/wp_dashboard_quick_press/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/wp_dashboard_recent_drafts/
