From ca0274c2ced7e72c774f2b7b11efddd06f2e5f52 Mon Sep 17 00:00:00 2001 From: "David A. Kennedy" Date: Fri, 27 Jan 2017 22:09:42 +0000 Subject: [PATCH] Bundled Themes: Allow category display in post preview even when only one category The category is not shown in the preview. And because of how `themename_categorized_blog()` function in each theme returns false for 1 or fewer categories, and in this case it won't show the new category. The patch uses `is_preview()` to fix that in Twenty Fourteen, Fifteen and Seventeen. Props lancewillett. Fixes #39531. Built from https://develop.svn.wordpress.org/trunk@40023 git-svn-id: http://core.svn.wordpress.org/trunk@39960 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-content/themes/twentyfifteen/inc/template-tags.php | 2 +- wp-content/themes/twentyfourteen/inc/template-tags.php | 2 +- wp-content/themes/twentyseventeen/inc/template-tags.php | 5 +++++ wp-includes/version.php | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/wp-content/themes/twentyfifteen/inc/template-tags.php b/wp-content/themes/twentyfifteen/inc/template-tags.php index fb6004ec38..f4de1d58bf 100644 --- a/wp-content/themes/twentyfifteen/inc/template-tags.php +++ b/wp-content/themes/twentyfifteen/inc/template-tags.php @@ -150,7 +150,7 @@ function twentyfifteen_categorized_blog() { set_transient( 'twentyfifteen_categories', $all_the_cool_cats ); } - if ( $all_the_cool_cats > 1 ) { + if ( $all_the_cool_cats > 1 || is_preview() ) { // This blog has more than 1 category so twentyfifteen_categorized_blog should return true. return true; } else { diff --git a/wp-content/themes/twentyfourteen/inc/template-tags.php b/wp-content/themes/twentyfourteen/inc/template-tags.php index f63ee8284b..1d35d0d5b9 100644 --- a/wp-content/themes/twentyfourteen/inc/template-tags.php +++ b/wp-content/themes/twentyfourteen/inc/template-tags.php @@ -140,7 +140,7 @@ function twentyfourteen_categorized_blog() { set_transient( 'twentyfourteen_category_count', $all_the_cool_cats ); } - if ( 1 !== (int) $all_the_cool_cats ) { + if ( $all_the_cool_cats > 1 || is_preview() ) { // This blog has more than 1 category so twentyfourteen_categorized_blog should return true return true; } else { diff --git a/wp-content/themes/twentyseventeen/inc/template-tags.php b/wp-content/themes/twentyseventeen/inc/template-tags.php index f94e3c9c87..782a81fe3b 100644 --- a/wp-content/themes/twentyseventeen/inc/template-tags.php +++ b/wp-content/themes/twentyseventeen/inc/template-tags.php @@ -177,6 +177,11 @@ function twentyseventeen_categorized_blog() { set_transient( 'twentyseventeen_categories', $category_count ); } + // Allow viewing case of 0 or 1 categories in post preview. + if ( is_preview() ) { + return true; + } + return $category_count > 1; } diff --git a/wp-includes/version.php b/wp-includes/version.php index d2fc2db28a..23acf20f9e 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.8-alpha-40022'; +$wp_version = '4.8-alpha-40023'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.