true ) ) ) ) $post_type = 'post'; parent::WP_List_Table( array( 'plural' => 'tags', 'singular' => 'tag', ) ); } function check_permissions( $type = 'manage' ) { global $tax; $cap = 'manage' == $type ? $tax->cap->manage_terms : $tax->cap->edit_terms; if ( !current_user_can( $tax->cap->manage_terms ) ) wp_die( __( 'Cheatin’ uh?' ) ); } function prepare_items() { global $taxonomy; $tags_per_page = $this->get_items_per_page( 'edit_' . $taxonomy . '_per_page' ); if ( 'post_tag' == $taxonomy ) { $tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page ); $tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); // Old filter } elseif ( 'category' == $taxonomy ) { $tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page ); // Old filter } $search = !empty( $_REQUEST['s'] ) ? trim( stripslashes( $_REQUEST['s'] ) ) : ''; $args = array( 'search' => $search, 'page' => $this->get_pagenum(), 'number' => $tags_per_page, ); if ( !empty( $_REQUEST['orderby'] ) ) $args['orderby'] = trim( stripslashes( $_REQUEST['orderby'] ) ); if ( !empty( $_REQUEST['order'] ) ) $args['order'] = trim( stripslashes( $_REQUEST['order'] ) ); $this->callback_args = $args; $this->set_pagination_args( array( 'total_items' => wp_count_terms( $taxonomy, compact( 'search' ) ), 'per_page' => $tags_per_page, ) ); } function get_bulk_actions() { $actions = array(); $actions['delete'] = __( 'Delete' ); return $actions; } function current_action() { if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' == $_REQUEST['action'] || 'delete' == $_REQUEST['action2'] ) ) return 'bulk-delete'; return parent::current_action(); } function get_columns() { global $taxonomy; $columns = array( 'cb' => '', 'name' => __( 'Name' ), 'description' => __( 'Description' ), 'slug' => __( 'Slug' ), ); if ( 'link_category' == $taxonomy ) $columns['links'] = __( 'Links' ); else $columns['posts'] = __( 'Posts' ); return $columns; } function get_sortable_columns() { return array( 'name' => 'name', 'description' => 'description', 'slug' => 'slug', 'posts' => 'count', 'links' => 'count' ); } function display_rows() { global $taxonomy; $args = wp_parse_args( $this->callback_args, array( 'page' => 1, 'number' => 20, 'search' => '', 'hide_empty' => 0 ) ); extract( $args, EXTR_SKIP ); $args['offset'] = $offset = ( $page - 1 ) * $number; // convert it to table rows $out = ''; $count = 0; if ( is_taxonomy_hierarchical( $taxonomy ) && !isset( $orderby ) ) { // We'll need the full set of terms then. $args['number'] = $args['offset'] = 0; $terms = get_terms( $taxonomy, $args ); if ( !empty( $search ) ) // Ignore children on searches. $children = array(); 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 $out .= $this->_rows( $taxonomy, $terms, $children, $offset, $number, $count ); } else { $terms = get_terms( $taxonomy, $args ); foreach ( $terms as $term ) $out .= $this->single_row( $term, 0, $taxonomy ); $count = $number; // Only displaying a single page. } echo $out; } function _rows( $taxonomy, $terms, &$children, $start = 0, $per_page = 20, &$count, $parent = 0, $level = 0 ) { $end = $start + $per_page; $output = ''; foreach ( $terms as $key => $term ) { if ( $count >= $end ) break; if ( $term->parent != $parent && empty( $_REQUEST['s'] ) ) continue; // If the page starts in a subtree, print the parents. if ( $count == $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) { $my_parents = $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. break; $parent_ids[] = $p; } unset( $parent_ids ); $num_parents = count( $my_parents ); while ( $my_parent = array_pop( $my_parents ) ) { $output .= "\t" . $this->single_row( $my_parent, $level - $num_parents, $taxonomy ); $num_parents--; } } if ( $count >= $start ) $output .= "\t" . $this->single_row( $term, $level, $taxonomy ); ++$count; unset( $terms[$key] ); if ( isset( $children[$term->term_id] ) && empty( $_REQUEST['s'] ) ) $output .= $this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 ); } return $output; } function single_row( $tag, $level = 0 ) { static $row_class = ''; $row_class = ( $row_class == '' ? ' class="alternate"' : '' ); $this->level = $level; echo '