Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) ) {
Comment thread
obenland marked this conversation as resolved.
Resolved
return $post->post_name;
}

return $title;
}

/**
* Filters the list of CSS body classes for the current post or page.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
?>

<article id="post-<?php the_ID(); ?>" <?php post_class( 'alignwide' ); ?>>
Expand Down
Loading