Make WordPress Core


Ignore:
Timestamp:
08/13/2022 10:42:12 PM (2 years ago)
Author:
johnbillion
Message:

Taxonomy: Introduce the is_term_publicly_viewable() function.

This is the taxonomy term counterpart to the is_post_publicly_viewable() function. Although the logic for terms is more straight forward this serves the same purpose as introducing the corresponding function for posts -- to centralise and reduce the logic needed to validate a term and determine if it's publicly viewable.

Props peterwilsoncc, costdev, johnbillion

Fixes #56215

File:
1 edited

Legend:

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

    r53877 r53893  
    49944994
    49954995/**
     4996 * Determines whether a term is publicly viewable.
     4997 *
     4998 * A term is considered publicly viewable if its taxonomy is viewable.
     4999 *
     5000 * @since 6.1.0
     5001 *
     5002 * @param int|WP_Term $term Term ID or term object.
     5003 * @return bool Whether the term is publicly viewable.
     5004 */
     5005function is_term_publicly_viewable( $term ) {
     5006    $term = get_term( $term );
     5007
     5008    if ( ! $term ) {
     5009        return false;
     5010    }
     5011
     5012    return is_taxonomy_viewable( $term->taxonomy );
     5013}
     5014
     5015/**
    49965016 * Sets the last changed time for the 'terms' cache group.
    49975017 *
Note: See TracChangeset for help on using the changeset viewer.