WP_Posts_List_Table::get_no_title_excerptprotectedWP 7.1.0

Gets a trimmed excerpt to display in place of a missing post title.

Only returns text in the Compact list view for posts that have no title, do not require a password, and that the current user is allowed to read.

Метод класса: WP_Posts_List_Table{}

Хуков нет.

Возвращает

Строку. The escaped, trimmed excerpt, or an empty string.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_no_title_excerpt( $post );
$post(WP_Post) (обязательный)
The current WP_Post object.

Заметки

Global. Строка. $mode List table view mode.

Список изменений

С версии 7.1.0 Введена.

Код WP_Posts_List_Table::get_no_title_excerpt() WP 7.1

protected function get_no_title_excerpt( $post ) {
	global $mode;

	if ( 'excerpt' === $mode
		|| '' !== get_the_title( $post )
		|| post_password_required( $post )
		|| ! current_user_can( 'read_post', $post->ID )
	) {
		return '';
	}

	$excerpt = get_the_excerpt( $post );

	if ( '' === $excerpt || ! is_string( $excerpt ) ) {
		return '';
	}

	return esc_html( wp_trim_words( $excerpt, 15 ) );
}