Taxonomy: Introduce `post_column_taxonomy_links`.

This filter allows plugin developers to modify the markup for the links
in taxonomy columns on edit.php.

Props DaveFX.
Fixes #42669.
Built from https://develop.svn.wordpress.org/trunk@44822


git-svn-id: http://core.svn.wordpress.org/trunk@44654 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2019-03-08 15:37:52 +00:00
parent 2b100c8151
commit 401d3c1b51
2 changed files with 17 additions and 4 deletions

View File

@ -1126,7 +1126,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$taxonomy_object = get_taxonomy( $taxonomy ); $taxonomy_object = get_taxonomy( $taxonomy );
$terms = get_the_terms( $post->ID, $taxonomy ); $terms = get_the_terms( $post->ID, $taxonomy );
if ( is_array( $terms ) ) { if ( is_array( $terms ) ) {
$out = array(); $term_links = array();
foreach ( $terms as $t ) { foreach ( $terms as $t ) {
$posts_in_term_qv = array(); $posts_in_term_qv = array();
if ( 'post' != $post->post_type ) { if ( 'post' != $post->post_type ) {
@ -1140,10 +1140,23 @@ class WP_Posts_List_Table extends WP_List_Table {
} }
$label = esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ); $label = esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) );
$out[] = $this->get_edit_link( $posts_in_term_qv, $label );
$term_links[] = $this->get_edit_link( $posts_in_term_qv, $label );
} }
/**
* Filters the links in `$taxonomy` column of edit.php.
*
* @since 5.2.0
*
* @param array $term_links List of links to edit.php, filtered by the taxonomy term.
* @param string $taxonomy Taxonomy name.
* @param array $terms Array of terms appearing in the post row.
*/
$term_links = apply_filters( 'post_column_taxonomy_links', $term_links, $taxonomy, $terms );
/* translators: used between list items, there is a space after the comma */ /* translators: used between list items, there is a space after the comma */
echo join( __( ', ' ), $out ); echo join( __( ', ' ), $term_links );
} else { } else {
echo '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>'; echo '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>';
} }

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.2-alpha-44821'; $wp_version = '5.2-alpha-44822';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.