X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/f5fcdc7994bb67cce809bc4777944ae8b7fad4a4..53f4633144ed68c8b8fb5861f992b5489894a940:/wp-admin/includes/class-wp-terms-list-table.php diff --git a/wp-admin/includes/class-wp-terms-list-table.php b/wp-admin/includes/class-wp-terms-list-table.php index 5eda1869..a4c81afb 100644 --- a/wp-admin/includes/class-wp-terms-list-table.php +++ b/wp-admin/includes/class-wp-terms-list-table.php @@ -21,6 +21,11 @@ class WP_Terms_List_Table extends WP_List_Table { * * @see WP_List_Table::__construct() for more information on default arguments. * + * @global string $post_type + * @global string $taxonomy + * @global string $action + * @global object $tax + * * @param array $args An associative array of arguments. */ public function __construct( $args = array() ) { @@ -50,10 +55,17 @@ class WP_Terms_List_Table extends WP_List_Table { } + /** + * + * @return bool + */ public function ajax_user_can() { return current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->manage_terms ); } + /** + * @access public + */ public function prepare_items() { $tags_per_page = $this->get_items_per_page( 'edit_' . $this->screen->taxonomy . '_per_page' ); @@ -109,15 +121,26 @@ class WP_Terms_List_Table extends WP_List_Table { ) ); } + /** + * + * @return bool + */ public function has_items() { // todo: populate $this->items in prepare_items() return true; } + /** + * @access public + */ public function no_items() { echo get_taxonomy( $this->screen->taxonomy )->labels->not_found; } + /** + * + * @return array + */ protected function get_bulk_actions() { $actions = array(); $actions['delete'] = __( 'Delete' ); @@ -125,6 +148,10 @@ class WP_Terms_List_Table extends WP_List_Table { return $actions; } + /** + * + * @return string + */ public function current_action() { if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' == $_REQUEST['action'] || 'delete' == $_REQUEST['action2'] ) ) return 'bulk-delete'; @@ -132,6 +159,10 @@ class WP_Terms_List_Table extends WP_List_Table { return parent::current_action(); } + /** + * + * @return array + */ public function get_columns() { $columns = array( 'cb' => '', @@ -149,6 +180,10 @@ class WP_Terms_List_Table extends WP_List_Table { return $columns; } + /** + * + * @return array + */ protected function get_sortable_columns() { return array( 'name' => 'name', @@ -159,6 +194,9 @@ class WP_Terms_List_Table extends WP_List_Table { ); } + /** + * @access public + */ public function display_rows_or_placeholder() { $taxonomy = $this->screen->taxonomy; @@ -185,7 +223,7 @@ class WP_Terms_List_Table extends WP_List_Table { } $terms = get_terms( $taxonomy, $args ); - if ( empty( $terms ) ) { + if ( empty( $terms ) || ! is_array( $terms ) ) { echo ''; $this->no_items(); echo ''; @@ -201,7 +239,6 @@ class WP_Terms_List_Table extends WP_List_Table { // 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 { - $terms = get_terms( $taxonomy, $args ); foreach ( $terms as $term ) { $this->single_row( $term ); } @@ -212,11 +249,11 @@ class WP_Terms_List_Table extends WP_List_Table { * @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 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 ) { @@ -302,9 +339,6 @@ class WP_Terms_List_Table extends WP_List_Table { */ public function column_name( $tag ) { $taxonomy = $this->screen->taxonomy; - $tax = get_taxonomy( $taxonomy ); - - $default_term = get_option( 'default_' . $taxonomy ); $pad = str_repeat( '— ', max( 0, $this->level ) ); @@ -328,6 +362,50 @@ class WP_Terms_List_Table extends WP_List_Table { $out = '' . $name . '
'; + $out .= ''; + + return $out; + } + + /** + * Gets the name of the default primary column. + * + * @since 4.3.0 + * @access protected + * + * @return string Name of the default primary column, in this case, 'name'. + */ + protected function get_default_primary_column_name() { + return 'name'; + } + + /** + * Generates and displays row action links. + * + * @since 4.3.0 + * @access protected + * + * @param object $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. + */ + protected function handle_row_actions( $tag, $column_name, $primary ) { + if ( $primary !== $column_name ) { + return ''; + } + + $taxonomy = $this->screen->taxonomy; + $tax = get_taxonomy( $taxonomy ); + $default_term = get_option( 'default_' . $taxonomy ); + + $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) ); + $actions = array(); if ( current_user_can( $tax->cap->edit_terms ) ) { $actions['edit'] = '' . __( 'Edit' ) . ''; @@ -363,15 +441,7 @@ class WP_Terms_List_Table extends WP_List_Table { */ $actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag ); - $out .= $this->row_actions( $actions ); - $out .= ''; - - return $out; + return $this->row_actions( $actions ); } /**