WordPress.org

Make WordPress Core


Ignore:
Timestamp:
07/03/2018 10:28:39 AM (2 years ago)
Author:
flixos90
Message:

Taxonomy: Introduce is_taxonomy_viewable().

This utility function allows for easy detection whether terms for a taxonomy are considered publicly viewable.

Props andizer.
Fixes #44466.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy.php

    r43378 r43386  
    45494549    return $parent;
    45504550}
     4551
     4552/**
     4553 * Determines whether a taxonomy is considered "viewable".
     4554 *
     4555 * @since 5.0.0
     4556 *
     4557 * @param string|WP_Taxonomy $taxonomy Taxonomy name or object.
     4558 * @return bool Whether the taxonomy should be considered viewable.
     4559 */
     4560function is_taxonomy_viewable( $taxonomy ) {
     4561    if ( is_scalar( $taxonomy ) ) {
     4562        $taxonomy = get_taxonomy( $taxonomy );
     4563        if ( ! $taxonomy ) {
     4564            return false;
     4565        }
     4566    }
     4567
     4568    return $taxonomy->publicly_queryable;
     4569}
Note: See TracChangeset for help on using the changeset viewer.