function run_js_lib(name, ...params){
if(hooks[name]) hooks[name].forEach( func => result = func(...params));
if( typeof result !== 'undefined' ) return result; return "";
}
/* - Обработка Select - */
var voiseType = [
{ "key": "man", "name": "Мужской" },
{ "key": "woman","name": "Женский" },
{ "key": "duet","name": "Дуэт" },
{ "key": "group","name": "Групповой" }
];
var SelectDataEditor = function (cell, onRendered, success, cancel, editorParams) {
var cellValue = cell.getValue();
var editor = document.createElement("select");
for (var i = 0; i < editorParams.length; i++) {
var opt = document.createElement('option');
opt.value = editorParams[i].key;
opt.innerHTML = editorParams[i].name;
editor.appendChild(opt);
}
editor.style.padding = "3px";
editor.style.width = "100%";
editor.style.boxSizing = "border-box";
editor.value = cell.getValue();
onRendered(function () { editor.focus(); editor.style.css = "100%"; });
function onSelect() { if(editor.value != cellValue){ saveChanges(cell.getData().id, cell.getField(), editor.value); success(editor.value); } else{ cancel(); } }
editor.addEventListener("blur", throttle(onSelect, 1000) );
return editor;
};
{title: "Тип вокала", field: 'gender', headerHozAlign: 'center', hozAlign: 'center', editor: SelectDataEditor, editorParams: voiseType,
formatter: function (cell, formatterParams) {
for (var i = 0; i < formatterParams.length; i++) {
if (formatterParams[i].key == cell.getValue()) { return formatterParams[i].name; }
}
}, formatterParams: voiseType,
},
const throttle = (fn, throttleTime) => {
let start = -Infinity;
let cachedResult;
return function() {
const end = Date.now();
if (end - start >= throttleTime) {
start = end;
cachedResult = fn.apply(this, arguments);
}
return cachedResult;
};
}
<?PHP
// $imageFile - переменная которой нужно присвоить путь к файлу из произвольного поля
$wpFileType = wp_check_filetype($imageFile, null);
// Attachment attributes for file
$attachment = array(
'post_mime_type' => $wpFileType['type'], // file type
'post_title' => sanitize_file_name($imageFile), // sanitize and use image name as file name
'post_content' => '', // could use the image description here as the content
'post_status' => 'inherit'
);
// insert and return attachment id
$attachmentId = wp_insert_attachment( $attachment, $imageFile, $postId );
// insert and return attachment metadata
$attachmentData = wp_generate_attachment_metadata( $attachmentId, $imageFile);
// update and return attachment metadata
wp_update_attachment_metadata( $attachmentId, $attachmentData );
// finally, associate attachment id to post id
$success = set_post_thumbnail( $postId, $attachmentId );
// was featured image associated with post?
/* не уверен, что этот кусок кода нужно, потому что у Вас пакетное переименовывание, но на всякий случай
if($success){
$message = $IMGFileName.' has been added as featured image to post.';
} else {
$message = $IMGFileName.' has NOT been added as featured image to post.';
}
*/
?>
{title:" ", field:"path", hozAlign:"center",
formatter:function(cell, formatterParams, onRendered){ return '<i class="fa fa-play" path="'+cell.getValue()+'"></i>'; },
cellClick:function(e, cell){
var el = cell.getElement().getElementsByClassName('fa')[0];
var state = el.classList;
if (state[1] == "fa-pause"){
jQuery(el).removeClass("fa-pause").addClass("fa-play");
includePlayer_controller( cell.getValue() );
}
else{
var divs = document.getElementsByClassName("fa-pause");
for (let i = 0; i < divs.length; i++) {
const div = divs[i];
div.classList.remove('fa-pause');
div.classList.add('fa-play');
}
jQuery(el).removeClass("fa-play").addClass("fa-pause");
includePlayer_controller( cell.getValue() );
}
},
},
jQuery(document).find('.email__button-click').each(function(){
jQuery(this).on("click", function(){
var needle_atts = ['date','title']; var data_ = []; var elm = jQuery(this);
jQuery.each(needle_atts, function(k,v){ data_[v] = elm.attr(`data-${v}`); console.log(v) });
console.log(data_);
});
});
function es_get_workingSheduler_data($needle_date, $personal){
if( !isset($personal) || empty($personal) ) { $personal = es_getPersonal(); } // Проверям id
if( isset( $needle_date) && !empty($needle_date) ){ list($month, $year) = explode("-", $needle_date); }
else{ $month = date('m'); $year = date('Y'); } // Определяем дату
$data=[]; $actual_dates = array();
$max_days = cal_days_in_month(CAL_GREGORIAN, date($month), date($year) );
for ($i=1; $i<$max_days+1; $i++) {
if( $i <= 9 ){ $day = "0" . $i; } else { $day = $i; }
array_push($actual_dates, "$year-$month-$day");
} // Формируем актуальные даты запрашиваемого месяца
foreach ($personal as $uid) { // Формируем выходящимй массив для каждого id
$all_uid_dates = get_user_meta($uid, 'sheduleGrafic', false); $dates=array();
foreach ($all_uid_dates as $needle_date) {
if( in_array( key($needle_date), $actual_dates) ){ array_push($dates, $needle_date); }
} $data[$uid] = $dates;
} wp_send_json($data);
}
function es_docsControl(){
$plugins = get_plugins(); $plugin = array_keys($plugins); $needle_plugin = 'Google Doc Embedder';
foreach($plugin as $path){
if( in_array($needle_plugin, $plugins[$path] ) ) {
if( is_plugin_active( $path )){ return true; } else { return false; }
}
}
}
add_shortcode('es_docsControl','es_docsControl');
// На всякий случай убиваем еще раз процесс ajax wp_die();