mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-17 13:33:32 +09:00
Rename helper function for consistency
This commit is contained in:
@@ -106,7 +106,7 @@ class Display_Featured_Image_Genesis_Admin {
|
||||
return;
|
||||
}
|
||||
|
||||
$image_id = displayfeaturedimagegenesis_term_image( $term_id );
|
||||
$image_id = displayfeaturedimagegenesis_get_term_image( $term_id );
|
||||
if ( ! $image_id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ class Display_Featured_Image_Genesis_Common {
|
||||
// taxonomy
|
||||
if ( is_category() || is_tag() || is_tax() ) {
|
||||
$term_id = $object->term_id;
|
||||
$term_meta = displayfeaturedimagegenesis_term_image( $term_id );
|
||||
$term_meta = displayfeaturedimagegenesis_get_term_image( $term_id );
|
||||
if ( $term_meta ) {
|
||||
$image_id = $term_meta;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ class Display_Featured_Image_Genesis_Taxonomies extends Display_Featured_Image_G
|
||||
public function edit_taxonomy_meta_fields( $term ) {
|
||||
|
||||
$term_id = $term->term_id;
|
||||
$image_id = displayfeaturedimagegenesis_term_image( $term_id );
|
||||
$image_id = displayfeaturedimagegenesis_get_term_image( $term_id );
|
||||
|
||||
echo '<tr class="form-field term-image-wrap">';
|
||||
printf( '<th scope="row" valign="top"><label for="displayfeaturedimagegenesis[term_image]">%s</label></th>',
|
||||
|
||||
@@ -9,6 +9,26 @@
|
||||
* @license GPL-2.0+
|
||||
*/
|
||||
|
||||
/**
|
||||
* Helper function to retrieve the term image ID, whether as term_meta or wp_options
|
||||
* @param int $term_id term ID
|
||||
* @param string $image_id image ID
|
||||
* @return int image ID
|
||||
* @since 2.4.0
|
||||
*/
|
||||
function displayfeaturedimagegenesis_get_term_image( $term_id, $image_id = '' ) {
|
||||
if ( function_exists( 'get_term_meta' ) ) {
|
||||
$image_id = get_term_meta( $term_id, 'displayfeaturedimagegenesis', true );
|
||||
}
|
||||
if ( ! $image_id ) {
|
||||
$term_meta = get_option( "displayfeaturedimagegenesis_$term_id" );
|
||||
if ( $term_meta ) {
|
||||
$image_id = displayfeaturedimagegenesis_check_image_id( $term_meta['term_image'] );
|
||||
}
|
||||
}
|
||||
return $image_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the term image ID
|
||||
* @return image_id reusable function to get a post's term image, if it exists
|
||||
@@ -23,7 +43,7 @@ function display_featured_image_genesis_get_term_image_id( $image_id = '' ) {
|
||||
|
||||
foreach ( $terms as $term ) {
|
||||
$term_id = $term->term_id;
|
||||
$image_id = displayfeaturedimagegenesis_term_image( $term_id );
|
||||
$image_id = displayfeaturedimagegenesis_get_term_image( $term_id );
|
||||
if ( $image_id ) {
|
||||
break;
|
||||
}
|
||||
@@ -33,26 +53,6 @@ function display_featured_image_genesis_get_term_image_id( $image_id = '' ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to retrieve the term image ID, whether as term_meta or wp_options
|
||||
* @param int $term_id term ID
|
||||
* @param string $image_id image ID
|
||||
* @return int image ID
|
||||
* @since 2.4.0
|
||||
*/
|
||||
function displayfeaturedimagegenesis_term_image( $term_id, $image_id = '' ) {
|
||||
if ( function_exists( 'get_term_meta' ) ) {
|
||||
$image_id = get_term_meta( $term_id, 'displayfeaturedimagegenesis', true );
|
||||
}
|
||||
if ( ! $image_id ) {
|
||||
$term_meta = get_option( "displayfeaturedimagegenesis_$term_id" );
|
||||
if ( $term_meta ) {
|
||||
$image_id = displayfeaturedimagegenesis_check_image_id( $term_meta['term_image'] );
|
||||
}
|
||||
}
|
||||
return $image_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to get the term image URL.
|
||||
* @param string $size image size
|
||||
|
||||
Reference in New Issue
Block a user