mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-11 18:46:03 +09:00
Update term meta retrieval method
Necessary for G 2.2.7. This maintains backwards compatibility for users running earlier WP/G versions.
This commit is contained in:
@@ -190,10 +190,10 @@ class Display_Featured_Image_Genesis_Common {
|
||||
$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 ) ) {
|
||||
if ( ! $term ) {
|
||||
return;
|
||||
}
|
||||
$title = $term->meta['headline'];
|
||||
$title = displayfeaturedimagegenesis_get_term_meta( $term, 'headline' );
|
||||
if ( empty( $title ) && $a11ycheck ) {
|
||||
$title = $term->name;
|
||||
}
|
||||
|
||||
@@ -104,11 +104,12 @@ class Display_Featured_Image_Genesis_Description {
|
||||
|
||||
$term = is_tax() ? get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ) : $wp_query->get_queried_object();
|
||||
|
||||
if ( ! $term || ! isset( $term->meta ) ) {
|
||||
if ( ! $term ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$intro_text = apply_filters( 'display_featured_image_genesis_term_description', $term->meta['intro_text'] );
|
||||
$intro_text = displayfeaturedimagegenesis_get_term_meta( $term, 'intro_text' );
|
||||
$intro_text = apply_filters( 'display_featured_image_genesis_term_description', $intro_text );
|
||||
|
||||
if ( $intro_text ) {
|
||||
$class = 'archive-description taxonomy-description';
|
||||
|
||||
@@ -225,3 +225,27 @@ function displayfeaturedimagegenesis_check_image_id( $image_id = '' ) {
|
||||
function displayfeaturedimagegenesis_get_setting() {
|
||||
return apply_filters( 'displayfeaturedimagegenesis_get_setting', false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the term meta (generally headline or intro text). Backwards compatible,
|
||||
* but uses new term meta (as of Genesis 2.2.7)
|
||||
* @param $term object the term
|
||||
* @param $key string meta key to retrieve
|
||||
* @param string $value string output of the term meta
|
||||
*
|
||||
* @return mixed|string
|
||||
*
|
||||
* @ since 2.5.0
|
||||
*/
|
||||
function displayfeaturedimagegenesis_get_term_meta( $term, $key, $value = '' ) {
|
||||
if ( ! $term ) {
|
||||
return $value;
|
||||
}
|
||||
if ( function_exists( 'get_term_meta' ) ) {
|
||||
$value = get_term_meta( $term->term_id, $key, true );
|
||||
}
|
||||
if ( ! $value && isset( $term->meta[ $key ] ) ) {
|
||||
$value = $term->meta[ $key ];
|
||||
}
|
||||
return $value;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ class Display_Featured_Image_Genesis_Widget_Taxonomy extends WP_Widget {
|
||||
return;
|
||||
}
|
||||
|
||||
$title = $term->meta['headline'];
|
||||
$title = displayfeaturedimagegenesis_get_term_meta( $term, 'headline' );
|
||||
if ( ! $title ) {
|
||||
$title = $term->name;
|
||||
}
|
||||
@@ -125,7 +125,8 @@ class Display_Featured_Image_Genesis_Widget_Taxonomy extends WP_Widget {
|
||||
|
||||
echo genesis_html5() ? '<div class="term-description">' : '';
|
||||
|
||||
$intro_text = apply_filters( 'display_featured_image_genesis_term_description', $term->meta['intro_text'] );
|
||||
$intro_text = displayfeaturedimagegenesis_get_term_meta( $term, 'intro_text' );
|
||||
$intro_text = apply_filters( 'display_featured_image_genesis_term_description', $intro_text );
|
||||
if ( ! $intro_text ) {
|
||||
$intro_text = $term->description;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user