--- 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(
- '<label class="screen-reader-text" for="cb-select-%1$s">%2$s</label>' .
- '<input type="checkbox" name="delete_tags[]" value="%1$s" id="cb-select-%1$s" />',
+ '<input type="checkbox" name="delete_tags[]" value="%1$s" id="cb-select-%1$s" />' .
+ '<label for="cb-select-%1$s"><span class="screen-reader-text">%2$s</span></label>',
$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(
'<strong>%s</strong><br />',
$name
);
- $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
- $out .= '<div class="name">' . $qe_data->name . '</div>';
+ /** 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 .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
+ $output .= '<div class="name">' . $qe_data->name . '</div>';
- /** This filter is documented in wp-admin/edit-tag-form.php */
- $out .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug, $qe_data ) . '</div>';
- $out .= '<div class="parent">' . $qe_data->parent . '</div></div>';
+ /** This filter is documented in wp-admin/edit-tag-form.php */
+ $output .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug, $qe_data ) . '</div>';
+ $output .= '<div class="parent">' . $qe_data->parent . '</div></div>';
+ }
- 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(
'<a href="%s" aria-label="%s">%s</a>',
- 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(
- '<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>',
- /* 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(
+ '<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>',
+ /* 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(
'<a href="%s" aria-label="%s">%s</a>',
get_term_link( $tag ),
@@ -549,7 +574,10 @@
if ( $tag->description ) {
return $tag->description;
} else {
- return '<span aria-hidden="true">—</span><span class="screen-reader-text">' . __( 'No description' ) . '</span>';
+ return '<span aria-hidden="true">—</span><span class="screen-reader-text">' .
+ /* translators: Hidden accessibility text. */
+ __( 'No description' ) .
+ '</span>';
}
}
@@ -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 @@
<span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>
</label>
- <?php if ( ! global_terms_enabled() ) : ?>
- <label>
- <span class="title"><?php _e( 'Slug' ); ?></span>
- <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
- </label>
- <?php endif; ?>
+ <label>
+ <span class="title"><?php _e( 'Slug' ); ?></span>
+ <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
+ </label>
</div>
</fieldset>
@@ -705,9 +734,16 @@
<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" />
<input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" />
- <div class="notice notice-error notice-alt inline hidden">
- <p class="error"></p>
- </div>
+ <?php
+ wp_admin_notice(
+ '<p class="error"></p>',
+ array(
+ 'type' => 'error',
+ 'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ),
+ 'paragraph_wrap' => false,
+ )
+ );
+ ?>
</div>
</div>