diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-admin/includes/class-wp-terms-list-table.php --- a/wp/wp-admin/includes/class-wp-terms-list-table.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-admin/includes/class-wp-terms-list-table.php Tue Dec 15 13:49:49 2020 +0100 @@ -61,7 +61,7 @@ $tax = get_taxonomy( $taxonomy ); // @todo Still needed? Maybe just the show_ui part. - if ( empty( $post_type ) || ! in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) ) { + if ( empty( $post_type ) || ! in_array( $post_type, get_post_types( array( 'show_ui' => true ) ), true ) ) { $post_type = 'post'; } @@ -93,11 +93,11 @@ * Filters the number of terms displayed per page for the Tags list table. * * @since 2.7.0 - * @deprecated 2.8.0 Use edit_tags_per_page instead. + * @deprecated 2.8.0 Use {@see 'edit_tags_per_page'} instead. * * @param int $tags_per_page Number of tags to be displayed. Default 20. */ - $tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); + $tags_per_page = apply_filters_deprecated( 'tagsperpage', array( $tags_per_page ), '2.8.0', 'edit_tags_per_page' ); } elseif ( 'category' === $this->screen->taxonomy ) { /** * Filters the number of terms displayed per page for the Categories list table. @@ -139,7 +139,7 @@ * @return bool */ public function has_items() { - // todo: populate $this->items in prepare_items() + // @todo Populate $this->items in prepare_items(). return true; } @@ -214,6 +214,7 @@ $args = wp_parse_args( $this->callback_args, array( + 'taxonomy' => $taxonomy, 'page' => 1, 'number' => 20, 'search' => '', @@ -226,16 +227,19 @@ // Set variable because $args['number'] can be subsequently overridden. $number = $args['number']; - $args['offset'] = $offset = ( $page - 1 ) * $number; + $offset = ( $page - 1 ) * $number; + $args['offset'] = $offset; // Convert it to table rows. $count = 0; if ( is_taxonomy_hierarchical( $taxonomy ) && ! isset( $args['orderby'] ) ) { // We'll need the full set of terms then. - $args['number'] = $args['offset'] = 0; + $args['number'] = 0; + $args['offset'] = $args['number']; } - $terms = get_terms( $taxonomy, $args ); + + $terms = get_terms( $args ); if ( empty( $terms ) || ! is_array( $terms ) ) { echo ''; @@ -250,7 +254,11 @@ } else { $children = _get_term_hierarchy( $taxonomy ); } - // Some funky recursion to get the job done( Paging & parents mainly ) is contained within, Skip it for non-hierarchical taxonomies for performance sake + + /* + * Some funky recursion to get the job done (paging & parents mainly) is contained within. + * Skip it for non-hierarchical taxonomies for performance sake. + */ $this->_rows( $taxonomy, $terms, $children, $offset, $number, $count ); } else { foreach ( $terms as $term ) { @@ -261,13 +269,13 @@ /** * @param string $taxonomy - * @param array $terms - * @param array $children - * @param int $start - * @param int $per_page - * @param int $count - * @param int $parent - * @param int $level + * @param array $terms + * @param array $children + * @param int $start + * @param int $per_page + * @param int $count + * @param int $parent + * @param int $level */ private function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$count, $parent = 0, $level = 0 ) { @@ -285,13 +293,14 @@ // If the page starts in a subtree, print the parents. if ( $count == $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) { - $my_parents = $parent_ids = array(); + $my_parents = array(); + $parent_ids = array(); $p = $term->parent; while ( $p ) { $my_parent = get_term( $p, $taxonomy ); $my_parents[] = $my_parent; $p = $my_parent->parent; - if ( in_array( $p, $parent_ids ) ) { // Prevent parent loops. + if ( in_array( $p, $parent_ids, true ) ) { // Prevent parent loops. break; } $parent_ids[] = $p; @@ -323,8 +332,8 @@ /** * @global string $taxonomy - * @param WP_Term $tag Term object. - * @param int $level + * @param WP_Term $tag Term object. + * @param int $level */ public function single_row( $tag, $level = 0 ) { global $taxonomy; @@ -350,8 +359,13 @@ */ public function column_cb( $tag ) { if ( current_user_can( 'delete_term', $tag->term_id ) ) { - return '' - . ''; + return sprintf( + '' . + '', + $tag->term_id, + /* translators: %s: Taxonomy term name. */ + sprintf( __( 'Select %s' ), $tag->name ) + ); } return ' '; @@ -396,7 +410,7 @@ $name = sprintf( '%s', esc_url( $edit_link ), - /* translators: %s: taxonomy term name */ + /* translators: %s: Taxonomy term name. */ esc_attr( sprintf( __( '“%s” (Edit)' ), $tag->name ) ), $name ); @@ -436,7 +450,8 @@ * @param WP_Term $tag Tag being acted upon. * @param string $column_name Current column name. * @param string $primary Primary column name. - * @return string Row actions output for terms. + * @return string Row actions output for terms, or an empty string + * if the current column is not the primary column. */ protected function handle_row_actions( $tag, $column_name, $primary ) { if ( $primary !== $column_name ) { @@ -458,13 +473,13 @@ $actions['edit'] = sprintf( '%s', esc_url( $edit_link ), - /* translators: %s: taxonomy term name */ + /* 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 */ + /* translators: %s: Taxonomy term name. */ esc_attr( sprintf( __( 'Quick edit “%s” inline' ), $tag->name ) ), __( 'Quick Edit' ) ); @@ -473,7 +488,7 @@ $actions['delete'] = sprintf( '%s', wp_nonce_url( "edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ), - /* translators: %s: taxonomy term name */ + /* translators: %s: Taxonomy term name. */ esc_attr( sprintf( __( 'Delete “%s”' ), $tag->name ) ), __( 'Delete' ) ); @@ -482,7 +497,7 @@ $actions['view'] = sprintf( '%s', get_term_link( $tag ), - /* translators: %s: taxonomy term name */ + /* translators: %s: Taxonomy term name. */ esc_attr( sprintf( __( 'View “%s” archive' ), $tag->name ) ), __( 'View' ) ); @@ -492,7 +507,8 @@ * Filters the action links displayed for each term in the Tags list table. * * @since 2.8.0 - * @deprecated 3.0.0 Use {$taxonomy}_row_actions instead. + * @since 3.0.0 Deprecated in favor of {@see '{$taxonomy}_row_actions'} filter. + * @since 5.4.2 Restored (un-deprecated). * * @param string[] $actions An array of action links to be displayed. Default * 'Edit', 'Quick Edit', 'Delete', and 'View'. @@ -560,7 +576,7 @@ ); } - if ( 'post' != $this->screen->post_type ) { + if ( 'post' !== $this->screen->post_type ) { $args['post_type'] = $this->screen->post_type; } @@ -584,8 +600,8 @@ } /** - * @param WP_Term $tag Term object. - * @param string $column_name + * @param WP_Term $tag Term object. + * @param string $column_name Name of the column. * @return string */ public function column_default( $tag, $column_name ) { @@ -617,8 +633,11 @@ } ?> -
- + +
+