From f689b0a36e99503aae443e333d4b934c616cdeb7 Mon Sep 17 00:00:00 2001 From: Konstantin Obenland Date: Thu, 5 Nov 2026 22:53:28 -0600 Subject: [PATCH] Plugin Directory: Show closed plugins by their slug everywhere on the front end Closed and disabled plugins already show their slug instead of their name in the plugin header, see [6469]. The document title, og:title, and the Contributors & Developers section still used the plugin name. Filter the_title and single_post_title on the front end instead, so every place that reads the title gets the slug, and drop the header's own special case. Fixes #8111. Co-Authored-By: Claude Opus 5.5 --- .../pub/wporg-plugins-2024/functions.php | 26 +++++++++++++++++++ .../template-parts/plugin-single.php | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/functions.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/functions.php index cda9389671..9579b92b3a 100644 --- a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/functions.php +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/functions.php @@ -202,6 +202,32 @@ function content() { } add_action( 'template_redirect', __NAMESPACE__ . '\content' ); +/** + * Show closed and disabled plugins by their slug instead of their name in the front-end. + */ +function closed_plugin_title_filters() { + add_filter( 'the_title', __NAMESPACE__ . '\closed_plugin_title', 10, 2 ); + add_filter( 'single_post_title', __NAMESPACE__ . '\closed_plugin_title', 10, 2 ); +} +add_action( 'template_redirect', __NAMESPACE__ . '\closed_plugin_title_filters' ); + +/** + * Replaces the title of a closed or disabled plugin with its slug. + * + * @param string $title The post title. + * @param int|\WP_Post|null $post Optional. The post ID or object. + * @return string The filtered title. + */ +function closed_plugin_title( $title, $post = null ) { + $post = $post ? get_post( $post ) : null; + + if ( $post && 'plugin' === $post->post_type && in_array( $post->post_status, array( 'closed', 'disabled' ), true ) ) { + return $post->post_name; + } + + return $title; +} + /** * Filters the list of CSS body classes for the current post or page. * diff --git a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php index f1fa2a127f..2bee00ef6e 100644 --- a/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php +++ b/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins-2024/template-parts/plugin-single.php @@ -17,7 +17,7 @@ $content = Plugin_Directory::instance()->split_post_content_into_pages( get_the_content() ); $is_closed = in_array( get_post_status(), [ 'closed', 'disabled' ], true ); -$plugin_title = $is_closed ? $post->post_name : get_the_title(); +$plugin_title = get_the_title(); ?>
>