From 387df73308382cdf80c29fba9500609bf93a4eb6 Mon Sep 17 00:00:00 2001 From: Thomas Guillot Date: Mon, 3 Jul 2017 10:43:21 +0100 Subject: [PATCH] _s: Add featured images to Post and Pages with the ability to hide them via Content Options. _s: Fix Travis CI error _s: Add missing coma in array --- inc/jetpack.php | 7 ++++++- inc/template-tags.php | 33 +++++++++++++++++++++++++++++++ template-parts/content-page.php | 2 ++ template-parts/content-search.php | 2 ++ template-parts/content.php | 2 ++ 5 files changed, 45 insertions(+), 1 deletion(-) diff --git a/inc/jetpack.php b/inc/jetpack.php index fda2615b..172afb81 100644 --- a/inc/jetpack.php +++ b/inc/jetpack.php @@ -27,7 +27,7 @@ function _s_jetpack_setup() { // Add theme support for Content Options. add_theme_support( 'jetpack-content-options', array( - 'post-details' => array( + 'post-details' => array( 'stylesheet' => '_s-style', 'date' => '.posted-on', 'categories' => '.cat-links', @@ -35,6 +35,11 @@ function _s_jetpack_setup() { 'author' => '.byline', 'comment' => '.comments-link', ), + 'featured-images' => array( + 'archive' => true, + 'post' => true, + 'page' => true, + ), ) ); } add_action( 'after_setup_theme', '_s_jetpack_setup' ); diff --git a/inc/template-tags.php b/inc/template-tags.php index 3260c44e..d1403d48 100644 --- a/inc/template-tags.php +++ b/inc/template-tags.php @@ -100,3 +100,36 @@ if ( ! function_exists( '_s_entry_footer' ) ) : ); } endif; + +if ( ! function_exists( '_s_post_thumbnail' ) ) : +/** + * Displays an optional post thumbnail. + * + * Wraps the post thumbnail in an anchor element on index views, or a div + * element when on single views. + */ +function _s_post_thumbnail() { + if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) { + return; + } + + if ( is_singular() ) : + ?> + +
+ +
+ + + + + + ', '' ); ?> + +
+ +
diff --git a/template-parts/content.php b/template-parts/content.php index 6e3b38f0..8ffc61a5 100644 --- a/template-parts/content.php +++ b/template-parts/content.php @@ -26,6 +26,8 @@ endif; ?> + +