过滤术语查找以设置发布格式。
原型
_wp_preview_terms_filter( array $terms, int $post_id, string $taxonomy )
参数
$terms
(array)
(Required)
$post_id
(int)
(Required)
$taxonomy
(string)
(Required)
返回值
(array)
源文件
路径:wp-includes/revision.php
<?php
...
function _wp_preview_terms_filter( $terms, $post_id, $taxonomy ) {
if ( ! $post = get_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();
elseif ( $term = get_term_by( 'slug', 'post-format-' . sanitize_key( $_REQUEST['post_format'] ), 'post_format' ) )
$terms = array( $term ); // Can only have one post format
return $terms;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/_wp_preview_terms_filter/