updated term option for uniqueness

This commit is contained in:
Robin Cornett
2015-01-07 19:08:49 -05:00
parent 521d2e02a3
commit 9b5da50918
5 changed files with 20 additions and 19 deletions
@@ -85,10 +85,11 @@ class Display_Featured_Image_Genesis_Admin {
*/
public function manage_taxonomy_column( $value, $column, $term_id ) {
$t_id = $term_id;
if ( 'featured_image' === $column ) {
$term_meta = get_option( "taxonomy_$term_id" );
if ( ! empty( $term_meta['dfig_image'] ) ) {
$id = Display_Featured_Image_Genesis_Common::get_image_id( $term_meta['dfig_image'] );
$term_meta = get_option( "displayfeaturedimagegenesis_$t_id" );
if ( ! empty( $term_meta['term_image'] ) ) {
$id = Display_Featured_Image_Genesis_Common::get_image_id( $term_meta['term_image'] );
$preview = wp_get_attachment_image_src( $id, 'thumbnail' );
echo '<img src="' . $preview[0] . '" width="60" />';
}
@@ -82,9 +82,9 @@ class Display_Featured_Image_Genesis_Common {
// taxonomy
elseif ( is_category() || is_tag() || is_tax() ) {
$t_id = $object->term_id;
$term_meta = get_option( "taxonomy_$t_id" );
$term_meta = get_option( "displayfeaturedimagegenesis_$t_id" );
if ( $term_meta ) {
$image_id = self::get_image_id( $term_meta['dfig_image'] );
$image_id = self::get_image_id( $term_meta['term_image'] );
}
}
// any singular post/page/CPT or there is no $item->fallback
@@ -104,9 +104,9 @@ class Display_Featured_Image_Genesis_Common {
foreach ( $terms as $term ) {
$t_id = $term->term_id;
$term_meta = get_option( "taxonomy_$t_id" );
if ( $term_meta['dfig_image'] ) {
$image_id = self::get_image_id( $term_meta['dfig_image'] );
$term_meta = get_option( "displayfeaturedimagegenesis_$t_id" );
if ( $term_meta['term_image'] ) {
$image_id = self::get_image_id( $term_meta['term_image'] );
break;
}
}
@@ -310,13 +310,13 @@ class Display_Featured_Image_Genesis_Settings {
if ( isset( $_POST['term_meta'] ) ) {
$t_id = $term_id;
$term_meta = get_option( "taxonomy_$t_id" );
$term_meta = get_option( "displayfeaturedimagegenesis_$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] ) {
if ( $_POST['term_meta']['term_image'] === $term_meta[$key] ) {
$term_meta[$key] = $this->validate_taxonomy_image( $_POST['term_meta'][$key] );
if ( false !== $term_meta[$key] ) {
$is_updated = true;
@@ -326,7 +326,7 @@ class Display_Featured_Image_Genesis_Settings {
}
//* Save the option array.
if ( $is_updated ) {
update_option( "taxonomy_$t_id", $term_meta );
update_option( "displayfeaturedimagegenesis_$t_id", $term_meta );
}
}
@@ -14,8 +14,8 @@ class Display_Featured_Image_Genesis_Taxonomies {
public function add_taxonomy_meta_fields() {
echo '<div class="form-field">';
echo '<label for="term_meta[dfig_image]">' . __( 'Featured Image', 'display-featured-image-genesis' ) . '</label>';
echo '<input type="url" class="upload_image_url" id="default_image_url" name="term_meta[dfig_image]" style="width:200px;" />';
echo '<label for="term_meta[term_image]">' . __( 'Featured Image', 'display-featured-image-genesis' ) . '</label>';
echo '<input type="url" class="upload_image_url" id="default_image_url" name="term_meta[term_image]" style="width:200px;" />';
echo '<input id="upload_default_image" type="button" class="upload_default_image button" value="' . __( 'Select Image', 'display-featured-image-genesis' ) . '" />';
echo '<p>' . __( 'Set Featured Image for Taxonomy','display-featured-image-genesis' ) . '</p>';
echo '</div>';
@@ -30,20 +30,20 @@ class Display_Featured_Image_Genesis_Taxonomies {
public function edit_taxonomy_meta_fields( $term ) {
$t_id = $term->term_id;
$term_meta = get_option( "taxonomy_$t_id" );
$term_meta = get_option( "displayfeaturedimagegenesis_$t_id" );
$large = get_option( 'large_size_w' );
echo '<tr class="form-field">';
echo '<th scope="row" valign="top"><label for="term_meta[dfig_image]">' . __( 'Featured Image', 'display-featured-image-genesis' ) . '</label></th>';
echo '<th scope="row" valign="top"><label for="term_meta[term_image]">' . __( 'Featured Image', 'display-featured-image-genesis' ) . '</label></th>';
echo '<td>';
if ( ! empty( $term_meta['dfig_image'] ) ) {
$id = Display_Featured_Image_Genesis_Common::get_image_id( $term_meta['dfig_image'] );
if ( ! empty( $term_meta['term_image'] ) ) {
$id = Display_Featured_Image_Genesis_Common::get_image_id( $term_meta['term_image'] );
$preview = wp_get_attachment_image_src( $id, 'medium' );
echo '<div id="upload_logo_preview">';
echo '<img src="' . esc_url( $preview[0] ) . '" width="300" />';
echo '</div>';
}
echo '<input type="url" class="upload_image_url" id="default_image_url" name="term_meta[dfig_image]" value="' . esc_url( $term_meta['dfig_image'] ) . '" style="width:200px;" />';
echo '<input type="url" class="upload_image_url" id="default_image_url" name="term_meta[term_image]" value="' . esc_url( $term_meta['term_image'] ) . '" style="width:200px;" />';
echo '<input id="upload_default_image" type="button" class="upload_default_image button" value="' . __( 'Select Image', 'display-featured-image-genesis' ) . '" />';
echo '<p class="description">' . sprintf(
__( 'Set Featured Image for %1$s. Must be at least %2$s pixels wide.', 'display-featured-image-genesis' ),
@@ -96,7 +96,7 @@ class Display_Featured_Image_Genesis_Widget extends WP_Widget {
}
if ( $term_meta ) {
$image_id = Display_Featured_Image_Genesis_Common::get_image_id( $term_meta['dfig_image'] );
$image_id = Display_Featured_Image_Genesis_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="' . $image_src[0] . '" title="' . $title . '" />';