سلام روزتون بخیر
بعد از کلیک روی button media uploder باز نمیشه و ارور this.activateMode is not a function تو کنسول برام میاد اون طور که من متوجه شدم برای کانفلیکت دوتا لایبریهای underscore و lodash این مشکل ایجاد میشه ولی هر چیزی رو امتحان کردم نتونستم مشکلو حل کنم فقط یه کد تو stackoverflow پیدا کردم که یه بار مشکلمو حل کرد ولی دوباره بعد از ادامه روند به همون مشکل قبل بر خوردم حالا نمیدونم کلا اون قطعه کد مشکلی رو حل نمیکنه یه صرفا بد جا دارم فانکشنو call میکنم.
jQuery(document).ready(function ($)
{
export const isLodash = () => {
let isLodash = false;
// If _ is defined and the function _.forEach exists then we know underscore OR lodash are in place
if ( 'undefined' != typeof( _ ) && 'function' == typeof( _.forEach ) )
{
// A small sample of some of the functions that exist in lodash but not underscore
const funcs = [ 'get', 'set', 'at', 'cloneDeep' ];
// Simplest if assume exists to start
isLodash = true;
funcs.forEach( function ( func ) {
// If just one of the functions do not exist, then not lodash
isLodash = ( 'function' != typeof( _[ func ] ) ) ? false : isLodash;
} );
}
if ( isLodash ) {
// We know that lodash is loaded in the _ variable
return true;
} else {
// We know that lodash is NOT loaded
return false;
}
};
if ( isLodash() )
{
_.noConflict();
}
var uploader;
$(document).on("click","#choosepicture",function(event)
{
event.preventDefault();
if (uploader)
{
uploader.open();
return;
}
uploader = wp.media({
title: 'انتخاب تصویر',
button: {
text: 'انتخاب تصویر'
},
multiple: false
});
uploader.on('select',function()
{
var attachmet = uploader.state().get('selection').first().toJSON();
$(#setting-img).attr('src',attachmet.url);
});
});
});