wp/wp-admin/includes/class-wp-terms-list-table.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
     1 <?php
     1 <?php
     2 /**
     2 /**
     3  * Terms List Table class.
     3  * List Table API: WP_Terms_List_Table class
     4  *
     4  *
     5  * @package WordPress
     5  * @package WordPress
     6  * @subpackage List_Table
     6  * @subpackage Administration
       
     7  * @since 3.1.0
       
     8  */
       
     9 
       
    10 /**
       
    11  * Core class used to implement displaying terms in a list table.
       
    12  *
     7  * @since 3.1.0
    13  * @since 3.1.0
     8  * @access private
    14  * @access private
       
    15  *
       
    16  * @see WP_List_Table
     9  */
    17  */
    10 class WP_Terms_List_Table extends WP_List_Table {
    18 class WP_Terms_List_Table extends WP_List_Table {
    11 
    19 
    12 	public $callback_args;
    20 	public $callback_args;
    13 
    21 
    15 
    23 
    16 	/**
    24 	/**
    17 	 * Constructor.
    25 	 * Constructor.
    18 	 *
    26 	 *
    19 	 * @since 3.1.0
    27 	 * @since 3.1.0
    20 	 * @access public
       
    21 	 *
    28 	 *
    22 	 * @see WP_List_Table::__construct() for more information on default arguments.
    29 	 * @see WP_List_Table::__construct() for more information on default arguments.
       
    30 	 *
       
    31 	 * @global string $post_type
       
    32 	 * @global string $taxonomy
       
    33 	 * @global string $action
       
    34 	 * @global object $tax
    23 	 *
    35 	 *
    24 	 * @param array $args An associative array of arguments.
    36 	 * @param array $args An associative array of arguments.
    25 	 */
    37 	 */
    26 	public function __construct( $args = array() ) {
    38 	public function __construct( $args = array() ) {
    27 		global $post_type, $taxonomy, $action, $tax;
    39 		global $post_type, $taxonomy, $action, $tax;
    38 
    50 
    39 		if ( empty( $taxonomy ) )
    51 		if ( empty( $taxonomy ) )
    40 			$taxonomy = 'post_tag';
    52 			$taxonomy = 'post_tag';
    41 
    53 
    42 		if ( ! taxonomy_exists( $taxonomy ) )
    54 		if ( ! taxonomy_exists( $taxonomy ) )
    43 			wp_die( __( 'Invalid taxonomy' ) );
    55 			wp_die( __( 'Invalid taxonomy.' ) );
    44 
    56 
    45 		$tax = get_taxonomy( $taxonomy );
    57 		$tax = get_taxonomy( $taxonomy );
    46 
    58 
    47 		// @todo Still needed? Maybe just the show_ui part.
    59 		// @todo Still needed? Maybe just the show_ui part.
    48 		if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) )
    60 		if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) )
    49 			$post_type = 'post';
    61 			$post_type = 'post';
    50 
    62 
    51 	}
    63 	}
    52 
    64 
       
    65 	/**
       
    66 	 *
       
    67 	 * @return bool
       
    68 	 */
    53 	public function ajax_user_can() {
    69 	public function ajax_user_can() {
    54 		return current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->manage_terms );
    70 		return current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->manage_terms );
    55 	}
    71 	}
    56 
    72 
       
    73 	/**
       
    74 	 */
    57 	public function prepare_items() {
    75 	public function prepare_items() {
    58 		$tags_per_page = $this->get_items_per_page( 'edit_' . $this->screen->taxonomy . '_per_page' );
    76 		$tags_per_page = $this->get_items_per_page( 'edit_' . $this->screen->taxonomy . '_per_page' );
    59 
    77 
    60 		if ( 'post_tag' == $this->screen->taxonomy ) {
    78 		if ( 'post_tag' === $this->screen->taxonomy ) {
    61 			/**
    79 			/**
    62 			 * Filter the number of terms displayed per page for the Tags list table.
    80 			 * Filters the number of terms displayed per page for the Tags list table.
    63 			 *
    81 			 *
    64 			 * @since 2.8.0
    82 			 * @since 2.8.0
    65 			 *
    83 			 *
    66 			 * @param int $tags_per_page Number of tags to be displayed. Default 20.
    84 			 * @param int $tags_per_page Number of tags to be displayed. Default 20.
    67 			 */
    85 			 */
    68 			$tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page );
    86 			$tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page );
    69 
    87 
    70 			/**
    88 			/**
    71 			 * Filter the number of terms displayed per page for the Tags list table.
    89 			 * Filters the number of terms displayed per page for the Tags list table.
    72 			 *
    90 			 *
    73 			 * @since 2.7.0
    91 			 * @since 2.7.0
    74 			 * @deprecated 2.8.0 Use edit_tags_per_page instead.
    92 			 * @deprecated 2.8.0 Use edit_tags_per_page instead.
    75 			 *
    93 			 *
    76 			 * @param int $tags_per_page Number of tags to be displayed. Default 20.
    94 			 * @param int $tags_per_page Number of tags to be displayed. Default 20.
    77 			 */
    95 			 */
    78 			$tags_per_page = apply_filters( 'tagsperpage', $tags_per_page );
    96 			$tags_per_page = apply_filters( 'tagsperpage', $tags_per_page );
    79 		} elseif ( 'category' == $this->screen->taxonomy ) {
    97 		} elseif ( 'category' === $this->screen->taxonomy ) {
    80 			/**
    98 			/**
    81 			 * Filter the number of terms displayed per page for the Categories list table.
    99 			 * Filters the number of terms displayed per page for the Categories list table.
    82 			 *
   100 			 *
    83 			 * @since 2.8.0
   101 			 * @since 2.8.0
    84 			 *
   102 			 *
    85 			 * @param int $tags_per_page Number of categories to be displayed. Default 20.
   103 			 * @param int $tags_per_page Number of categories to be displayed. Default 20.
    86 			 */
   104 			 */
   107 			'total_items' => wp_count_terms( $this->screen->taxonomy, compact( 'search' ) ),
   125 			'total_items' => wp_count_terms( $this->screen->taxonomy, compact( 'search' ) ),
   108 			'per_page' => $tags_per_page,
   126 			'per_page' => $tags_per_page,
   109 		) );
   127 		) );
   110 	}
   128 	}
   111 
   129 
       
   130 	/**
       
   131 	 *
       
   132 	 * @return bool
       
   133 	 */
   112 	public function has_items() {
   134 	public function has_items() {
   113 		// todo: populate $this->items in prepare_items()
   135 		// todo: populate $this->items in prepare_items()
   114 		return true;
   136 		return true;
   115 	}
   137 	}
   116 
   138 
       
   139 	/**
       
   140 	 */
   117 	public function no_items() {
   141 	public function no_items() {
   118 		echo get_taxonomy( $this->screen->taxonomy )->labels->not_found;
   142 		echo get_taxonomy( $this->screen->taxonomy )->labels->not_found;
   119 	}
   143 	}
   120 
   144 
       
   145 	/**
       
   146 	 *
       
   147 	 * @return array
       
   148 	 */
   121 	protected function get_bulk_actions() {
   149 	protected function get_bulk_actions() {
   122 		$actions = array();
   150 		$actions = array();
   123 		$actions['delete'] = __( 'Delete' );
   151 
       
   152 		if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) ) {
       
   153 			$actions['delete'] = __( 'Delete' );
       
   154 		}
   124 
   155 
   125 		return $actions;
   156 		return $actions;
   126 	}
   157 	}
   127 
   158 
       
   159 	/**
       
   160 	 *
       
   161 	 * @return string
       
   162 	 */
   128 	public function current_action() {
   163 	public function current_action() {
   129 		if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' == $_REQUEST['action'] || 'delete' == $_REQUEST['action2'] ) )
   164 		if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' === $_REQUEST['action'] || 'delete' === $_REQUEST['action2'] ) )
   130 			return 'bulk-delete';
   165 			return 'bulk-delete';
   131 
   166 
   132 		return parent::current_action();
   167 		return parent::current_action();
   133 	}
   168 	}
   134 
   169 
       
   170 	/**
       
   171 	 *
       
   172 	 * @return array
       
   173 	 */
   135 	public function get_columns() {
   174 	public function get_columns() {
   136 		$columns = array(
   175 		$columns = array(
   137 			'cb'          => '<input type="checkbox" />',
   176 			'cb'          => '<input type="checkbox" />',
   138 			'name'        => _x( 'Name', 'term name' ),
   177 			'name'        => _x( 'Name', 'term name' ),
   139 			'description' => __( 'Description' ),
   178 			'description' => __( 'Description' ),
   140 			'slug'        => __( 'Slug' ),
   179 			'slug'        => __( 'Slug' ),
   141 		);
   180 		);
   142 
   181 
   143 		if ( 'link_category' == $this->screen->taxonomy ) {
   182 		if ( 'link_category' === $this->screen->taxonomy ) {
   144 			$columns['links'] = __( 'Links' );
   183 			$columns['links'] = __( 'Links' );
   145 		} else {
   184 		} else {
   146 			$columns['posts'] = _x( 'Count', 'Number/count of items' );
   185 			$columns['posts'] = _x( 'Count', 'Number/count of items' );
   147 		}
   186 		}
   148 
   187 
   149 		return $columns;
   188 		return $columns;
   150 	}
   189 	}
   151 
   190 
       
   191 	/**
       
   192 	 *
       
   193 	 * @return array
       
   194 	 */
   152 	protected function get_sortable_columns() {
   195 	protected function get_sortable_columns() {
   153 		return array(
   196 		return array(
   154 			'name'        => 'name',
   197 			'name'        => 'name',
   155 			'description' => 'description',
   198 			'description' => 'description',
   156 			'slug'        => 'slug',
   199 			'slug'        => 'slug',
   157 			'posts'       => 'count',
   200 			'posts'       => 'count',
   158 			'links'       => 'count'
   201 			'links'       => 'count'
   159 		);
   202 		);
   160 	}
   203 	}
   161 
   204 
       
   205 	/**
       
   206 	 */
   162 	public function display_rows_or_placeholder() {
   207 	public function display_rows_or_placeholder() {
   163 		$taxonomy = $this->screen->taxonomy;
   208 		$taxonomy = $this->screen->taxonomy;
   164 
   209 
   165 		$args = wp_parse_args( $this->callback_args, array(
   210 		$args = wp_parse_args( $this->callback_args, array(
   166 			'page' => 1,
   211 			'page' => 1,
   183 			// We'll need the full set of terms then.
   228 			// We'll need the full set of terms then.
   184 			$args['number'] = $args['offset'] = 0;
   229 			$args['number'] = $args['offset'] = 0;
   185 		}
   230 		}
   186 		$terms = get_terms( $taxonomy, $args );
   231 		$terms = get_terms( $taxonomy, $args );
   187 
   232 
   188 		if ( empty( $terms ) ) {
   233 		if ( empty( $terms ) || ! is_array( $terms ) ) {
   189 			echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
   234 			echo '<tr class="no-items"><td class="colspanchange" colspan="' . $this->get_column_count() . '">';
   190 			$this->no_items();
   235 			$this->no_items();
   191 			echo '</td></tr>';
   236 			echo '</td></tr>';
   192 			return;
   237 			return;
   193 		}
   238 		}
   199 				$children = _get_term_hierarchy( $taxonomy );
   244 				$children = _get_term_hierarchy( $taxonomy );
   200 			}
   245 			}
   201 			// Some funky recursion to get the job done( Paging & parents mainly ) is contained within, Skip it for non-hierarchical taxonomies for performance sake
   246 			// Some funky recursion to get the job done( Paging & parents mainly ) is contained within, Skip it for non-hierarchical taxonomies for performance sake
   202 			$this->_rows( $taxonomy, $terms, $children, $offset, $number, $count );
   247 			$this->_rows( $taxonomy, $terms, $children, $offset, $number, $count );
   203 		} else {
   248 		} else {
   204 			$terms = get_terms( $taxonomy, $args );
       
   205 			foreach ( $terms as $term ) {
   249 			foreach ( $terms as $term ) {
   206 				$this->single_row( $term );
   250 				$this->single_row( $term );
   207 			}
   251 			}
   208 		}
   252 		}
   209 	}
   253 	}
   210 
   254 
   211 	/**
   255 	/**
   212 	 * @param string $taxonomy
   256 	 * @param string $taxonomy
   213 	 * @param array $terms
   257 	 * @param array $terms
   214 	 * @param array $children
   258 	 * @param array $children
   215 	 * @param int $start
   259 	 * @param int   $start
   216 	 * @param int $per_page
   260 	 * @param int   $per_page
   217 	 * @param int $count
   261 	 * @param int   $count
   218 	 * @param int $parent
   262 	 * @param int   $parent
   219 	 * @param int $level
   263 	 * @param int   $level
   220 	 */
   264 	 */
   221 	private function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$count, $parent = 0, $level = 0 ) {
   265 	private function _rows( $taxonomy, $terms, &$children, $start, $per_page, &$count, $parent = 0, $level = 0 ) {
   222 
   266 
   223 		$end = $start + $per_page;
   267 		$end = $start + $per_page;
   224 
   268 
   266 		}
   310 		}
   267 	}
   311 	}
   268 
   312 
   269 	/**
   313 	/**
   270 	 * @global string $taxonomy
   314 	 * @global string $taxonomy
   271 	 * @param object $tag
   315 	 * @param WP_Term $tag Term object.
   272 	 * @param int $level
   316 	 * @param int $level
   273 	 */
   317 	 */
   274 	public function single_row( $tag, $level = 0 ) {
   318 	public function single_row( $tag, $level = 0 ) {
   275 		global $taxonomy;
   319 		global $taxonomy;
   276  		$tag = sanitize_term( $tag, $taxonomy );
   320  		$tag = sanitize_term( $tag, $taxonomy );
   281 		$this->single_row_columns( $tag );
   325 		$this->single_row_columns( $tag );
   282 		echo '</tr>';
   326 		echo '</tr>';
   283 	}
   327 	}
   284 
   328 
   285 	/**
   329 	/**
   286 	 * @param object $tag
   330 	 * @param WP_Term $tag Term object.
   287 	 * @return string
   331 	 * @return string
   288 	 */
   332 	 */
   289 	public function column_cb( $tag ) {
   333 	public function column_cb( $tag ) {
   290 		$default_term = get_option( 'default_' . $this->screen->taxonomy );
   334 		if ( current_user_can( 'delete_term', $tag->term_id ) ) {
   291 
       
   292 		if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) && $tag->term_id != $default_term )
       
   293 			return '<label class="screen-reader-text" for="cb-select-' . $tag->term_id . '">' . sprintf( __( 'Select %s' ), $tag->name ) . '</label>'
   335 			return '<label class="screen-reader-text" for="cb-select-' . $tag->term_id . '">' . sprintf( __( 'Select %s' ), $tag->name ) . '</label>'
   294 				. '<input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" id="cb-select-' . $tag->term_id . '" />';
   336 				. '<input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" id="cb-select-' . $tag->term_id . '" />';
       
   337 		}
   295 
   338 
   296 		return '&nbsp;';
   339 		return '&nbsp;';
   297 	}
   340 	}
   298 
   341 
   299 	/**
   342 	/**
   300 	 * @param object $tag
   343 	 * @param WP_Term $tag Term object.
   301 	 * @return string
   344 	 * @return string
   302 	 */
   345 	 */
   303 	public function column_name( $tag ) {
   346 	public function column_name( $tag ) {
   304 		$taxonomy = $this->screen->taxonomy;
   347 		$taxonomy = $this->screen->taxonomy;
   305 		$tax = get_taxonomy( $taxonomy );
       
   306 
       
   307 		$default_term = get_option( 'default_' . $taxonomy );
       
   308 
   348 
   309 		$pad = str_repeat( '&#8212; ', max( 0, $this->level ) );
   349 		$pad = str_repeat( '&#8212; ', max( 0, $this->level ) );
   310 
   350 
   311 		/**
   351 		/**
   312 		 * Filter display of the term name in the terms list table.
   352 		 * Filters display of the term name in the terms list table.
   313 		 *
   353 		 *
   314 		 * The default output may include padding due to the term's
   354 		 * The default output may include padding due to the term's
   315 		 * current level in the term hierarchy.
   355 		 * current level in the term hierarchy.
   316 		 *
   356 		 *
   317 		 * @since 2.5.0
   357 		 * @since 2.5.0
   318 		 *
   358 		 *
   319 		 * @see WP_Terms_List_Table::column_name()
   359 		 * @see WP_Terms_List_Table::column_name()
   320 		 *
   360 		 *
   321 		 * @param string $pad_tag_name The term name, padded if not top-level.
   361 		 * @param string $pad_tag_name The term name, padded if not top-level.
   322 		 * @param object $tag          Term object.
   362 		 * @param WP_Term $tag         Term object.
   323 		 */
   363 		 */
   324 		$name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag );
   364 		$name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag );
   325 
   365 
   326 		$qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' );
   366 		$qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' );
   327 		$edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) );
   367 
   328 
   368 		$uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
   329 		$out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $name ) ) . '">' . $name . '</a></strong><br />';
   369 
       
   370 		$edit_link = add_query_arg(
       
   371 			'wp_http_referer',
       
   372 			urlencode( wp_unslash( $uri ) ),
       
   373 			get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type )
       
   374 		);
       
   375 
       
   376 		$out = sprintf(
       
   377 			'<strong><a class="row-title" href="%s" aria-label="%s">%s</a></strong><br />',
       
   378 			esc_url( $edit_link ),
       
   379 			/* translators: %s: taxonomy term name */
       
   380 			esc_attr( sprintf( __( '&#8220;%s&#8221; (Edit)' ), $tag->name ) ),
       
   381 			$name
       
   382 		);
       
   383 
       
   384 		$out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
       
   385 		$out .= '<div class="name">' . $qe_data->name . '</div>';
       
   386 
       
   387 		/** This filter is documented in wp-admin/edit-tag-form.php */
       
   388 		$out .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug, $qe_data ) . '</div>';
       
   389 		$out .= '<div class="parent">' . $qe_data->parent . '</div></div>';
       
   390 
       
   391 		return $out;
       
   392 	}
       
   393 
       
   394 	/**
       
   395 	 * Gets the name of the default primary column.
       
   396 	 *
       
   397 	 * @since 4.3.0
       
   398 	 *
       
   399 	 * @return string Name of the default primary column, in this case, 'name'.
       
   400 	 */
       
   401 	protected function get_default_primary_column_name() {
       
   402 		return 'name';
       
   403 	}
       
   404 
       
   405 	/**
       
   406 	 * Generates and displays row action links.
       
   407 	 *
       
   408 	 * @since 4.3.0
       
   409 	 *
       
   410 	 * @param WP_Term $tag         Tag being acted upon.
       
   411 	 * @param string  $column_name Current column name.
       
   412 	 * @param string  $primary     Primary column name.
       
   413 	 * @return string Row actions output for terms.
       
   414 	 */
       
   415 	protected function handle_row_actions( $tag, $column_name, $primary ) {
       
   416 		if ( $primary !== $column_name ) {
       
   417 			return '';
       
   418 		}
       
   419 
       
   420 		$taxonomy = $this->screen->taxonomy;
       
   421 		$tax = get_taxonomy( $taxonomy );
       
   422 		$uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];
       
   423 
       
   424 		$edit_link = add_query_arg(
       
   425 			'wp_http_referer',
       
   426 			urlencode( wp_unslash( $uri ) ),
       
   427 			get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type )
       
   428 		);
   330 
   429 
   331 		$actions = array();
   430 		$actions = array();
   332 		if ( current_user_can( $tax->cap->edit_terms ) ) {
   431 		if ( current_user_can( 'edit_term', $tag->term_id ) ) {
   333 			$actions['edit'] = '<a href="' . $edit_link . '">' . __( 'Edit' ) . '</a>';
   432 			$actions['edit'] = sprintf(
   334 			$actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __( 'Quick&nbsp;Edit' ) . '</a>';
   433 				'<a href="%s" aria-label="%s">%s</a>',
   335 		}
   434 				esc_url( $edit_link ),
   336 		if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term )
   435 				/* translators: %s: taxonomy term name */
   337 			$actions['delete'] = "<a class='delete-tag' href='" . wp_nonce_url( "edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ) . "'>" . __( 'Delete' ) . "</a>";
   436 				esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $tag->name ) ),
   338 		if ( $tax->public )
   437 				__( 'Edit' )
   339 			$actions['view'] = '<a href="' . get_term_link( $tag ) . '">' . __( 'View' ) . '</a>';
   438 			);
       
   439 			$actions['inline hide-if-no-js'] = sprintf(
       
   440 				'<a href="#" class="editinline aria-button-if-js" aria-label="%s">%s</a>',
       
   441 				/* translators: %s: taxonomy term name */
       
   442 				esc_attr( sprintf( __( 'Quick edit &#8220;%s&#8221; inline' ), $tag->name ) ),
       
   443 				__( 'Quick&nbsp;Edit' )
       
   444 			);
       
   445 		}
       
   446 		if ( current_user_can( 'delete_term', $tag->term_id ) ) {
       
   447 			$actions['delete'] = sprintf(
       
   448 				'<a href="%s" class="delete-tag aria-button-if-js" aria-label="%s">%s</a>',
       
   449 				wp_nonce_url( "edit-tags.php?action=delete&amp;taxonomy=$taxonomy&amp;tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id ),
       
   450 				/* translators: %s: taxonomy term name */
       
   451 				esc_attr( sprintf( __( 'Delete &#8220;%s&#8221;' ), $tag->name ) ),
       
   452 				__( 'Delete' )
       
   453 			);
       
   454 		}
       
   455 		if ( $tax->public ) {
       
   456 			$actions['view'] = sprintf(
       
   457 				'<a href="%s" aria-label="%s">%s</a>',
       
   458 				get_term_link( $tag ),
       
   459 				/* translators: %s: taxonomy term name */
       
   460 				esc_attr( sprintf( __( 'View &#8220;%s&#8221; archive' ), $tag->name ) ),
       
   461 				__( 'View' )
       
   462 			);
       
   463 		}
   340 
   464 
   341 		/**
   465 		/**
   342 		 * Filter the action links displayed for each term in the Tags list table.
   466 		 * Filters the action links displayed for each term in the Tags list table.
   343 		 *
   467 		 *
   344 		 * @since 2.8.0
   468 		 * @since 2.8.0
   345 		 * @deprecated 3.0.0 Use {$taxonomy}_row_actions instead.
   469 		 * @deprecated 3.0.0 Use {$taxonomy}_row_actions instead.
   346 		 *
   470 		 *
   347 		 * @param array  $actions An array of action links to be displayed. Default
   471 		 * @param array  $actions An array of action links to be displayed. Default
   348 		 *                        'Edit', 'Quick Edit', 'Delete', and 'View'.
   472 		 *                        'Edit', 'Quick Edit', 'Delete', and 'View'.
   349 		 * @param object $tag     Term object.
   473 		 * @param WP_Term $tag    Term object.
   350 		 */
   474 		 */
   351 		$actions = apply_filters( 'tag_row_actions', $actions, $tag );
   475 		$actions = apply_filters( 'tag_row_actions', $actions, $tag );
   352 
   476 
   353 		/**
   477 		/**
   354 		 * Filter the action links displayed for each term in the terms list table.
   478 		 * Filters the action links displayed for each term in the terms list table.
   355 		 *
   479 		 *
   356 		 * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
   480 		 * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
   357 		 *
   481 		 *
   358 		 * @since 3.0.0
   482 		 * @since 3.0.0
   359 		 *
   483 		 *
   360 		 * @param array  $actions An array of action links to be displayed. Default
   484 		 * @param array  $actions An array of action links to be displayed. Default
   361 		 *                        'Edit', 'Quick Edit', 'Delete', and 'View'.
   485 		 *                        'Edit', 'Quick Edit', 'Delete', and 'View'.
   362 		 * @param object $tag     Term object.
   486 		 * @param WP_Term $tag    Term object.
   363 		 */
   487 		 */
   364 		$actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag );
   488 		$actions = apply_filters( "{$taxonomy}_row_actions", $actions, $tag );
   365 
   489 
   366 		$out .= $this->row_actions( $actions );
   490 		return $this->row_actions( $actions );
   367 		$out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
   491 	}
   368 		$out .= '<div class="name">' . $qe_data->name . '</div>';
   492 
   369 
   493 	/**
   370 		/** This filter is documented in wp-admin/edit-tag-form.php */
   494 	 * @param WP_Term $tag Term object.
   371 		$out .= '<div class="slug">' . apply_filters( 'editable_slug', $qe_data->slug ) . '</div>';
       
   372 		$out .= '<div class="parent">' . $qe_data->parent . '</div></div>';
       
   373 
       
   374 		return $out;
       
   375 	}
       
   376 
       
   377 	/**
       
   378 	 * @param object $tag
       
   379 	 * @return string
   495 	 * @return string
   380 	 */
   496 	 */
   381 	public function column_description( $tag ) {
   497 	public function column_description( $tag ) {
   382 		return $tag->description;
   498 		if ( $tag->description ) {
   383 	}
   499 			return $tag->description;
   384 
   500 		} else {
   385 	/**
   501 			return '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">' . __( 'No description' ) . '</span>';
   386 	 * @param object $tag
   502 		}
       
   503 	}
       
   504 
       
   505 	/**
       
   506 	 * @param WP_Term $tag Term object.
   387 	 * @return string
   507 	 * @return string
   388 	 */
   508 	 */
   389 	public function column_slug( $tag ) {
   509 	public function column_slug( $tag ) {
   390 		/** This filter is documented in wp-admin/edit-tag-form.php */
   510 		/** This filter is documented in wp-admin/edit-tag-form.php */
   391 		return apply_filters( 'editable_slug', $tag->slug );
   511 		return apply_filters( 'editable_slug', $tag->slug, $tag );
   392 	}
   512 	}
   393 
   513 
   394 	/**
   514 	/**
   395 	 * @param object $tag
   515 	 * @param WP_Term $tag Term object.
   396 	 * @return string
   516 	 * @return string
   397 	 */
   517 	 */
   398 	public function column_posts( $tag ) {
   518 	public function column_posts( $tag ) {
   399 		$count = number_format_i18n( $tag->count );
   519 		$count = number_format_i18n( $tag->count );
   400 
   520 
   411 		}
   531 		}
   412 
   532 
   413 		if ( 'post' != $this->screen->post_type )
   533 		if ( 'post' != $this->screen->post_type )
   414 			$args['post_type'] = $this->screen->post_type;
   534 			$args['post_type'] = $this->screen->post_type;
   415 
   535 
   416 		if ( 'attachment' == $this->screen->post_type )
   536 		if ( 'attachment' === $this->screen->post_type )
   417 			return "<a href='" . esc_url ( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>";
   537 			return "<a href='" . esc_url ( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>";
   418 
   538 
   419 		return "<a href='" . esc_url ( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>";
   539 		return "<a href='" . esc_url ( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>";
   420 	}
   540 	}
   421 
   541 
   422 	/**
   542 	/**
   423 	 * @param object $tag
   543 	 * @param WP_Term $tag Term object.
   424 	 * @return string
   544 	 * @return string
   425 	 */
   545 	 */
   426 	public function column_links( $tag ) {
   546 	public function column_links( $tag ) {
   427 		$count = number_format_i18n( $tag->count );
   547 		$count = number_format_i18n( $tag->count );
   428 		if ( $count )
   548 		if ( $count )
   429 			$count = "<a href='link-manager.php?cat_id=$tag->term_id'>$count</a>";
   549 			$count = "<a href='link-manager.php?cat_id=$tag->term_id'>$count</a>";
   430 		return $count;
   550 		return $count;
   431 	}
   551 	}
   432 
   552 
   433 	/**
   553 	/**
   434 	 * @param object $tag
   554 	 * @param WP_Term $tag Term object.
   435 	 * @param string $column_name
   555 	 * @param string $column_name
   436 	 * @return string
   556 	 * @return string
   437 	 */
   557 	 */
   438 	public function column_default( $tag, $column_name ) {
   558 	public function column_default( $tag, $column_name ) {
   439 		/**
   559 		/**
   440 		 * Filter the displayed columns in the terms list table.
   560 		 * Filters the displayed columns in the terms list table.
   441 		 *
   561 		 *
   442 		 * The dynamic portion of the hook name, `$this->screen->taxonomy`,
   562 		 * The dynamic portion of the hook name, `$this->screen->taxonomy`,
   443 		 * refers to the slug of the current taxonomy.
   563 		 * refers to the slug of the current taxonomy.
   444 		 *
   564 		 *
   445 		 * @since 2.8.0
   565 		 * @since 2.8.0
   464 ?>
   584 ?>
   465 
   585 
   466 	<form method="get"><table style="display: none"><tbody id="inlineedit">
   586 	<form method="get"><table style="display: none"><tbody id="inlineedit">
   467 		<tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
   587 		<tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange">
   468 
   588 
   469 			<fieldset><div class="inline-edit-col">
   589 			<fieldset>
   470 				<h4><?php _e( 'Quick Edit' ); ?></h4>
   590 				<legend class="inline-edit-legend"><?php _e( 'Quick Edit' ); ?></legend>
   471 
   591 				<div class="inline-edit-col">
   472 				<label>
   592 				<label>
   473 					<span class="title"><?php _ex( 'Name', 'term name' ); ?></span>
   593 					<span class="title"><?php _ex( 'Name', 'term name' ); ?></span>
   474 					<span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>
   594 					<span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>
   475 				</label>
   595 				</label>
   476 	<?php if ( !global_terms_enabled() ) { ?>
   596 	<?php if ( !global_terms_enabled() ) { ?>
   494 			do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy );
   614 			do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy );
   495 		}
   615 		}
   496 
   616 
   497 	?>
   617 	?>
   498 
   618 
   499 		<p class="inline-edit-save submit">
   619 		<div class="inline-edit-save submit">
   500 			<a href="#inline-edit" class="cancel button-secondary alignleft"><?php _e( 'Cancel' ); ?></a>
   620 			<button type="button" class="cancel button alignleft"><?php _e( 'Cancel' ); ?></button>
   501 			<a href="#inline-edit" class="save button-primary alignright"><?php echo $tax->labels->update_item; ?></a>
   621 			<button type="button" class="save button button-primary alignright"><?php echo $tax->labels->update_item; ?></button>
   502 			<span class="spinner"></span>
   622 			<span class="spinner"></span>
   503 			<span class="error" style="display:none;"></span>
       
   504 			<?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?>
   623 			<?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?>
   505 			<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" />
   624 			<input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" />
   506 			<input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" />
   625 			<input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" />
   507 			<br class="clear" />
   626 			<br class="clear" />
   508 		</p>
   627 			<div class="notice notice-error notice-alt inline hidden">
       
   628 				<p class="error"></p>
       
   629 			</div>
       
   630 		</div>
   509 		</td></tr>
   631 		</td></tr>
   510 		</tbody></table></form>
   632 		</tbody></table></form>
   511 	<?php
   633 	<?php
   512 	}
   634 	}
   513 }
   635 }