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(); ?>
>