From 3af610b13e5b74393b336a22bdb7b9a603d38a7f Mon Sep 17 00:00:00 2001 From: SirLouen Date: Mon, 15 Sep 2025 13:58:51 +0200 Subject: [PATCH 1/3] Adding new filter to the filter links --- .../includes/class-wp-posts-list-table.php | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/includes/class-wp-posts-list-table.php b/src/wp-admin/includes/class-wp-posts-list-table.php index bc25dd0045a87..e8c489d751b6e 100644 --- a/src/wp-admin/includes/class-wp-posts-list-table.php +++ b/src/wp-admin/includes/class-wp-posts-list-table.php @@ -272,12 +272,28 @@ protected function get_edit_link( $args, $link_text, $css_class = '' ) { } } + $edit_filter_link_vars = compact( 'url', 'link_text', 'class_html' ); + /** + * Filters the links created for filtering the posts list table. + * + * @since 6.9.0 + * + * @param array $edit_filter_link_vars { + * The edit filter link variables. + * @type string $url The formatted link string. + * @type string $link_text The link text. + * @type string $class_html The class HTML. + * } + * @param array $args URL parameters for the link. + */ + $edit_filter_link_vars = apply_filters( 'edit_filter_links', $edit_filter_link_vars, $args ); + return sprintf( '%s', - esc_url( $url ), - $class_html, + esc_url( $edit_filter_link_vars['url'] ), + $edit_filter_link_vars['class_html'], $aria_current, - $link_text + $edit_filter_link_vars['link_text'] ); } From d769c6608dbe3ed56478df6b9f8c4fe063fe25f0 Mon Sep 17 00:00:00 2001 From: SirLouen Date: Mon, 15 Sep 2025 15:00:04 +0200 Subject: [PATCH 2/3] Better filter placement to target css_class --- .../includes/class-wp-posts-list-table.php | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/wp-admin/includes/class-wp-posts-list-table.php b/src/wp-admin/includes/class-wp-posts-list-table.php index e8c489d751b6e..a8a5f5d99c5e0 100644 --- a/src/wp-admin/includes/class-wp-posts-list-table.php +++ b/src/wp-admin/includes/class-wp-posts-list-table.php @@ -261,18 +261,7 @@ protected function get_edit_link( $args, $link_text, $css_class = '' ) { $class_html = ''; $aria_current = ''; - if ( ! empty( $css_class ) ) { - $class_html = sprintf( - ' class="%s"', - esc_attr( $css_class ) - ); - - if ( 'current' === $css_class ) { - $aria_current = ' aria-current="page"'; - } - } - - $edit_filter_link_vars = compact( 'url', 'link_text', 'class_html' ); + $edit_filter_link_vars = compact( 'url', 'link_text', 'css_class' ); /** * Filters the links created for filtering the posts list table. * @@ -282,16 +271,27 @@ protected function get_edit_link( $args, $link_text, $css_class = '' ) { * The edit filter link variables. * @type string $url The formatted link string. * @type string $link_text The link text. - * @type string $class_html The class HTML. + * @type string $css_class The class HTML. * } * @param array $args URL parameters for the link. */ $edit_filter_link_vars = apply_filters( 'edit_filter_links', $edit_filter_link_vars, $args ); + if ( ! empty( $edit_filter_link_vars['css_class'] ) ) { + $class_html = sprintf( + ' class="%s"', + esc_attr( $edit_filter_link_vars['css_class'] ) + ); + + if ( 'current' === $edit_filter_link_vars['css_class'] ) { + $aria_current = ' aria-current="page"'; + } + } + return sprintf( '%s', esc_url( $edit_filter_link_vars['url'] ), - $edit_filter_link_vars['class_html'], + $class_html, $aria_current, $edit_filter_link_vars['link_text'] ); From eaece89b46756903dd0c144ec87d8b91acb18f77 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 20 Oct 2025 12:18:27 -0700 Subject: [PATCH 3/3] Tidy phpdoc --- src/wp-admin/includes/class-wp-posts-list-table.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/wp-admin/includes/class-wp-posts-list-table.php b/src/wp-admin/includes/class-wp-posts-list-table.php index a8a5f5d99c5e0..e54ce781d95ed 100644 --- a/src/wp-admin/includes/class-wp-posts-list-table.php +++ b/src/wp-admin/includes/class-wp-posts-list-table.php @@ -262,16 +262,18 @@ protected function get_edit_link( $args, $link_text, $css_class = '' ) { $aria_current = ''; $edit_filter_link_vars = compact( 'url', 'link_text', 'css_class' ); + /** * Filters the links created for filtering the posts list table. * * @since 6.9.0 * * @param array $edit_filter_link_vars { - * The edit filter link variables. - * @type string $url The formatted link string. - * @type string $link_text The link text. - * @type string $css_class The class HTML. + * The edit filter link variables. + * + * @type string $url The formatted link string. + * @type string $link_text The link text. + * @type string $css_class The class HTML. * } * @param array $args URL parameters for the link. */