public function woocommerce_edit_attributre_thumbnail_field($term, $taxonomy) { global $woocommerce; $swatch_term = new WC_Swatch_Term($this->meta_key, $term->term_id, $taxonomy, false, $this->image_size); $image = ''; ?> <tr class="form-field "> <th scope="row" valign="top"><label><?php _e('Type', 'wc_swatches_and_photos'); ?> </label></th> <td> <label for="product_attribute_swatchtype_<?php echo $this->meta_key; ?> ">Swatch Type</label> <select name="product_attribute_meta[<?php echo $this->meta_key; ?> ][type]" id="product_attribute_swatchtype_<?php echo $this->meta_key; ?> " class="postform"> <option <?php selected('none', $swatch_term->get_type()); ?> value="-1"><?php _e('None', 'wc_swatches_and_photos'); ?> </option> <option <?php selected('color', $swatch_term->get_type()); ?> value="color"><?php _e('Color Swatch', 'wc_swatches_and_photos'); ?> </option> <option <?php selected('photo', $swatch_term->get_type()); ?> value="photo"><?php _e('Photo', 'wc_swatches_and_photos'); ?> </option> </select> <script type="text/javascript"> jQuery(document).ready(function($) { $('#product_attribute_swatchtype_<?php echo $this->meta_key; ?> ').change(function() { $('.swatch-field-active').hide().removeClass('swatch-field-active'); $('.swatch-field-' + $(this).val()).show().addClass('swatch-field-active'); }); }); </script> </td> </tr> <?php $style = $swatch_term->get_type() != 'color' ? 'display:none;' : ''; ?> <tr class="form-field swatch-field swatch-field-color section-color-swatch" style="overflow:visible;<?php echo $style; ?> "> <th scope="row" valign="top"><label><?php _e('Color', 'wc_swatches_and_photos'); ?> </label></th> <td> <div id="swatch-color" class="<?php echo sanitize_title($this->meta_key); ?> -color"> <div id="product_attribute_color_<?php echo $this->meta_key; ?> _picker" class="colorSelector"><div></div></div> <input class="woo-color" id="product_attribute_color_<?php echo $this->meta_key; ?> " type="text" class="text" name="product_attribute_meta[<?php echo $this->meta_key; ?> ][color]" value="<?php echo $swatch_term->get_color(); ?> " /> </div> </td> </tr> <?php $style = $swatch_term->get_type() != 'photo' ? 'display:none;' : ''; ?> <tr class="form-field swatch-field swatch-field-photo" style="overflow:visible;<?php echo $style; ?> "> <th scope="row" valign="top"><label><?php _e('Photo', 'wc_swatches_and_photos'); ?> </label></th> <td> <div id="product_attribute_thumbnail_<?php echo $this->meta_key; ?> " style="float:left;margin-right:10px;"> <img src="<?php echo $swatch_term->get_image_src(); ?> " width="<?php echo $swatch_term->get_width(); ?> px" height="<?php echo $swatch_term->get_height(); ?> px" /> </div> <div style="line-height:60px;"> <input type="hidden" id="product_attribute_<?php echo $this->meta_key; ?> " name="product_attribute_meta[<?php echo $this->meta_key; ?> ][photo]" value="<?php echo $swatch_term->get_image_id(); ?> " /> <button type="submit" class="upload_image_button button"><?php _e('Upload/Add image', 'woocommerce'); ?> </button> <button type="submit" class="remove_image_button button"><?php _e('Remove image', 'woocommerce'); ?> </button> </div> <script type="text/javascript"> window.send_to_termmeta = function(html) { jQuery('body').append('<div id="temp_image">' + html + '</div>'); var img = jQuery('#temp_image').find('img'); imgurl = img.attr('src'); imgclass = img.attr('class'); imgid = parseInt(imgclass.replace(/\D/g, ''), 10); jQuery('#product_attribute_<?php echo $this->meta_key; ?> ').val(imgid); jQuery('#product_attribute_thumbnail_<?php echo $this->meta_key; ?> img').attr('src', imgurl); jQuery('#temp_image').remove(); tb_remove(); } jQuery('.upload_image_button').live('click', function() { var post_id = 0; window.send_to_editor = window.send_to_termmeta; tb_show('', 'media-upload.php?post_id=' + post_id + '&type=image&TB_iframe=true'); return false; }); jQuery('.remove_image_button').live('click', function() { jQuery('#product_attribute_thumbnail_<?php echo $this->meta_key; ?> img').attr('src', '<?php echo $woocommerce->plugin_url() . '/assets/images/placeholder.png'; ?> '); jQuery('#product_attribute_<?php echo $this->meta_key; ?> ').val(''); return false; }); </script> <div class="clear"></div> </td> </tr> <?php }
public function woocommerce_edit_attributre_thumbnail_field($term, $taxonomy) { global $woocommerce; $swatch_term = new WC_Swatch_Term($this->meta_key, $term->term_id, $taxonomy, false, $this->image_size); $image = ''; ?> <tr class="form-field "> <th scope="row" valign="top"><label><?php _e('Type', 'wc_swatches_and_photos'); ?> </label></th> <td> <label for="product_attribute_swatchtype_<?php echo $this->meta_key; ?> ">Swatch Type</label> <select name="product_attribute_meta[<?php echo $this->meta_key; ?> ][type]" id="product_attribute_swatchtype_<?php echo $this->meta_key; ?> " class="postform"> <option <?php selected('none', $swatch_term->get_type()); ?> value="-1"><?php _e('None', 'wc_swatches_and_photos'); ?> </option> <option <?php selected('color', $swatch_term->get_type()); ?> value="color"><?php _e('Color Swatch', 'wc_swatches_and_photos'); ?> </option> <option <?php selected('photo', $swatch_term->get_type()); ?> value="photo"><?php _e('Photo', 'wc_swatches_and_photos'); ?> </option> </select> <script type="text/javascript"> jQuery(document).ready(function ($) { $('#product_attribute_swatchtype_<?php echo $this->meta_key; ?> ').change(function () { $('.swatch-field-active').hide().removeClass('swatch-field-active'); $('.swatch-field-' + $(this).val()).show().addClass('swatch-field-active'); }); }); </script> </td> </tr> <?php $style = $swatch_term->get_type() != 'color' ? 'display:none;' : ''; ?> <tr class="form-field swatch-field swatch-field-color section-color-swatch" style="overflow:visible;<?php echo $style; ?> "> <th scope="row" valign="top"><label><?php _e('Color', 'wc_swatches_and_photos'); ?> </label></th> <td> <div id="swatch-color" class="<?php echo sanitize_title($this->meta_key); ?> -color"> <div id="product_attribute_color_<?php echo $this->meta_key; ?> _picker" class="colorSelector"><div></div></div> <input class="woo-color" id="product_attribute_color_<?php echo $this->meta_key; ?> " type="text" class="text" name="product_attribute_meta[<?php echo $this->meta_key; ?> ][color]" value="<?php echo $swatch_term->get_color(); ?> " /> </div> </td> </tr> <?php $style = $swatch_term->get_type() != 'photo' ? 'display:none;' : ''; ?> <tr class="form-field sub_field swatch-field swatch-field-photo" style="overflow:visible;<?php echo $style; ?> "> <th scope="row" valign="top"><label><?php _e('Photo', 'wc_swatches_and_photos'); ?> </label></th> <td> <div id="product_attribute_thumbnail_<?php echo $this->meta_key; ?> " style="float:left;margin-right:10px;"> <img src="<?php echo $swatch_term->get_image_src(); ?> " width="<?php echo $swatch_term->get_width(); ?> px" height="<?php echo $swatch_term->get_height(); ?> px" /> </div> <div style="line-height:60px;"> <input class="upload_image_id" type="hidden" id="product_attribute_<?php echo $this->meta_key; ?> " name="product_attribute_meta[<?php echo $this->meta_key; ?> ][photo]" value="<?php echo $swatch_term->get_image_id(); ?> " /> <button type="submit" class="upload_swatch_image_button button"><?php _e('Upload/Add image', 'woocommerce'); ?> </button> <button type="submit" class="remove_swatch_image_button button"><?php _e('Remove image', 'woocommerce'); ?> </button> </div> <div class="clear"></div> </td> </tr> <?php }