is_post_type_viewable хук-фильтрWP 5.9.0

Filters whether a post type is considered "viewable".

The returned filtered value must be a boolean type to ensure is_post_type_viewable() returns a boolean. This strictness is by design to maintain backwards-compatibility and guard against potential type errors in PHP 8.1+. Non-boolean values (even falsey and truthy values) will result in the function returning false.

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

add_filter( 'is_post_type_viewable', 'wp_kama_is_post_type_viewable_filter', 10, 2 );

/**
 * Function for `is_post_type_viewable` filter-hook.
 * 
 * @param bool         $is_viewable Whether the post type is "viewable" (strict type).
 * @param WP_Post_Type $post_type   Post type object.
 *
 * @return bool
 */
function wp_kama_is_post_type_viewable_filter( $is_viewable, $post_type ){

	// filter...
	return $is_viewable;
}
$is_viewable(true|false)
Whether the post type is "viewable" (strict type).
$post_type(WP_Post_Type)
Post type object.

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

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

Где вызывается хук

is_post_type_viewable()
is_post_type_viewable
wp-includes/post.php 2378
return true === apply_filters( 'is_post_type_viewable', $is_viewable, $post_type );

Где используется хук в WordPress

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