Filter hook 'is_post_type_viewable'

in WP Core File wp-includes/post.php at line 2397

Description

Filters whether a post type is considered "viewable". The returned filtered value must be a boolean type to ensure `is_post_type_viewable()` only 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.

Occurrences

Filename Line Number
wp-includes/post.php 2397

Parameters

Type Name Description
bool $is_viewable Whether the post type is "viewable" (strict type).
WP_Post_Type $post_type Post type object.

PHP Doc

/**
	 * Filters whether a post type is considered "viewable".
	 *
	 * The returned filtered value must be a boolean type to ensure
	 * `is_post_type_viewable()` only 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.
	 *
	 * @since 5.9.0
	 *
	 * @param bool         $is_viewable Whether the post type is "viewable" (strict type).
	 * @param WP_Post_Type $post_type   Post type object.
	 */