From 10b9a6673a0647b3aaf07ba640caa7a6c2fc9e8e Mon Sep 17 00:00:00 2001 From: Thomas Guillot Date: Mon, 3 Jul 2017 10:43:21 +0100 Subject: [PATCH 1/5] _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 fda2615..172afb8 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 e4b9cf0..0ff12f1 100644 --- a/inc/template-tags.php +++ b/inc/template-tags.php @@ -100,3 +100,36 @@ function _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 6e3b38f..8ffc61a 100644 --- a/template-parts/content.php +++ b/template-parts/content.php @@ -26,6 +26,8 @@ endif; ?> + +
Date: Mon, 3 Jul 2017 10:43:21 +0100 Subject: [PATCH 2/5] _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 fda2615..172afb8 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 3260c44..d1403d4 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 6e3b38f..8ffc61a 100644 --- a/template-parts/content.php +++ b/template-parts/content.php @@ -26,6 +26,8 @@ endif; ?> + +
Date: Thu, 28 Sep 2017 16:00:04 +0100 Subject: [PATCH 3/5] Remove `aria-hidden` attribute from the post thumbnail link --- inc/template-tags.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/template-tags.php b/inc/template-tags.php index 6a0330b..19cb67c 100644 --- a/inc/template-tags.php +++ b/inc/template-tags.php @@ -155,7 +155,7 @@ function _s_post_thumbnail() { - the_title_attribute( 'echo=0' ), From 2a1a954b984ef6ce0b1269d1ecafb1282b709e69 Mon Sep 17 00:00:00 2001 From: Thomas Guillot Date: Mon, 30 Oct 2017 10:57:58 +0000 Subject: [PATCH 4/5] Replace `'echo=0'` with `array( 'echo' => false )` and remove duplicate function --- inc/template-tags.php | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/inc/template-tags.php b/inc/template-tags.php index 19cb67c..fdf1929 100644 --- a/inc/template-tags.php +++ b/inc/template-tags.php @@ -125,40 +125,7 @@ function _s_post_thumbnail() { - - - -
- -
- - - - - the_title_attribute( 'echo=0' ), + 'alt' => the_title_attribute( array( 'echo' => false ) ), ) ); ?> From c6427768ef20dece15e0d8efeea9a38538062e02 Mon Sep 17 00:00:00 2001 From: laurelfulford Date: Tue, 12 Dec 2017 15:26:47 -1000 Subject: [PATCH 5/5] Update array using associative keys to have each value on a new line. --- inc/template-tags.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/inc/template-tags.php b/inc/template-tags.php index fdf1929..fb2d453 100644 --- a/inc/template-tags.php +++ b/inc/template-tags.php @@ -125,7 +125,9 @@ function _s_post_thumbnail() {