mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01:00
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 Built from https://develop.svn.wordpress.org/trunk@53893 git-svn-id: http://core.svn.wordpress.org/trunk@53452 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e8a05d5082
commit
85306e1fd6
@ -460,7 +460,6 @@ class WP_Terms_List_Table extends WP_List_Table {
|
|||||||
// Restores the more descriptive, specific name for use within this method.
|
// Restores the more descriptive, specific name for use within this method.
|
||||||
$tag = $item;
|
$tag = $item;
|
||||||
$taxonomy = $this->screen->taxonomy;
|
$taxonomy = $this->screen->taxonomy;
|
||||||
$tax = get_taxonomy( $taxonomy );
|
|
||||||
$uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
|
$uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
|
||||||
|
|
||||||
$edit_link = add_query_arg(
|
$edit_link = add_query_arg(
|
||||||
@ -497,7 +496,7 @@ class WP_Terms_List_Table extends WP_List_Table {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( is_taxonomy_viewable( $tax ) ) {
|
if ( is_term_publicly_viewable( $tag ) ) {
|
||||||
$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 ),
|
||||||
|
@ -809,7 +809,7 @@ function wp_admin_bar_edit_menu( $wp_admin_bar ) {
|
|||||||
);
|
);
|
||||||
} elseif ( 'term' === $current_screen->base && isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag ) ) {
|
} elseif ( 'term' === $current_screen->base && isset( $tag ) && is_object( $tag ) && ! is_wp_error( $tag ) ) {
|
||||||
$tax = get_taxonomy( $tag->taxonomy );
|
$tax = get_taxonomy( $tag->taxonomy );
|
||||||
if ( is_taxonomy_viewable( $tax ) ) {
|
if ( is_term_publicly_viewable( $tag ) ) {
|
||||||
$wp_admin_bar->add_node(
|
$wp_admin_bar->add_node(
|
||||||
array(
|
array(
|
||||||
'id' => 'view',
|
'id' => 'view',
|
||||||
|
@ -4992,6 +4992,26 @@ function is_taxonomy_viewable( $taxonomy ) {
|
|||||||
return $taxonomy->publicly_queryable;
|
return $taxonomy->publicly_queryable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether a term is publicly viewable.
|
||||||
|
*
|
||||||
|
* A term is considered publicly viewable if its taxonomy is viewable.
|
||||||
|
*
|
||||||
|
* @since 6.1.0
|
||||||
|
*
|
||||||
|
* @param int|WP_Term $term Term ID or term object.
|
||||||
|
* @return bool Whether the term is publicly viewable.
|
||||||
|
*/
|
||||||
|
function is_term_publicly_viewable( $term ) {
|
||||||
|
$term = get_term( $term );
|
||||||
|
|
||||||
|
if ( ! $term ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return is_taxonomy_viewable( $term->taxonomy );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the last changed time for the 'terms' cache group.
|
* Sets the last changed time for the 'terms' cache group.
|
||||||
*
|
*
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.1-alpha-53892';
|
$wp_version = '6.1-alpha-53893';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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