From 9cc9bfc2bba4886789d1049ec7135a25f512e83d Mon Sep 17 00:00:00 2001 From: Robin Cornett Date: Sat, 1 Nov 2014 20:08:24 -0400 Subject: [PATCH] rewrite description functions --- ...isplayfeaturedimagegenesis-description.php | 51 +++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/includes/class-displayfeaturedimagegenesis-description.php b/includes/class-displayfeaturedimagegenesis-description.php index 1a8e2bd..1c90a5e 100644 --- a/includes/class-displayfeaturedimagegenesis-description.php +++ b/includes/class-displayfeaturedimagegenesis-description.php @@ -16,13 +16,56 @@ class Display_Featured_Image_Genesis_Description { public static function do_excerpt() { - if ( !is_single() || !has_excerpt() ) { + if ( ! is_singular() || is_front_page() ) { return; } - else { - $item = Display_Featured_Image_Genesis_Common::get_image_variables(); - printf( '

%s

%s
', $item->title, $item->description ); + $item = Display_Featured_Image_Genesis_Common::get_image_variables(); + + $headline = $intro_text = ''; + + if ( $item->title ) { + $headline = sprintf( '

%s

', esc_attr( $item->title ) ); } + if ( has_excerpt() ) { + $intro_text = wpautop( $item->description ); + } + if ( $headline || $intro_text ) { + printf( '
%s
', $headline . $intro_text ); + } + } + + /** + * Show optional excerpt on blog or front page. + * + * If it's not the front page and isn't home, nothing happens. + * + * If there's an excerpt and the move excerpts option is selected, it runs through `wpautop()` before being added to a div. + * + * @since 1.3.0 + * + * @return null Return early if not blog/front page. + */ + public static function do_front_blog_excerpt() { + + if ( ! is_front_page() && ! is_home() ) { + return; + } + + $item = Display_Featured_Image_Genesis_Common::get_image_variables(); + $frontpage = get_option( 'show_on_front' ); + $headline = $intro_text = ''; + + if ( is_home() && 'page' === $frontpage ) { + $headline = sprintf( '

%s

', esc_attr( $item->title ) ); + $intro_text = wpautop( $item->description ); + } + else { + $intro_text = wpautop( get_bloginfo( 'description' ) ); + } + if ( $headline || $intro_text ) { + printf( '
%s
', $headline . $intro_text ); + } + } /**