taxonomies to filter. * @param boolean $filter (Optional) Whether to filter taxonomies. * * @return array|object */ public static function filter_exclude_taxonomies( $taxonomies, $filter = true ) { $taxonomies = $filter ? array_filter( $taxonomies, [ __CLASS__, 'is_taxonomy_viewable' ] ) : $taxonomies; /** * Filter: 'rank_math_excluded_taxonomies' - Allow changing the accessible taxonomies. * * @api array $taxonomies The public taxonomies. */ $taxonomies = apply_filters( 'rank_math/excluded_taxonomies', $taxonomies ); return $taxonomies; } /** * Determine whether a taxonomy is viewable. * * @codeCoverageIgnore * * @param string|WP_Taxonomy $taxonomy Taxonomy name or object. * * @return bool */ public static function is_taxonomy_viewable( $taxonomy ) { if ( is_scalar( $taxonomy ) ) { $taxonomy = get_taxonomy( $taxonomy ); if ( ! $taxonomy ) { return false; } } /* * For categories and tags, we check for the 'public' parameter. * For others, we use the 'publicly_queryable' parameter. */ return $taxonomy->publicly_queryable || ( $taxonomy->_builtin && $taxonomy->public ); } }