mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-08 17:38:26 +01:00
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. Built from https://develop.svn.wordpress.org/trunk@43386 git-svn-id: http://core.svn.wordpress.org/trunk@43214 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
efafeed66c
commit
b76a714bba
@ -470,7 +470,7 @@ class WP_Terms_List_Table extends WP_List_Table {
|
|||||||
__( 'Delete' )
|
__( 'Delete' )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ( $tax->public ) {
|
if ( is_taxonomy_viewable( $tax ) ) {
|
||||||
$actions['view'] = sprintf(
|
$actions['view'] = sprintf(
|
||||||
'<a href="%s" aria-label="%s">%s</a>',
|
'<a href="%s" aria-label="%s">%s</a>',
|
||||||
get_term_link( $tag ),
|
get_term_link( $tag ),
|
||||||
|
@ -728,7 +728,7 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
|
|||||||
} elseif ( 'term' == $current_screen->base
|
} elseif ( 'term' == $current_screen->base
|
||||||
&& isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag )
|
&& isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag )
|
||||||
&& ( $tax = get_taxonomy( $tag->taxonomy ) )
|
&& ( $tax = get_taxonomy( $tag->taxonomy ) )
|
||||||
&& $tax->public ) {
|
&& is_taxonomy_viewable( $tax ) ) {
|
||||||
$wp_admin_bar->add_menu(
|
$wp_admin_bar->add_menu(
|
||||||
array(
|
array(
|
||||||
'id' => 'view',
|
'id' => 'view',
|
||||||
|
@ -4548,3 +4548,22 @@ function wp_check_term_hierarchy_for_loops( $parent, $term_id, $taxonomy ) {
|
|||||||
|
|
||||||
return $parent;
|
return $parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether a taxonomy is considered "viewable".
|
||||||
|
*
|
||||||
|
* @since 5.0.0
|
||||||
|
*
|
||||||
|
* @param string|WP_Taxonomy $taxonomy Taxonomy name or object.
|
||||||
|
* @return bool Whether the taxonomy should be considered viewable.
|
||||||
|
*/
|
||||||
|
function is_taxonomy_viewable( $taxonomy ) {
|
||||||
|
if ( is_scalar( $taxonomy ) ) {
|
||||||
|
$taxonomy = get_taxonomy( $taxonomy );
|
||||||
|
if ( ! $taxonomy ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $taxonomy->publicly_queryable;
|
||||||
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.0-alpha-43385';
|
$wp_version = '5.0-alpha-43386';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user