From 5427a4e083d3328b1afe3a537bc39fd2c921c6ed Mon Sep 17 00:00:00 2001 From: Robin Cornett Date: Fri, 12 Jun 2015 08:24:19 -0400 Subject: [PATCH] Add filter to optionally show title on static front page --- ...isplayfeaturedimagegenesis-description.php | 32 ++++++++++++------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/includes/class-displayfeaturedimagegenesis-description.php b/includes/class-displayfeaturedimagegenesis-description.php index 047da8b..ccf6d19 100644 --- a/includes/class-displayfeaturedimagegenesis-description.php +++ b/includes/class-displayfeaturedimagegenesis-description.php @@ -38,7 +38,7 @@ class Display_Featured_Image_Genesis_Description { $intro_text = apply_filters( 'display_featured_image_genesis_singular_description', get_the_excerpt() ); } if ( $headline || $intro_text ) { - printf( '
%s
', $headline . wpautop( $intro_text ) ); + printf( '
%s
', wp_kses_post( $headline . wpautop( $intro_text ) ) ); } } @@ -59,24 +59,34 @@ class Display_Featured_Image_Genesis_Description { return; } - $frontpage = get_option( 'show_on_front' ); - $postspage = get_post( get_option( 'page_for_posts' ) ); - $headline = ''; - $intro_text = get_bloginfo( 'description' ); + // set front page and posts page variables + $frontpage = get_option( 'show_on_front' ); + $postspage = get_post( get_option( 'page_for_posts' ) ); + + /** + * filter to show title on front page + * @return boolean true/false + * + * @since x.y.z + */ + $show_front_page_title = apply_filters( 'display_featured_image_genesis_show_front_page_title', false ); + $show_front_page_title = true === $show_front_page_title ? $show_front_page_title : false; + + $title = $show_front_page_title ? get_the_title() : ''; + $intro_text = get_the_excerpt() ? get_the_excerpt() : get_bloginfo( 'description' ); + $itemprop = genesis_html5() ? 'itemprop="headline"' : ''; if ( is_home() && 'page' === $frontpage ) { - $itemprop = ''; - if ( genesis_html5() ) { - $itemprop = 'itemprop="headline"'; - } - $headline = sprintf( '

%s

', $postspage->post_title ); + $title = $postspage->post_title; $intro_text = $postspage->post_excerpt; } + $title = apply_filters( 'display_featured_image_genesis_front_blog_title', $title ); + $headline = $title ? sprintf( '

%s

', $title ) : ''; $intro_text = apply_filters( 'display_featured_image_genesis_front_blog_description', $intro_text ); if ( $headline || $intro_text ) { - printf( '
%s
', $headline . wpautop( $intro_text ) ); + printf( '
%s
', wp_kses_post( $headline . wpautop( $intro_text ) ) ); } }