From 4b61557eeb133bd779027b5b188e6951cfca8cd9 Mon Sep 17 00:00:00 2001 From: Robin Cornett Date: Tue, 1 Sep 2015 20:34:25 -0400 Subject: [PATCH] Fix front page filter DRY DRY --- ...isplayfeaturedimagegenesis-description.php | 28 ++++++++++--------- ...ass-displayfeaturedimagegenesis-output.php | 12 +------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/includes/class-displayfeaturedimagegenesis-description.php b/includes/class-displayfeaturedimagegenesis-description.php index d74fdde..ecee7d4 100644 --- a/includes/class-displayfeaturedimagegenesis-description.php +++ b/includes/class-displayfeaturedimagegenesis-description.php @@ -60,19 +60,9 @@ class Display_Featured_Image_Genesis_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 2.3.0 - */ - $show_front_page_title = apply_filters( 'display_featured_image_genesis_excerpt_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() : ''; + $frontpage = get_option( 'show_on_front' ); + $postspage = get_post( get_option( 'page_for_posts' ) ); + $title = $this->show_front_page_title() ? get_the_title() : ''; $intro_text = get_the_excerpt() ? get_the_excerpt() : get_bloginfo( 'description' ); $itemprop = genesis_html5() ? 'itemprop="headline"' : ''; @@ -196,4 +186,16 @@ class Display_Featured_Image_Genesis_Description { } + /** + * Filter to show title on front page. + * @return boolean true/false + * + * @since 2.3.0 + */ + public function show_front_page_title() { + + $show_front_title = apply_filters( 'display_featured_image_genesis_excerpt_show_front_page_title', false ); + return true === $show_front_title ? true : false; + + } } diff --git a/includes/class-displayfeaturedimagegenesis-output.php b/includes/class-displayfeaturedimagegenesis-output.php index 9a03b51..4966531 100644 --- a/includes/class-displayfeaturedimagegenesis-output.php +++ b/includes/class-displayfeaturedimagegenesis-output.php @@ -234,17 +234,7 @@ class Display_Featured_Image_Genesis_Output { * @since 2.3.1 */ protected function do_the_title() { - - /** - * filter to show title on front page - * @return boolean true/false - * - * @since 2.3.0 - */ - $show_front_title = apply_filters( 'display_featured_image_genesis_excerpt_show_front_page_title', false ); - $show_front_title = true === $show_front_title ? $show_front_title : false; - - if ( is_front_page() && ! $show_front_title ) { + if ( is_front_page() && ! $this->description->show_front_page_title() ) { return; } $class = is_singular() ? 'entry-title' : 'archive-title';