wpseek.com
WordPress开发者和主题制作者的搜索引擎



_wp_preview_post_thumbnail_filter › WordPress Function

Since4.6.0
已弃用n/a
_wp_preview_post_thumbnail_filter ( $value, $post_id, $meta_key )
访问:
  • private
参数: (3)
  • (null|array|string) $value The value to return - a single metadata value, or an array of values.
    Required: Yes
  • (int) $post_id Post ID.
    Required: Yes
  • (string) $meta_key Meta key.
    Required: Yes
返回:
  • (null|array) The default return value or the post thumbnail meta array.
定义在:
文档:

Filters post thumbnail lookup to set the post thumbnail.



源码

function _wp_preview_post_thumbnail_filter( $value, $post_id, $meta_key ) {
	$post = get_post();

	if ( ! $post ) {
		return $value;
	}

	if ( empty( $_REQUEST['_thumbnail_id'] ) || empty( $_REQUEST['preview_id'] )
		|| $post->ID !== $post_id || $post_id !== (int) $_REQUEST['preview_id']
		|| '_thumbnail_id' !== $meta_key || 'revision' === $post->post_type
	) {
		return $value;
	}

	$thumbnail_id = (int) $_REQUEST['_thumbnail_id'];

	if ( $thumbnail_id <= 0 ) {
		return '';
	}

	return (string) $thumbnail_id;
}