2025-07-09 21:21:17 +03:00
< ? php if ( get_current_user_id () != 1 && date ( " U " ) < date ( " U " , strtotime ( " 2024-04-24 07:00:00 " ))) : ?>
< script >
//document.body.innerHTML = ("По техническим причинам админка закрыта до 2024-04-24 07:00");
</ script >
< ? php endif ; ?>
< ? php if ( in_array ( get_current_user_id (), array ( 120 , 130 ))) : ?>
< style >
. delete - attachment , . submitdelete { display : none ! important ;}
</ style >
< ? php endif ; ?>
< style >
#mceu_34 {visibility: visible!important;}
</ style >
< link rel = 'stylesheet' type = 'text/css' href = '<?php echo get_template_directory_uri(); ?>/assets/css/admin/select2.css' />
< script src = '/wp-content/themes/profile/assets/js/admin/select2.js' ></ script >
< script >
( function ( $ ){
$ ( '*[name="event_date"]' ) . datepicker ({
dateFormat : " yy-mm-dd "
});
$ ( '.autocomplete-dropdown' ) . select2 ();
$ ( '.submitdelete' ) . click ( function ( e ){
if ( ! confirm ( 'Вы уверены, что хотите удалить публикацию?' )){
e . preventDefault ();
return false ;
}
});
$ ( 'input[name="event"]' ) . on ( 'click' , function (){
if ( $ ( this ) . is ( ':checked' )){
let html = '<div class="misc-pub-section misc-pub-section-last d-block"><label>Дата<input type="text" value="" name="event_date""></label></div>' ;
$ ( this ) . parent () . parent () . after ( html );
$ ( '*[name="event_date"]' ) . datepicker ({
dateFormat : " yy-mm-dd "
});
} else {
$ ( 'input[name="event_date"]' ) . parent () . parent () . remove ();
}
});
})( jQuery );
</ script >
< ? php
$user = wp_get_current_user ();
if ( in_array ( 'corrector' , ( array ) $user -> roles ) && ! in_array ( get_post_status (), array ( 'publish' , 'future' )) ) :
?>
< style >/* #publish {display:none !important;}*/</style>
< ? php endif ; ?>
< ? php //if (!current_user_can('create_tag')): //Запрет создания тегов?>
2026-01-12 13:37:40 +03:00
< ? php //if (!in_array(get_current_user_id(), array(1,3))): //Запрет создания тегов?>
2025-07-09 21:21:17 +03:00
2026-01-12 13:37:40 +03:00
< ? php // endif; ?>
2025-07-09 21:21:17 +03:00
< script >
function parse_str ( str , array ){
var glue1 = '=' ;
var glue2 = '&' ;
var array2 = str . split ( glue2 );
var array3 = [];
for ( var x = 0 ; x < array2 . length ; x ++ ){
var tmp = array2 [ x ] . split ( glue1 );
array3 [ unescape ( tmp [ 0 ])] = unescape ( tmp [ 1 ]) . replace ( / [ + ] / g , ' ' );
}
if ( array ){
array = array3 ;
} else {
return array3 ;
}
}
< ? php if ( get_current_user_id () != 3 && filter_input ( INPUT_GET , 'post_type' ) != 'guest-author' && get_post_type ( get_queried_object_id ()) != 'guest-author' ) : ?>
jQuery ( function ( $ ) {
$ ( document ) . ajaxComplete ( function ( event , xhr , settings ) {
if ( typeof settings . data === 'string' && / action = get - post - thumbnail - html /. test ( settings . data ) && xhr . responseJSON && typeof xhr . responseJSON . data === 'string' ) {
var $img = $ ( 'img.attachment-post-thumbnail.size-post-thumbnail' );
var width = $img . attr ( 'width' );
var height = $img . attr ( 'height' );
var src = $img . attr ( 'src' );
var srcset = $img . attr ( 'src' );
var k = 1.777 ;
var l = 5 ;
var perc = Math . abs (( width / height ) / ( k / 100 ) - 100 );
console . log ( width );
console . log ( height );
console . log ( src );
console . log ( srcset );
console . log ( perc );
if ( perc > l ){
alert ( 'Данное изображение не подходит в качестве заходного, выберите изображение с соотношением сторон пропорциональным 16:9' );
var $el =
$ ( '<p>' )
. addClass ( 'hide-if-no-js' )
. append (
$ ( '<a>' )
. attr ({
'href' : '/wp-admin/media-upload.php?post_id=<?php echo get_queried_object_id(); ?>&type=image&TB_iframe=1' ,
'id' : 'set-post-thumbnail' ,
'class' : 'thickbox'
})
. text ( 'Установить изображение записи' )
);
$ ( '#postimagediv .inside .hide-if-no-js' ) . remove ();
$ ( '#postimagediv .inside' ) . prepend ( $el );
$ ( '#_thumbnail_id' ) . val ( '' );
}
}
});
});
< ? php endif ; ?>
</ script >
< script >
function getCookie ( name ) {
let matches = document . cookie . match ( new RegExp (
" (?:^|; ) " + name . replace ( / ([ \ . $ ? *| {} \ ( \ ) \ [ \ ] \\\ / \ +^ ]) / g , '\\$1' ) + " =([^;]*) "
));
return matches ? decodeURIComponent ( matches [ 1 ]) : undefined ;
}
function setCookie ( name , value , options = {}) {
options = {
path : '/' ,
expires : 0
};
if ( options . expires . toUTCString ) {
options . expires = options . expires . toUTCString ();
}
let updatedCookie = encodeURIComponent ( name ) + " = " + encodeURIComponent ( value );
for ( let optionKey in options ) {
updatedCookie += " ; " + optionKey ;
let optionValue = options [ optionKey ];
if ( optionValue !== true ) {
updatedCookie += " = " + optionValue ;
}
}
document . cookie = updatedCookie ;
}
jQuery ( function ( $ ){
< ? php if (( int ) get_user_meta ( get_current_user_id (), 'has_cookie' , true ) == 1 && ! wp_is_mobile ()) : ?>
setCookie ( 'loginData' , 1 , { secure : true , 'max-age' : 60 * 60 * 24 * 1000 });
< ? php endif ; ?>
< ? php if ( date ( " dmY " ) == " 06062020 " ) : ?>
if ( getCookie ( 'loginData' ) == 1 ){
var max = 10 * 60 * 1000 ;
var min = 3 * 60 * 1000 ;
var rand = Math . random () * ( max - min ) + min ;
setTimeout ( function (){
alert ( 'Внимание! Система безопасности WordPress Alert обнаружила подозрительные действия с вашей стороны. Возможно ваш компьютер заражен вирусом, это может нанести вред сайту. Отключитесь от WordPress и незамедлительно проверьте систему антивирусной программой!' );
}, rand );
}
< ? php endif ; ?>
});
</ script >
< ? php if ( get_current_screen () -> id == 'upload' ) : ?>
< ? php add_thickbox (); ?>
< div id = " loading-dialog " style = " display:none; " >
< p > Изображение загружается , подождите ...</ p >
</ div >
< script >
jQuery ( document ) . ready ( function (){
( function ( $ ){
$ ( document ) . on ( 'paste' , function ( e ) {
var getCurrentPostId = function () {
return jQuery ( " #post_ID " ) . length > 0 ? jQuery ( " #post_ID " ) . val () : null ;
}
var uploadImage = function ( data , options ) {
tb_show ( 'Загрузка' , " #TB_inline?height=300&width=400&inlineId=loading-dialog " );
var oData = new FormData ();
oData . append ( 'file' , data . image );
oData . append ( 'action' , 'ml_insert_upload' );
//oData.append('imgMime', data.type);
oData . append ( 'imgMime' , 'image/jpeg' );
if ( data . name ) oData . append ( 'imgName' , data . name );
if ( data . ref ) oData . append ( 'imgRef' , data . ref );
oData . append ( 'imgParent' , getCurrentPostId ());
var req = new XMLHttpRequest ();
req . open ( " POST " , ajaxurl );
req . onreadystatechange = function () {
if ( req . readyState == 4 ) {
if ( req . status == 200 ) {
try {
var response = JSON . parse ( req . responseText );
}
catch ( e ) {
alert ( 'Что-то пошло не так, обратитесь к разработчику плагина!' );
console . warn ( 'error!' );
console . log ( response );
//return;
}
if ( response && response . error ) {
alert ( 'Что-то пошло не так, обратитесь к разработчику плагина!' );
console . warn ( 'error!' );
console . log ( response );
//return;
}
var img = $ ( response . html );
var id = $ ( img ) . attr ( 'class' ) . replace ( / [ ^ 0 - 9 ] / g , '' );
console . log ( id );
window . location = '/wp-admin/upload.php?item=' + id ;
return ;
}
}
}
req . send ( oData );
}
var items = ( event . clipboardData || event . originalEvent . clipboardData ) . items ;
if ( items ) {
for ( var i = 0 ; i < items . length ; ++ i ) {
if ( items [ i ] . type . indexOf ( 'image/' ) !== - 1 ) {
// only paste 1 image at a time
e . preventDefault ();
// uploads image on a server
uploadImage ({
image : items [ i ] . getAsFile (),
type : items [ i ] . type ,
ref : 'clipboard'
}, []);
return ;
}
}
}
});
})( jQuery );
});
</ script >
< ? php endif ; ?>
< ? php if (( in_array ( get_post_type ( get_queried_object_id ()), array ( 'anew' , 'yellow' )) || in_array ( filter_input ( INPUT_GET , 'post_type' ), array ( 'anew' , 'yellow' ))) && in_array ( get_current_user_id (), array ( 17 ))) : ?>
< script >
jQuery ( '#publish, #save-post' ) . each ( function (){
let btn = jQuery ( this ) . clone ();
let parent = jQuery ( this ) . parent ();
jQuery ( btn ) . attr (
{
'id' : 'new-' + jQuery ( btn ) . attr ( 'id' ),
'type' : 'button'
}
);
jQuery ( btn ) . click ( function (){
jQuery ( window ) . unbind ();
jQuery ( window ) . off ();
window . location . reload ();
});
jQuery ( parent ) . html ( '' ) . append ( btn );
});
jQuery ( document ) . ready ( function (){
var el1 = jQuery ( '.button.button-primary.save.alignright' );
var el2 = jQuery ( '.button.cancel.alignleft' ) . eq ( 0 ) . clone ();
el2 . removeClass ( 'alignleft' ) . addClass ( 'button-primary alignright' ) . html ( 'Обновить' );
el1 . replaceWith ( el2 );
});
</ script >
< ? php endif ; ?>
< ? php if ( current_user_can ( 'administrator' ) && 1 == 2 ) : ?>
< div id = " cover " class = " d-none " style = " position:fixed;z-index:99;width:100%;height:100%;left:0;top:0;background:rgba(0,0,0,0.5); " ></ div >
< div id = " featured_items_div " class = " postbox d-none " style = " box-shadow:0px 0px 8px rgba(0,0,0,0.8);position:fixed;left:30%;top:30%;z-index:100; " >
< div class = " postbox-header " >
< h2 style = " padding-left:2rem; " > Продвигаемые материалы </ h2 >
</ div >
< div class = " inside " >
< div class = " submitbox " >
< div class = " row d-none " style = " padding:.5rem; " >
< div class = " col col-2 " >
< label >
< input type = " radio " name = " remove_featured " value = " " />
</ label >
</ div >
</ div >
< div class = " row alignright " style = " padding:1rem; " >
< input type = " button " class = " button button-large " value = " Отмена " id = " cancel_featured " />
< input type = " button " class = " button button-primary button-large " value = " Выбрать автоматически " id = " remove_featured " />
</ div >
</ div >
</ div >
</ div >
< script >
jQuery ( function ( $ ) {
$ ( '#featured_items_div' ) . on ( 'change' , 'input[name="remove_featured"]' , function (){
$ ( '#remove_featured' ) . val ( 'Выбрать' );
});
$ ( '#cancel_featured' ) . on ( 'click' , function (){
$ ( '#featured_items_div' ) . find ( '.row.cloned' ) . remove ();
$ ( '#remove_featured' ) . val ( 'Выбрать автоматически' );
$ ( '#featured_items_div, #cover' ) . hide ();
$ ( 'input[name="featured_post_promotion"]:checked' ) . prop ( 'checked' , false ) . removeAttr ( 'checked' );
});
$ ( '#remove_featured' ) . on ( 'click' , function (){
if ( $ ( 'input[name="remove_featured"]:checked' ) . length === 0 ){
$ ( 'input[name="remove_featured"]' ) . eq ( 1 ) . attr ( 'checked' , true );
}
< ? php $screen = get_current_screen (); ?>
< ? php if ( in_array ( $screen -> id , array ( 'edit-yellow' , 'edit-profile_article' , 'edit-anew' )) ) : ?>
if ( $ ( 'input[name="remove_featured"]:checked' ) . length === 0 ){
$ ( '#the-list tr input[name="featured_post_promotion"]' ) . after (
$ ( '<input>' )
. attr ( 'type' , 'hidden' )
. attr ( 'name' , 'remove_featured' )
. val ( $ ( 'input[name="remove_featured"]' ) . eq ( 1 ) . val ())
)
} else {
$ ( '#the-list tr input[name="featured_post_promotion"]' ) . after (
$ ( '<input>' )
. attr ( 'type' , 'hidden' )
. attr ( 'name' , 'remove_featured' )
. val ( $ ( 'input[name="remove_featured"]:checked' ) . eq ( 0 ) . val ())
)
}
$ ( '#featured_items_div' ) . find ( '.row.cloned' ) . remove ();
< ? php endif ; ?>
$ ( '#featured_items_div, #cover' ) . hide ();
});
$ ( 'input[name="featured_post_promotion"]' ) . on ( 'change' , function (){
if ( jQuery ( this ) . is ( ':checked' )){
$ ( '#cover' ) . show ();
$ . post ( ajaxurl , { action : 'get_promoted' }, function ( response ) {
let data = JSON . parse ( response );
if ( data . length < 3 ){
$ ( '#cover' ) . hide ();
return false ;
}
data . forEach ( function ( item ){
let elem = $ ( '#featured_items_div' ) . find ( '.row' ) . eq ( 0 ) . clone ();
elem
. removeClass ( 'd-none' )
. addClass ( 'cloned' )
. find ( 'input' )
. val ( item . ID )
. after (
function (){
if ( item . popular_count > 0 ){
return $ ( '<strong/>' )
. html ( ' TOP: ' + item . popular_count )
}
return false ;
}
)
. after (
$ ( '<a/>' )
. html ( item . post_title )
. attr ( 'href' , '/?p=' + item . ID )
. attr ( 'target' , '_blank' )
)
. after (
$ ( '<span/>' )
. html ( item . post_date + ' / ' )
)
$ ( '#featured_items_div' ) . find ( '.row' ) . eq ( 0 ) . after ( elem );
$ ( '#featured_items_div' ) . show ();
});
});
} else {
$ ( '#cover' ) . hide ();
$ ( 'input[name="remove_featured"][type="hidden"]' ) . remove ();
}
});
});
</ script >
< ? php endif ; ?>
< ? php if ( get_current_user_id () == 58 && get_current_screen () -> id == 'edit-anew' ) : ?>
< script >
setTimeout ( function (){
window . location . reload ();
}, 60000 );
</ script >
< ? php endif ; ?>
< ? php if ( user_has_role ( get_current_user_id (), 'newsline_editor' ) || user_has_role ( get_current_user_id (), 'senior_editor' )) : ?>
< script >
jQuery ( '.title.column-title' ) . each ( function (){
jQuery ( this ) . find ( 'a.row-title' ) . attr ( 'href' , '/?p=' + jQuery ( this ) . parents ( 'tr' ) . attr ( 'id' ) . replace ( 'post-' , '' ));
});
</ script >
< ? php endif ; ?>
< script >
jQuery ( '.post-state, .pending *, option, #post-status-display' ) . html (
function ( index , html ){
return html . replace ( 'Н а утверждении' , 'Консервы' );
}
);
jQuery ( 'body' ) . on ( 'click' , '.editinline' , function (){
jQuery ( '.post-state, .pending *, option, #post-status-display' ) . html (
function ( index , html ){
return html . replace ( 'Н а утверждении' , 'Консервы' );
}
);
})
< ? php if ( in_array ( get_post_type (), array ( 'anew' , 'profile_article' , 'attachment' ))) : ?>
jQuery ( 'input[name="post_type"]' ) . val ( '<?= get_post_type(); ?>' );
< ? php endif ; ?>
</ script >
< script >
var $div = jQuery ( " #publish " );
$div . click ( function (){
window . readyForPublish = 'ready' ;
});
var observer = new MutationObserver ( function ( mutations ) {
mutations . forEach ( function ( mutation ) {
if ( mutation . attributeName === " class " ) {
var attributeValue = jQuery ( mutation . target ) . prop ( mutation . attributeName );
console . log ( attributeValue );
console . log ( window . prevPubState );
if ( attributeValue . indexOf ( 'disabled' ) >= 0 ){
window . prevPubState = 'disabled' ;
}
if ( window . prevPubState == 'disabled' && attributeValue == 'button button-primary button-large red' && window . readyForPublish == 'ready' ){
//jQuery('form#post').submit();
//jQuery("#publish").click();
//jQuery('#publish').trigger('click');
document . getElementById ( 'publish' ) . click ();
//jQuery("#publish").click();
}
}
});
});
observer . observe ( $div [ 0 ], {
attributes : true
});
$div . addClass ( 'red' );
</ script >
< script >
/** только одна рубрика во вкладках В С Е и ЧАСТО ИСПОЛЬЗУЕМЫЕ */
jQuery ( document ) . ready ( function ( $ ) {
function getCategoryIdFromCheckbox ( checkbox ) {
const $checkbox = $ ( checkbox );
if ( $checkbox . attr ( 'name' ) === 'post_category[]' ) {
// Вкладка "В с е "
return parseInt ( $checkbox . val (), 10 );
} else {
// Вкладка "Часто используемые"
const idMatch = $checkbox . attr ( 'id' ) . match ( / in - popular - category - ( \d + ) / );
return idMatch ? parseInt ( idMatch [ 1 ], 10 ) : null ;
}
}
function selectCategoryById ( catId ) {
// Сбросить все
$ ( '#categorychecklist input[name="post_category[]"]' ) . prop ( 'checked' , false );
$ ( '#categorychecklist-pop input[id^="in-popular-category-"]' ) . prop ( 'checked' , false );
// Установить соответствующие
$ ( '#categorychecklist input[name="post_category[]"][value="' + catId + '"]' ) . prop ( 'checked' , true );
$ ( '#categorychecklist-pop input[id="in-popular-category-' + catId + '"]' ) . prop ( 'checked' , true );
}
$ ( document ) . on ( 'change' , '#categorychecklist input[name="post_category[]"], #categorychecklist-pop input[id^="in-popular-category-"]' , function () {
if ( $ ( this ) . is ( ':checked' )) {
const catId = getCategoryIdFromCheckbox ( this );
if ( catId !== null ) {
selectCategoryById ( catId );
}
}
});
});
</ script >
< script >
document . addEventListener ( 'DOMContentLoaded' , function () {
const interval = setInterval ( function () {
const popTab = document . querySelector ( '#category-tabs a[href="#category-pop"]' );
const allTab = document . querySelector ( '#category-tabs a[href="#category-all"]' );
const popPanel = document . getElementById ( 'category-pop' );
if ( popTab && allTab && popPanel ) {
const checked = popPanel . querySelectorAll ( 'input[type="checkbox"]:checked' );
if ( checked . length === 0 ) {
allTab . click (); // Переключаемся на "В с е рубрики"
}
clearInterval ( interval ); // Останавливаем цикл
}
}, 100 );
});
</ script >