Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

_wp_preview_terms_filter() WordPress Function

The wp_preview_terms_filter function is used to filter the terms that are being previewed in the current post. This function is useful for customizing the terms that are displayed in the post preview.

_wp_preview_terms_filter( array $terms, int $post_id, string $taxonomy ) #

Filters terms lookup to set the post format.


Parameters

$terms

(array)(Required)

$post_id

(int)(Required)

$taxonomy

(string)(Required)


Top ↑

Return

(array)


Top ↑

Source

File: wp-includes/revision.php

function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) {
	$post = get_post();
	if ( ! $post ) {
		return $terms;
	}

	if ( empty( $_REQUEST['post_format'] ) || $post->ID != $post_id
		|| 'post_format' !== $taxonomy || 'revision' === $post->post_type
	) {
		return $terms;
	}

	if ( 'standard' === $_REQUEST['post_format'] ) {
		$terms = array();
	} else {
		$term = get_term_by( 'slug', 'post-format-' . sanitize_key( $_REQUEST['post_format'] ), 'post_format' );
		if ( $term ) {
			$terms = array( $term ); // Can only have one post format.
		}
	}

	return $terms;
}


Top ↑

Changelog

Changelog
VersionDescription
3.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.