From b8bd46c40666ff146d6671e53706d4ec8475c3bc Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Wed, 2 Jul 2014 22:53:14 +0000 Subject: [PATCH] Prepend "Draft:" to draft post titles when previewing on the front end, and add a "single-status-$status" class to the body classes for all post statuses. Fixes #28006. Props hlashbrooke Built from https://develop.svn.wordpress.org/trunk@28963 git-svn-id: http://core.svn.wordpress.org/trunk@28756 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post-template.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index 0c63083334..7af1d96612 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -145,6 +145,21 @@ function get_the_title( $post = 0 ) { */ $private_title_format = apply_filters( 'private_title_format', __( 'Private: %s' ), $post ); $title = sprintf( $private_title_format, $title ); + } else if ( isset( $post->post_status ) && 'draft' == $post->post_status ) { + + /** + * Filter the text prepended to the post title of draft posts. + * + * The filter is only applied on the front end. + * + * @since 4.0.0 + * + * @param string $prepend Text displayed before the post title. + * Default 'Draft: %s'. + * @param WP_Post $post Current post object. + */ + $draft_title_format = apply_filters( 'draft_title_format', __( 'Draft: %s' ), $post ); + $title = sprintf( $draft_title_format, $title ); } } @@ -537,6 +552,7 @@ function get_body_class( $class = '' ) { if ( isset( $post->post_type ) ) { $classes[] = 'single-' . sanitize_html_class($post->post_type, $post_id); $classes[] = 'postid-' . $post_id; + $classes[] = 'single-status-' . sanitize_html_class( $post->post_status ); // Post Format if ( post_type_supports( $post->post_type, 'post-formats' ) ) {