diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-admin/includes/class-wp-terms-list-table.php
--- a/wp/wp-admin/includes/class-wp-terms-list-table.php Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-admin/includes/class-wp-terms-list-table.php Fri Sep 05 18:40:08 2025 +0200
@@ -11,7 +11,6 @@
* Core class used to implement displaying terms in a list table.
*
* @since 3.1.0
- * @access private
*
* @see WP_List_Table
*/
@@ -28,8 +27,8 @@
*
* @see WP_List_Table::__construct() for more information on default arguments.
*
- * @global string $post_type
- * @global string $taxonomy
+ * @global string $post_type Global post type.
+ * @global string $taxonomy Global taxonomy.
* @global string $action
* @global object $tax
*
@@ -64,7 +63,6 @@
if ( empty( $post_type ) || ! in_array( $post_type, get_post_types( array( 'show_ui' => true ) ), true ) ) {
$post_type = 'post';
}
-
}
/**
@@ -186,7 +184,7 @@
}
/**
- * @return array
+ * @return string[] Array of column titles keyed by their column name.
*/
public function get_columns() {
$columns = array(
@@ -209,12 +207,20 @@
* @return array
*/
protected function get_sortable_columns() {
+ $taxonomy = $this->screen->taxonomy;
+
+ if ( ! isset( $_GET['orderby'] ) && is_taxonomy_hierarchical( $taxonomy ) ) {
+ $name_orderby_text = __( 'Table ordered hierarchically.' );
+ } else {
+ $name_orderby_text = __( 'Table ordered by Name.' );
+ }
+
return array(
- 'name' => 'name',
- 'description' => 'description',
- 'slug' => 'slug',
- 'posts' => 'count',
- 'links' => 'count',
+ 'name' => array( 'name', false, _x( 'Name', 'term name' ), $name_orderby_text, 'asc' ),
+ 'description' => array( 'description', false, __( 'Description' ), __( 'Table ordered by Description.' ) ),
+ 'slug' => array( 'slug', false, __( 'Slug' ), __( 'Table ordered by Slug.' ) ),
+ 'posts' => array( 'count', false, _x( 'Count', 'Number/count of items' ), __( 'Table ordered by Posts Count.' ) ),
+ 'links' => array( 'count', false, __( 'Links' ), __( 'Table ordered by Links.' ) ),
);
}
@@ -304,7 +310,7 @@
while ( $my_parent = array_pop( $my_parents ) ) {
echo "\t";
$this->single_row( $my_parent, $level - $num_parents );
- $num_parents--;
+ --$num_parents;
}
}
@@ -324,7 +330,8 @@
}
/**
- * @global string $taxonomy
+ * @global string $taxonomy Global taxonomy.
+ *
* @param WP_Term $tag Term object.
* @param int $level
*/
@@ -358,10 +365,10 @@
if ( current_user_can( 'delete_term', $tag->term_id ) ) {
return sprintf(
- '' .
- '',
+ '' .
+ '',
$tag->term_id,
- /* translators: %s: Taxonomy term name. */
+ /* translators: Hidden accessibility text. %s: Taxonomy term name. */
sprintf( __( 'Select %s' ), $tag->name )
);
}
@@ -414,19 +421,24 @@
);
}
- $out = sprintf(
+ $output = sprintf(
'%s
',
$name
);
- $out .= '
';
- $out .= '
' . $qe_data->name . '
';
+ /** This filter is documented in wp-admin/includes/class-wp-terms-list-table.php */
+ $quick_edit_enabled = apply_filters( 'quick_edit_enabled_for_taxonomy', true, $taxonomy );
+
+ if ( $quick_edit_enabled ) {
+ $output .= '
';
+ $output .= '
' . $qe_data->name . '
';
- /** This filter is documented in wp-admin/edit-tag-form.php */
- $out .= '
' . apply_filters( 'editable_slug', $qe_data->slug, $qe_data ) . '
';
- $out .= '
' . $qe_data->parent . '
';
+ /** This filter is documented in wp-admin/edit-tag-form.php */
+ $output .= '
' . apply_filters( 'editable_slug', $qe_data->slug, $qe_data ) . '
';
+ $output .= '
' . $qe_data->parent . '
';
+ }
- return $out;
+ return $output;
}
/**
@@ -458,33 +470,46 @@
}
// Restores the more descriptive, specific name for use within this method.
- $tag = $item;
- $taxonomy = $this->screen->taxonomy;
- $tax = get_taxonomy( $taxonomy );
- $uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
+ $tag = $item;
- $edit_link = add_query_arg(
- 'wp_http_referer',
- urlencode( wp_unslash( $uri ) ),
- get_edit_term_link( $tag, $taxonomy, $this->screen->post_type )
- );
+ $taxonomy = $this->screen->taxonomy;
+ $uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
$actions = array();
if ( current_user_can( 'edit_term', $tag->term_id ) ) {
$actions['edit'] = sprintf(
'%s',
- esc_url( $edit_link ),
+ esc_url(
+ add_query_arg(
+ 'wp_http_referer',
+ urlencode( wp_unslash( $uri ) ),
+ get_edit_term_link( $tag, $taxonomy, $this->screen->post_type )
+ )
+ ),
/* translators: %s: Taxonomy term name. */
esc_attr( sprintf( __( 'Edit “%s”' ), $tag->name ) ),
__( 'Edit' )
);
- $actions['inline hide-if-no-js'] = sprintf(
- '',
- /* translators: %s: Taxonomy term name. */
- esc_attr( sprintf( __( 'Quick edit “%s” inline' ), $tag->name ) ),
- __( 'Quick Edit' )
- );
+
+ /**
+ * Filters whether Quick Edit should be enabled for the given taxonomy.
+ *
+ * @since 6.4.0
+ *
+ * @param bool $enable Whether to enable the Quick Edit functionality. Default true.
+ * @param string $taxonomy Taxonomy name.
+ */
+ $quick_edit_enabled = apply_filters( 'quick_edit_enabled_for_taxonomy', true, $taxonomy );
+
+ if ( $quick_edit_enabled ) {
+ $actions['inline hide-if-no-js'] = sprintf(
+ '',
+ /* translators: %s: Taxonomy term name. */
+ esc_attr( sprintf( __( 'Quick edit “%s” inline' ), $tag->name ) ),
+ __( 'Quick Edit' )
+ );
+ }
}
if ( current_user_can( 'delete_term', $tag->term_id ) ) {
@@ -497,7 +522,7 @@
);
}
- if ( is_taxonomy_viewable( $tax ) ) {
+ if ( is_term_publicly_viewable( $tag ) ) {
$actions['view'] = sprintf(
'%s',
get_term_link( $tag ),
@@ -549,7 +574,10 @@
if ( $tag->description ) {
return $tag->description;
} else {
- return '—' . __( 'No description' ) . '';
+ return '—' .
+ /* translators: Hidden accessibility text. */
+ __( 'No description' ) .
+ '';
}
}
@@ -618,6 +646,9 @@
* @return string
*/
public function column_default( $item, $column_name ) {
+ // Restores the more descriptive, specific name for use within this method.
+ $tag = $item;
+
/**
* Filters the displayed columns in the terms list table.
*
@@ -635,7 +666,7 @@
* @param string $column_name Name of the column.
* @param int $term_id Term ID.
*/
- return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $item->term_id );
+ return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $tag->term_id );
}
/**
@@ -666,12 +697,10 @@
-
-
-
+
@@ -705,9 +734,16 @@
-
+ ',
+ array(
+ 'type' => 'error',
+ 'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ),
+ 'paragraph_wrap' => false,
+ )
+ );
+ ?>