refactor titles/descriptions

This commit is contained in:
Robin Cornett
2015-02-13 17:06:03 -05:00
parent f9dfc8e1b8
commit 3e7171eae1
2 changed files with 36 additions and 49 deletions
@@ -168,35 +168,28 @@ class Display_Featured_Image_Genesis_Common {
}
// Set Post/Page Title
$item->title = $item->description = '';
$title = '';
if ( is_singular() ) {
$item->title = get_the_title();
if ( has_excerpt() ) {
$item->description = get_the_excerpt();
}
$title = get_the_title();
}
elseif ( is_home() && 'page' === $frontpage ) {
$item->title = get_post( $postspage )->post_title;
$item->description = get_post( $postspage )->post_excerpt;
$title = get_post( $postspage )->post_title;
}
elseif ( is_category() || is_tag() || is_tax() ) {
$term = is_tax() ? get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ) : get_queried_object();
if ( ! $term || ! isset( $term->meta ) ) {
return;
}
$item->title = $term->meta['headline'];
$item->description = $term->meta['intro_text'];
$title = $term->meta['headline'];
}
elseif ( is_author() ) {
$item->title = get_the_author_meta( 'headline', (int) get_query_var( 'author' ) );
$item->description = get_the_author_meta( 'intro_text', (int) get_query_var( 'author' ) );
$title = get_the_author_meta( 'headline', (int) get_query_var( 'author' ) );
}
elseif ( is_post_type_archive() && genesis_has_post_type_archive_support() && ! empty( $item->fallback ) ) {
$item->title = genesis_get_cpt_option( 'headline' );
$item->description = genesis_get_cpt_option( 'intro_text' );
$title = genesis_get_cpt_option( 'headline' );
}
$item->title = apply_filters( 'display_featured_image_genesis_title', $title );
return $item;
@@ -26,19 +26,16 @@ class Display_Featured_Image_Genesis_Description {
if ( ! is_singular() || is_front_page() ) {
return;
}
$item = Display_Featured_Image_Genesis_Common::get_image_variables();
$headline = $intro_text = '';
$headline = $intro_text = $itemprop = '';
if ( $item->title ) {
$itemprop = '';
if ( genesis_html5() ) {
$itemprop = 'itemprop="headline"';
}
$headline = sprintf( '<h1 class="entry-title" ' . $itemprop . '>%s</h1>', $item->title );
if ( genesis_html5() ) {
$itemprop = 'itemprop="headline"';
}
$headline = sprintf( '<h1 class="entry-title" ' . $itemprop . '>%s</h1>', get_the_title() );
if ( has_excerpt() ) {
$intro_text = wpautop( $item->description );
$intro_text = wpautop( apply_filters( 'display_featured_image_genesis_singular_description', get_the_excerpt() ) );
}
if ( $headline || $intro_text ) {
printf( '<div class="excerpt">%s</div>', $headline . $intro_text );
@@ -62,20 +59,22 @@ class Display_Featured_Image_Genesis_Description {
return;
}
$item = Display_Featured_Image_Genesis_Common::get_image_variables();
$frontpage = get_option( 'show_on_front' );
$postspage = get_option( 'page_for_posts' );
$headline = '';
$intro_text = wpautop( get_bloginfo( 'description' ) );
$intro_text = get_bloginfo( 'description' );
if ( is_home() && 'page' === $frontpage ) {
$itemprop = '';
if ( genesis_html5() ) {
$itemprop = 'itemprop="headline"';
}
$headline = sprintf( '<h1 class="entry-title" ' . $itemprop . '>%s</h1>', $item->title );
$intro_text = wpautop( $item->description );
$headline = sprintf( '<h1 class="entry-title" ' . $itemprop . '>%s</h1>', get_post( $postspage )->post_title );
$intro_text = get_post( $postspage )->post_excerpt;
}
$intro_text = wpautop( apply_filters( 'display_featured_image_genesis_front_blog_description', $intro_text ) );
if ( $headline || $intro_text ) {
printf( '<div class="excerpt">%s</div>', $headline . $intro_text );
}
@@ -112,14 +111,11 @@ class Display_Featured_Image_Genesis_Description {
if ( ! $term || ! isset( $term->meta ) )
return;
$intro_text = '';
$intro_text = apply_filters( 'display_featured_image_genesis_term_description', $$term->meta['intro_text'] );
if ( $term->meta['intro_text'] )
$intro_text = apply_filters( 'genesis_term_intro_text_output', $term->meta['intro_text'] );
if ( $intro_text )
if ( $intro_text ) {
printf( '<div class="archive-description taxonomy-description">%s</div>', $intro_text );
}
}
@@ -139,18 +135,15 @@ class Display_Featured_Image_Genesis_Description {
public static function do_author_description() {
if ( ! is_author() )
if ( ! is_author() || get_query_var( 'paged' ) >= 2 ) {
return;
}
if ( get_query_var( 'paged' ) >= 2 )
return;
$intro_text = apply_filters( 'display_featured_image_genesis_author_description', get_the_author_meta( 'intro_text', (int) get_query_var( 'author' ) ) );
$intro_text = get_the_author_meta( 'intro_text', (int) get_query_var( 'author' ) );
$intro_text = $intro_text ? apply_filters( 'genesis_author_intro_text_output', $intro_text ) : '';
if ( $intro_text )
printf( '<div class="archive-description author-description">%s</div>', $intro_text );
if ( $intro_text ) {
printf( '<div class="archive-description author-description">%s</div>', wpautop( $intro_text ) );
}
}
@@ -175,18 +168,19 @@ class Display_Featured_Image_Genesis_Description {
public static function do_cpt_archive_description() {
if ( ! is_post_type_archive() || ! genesis_has_post_type_archive_support() )
if ( ! is_post_type_archive() || ! genesis_has_post_type_archive_support() ) {
return;
}
if ( get_query_var( 'paged' ) >= 2 )
if ( get_query_var( 'paged' ) >= 2 ) {
return;
}
$intro_text = genesis_get_cpt_option( 'intro_text' );
$intro_text = apply_filters( 'display_featured_image_genesis_cpt_description', genesis_get_cpt_option( 'intro_text' ) );
$intro_text = $intro_text ? apply_filters( 'genesis_cpt_archive_intro_text_output', $intro_text ) : '';
if ( $intro_text )
printf( '<div class="archive-description cpt-archive-description">%s</div>', $intro_text );
if ( $intro_text ) {
printf( '<div class="archive-description cpt-archive-description">%s</div>', wpautop( $intro_text ) );
}
}