WordPress.org

Make WordPress Core

Changeset 43386


Ignore:
Timestamp:
07/03/2018 10:28:39 AM (4 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.

Location:
trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-terms-list-table.php

    r42871 r43386  
    471471            );
    472472        }
    473         if ( $tax->public ) {
     473        if ( is_taxonomy_viewable( $tax ) ) {
    474474            $actions['view'] = sprintf(
    475475                '<a href="%s" aria-label="%s">%s</a>',
  • trunk/src/wp-includes/admin-bar.php

    r42843 r43386  
    729729            && isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag )
    730730            && ( $tax = get_taxonomy( $tag->taxonomy ) )
    731             && $tax->public ) {
     731            && is_taxonomy_viewable( $tax ) ) {
    732732            $wp_admin_bar->add_menu(
    733733                array(
  • 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.