From f400a7cc57063d6d26a3d3b6a5ff2d9d5a4510f5 Mon Sep 17 00:00:00 2001 From: Robin Cornett Date: Fri, 2 Jan 2015 16:40:46 -0500 Subject: [PATCH] fixed returned value for taxonomy images The taxonomy option is not updated if the image is invalid or too small. If the image is deleted (the field is empty), that's OK. --- ...ss-displayfeaturedimagegenesis-taxonomies.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/includes/class-displayfeaturedimagegenesis-taxonomies.php b/includes/class-displayfeaturedimagegenesis-taxonomies.php index 08efc72..7defee7 100644 --- a/includes/class-displayfeaturedimagegenesis-taxonomies.php +++ b/includes/class-displayfeaturedimagegenesis-taxonomies.php @@ -79,19 +79,25 @@ class Display_Featured_Image_Genesis_Taxonomies { public function save_taxonomy_custom_meta( $term_id ) { if ( isset( $_POST['term_meta'] ) ) { - $t_id = $term_id; - $term_meta = get_option( "taxonomy_$t_id" ); - $cat_keys = array_keys( $_POST['term_meta'] ); + $t_id = $term_id; + $term_meta = get_option( "taxonomy_$t_id" ); + $cat_keys = array_keys( $_POST['term_meta'] ); + $is_updated = false; foreach ( $cat_keys as $key ) { if ( isset ( $_POST['term_meta'][$key] ) ) { $term_meta[$key] = $_POST['term_meta'][$key]; if ( $_POST['term_meta']['dfig_image'] === $term_meta[$key] ) { $term_meta[$key] = $this->validate_image( $_POST['term_meta'][$key] ); + if ( false !== $term_meta[$key] ) { + $is_updated = true; + } } } } //* Save the option array. - update_option( "taxonomy_$t_id", $term_meta ); + if ( $is_updated ) { + update_option( "taxonomy_$t_id", $term_meta ); + } } } @@ -113,7 +119,7 @@ class Display_Featured_Image_Genesis_Taxonomies { // ok for field to be empty if ( $new_value && ( ! $valid || $width <= $large ) ) { - $new_value = $term_meta['dfig_image']; + $new_value = false; } return $new_value;