Clean up static methods

Needs lots more testing
This commit is contained in:
Robin Cornett
2015-06-03 14:36:16 -04:00
parent 955fba0e67
commit 93b7c5aa35
11 changed files with 141 additions and 116 deletions
+15 -4
View File
@@ -43,13 +43,24 @@ function display_featured_image_genesis_require() {
display_featured_image_genesis_require();
// Instantiate dependent classes
$displayfeaturedimagegenesis_admin = new Display_Featured_Image_Genesis_Admin();
$displayfeaturedimagegenesis_common = new Display_Featured_Image_Genesis_Common();
$displayfeaturedimagegenesis_description = new Display_Featured_Image_Genesis_Description();
$displayfeaturedimagegenesis_output = new Display_Featured_Image_Genesis_Output();
// Classes with dependencies
$displayfeaturedimagegenesis_admin = new Display_Featured_Image_Genesis_Admin(
$displayfeaturedimagegenesis_common
);
$displayfeaturedimagegenesis_output = new Display_Featured_Image_Genesis_Output(
$displayfeaturedimagegenesis_common,
$displayfeaturedimagegenesis_description
);
$displayfeaturedimagegenesis_rss = new Display_Featured_Image_Genesis_RSS();
$displayfeaturedimagegenesis_settings = new Display_Featured_Image_Genesis_Settings();
$displayfeaturedimagegenesis_taxonomies = new Display_Featured_Image_Genesis_Taxonomies();
$displayfeaturedimagegenesis_settings = new Display_Featured_Image_Genesis_Settings(
$displayfeaturedimagegenesis_common
);
$displayfeaturedimagegenesis_taxonomies = new Display_Featured_Image_Genesis_Taxonomies(
$displayfeaturedimagegenesis_settings
);
$displayfeaturedimage = new Display_Featured_Image_Genesis(
$displayfeaturedimagegenesis_admin,
@@ -13,6 +13,10 @@
class Display_Featured_Image_Genesis_Admin {
public function __construct( $common ) {
$this->common = $common;
}
public function set_up_columns() {
$this->set_up_taxonomy_columns();
$this->set_up_post_type_columns();
@@ -101,11 +105,7 @@ class Display_Featured_Image_Genesis_Admin {
$taxonomy = filter_input( INPUT_POST, 'taxonomy', FILTER_SANITIZE_STRING );
$taxonomy = ! is_null( $taxonomy ) ? $taxonomy : get_current_screen()->taxonomy;
$alt = get_term( $term_id, $taxonomy )->name;
$id = $term_meta['term_image'];
if ( ! is_numeric( $term_meta['term_image'] ) ) {
$id = Display_Featured_Image_Genesis_Common::get_image_id( $term_meta['term_image'] );
}
$id = is_numeric( $term_meta['term_image'] ) ? $term_meta['term_image'] : $this->common->get_image_id( $term_meta['term_image'] );
$preview = apply_filters(
'display_featured_image_genesis_admin_term_thumbnail',
@@ -13,9 +13,9 @@ class Display_Featured_Image_Genesis_Common {
* @var string
* @since 1.4.3
*/
public static $version = '2.2.2';
public $version = '2.2.2';
protected static $post_types;
protected $post_types;
/**
* set and retreive variables for the featured image.
@@ -23,9 +23,9 @@ class Display_Featured_Image_Genesis_Common {
*
* @since 1.1.0
*/
public static function get_image_variables() {
public function get_image_variables() {
self::$post_types = array();
$this->post_types = array();
$item = new stdClass();
@@ -52,14 +52,14 @@ class Display_Featured_Image_Genesis_Common {
*
* @since 2.0.0
*/
$use_large_image = apply_filters( 'display_featured_image_genesis_use_large_image', self::$post_types );
$use_large_image = apply_filters( 'display_featured_image_genesis_use_large_image', $this->post_types );
$image_size = 'displayfeaturedimage_backstretch';
if ( in_array( get_post_type(), $use_large_image ) ) {
$image_size = 'large';
}
// $image_id is set by new set_image_id function
$image_id = self::set_image_id();
$image_id = $this->set_image_id();
$item->backstretch = wp_get_attachment_image_src( $image_id, $image_size );
@@ -94,7 +94,7 @@ class Display_Featured_Image_Genesis_Common {
}
// $title is set by new title function
$title = self::set_item_title();
$title = $this->set_item_title();
/**
* Optional filter to change the title text
@@ -112,7 +112,7 @@ class Display_Featured_Image_Genesis_Common {
*
* @since 2.2.1
*/
protected static function set_image_id( $image_id = '' ) {
protected function set_image_id( $image_id = '' ) {
$frontpage = get_option( 'show_on_front' ); // either 'posts' or 'page'
$postspage = get_option( 'page_for_posts' );
@@ -131,7 +131,7 @@ class Display_Featured_Image_Genesis_Common {
$fallback_id = $fallback;
if ( ! is_numeric( $fallback ) ) {
$fallback_id = self::get_image_id( $fallback ); // gets image id with attached metadata
$fallback_id = $this->get_image_id( $fallback ); // gets image id with attached metadata
}
$fallback_id = absint( $fallback_id );
@@ -140,7 +140,7 @@ class Display_Featured_Image_Genesis_Common {
* @var filter
* @since 2.0.0 (deprecated old use_fallback_image function from 1.2.2)
*/
$use_fallback = apply_filters( 'display_featured_image_genesis_use_default', self::$post_types );
$use_fallback = apply_filters( 'display_featured_image_genesis_use_default', $this->post_types );
// set here with fallback preemptively, if it exists
if ( ! empty( $fallback ) ) {
@@ -171,18 +171,14 @@ class Display_Featured_Image_Genesis_Common {
$post_type = $object->post_type;
}
if ( ! empty( $displaysetting['post_type'][ $post_type ] ) ) {
$image_id = $displaysetting['post_type'][ $post_type ];
// if $image_id is using the old URL
if ( ! is_numeric( $displaysetting['post_type'][ $post_type ] ) ) {
$image_id = self::get_image_id( $displaysetting['post_type'][ $post_type ] );
}
$image_id = is_numeric( $displaysetting['post_type'][ $post_type ] ) ? $displaysetting['post_type'][ $post_type ] : $this->get_image_id( $displaysetting['post_type'][ $post_type ] );
/**
* use the custom post type featured image
*
* @since 2.2.1
*/
$use_cpt = apply_filters( 'displayfeaturedimagegenesis_use_post_type_image', self::$post_types );
$use_cpt = apply_filters( 'displayfeaturedimagegenesis_use_post_type_image', $this->post_types );
if ( in_array( get_post_type(), $use_cpt ) ) {
return $image_id;
}
@@ -194,11 +190,7 @@ class Display_Featured_Image_Genesis_Common {
$term_meta = get_option( "displayfeaturedimagegenesis_$t_id" );
// if there is a term image
if ( ! empty( $term_meta['term_image'] ) ) {
$image_id = $term_meta['term_image'];
// if $image_id is using the old URL
if ( ! is_numeric( $term_meta['term_image'] ) ) {
$image_id = self::get_image_id( $term_meta['term_image'] );
}
$image_id = is_numeric( $term_meta['term_image'] ) ? $term_meta['term_image'] : $this->get_image_id( $term_meta['term_image'] );
}
}
@@ -213,7 +205,7 @@ class Display_Featured_Image_Genesis_Common {
* create filter to use taxonomy image if single post doesn't have a thumbnail, but one of its terms does.
* @var filter
*/
$use_tax_image = apply_filters( 'display_featured_image_genesis_use_taxonomy', self::$post_types );
$use_tax_image = apply_filters( 'display_featured_image_genesis_use_taxonomy', $this->post_types );
if ( in_array( get_post_type(), $use_tax_image ) ) {
return $image_id;
@@ -241,7 +233,7 @@ class Display_Featured_Image_Genesis_Common {
}
protected static function set_item_title( $title = '' ) {
protected function set_item_title( $title = '' ) {
$frontpage = get_option( 'show_on_front' ); // either 'posts' or 'page'
$postspage = get_option( 'page_for_posts' );
@@ -287,7 +279,7 @@ class Display_Featured_Image_Genesis_Common {
* @author Philip Newcomer
* @link http://philipnewcomer.net/2012/11/get-the-attachment-id-from-an-image-url-in-wordpress/
*/
public static function get_image_id( $attachment_url = '' ) {
public function get_image_id( $attachment_url = '' ) {
$attachment_id = false;
@@ -314,7 +306,7 @@ class Display_Featured_Image_Genesis_Common {
$url_stripped = preg_replace( '/-\d+x\d+(?=\.(jpg|jpeg|png|gif)$)/i', '', $attachment_url );
// Finally, run a custom database query to get the attachment ID from the modified attachment URL
$attachment_id = self::fetch_image_id_query( $url_stripped, $attachment_url );
$attachment_id = $this->fetch_image_id_query( $url_stripped, $attachment_url );
}
@@ -331,7 +323,7 @@ class Display_Featured_Image_Genesis_Common {
*
* @author hellofromtonya
*/
protected static function fetch_image_id_query( $url_stripped, $attachment_url ) {
protected function fetch_image_id_query( $url_stripped, $attachment_url ) {
global $wpdb;
@@ -355,7 +347,7 @@ class Display_Featured_Image_Genesis_Common {
*
* @since 2.2.0
*/
public static function minimum_backstretch_width() {
public function minimum_backstretch_width() {
$large = apply_filters( 'display_featured_image_genesis_set_minimum_backstretch_width', get_option( 'large_size_w' ) );
if ( ! is_numeric( $large ) ) {
$large = get_option( 'large_size_w' );
@@ -21,7 +21,7 @@ class Display_Featured_Image_Genesis_Description {
* @return null Return early if not a single post with an excerpt.
*/
public static function do_excerpt() {
public function do_excerpt() {
if ( ! is_singular() || is_front_page() ) {
return;
@@ -53,7 +53,7 @@ class Display_Featured_Image_Genesis_Description {
*
* @return null Return early if not blog/front page.
*/
public static function do_front_blog_excerpt() {
public function do_front_blog_excerpt() {
if ( ! is_front_page() && ! is_home() ) {
return;
@@ -96,7 +96,7 @@ class Display_Featured_Image_Genesis_Description {
* @return null Return early if not the correct archive page, not page one, or no term meta is set.
*/
public static function do_tax_description() {
public function do_tax_description() {
global $wp_query;
@@ -136,7 +136,7 @@ class Display_Featured_Image_Genesis_Description {
* @return null Return early if not author archive or not page one.
*/
public static function do_author_description() {
public function do_author_description() {
if ( ! is_author() || get_query_var( 'paged' ) >= 2 ) {
return;
@@ -168,7 +168,7 @@ class Display_Featured_Image_Genesis_Description {
* @return null Return early if not on relevant post type archive.
*/
public static function do_cpt_archive_description() {
public function do_cpt_archive_description() {
if ( ! is_post_type_archive() || ! genesis_has_post_type_archive_support() ) {
return;
@@ -9,6 +9,11 @@
class Display_Featured_Image_Genesis_Output {
public function __construct( $common, $description ) {
$this->common = $common;
$this->description = $description;
}
/**
* set parameters for scripts, etc. to run.
*
@@ -44,9 +49,9 @@ class Display_Featured_Image_Genesis_Output {
*/
public function load_scripts() {
$version = Display_Featured_Image_Genesis_Common::$version;
$item = Display_Featured_Image_Genesis_Common::get_image_variables();
$large = Display_Featured_Image_Genesis_Common::minimum_backstretch_width();
$version = $this->common->version;
$item = $this->common->get_image_variables();
$large = $this->common->minimum_backstretch_width();
$medium = absint( get_option( 'medium_size_w' ) );
$width = absint( $item->backstretch[1] );
@@ -100,8 +105,8 @@ class Display_Featured_Image_Genesis_Output {
*/
public function add_body_class( $classes ) {
$item = Display_Featured_Image_Genesis_Common::get_image_variables();
$large = Display_Featured_Image_Genesis_Common::minimum_backstretch_width();
$item = $this->common->get_image_variables();
$large = $this->common->minimum_backstretch_width();
$medium = absint( get_option( 'medium_size_w' ) );
$width = absint( $item->backstretch[1] );
@@ -133,7 +138,7 @@ class Display_Featured_Image_Genesis_Output {
*/
public function do_backstretch_image_title() {
$item = Display_Featured_Image_Genesis_Common::get_image_variables();
$item = $this->common->get_image_variables();
$displaysetting = get_option( 'displayfeaturedimagegenesis' );
$keep_titles = $displaysetting['keep_titles'];
@@ -191,8 +196,8 @@ class Display_Featured_Image_Genesis_Output {
// if move excerpts is enabled
if ( $move_excerpts && ! in_array( get_post_type(), $omit_excerpt ) ) {
Display_Featured_Image_Genesis_Description::do_front_blog_excerpt();
Display_Featured_Image_Genesis_Description::do_excerpt();
$this->description->do_front_blog_excerpt();
$this->description->do_excerpt();
genesis_do_taxonomy_title_description();
genesis_do_author_title_description();
genesis_do_cpt_archive_title_description();
@@ -249,7 +254,7 @@ class Display_Featured_Image_Genesis_Output {
* @since 1.0.0
*/
public function do_large_image() {
$item = Display_Featured_Image_Genesis_Common::get_image_variables();
$item = $this->common->get_image_variables();
$image = sprintf( '<img src="%1$s" class="aligncenter featured" alt="%2$s" />',
esc_url( $item->backstretch[0] ),
esc_attr( $item->title )
@@ -271,9 +276,9 @@ class Display_Featured_Image_Genesis_Output {
*/
public function move_titles() {
Display_Featured_Image_Genesis_Description::do_tax_description();
Display_Featured_Image_Genesis_Description::do_author_description();
Display_Featured_Image_Genesis_Description::do_cpt_archive_description();
$this->description->do_tax_description();
$this->description->do_author_description();
$this->description->do_cpt_archive_description();
}
@@ -13,7 +13,11 @@ class Display_Featured_Image_Genesis_Settings {
* variable set for featured image option
* @var option
*/
protected $page, $displaysetting, $post_types;
protected $common, $page, $displaysetting, $post_types;
public function __construct( $common ) {
$this->common = $common;
}
/**
* add a submenu page under Appearance
@@ -235,7 +239,7 @@ class Display_Featured_Image_Genesis_Settings {
*/
public function set_default_image() {
$large = Display_Featured_Image_Genesis_Common::minimum_backstretch_width();
$large = $this->common->minimum_backstretch_width();
$id = $this->displaysetting['default'] ? $this->displaysetting['default'] : '';
$name = 'displayfeaturedimagegenesis[default]';
if ( ! empty( $id ) ) {
@@ -274,7 +278,7 @@ class Display_Featured_Image_Genesis_Settings {
*/
public function set_cpt_image( $args ) {
$item = Display_Featured_Image_Genesis_Common::get_image_variables();
$item = $this->common->get_image_variables();
$post_type = $args['post_type']->name;
if ( empty( $this->displaysetting['post_type'][ $post_type ] ) ) {
@@ -307,13 +311,13 @@ class Display_Featured_Image_Genesis_Settings {
*
* @since x.y.z
*/
public static function render_image_preview( $id ) {
public function render_image_preview( $id ) {
if ( empty( $id ) ) {
return;
}
if ( ! is_numeric( $id ) ) {
$id = Display_Featured_Image_Genesis_Common::get_image_id( $id );
$id = $this->common->get_image_id( $id );
}
$preview = wp_get_attachment_image_src( absint( $id ), 'medium' );
@@ -331,11 +335,9 @@ class Display_Featured_Image_Genesis_Settings {
*
* @since x.y.z
*/
public static function render_buttons( $id, $name ) {
if ( ! is_numeric( $id ) ) {
$id = Display_Featured_Image_Genesis_Common::get_image_id( $id );
}
$id = $id ? absint( $id ) : '';
public function render_buttons( $id, $name ) {
$id = is_numeric( $id ) ? $id : $this->common->get_image_id( $id );
$id = $id ? (int) $id : '';
printf( '<input type="hidden" class="upload_image_id" id="%1$s" name="%1$s" value="%2$s" />', esc_attr( $name ), $id );
printf( '<input id="%s" type="button" class="upload_default_image button-secondary" value="%s" />',
esc_attr( $name ),
@@ -411,7 +413,7 @@ class Display_Featured_Image_Genesis_Settings {
// extra variables to pass through to image validation
$old_value = $this->displaysetting['default'];
$label = 'Default';
$size_to_check = Display_Featured_Image_Genesis_Common::minimum_backstretch_width();
$size_to_check = $this->common->minimum_backstretch_width();
// validate default image
$new_value['default'] = $this->validate_image( $new_value['default'], $old_value, $label, $size_to_check );
@@ -441,10 +443,10 @@ class Display_Featured_Image_Genesis_Settings {
// if the image was selected using the old URL method
if ( ! is_numeric( $new_value ) ) {
$new_value = (int) Display_Featured_Image_Genesis_Common::get_image_id( $new_value );
$new_value = (int) $this->common->get_image_id( $new_value );
}
if ( ! is_numeric( $old_value ) ) {
$old_value = (int) Display_Featured_Image_Genesis_Common::get_image_id( $old_value );
$old_value = (int) $this->common->get_image_id( $old_value );
}
$source = wp_get_attachment_image_src( $new_value, 'full' );
$valid = $this->is_valid_img_ext( $source[0] );
@@ -452,32 +454,33 @@ class Display_Featured_Image_Genesis_Settings {
$reset = sprintf( __( ' The %s Featured Image has been reset to the last valid setting.', 'display-featured-image-genesis' ), $label );
// ok for field to be empty
if ( $new_value ) {
if ( $valid && $width > $size_to_check ) {
return $new_value;
}
$new_value = $old_value;
if ( ! $valid ) {
$message = __( 'Sorry, that is an invalid file type.', 'display-featured-image-genesis' );
$class = 'invalid';
}
// if file is an image, but is too small, throw it back
elseif ( $width <= $size_to_check ) {
$message = __( 'Sorry, your image is too small.', 'display-featured-image-genesis' );
$class = 'weetiny';
}
add_settings_error(
$old_value,
esc_attr( $class ),
esc_attr( $message . $reset ),
'error'
);
if ( ! $new_value ) {
return '';
}
if ( $valid && $width > $size_to_check ) {
return $new_value;
}
$new_value = $old_value;
if ( ! $valid ) {
$message = __( 'Sorry, that is an invalid file type.', 'display-featured-image-genesis' );
$class = 'invalid';
}
// if file is an image, but is too small, throw it back
elseif ( $width <= $size_to_check ) {
$message = __( 'Sorry, your image is too small.', 'display-featured-image-genesis' );
$class = 'weetiny';
}
add_settings_error(
$old_value,
esc_attr( $class ),
esc_attr( $message . $reset ),
'error'
);
return $new_value;
}
@@ -491,9 +494,9 @@ class Display_Featured_Image_Genesis_Settings {
// if the image was selected using the old URL method
if ( ! is_numeric( $new_value ) ) {
$new_value = Display_Featured_Image_Genesis_Common::get_image_id( $new_value );
$new_value = $this->common->get_image_id( $new_value );
}
$new_value = absint( $new_value );
$new_value = (int) $new_value;
$medium = get_option( 'medium_size_w' );
$source = wp_get_attachment_image_src( $new_value, 'full' );
$valid = $this->is_valid_img_ext( $source[0] );
@@ -551,7 +554,7 @@ class Display_Featured_Image_Genesis_Settings {
*/
public function help() {
$screen = get_current_screen();
$large = Display_Featured_Image_Genesis_Common::minimum_backstretch_width();
$large = $this->common->minimum_backstretch_width();
$height_help = '<h3>' . __( 'Height', 'display-featured-image-genesis' ) . '</h3>';
$height_help .= '<p>' . __( 'Depending on how your header/nav are set up, or if you just do not want your backstretch image to extend to the bottom of the user screen, you may want to change this number. It will raise the bottom line of the backstretch image, making it shorter.', 'display-featured-image-genesis' ) . '</p>';
@@ -9,6 +9,12 @@
*/
class Display_Featured_Image_Genesis_Taxonomies {
protected $settings;
public function __construct( $settings ) {
$this->settings = $settings;
}
/**
* add featured image uploader to new term add
*/
@@ -55,9 +61,9 @@ class Display_Featured_Image_Genesis_Taxonomies {
$id = $displaysetting['term_image'];
$name = 'displayfeaturedimagegenesis[term_image]';
if ( ! empty( $id ) ) {
echo wp_kses_post( Display_Featured_Image_Genesis_Settings::render_image_preview( $id ) );
echo wp_kses_post( $this->settings->render_image_preview( $id ) );
}
echo Display_Featured_Image_Genesis_Settings::render_buttons( $id, $name );
$this->settings->render_buttons( $id, $name );
echo '<p class="description">';
printf(
__( 'Set Featured Image for %1$s.', 'display-featured-image-genesis' ),
+19 -10
View File
@@ -17,13 +17,13 @@
class Display_Featured_Image_Genesis {
function __construct( $admin, $common, $description, $output, $rss, $settings, $taxonomies ) {
$this->admin = $admin;
$this->common = $common;
$this->archive = $description;
$this->output = $output;
$this->rss = $rss;
$this->settings = $settings;
$this->taxonomies = $taxonomies;
$this->admin = $admin;
$this->common = $common;
$this->description = $description;
$this->output = $output;
$this->rss = $rss;
$this->settings = $settings;
$this->taxonomies = $taxonomies;
}
public function run() {
@@ -186,7 +186,7 @@ class Display_Featured_Image_Genesis {
*/
public function enqueue_scripts() {
$version = Display_Featured_Image_Genesis_Common::$version;
$version = $this->common->version;
$check = strpos( get_current_screen()->id, 'displayfeaturedimagegenesis' );
wp_register_script( 'displayfeaturedimage-upload', plugins_url( '/includes/js/settings-upload.js', dirname( __FILE__ ) ), array( 'jquery', 'media-upload', 'thickbox' ), $version );
@@ -211,8 +211,17 @@ class Display_Featured_Image_Genesis {
function register_widgets() {
require plugin_dir_path( __FILE__ ) . 'widgets/displayfeaturedimagegenesis-cpt-archive-widget.php';
require plugin_dir_path( __FILE__ ) . 'widgets/displayfeaturedimagegenesis-taxonomy-widget.php';
$files = array(
'cpt-archive',
'taxonomy',
);
foreach ( $files as $file ) {
require plugin_dir_path( __FILE__ ) . 'widgets/displayfeaturedimagegenesis-' . $file . '-widget.php';
}
// require plugin_dir_path( __FILE__ ) . 'widgets/displayfeaturedimagegenesis-cpt-archive-widget.php';
// require plugin_dir_path( __FILE__ ) . 'widgets/displayfeaturedimagegenesis-taxonomy-widget.php';
register_widget( 'Display_Featured_Image_Genesis_Widget_Taxonomy' );
register_widget( 'Display_Featured_Image_Genesis_Widget_CPT' );
+6 -3
View File
@@ -28,7 +28,8 @@ function display_featured_image_genesis_get_term_image_id() {
if ( ! empty( $term_meta['term_image'] ) ) {
$image_id = $term_meta['term_image'];
if ( ! is_numeric( $term_meta['term_image'] ) ) {
$image_id = Display_Featured_Image_Genesis_Common::get_image_id( $term_meta['term_image'] );
$common = new Display_Featured_Image_Genesis_Common();
$image_id = $common->get_image_id( $term_meta['term_image'] );
}
break;
}
@@ -67,7 +68,8 @@ function display_featured_image_genesis_get_default_image_id() {
$fallback = $displaysetting['default'];
$image_id = $fallback;
if ( ! is_numeric( $fallback ) ) {
$image_id = Display_Featured_Image_Genesis_Common::get_image_id( $fallback ); // gets image id with attached metadata
$common = new Display_Featured_Image_Genesis_Common();
$image_id = $common->get_image_id( $fallback ); // gets image id with attached metadata
}
return absint( $image_id );
@@ -117,7 +119,8 @@ function display_featured_image_genesis_get_cpt_image_id() {
if ( ! empty( $displaysetting['post_type'][ $post_type ] ) ) {
$image_id = $displaysetting['post_type'][ $post_type ];
if ( ! is_numeric( $displaysetting['post_type'][ $post_type ] ) ) {
$image_id = Display_Featured_Image_Genesis_Common::get_image_id( $displaysetting['post_type'][ $post_type ] );
$common = new Display_Featured_Image_Genesis_Common();
$image_id = $common->get_image_id( $displaysetting['post_type'][ $post_type ] );
}
}
@@ -109,10 +109,8 @@ class Display_Featured_Image_Genesis_Widget_CPT extends WP_Widget {
$image_id = $postspage_image;
}
else {
$image_id = $option['post_type'][ $post_type->name ];
if ( ! is_numeric( $option['post_type'][ $post_type->name ] ) ) {
$image_id = Display_Featured_Image_Genesis_Common::get_image_id( $option['post_type'][ $post_type->name ] );
}
$common = new Display_Featured_Image_Genesis_Common();
$image_id = is_numeric( $option['post_type'][ $post_type->name ] ) ? $option['post_type'][ $post_type->name ] : $common->get_image_id( $option['post_type'][ $post_type->name ] );
}
$image_src = wp_get_attachment_image_src( $image_id, $instance['image_size'] );
if ( $image_src ) {
@@ -97,10 +97,8 @@ class Display_Featured_Image_Genesis_Widget_Taxonomy extends WP_Widget {
}
if ( $term_meta ) {
$image_id = $term_meta['term_image'];
if ( ! is_numeric( $term_meta['term_image'] ) ) {
$image_id = Display_Featured_Image_Genesis_Common::get_image_id( $term_meta['term_image'] );
}
$common = new Display_Featured_Image_Genesis_Common();
$image_id = is_numeric( $term_meta['term_image'] ) ? $term_meta['term_image'] : $common->get_image_id( $term_meta['term_image'] );
$image_src = wp_get_attachment_image_src( $image_id, $instance['image_size'] );
if ( $image_src ) {
$image = '<img src="' . esc_url( $image_src[0] ) . '" alt="' . esc_html( $title ) . '" />';