Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('body').on('click', "#add_selection_item", function() {
- max_index = max_index+1;
- $("#w2dc-selection-items-wrapper").append('<div class="selection_item"><input name="selection_items['+max_index+']" type="text" class="regular-text" value="" /><img class="w2dc-delete-selection-item" src="<?php echo W2DC_RESOURCES_URL . 'images/delete.png' ?>" title="<?php esc_attr_e( 'Remove selection item', 'W2DC' )?>" /> <span class="w2dc-icon-tag w2dc-icon-tag-'+max_index+'" style="display: none;"></span><input type="hidden" name="icon_images['+max_index+']" id="w2dc-icon-image-'+max_index+'" value=""><input class="upload_image_button button" name="_amenities_icon" id="_amenities_icon_'+max_index+'" type="button" value="Upload Amenities Icon" /><input class="remove_icon_button button" name="remove_icon" id="remove_icon_'+max_index+'" type="button" value="Remove Icon" /><img class="amenities_icon_'+max_index+'" width="20"><script>jQuery(document).ready(function($){varcustom_uploader;$("#remove_icon_'+max_index+'").hide();$("#_amenities_icon_'+max_index+'").click(function(e){e.preventDefault();if(custom_uploader){custom_uploader.open();return;}custom_uploader=wp.media.frames.file_frame=wp.media({title:"Select/UploadAmenitiesIcon",button:{text:"SelectAmenitiesIcon"},library:{type:"image/svg+xml"},multiple:false});custom_uploader.on("select",function(){attachment=custom_uploader.state().get("selection").first().toJSON();$("input#w2dc-icon-image-'+max_index+'").val(attachment.url);$("img.amenities_icon_'+max_index+'").attr("src",attachment.url);$("#_amenities_icon_'+max_index+'").hide();$("#remove_icon_'+max_index+'").show();});custom_uploader.open();returntrue;});$("#remove_icon_'+max_index+'").click(function(e){$(this).hide();$("#_amenities_icon_'+max_index+'").show();$("input#w2dc-icon-image-'+max_index+'").removeAttr("value");$("img.amenities_icon_'+max_index+'").removeAttr("src");});});</script><span class="w2dc-move-label"><?php esc_attr_e( 'move', 'W2DC' );?></span><?php echo esc_js( '(ID: ', 'W2DC' ); ?>'+max_index+')</div>');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement