plugin updates
This commit is contained in:
@@ -181,6 +181,125 @@ var wpmfFoldersModule = void 0,
|
||||
$('.page-title-action').after('<a href="#" class="wpmf_btn_upload_folder">' + wpmf.l18n.upload_folder_label + '</a><input name="id_category" class="wpmf_id_category" type="hidden" value="0">');
|
||||
}
|
||||
|
||||
//Select tag for media
|
||||
$('#doaction').on('click', function (e) {
|
||||
var action = $('#bulk-action-selector-top').val();
|
||||
if (wpmf.vars.wpmf_pagenow === 'upload.php' && action == 'tag') {
|
||||
e.preventDefault();
|
||||
//get list post id
|
||||
var cboxes = document.getElementsByName('media[]');
|
||||
var post_ids = [];
|
||||
var len = cboxes.length;
|
||||
if (cboxes !== 'undefined') {
|
||||
for (var i=0; i<len; i++) {
|
||||
if(cboxes[i].checked) {
|
||||
post_ids.push(cboxes[i].value);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (post_ids.length > 0) {
|
||||
var html = "<p class='tag-note'>To select a tag, first choose one from the existing list. If the tag you need isn't there, you can create a new one.</p>";
|
||||
html += '<input name="tags-outside" class="tagify--outside" value="" placeholder="Write tags to add below">';
|
||||
//show tagify for tags
|
||||
showDialog({
|
||||
id: 'wpmf-add-tag-dialog',
|
||||
title: wpmf.l18n.create_or_select_tag,
|
||||
text: html,
|
||||
negative: {
|
||||
title: wpmf.l18n.cancel
|
||||
},
|
||||
positive: {
|
||||
title: wpmf.l18n.add,
|
||||
onClick: function onClick(e) {
|
||||
var value = $('input[name=tags-outside]').val();
|
||||
if (value) {
|
||||
var array_value = JSON.parse(value);
|
||||
var tag_name = [];
|
||||
array_value.forEach(element => {
|
||||
tag_name.push(element.value);
|
||||
});
|
||||
//save tag
|
||||
if (tag_name.length) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
dataType: "json",
|
||||
url: wpmf.vars.ajaxurl,
|
||||
data: {
|
||||
action: "wpmf",
|
||||
task: "save_tag_item",
|
||||
tag_name: tag_name,
|
||||
post_ids: post_ids,
|
||||
wpmf_nonce: wpmf.vars.wpmf_nonce
|
||||
},
|
||||
success: function success(response) {
|
||||
if (response.status) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
console.log(response.status);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//set tagify
|
||||
var input = document.querySelector('input[name=tags-outside]')
|
||||
var tagify = new Tagify(input, {
|
||||
focusable: false,
|
||||
dropdown: {
|
||||
position: 'input',
|
||||
enabled: 0 // always opens dropdown when input gets focus
|
||||
}
|
||||
});
|
||||
//get 10 tag items
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
dataType: "json",
|
||||
url: wpmf.vars.ajaxurl,
|
||||
data: {
|
||||
action: "wpmf",
|
||||
task: "get_tag_item",
|
||||
wpmf_nonce: wpmf.vars.wpmf_nonce
|
||||
},
|
||||
success: function success(response) {
|
||||
if (response.status) {
|
||||
tagify.whitelist = response.list_tags; // update whitelist
|
||||
}
|
||||
}
|
||||
});
|
||||
//search tag
|
||||
document.querySelector('.tagify__input').addEventListener("keyup", function (e) {
|
||||
var tag_name = $(this).html();
|
||||
if (tag_name.length > 1) {
|
||||
$.ajax({
|
||||
method: "POST",
|
||||
dataType: "json",
|
||||
url: wpmf.vars.ajaxurl,
|
||||
data: {
|
||||
action: "wpmf",
|
||||
task: "get_tag_item",
|
||||
tag_name : tag_name,
|
||||
wpmf_nonce: wpmf.vars.wpmf_nonce
|
||||
},
|
||||
success: function success(response) {
|
||||
if (response.status) {
|
||||
tagify.whitelist = response.list_tags // update whitelist
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
showDialog({
|
||||
text: wpmf.l18n.select_file_required,
|
||||
closeicon: true
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// add bulk upload to s3 button
|
||||
if (parseInt(wpmf.vars.copy_files_to_bucket) === 1) {
|
||||
if (!$current_frame.find('.bulk-upload-s3-btn').length) {
|
||||
|
||||
Reference in New Issue
Block a user