add actual version
This commit is contained in:
@@ -49,37 +49,9 @@ if ( in_array( 'corrector', (array) $user->roles ) && !in_array(get_post_status(
|
||||
|
||||
|
||||
<?php //if (!current_user_can('create_tag')): //Запрет создания тегов?>
|
||||
<?php if (!in_array(get_current_user_id(), array(1,3))): //Запрет создания тегов?>
|
||||
<script>
|
||||
(function ($) {
|
||||
setTimeout(function(){
|
||||
var b = $("div.ajaxtag");
|
||||
$(".tagadd", b).off('click');
|
||||
$("input.newtag").off('keypress');
|
||||
$("input.newtag").unbind('keypress').off('keypress').on('keypress', function(e){
|
||||
if (e.which == 13) {
|
||||
window.tagBox.userAction = "";
|
||||
return false;
|
||||
}
|
||||
});
|
||||
$("input.newtag").keypress(function(e){
|
||||
if (e.which == 13){
|
||||
window.tagBox.userAction = "";
|
||||
return false;
|
||||
}
|
||||
})
|
||||
<?php //if (!in_array(get_current_user_id(), array(1,3))): //Запрет создания тегов?>
|
||||
|
||||
$('.wp-tags-autocomplete').on('click', 'li', function(){
|
||||
|
||||
let container = jQuery('*[aria-owns='+$(this).parent().attr('id')+']').parents('.postbox');
|
||||
|
||||
window.tagBox.userAction = "add", window.tagBox.flushTags(container.find('.tagsdiv'))
|
||||
});
|
||||
},2000);
|
||||
|
||||
})(jQuery);
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
<?php // endif; ?>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
@@ -13,7 +13,14 @@
|
||||
<?php else : ?>
|
||||
|
||||
<?php get_template_part( "template-parts/archive/grid" ) ?>
|
||||
|
||||
<?php
|
||||
// Выводим ajax-load-more только если элементов 20 или больше
|
||||
global $wp_query;
|
||||
if ( $wp_query->found_posts >= 20 ) :
|
||||
?>
|
||||
<?php get_template_part( "template-parts/archive/ajax-load-more" ) ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
@@ -56,6 +56,20 @@ function clear_template_cache ( $template ) {
|
||||
}
|
||||
|
||||
|
||||
// Функция очистки главной страницы
|
||||
function clear_index_cache () {
|
||||
|
||||
$index_file = '/var/www/profile/html/wp-content/uploads/fpcache/regenerate/index.html';
|
||||
|
||||
if (file_exists($index_file)) {
|
||||
return unlink($index_file);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Общая функция для сброса кеша на основе условий поста
|
||||
*
|
||||
@@ -63,6 +77,11 @@ function clear_template_cache ( $template ) {
|
||||
*/
|
||||
function clear_post_cache_based_on_conditions( $post_id, $post ) {
|
||||
|
||||
$fpc_signal = WP_CONTENT_DIR . '/uploads/fpcache/.last_modified';
|
||||
|
||||
// Обновляем сигнальный файл если вдруг прервется выполнение
|
||||
touch($fpc_signal);
|
||||
|
||||
// Кеш по типу поста
|
||||
if ($post->post_type == 'profile_article') {
|
||||
clear_template_cache('template-parts/home/main-item');
|
||||
@@ -78,6 +97,7 @@ function clear_post_cache_based_on_conditions( $post_id, $post ) {
|
||||
if ($main_item === 'true' || $main_item === '1') {
|
||||
clear_template_cache('template-parts/home/main-item');
|
||||
clear_template_cache('template-parts/home/list-items');
|
||||
clear_index_cache(); // на всякий случай сбросим главную
|
||||
}
|
||||
|
||||
// Сброс колонки
|
||||
@@ -85,10 +105,10 @@ function clear_post_cache_based_on_conditions( $post_id, $post ) {
|
||||
if ($colon_item === 'true' || $colon_item === '1') {
|
||||
clear_template_cache('template-parts/home/colon-item');
|
||||
clear_template_cache('template-parts/home/list-items');
|
||||
clear_index_cache(); // на всякий случай сбросим главную
|
||||
}
|
||||
|
||||
// Обновляем сигнальный файл
|
||||
$fpc_signal = WP_CONTENT_DIR . '/uploads/fpcache/.last_modified';
|
||||
// Обновляем сигнальный файл по завершению
|
||||
touch($fpc_signal);
|
||||
|
||||
}
|
||||
@@ -97,7 +117,7 @@ function clear_post_cache_based_on_conditions( $post_id, $post ) {
|
||||
add_action('save_post', function($post_id, $post, $update) {
|
||||
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
|
||||
if (wp_is_post_revision($post_id)) return;
|
||||
if (!current_user_can('edit_post', $post_id)) return;
|
||||
//if (!current_user_can('edit_post', $post_id)) return;
|
||||
if ($post->post_status !== 'publish') return;
|
||||
|
||||
clear_post_cache_based_on_conditions($post_id, $post); // Передаем только $post
|
||||
@@ -105,8 +125,8 @@ add_action('save_post', function($post_id, $post, $update) {
|
||||
|
||||
// Хук для запланированных публикаций
|
||||
add_action('transition_post_status', function($new_status, $old_status, $post) {
|
||||
if ($new_status !== 'publish') return;
|
||||
if (!current_user_can('edit_post', $post->ID)) return; // Используем $post->ID
|
||||
|
||||
if ($new_status !== 'publish') return;
|
||||
clear_post_cache_based_on_conditions($post->ID, $post); // Передаем только $post
|
||||
|
||||
}, 10, 3);
|
||||
@@ -148,7 +148,7 @@
|
||||
]
|
||||
);
|
||||
|
||||
add_theme_support( 'post-thumbnails', ['post', 'profile_article', 'anew', 'guest-author', 'yellow'] );
|
||||
add_theme_support( 'post-thumbnails', ['post', 'profile_article', 'anew', 'guest-author', 'yellow', 'journal_issue'] );
|
||||
|
||||
}
|
||||
|
||||
@@ -325,7 +325,21 @@
|
||||
$color = get_post_meta($data_object->ID, "_menu_item_color", true);
|
||||
$color = $color ? $color : "black";
|
||||
|
||||
$li_class = self::menu_classes[$args->theme_location]["li_class"] . implode(" ", $data_object->classes);
|
||||
//$li_class = self::menu_classes[$args->theme_location]["li_class"] . implode(" ", $data_object->classes);
|
||||
$li_class = self::menu_classes[$args->theme_location]["li_class"] ?? '';
|
||||
$classes_part = '';
|
||||
if (is_array($data_object->classes)) {
|
||||
$classes_part = implode(" ", $data_object->classes);
|
||||
} else {
|
||||
$classes_part = $data_object->classes ?? '';
|
||||
}
|
||||
$li_class .= ' ' . trim($classes_part);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$a_class = self::menu_classes[$args->theme_location]["a_class"];
|
||||
|
||||
$link_attr = ! empty( $data_object->attr_title ) ? ' title="' . esc_attr( $data_object->attr_title ) .'"' : '';
|
||||
@@ -1289,7 +1303,8 @@
|
||||
/**
|
||||
* Сжатие html
|
||||
*/
|
||||
require_once 'inc/compress-html.php';
|
||||
require_once get_theme_file_path('/inc/compress-html.php');
|
||||
//require_once 'inc/compress-html.php';
|
||||
//require_once __DIR__ . "/inc/compress-html.php";
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
error_reporting(E_ERROR);
|
||||
//ini_set('display_errors', 0);
|
||||
//error_reporting(E_ALL);
|
||||
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
|
||||
@@ -8,7 +8,30 @@ require get_theme_file_path('clear-functions.php');
|
||||
require "dirty-functions.php";
|
||||
require "garbage-functions.php";
|
||||
require "block-cache-manager.php"; //кешируем долгоживущие блоки
|
||||
require "inc/cache-cleaner-home.php";
|
||||
require 'inc/article-rss-feed.php'; //rss ленты статей по датам
|
||||
require "inc/meta_keywords.php";
|
||||
require "inc/journal_issue.php"; //номера журналов
|
||||
require "inc/rank-description.php";
|
||||
|
||||
//scheduler
|
||||
require "inc/schedule_async_post_processing.php";
|
||||
if ( defined( 'WP_CLI' ) && WP_CLI ) {
|
||||
require "inc/action-scheduler-functions.php";
|
||||
require "inc/wp-cli-scheduler-commands.php";
|
||||
require "inc/adfox_on.php"; // управление adfox
|
||||
}
|
||||
|
||||
include "inc/get_cached_alm.php";
|
||||
include "inc/graphql.php";
|
||||
|
||||
if (is_admin()) {
|
||||
require "inc/add_adv_checked.php"; // рекламная статья
|
||||
require "inc/admin/auto_check.php"; // помечакм не отправлять в Дзен
|
||||
require "inc/admin/lock-terms.php"; // banned и keys
|
||||
}
|
||||
|
||||
|
||||
|
||||
//TODO: Убрать все эти is_yn, is_zen и прочее и внутри плагинов регулировать вывод
|
||||
//TODO: Убрать все posts_where, переписать в pre_get_posts
|
||||
@@ -1035,9 +1058,13 @@ add_action('wp_enqueue_scripts', function() {
|
||||
);
|
||||
|
||||
// Добавляем стиль
|
||||
|
||||
$css_url = get_template_directory_uri() . '/assets/css/profile-style.css';
|
||||
//$css_url = 'https://profile.ru//wp-content/themes/profile/assets/css/profile-style.css';
|
||||
|
||||
wp_enqueue_style(
|
||||
'profile-style', // уникальный идентификатор
|
||||
get_template_directory_uri() . '/assets/css/profile-style.css', // путь к файлу
|
||||
$css_url, // путь к файлу
|
||||
array(), // зависимости
|
||||
filemtime(get_template_directory() . '/assets/css/profile-style.css') // версия
|
||||
);
|
||||
@@ -1076,11 +1103,18 @@ function hide_revisions_style() {
|
||||
|
||||
add_action('admin_footer', 'check_content_layout');
|
||||
function check_content_layout() {
|
||||
if(get_current_user_id() == 1){return;}
|
||||
if (get_current_user_id() == 53) {
|
||||
|
||||
//if(get_current_user_id() == 1 or ){return;}
|
||||
|
||||
$user = wp_get_current_user();
|
||||
if (in_array('administrator', $user->roles)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//if (get_current_user_id() == 53) {
|
||||
//echo '<script>console.log("т-c-c-c;")</script>';
|
||||
//return;
|
||||
}
|
||||
//}
|
||||
echo <<<EOL
|
||||
<script>
|
||||
document.forms.post.onsubmit = function(e) {
|
||||
@@ -3041,6 +3075,7 @@ function send_telegram($post) {
|
||||
$curr_url = fix_broken_url($curr_url, 'profile.ru'); //корректируем ссылку с ошиюбками
|
||||
|
||||
|
||||
|
||||
if(has_tag(103565, $post_id)){
|
||||
$chat_id = "-1001241573514";//идентификатор канала profile_lifestyle
|
||||
|
||||
@@ -4802,15 +4837,17 @@ function customize_my_wp_admin_bar( $wp_admin_bar ) {
|
||||
|
||||
|
||||
|
||||
add_filter( 'pre_insert_term', 'deny_term_creation', 10, 2 );
|
||||
// add_filter( 'pre_insert_term', 'deny_term_creation', 10, 2 );
|
||||
function deny_term_creation( $term, $taxonomy ) {
|
||||
// Таксономия будет 'post_tag'
|
||||
if ( $taxonomy === 'post_tag' ) {
|
||||
if ( !user_has_role(get_current_user_id(),'administrator') && !user_has_role(get_current_user_id(),'chief_editor') ) {
|
||||
//if(!in_array(get_current_user_id(), array(1,3)) && in_array($taxonomy, array('post_tag', 'banned'))){
|
||||
return new WP_Error( 'error', 'НЕЛЬЗЯ СОЗДАВАТЬ МЕТКИ!' );
|
||||
}
|
||||
}
|
||||
return $term;
|
||||
}
|
||||
|
||||
add_filter( 'pre_insert_term', 'deny_term_creation', 10, 2 );
|
||||
|
||||
|
||||
|
||||
@@ -6071,13 +6108,6 @@ add_filter( 'http_request_args',
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
138
inc/cache-cleaner-home.php
Normal file
138
inc/cache-cleaner-home.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
// Добавляем пункт меню в админ-панель
|
||||
add_action('admin_menu', 'register_cache_cleaner_menu');
|
||||
|
||||
function register_cache_cleaner_menu() {
|
||||
add_menu_page(
|
||||
'Очистка кэша главной', // Заголовок страницы
|
||||
'Очистка кэша', // Название в меню
|
||||
'edit_posts', // Права доступа
|
||||
'cache-cleaner', // Ярлык меню
|
||||
'cache_cleaner_page', // Функция отображения
|
||||
'dashicons-trash', // Иконка
|
||||
100 // Позиция в меню
|
||||
);
|
||||
}
|
||||
|
||||
// Функция отображения страницы
|
||||
function cache_cleaner_page() {
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1>Очистка кэша главной страницы</h1>
|
||||
|
||||
<?php
|
||||
// Обрабатываем запрос на очистку кэша
|
||||
if (isset($_POST['clear_cache'])) {
|
||||
$result = clear_and_regenerate_cache();
|
||||
|
||||
if ($result['success']) {
|
||||
echo '<div class="notice notice-success is-dismissible">';
|
||||
echo '<p><strong>Кэш очищен и файлы пересозданы!</strong></p>';
|
||||
|
||||
if (!empty($result['cleared_files'])) {
|
||||
echo '<p>Удалены следующие файлы:</p>';
|
||||
echo '<ul>';
|
||||
foreach ($result['cleared_files'] as $file) {
|
||||
echo '<li>' . esc_html($file) . '</li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
|
||||
if (!empty($result['created_files'])) {
|
||||
echo '<p>Созданы следующие файлы:</p>';
|
||||
echo '<ul>';
|
||||
foreach ($result['created_files'] as $file) {
|
||||
echo '<li>' . esc_html($file) . '</li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo '<div class="notice notice-error is-dismissible">';
|
||||
echo '<p><strong>Ошибка:</strong> ' . esc_html($result['message']) . '</p>';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<form method="post">
|
||||
<p>Нажмите кнопку ниже для очистки кэша главной страницы и пересоздания файлов:</p>
|
||||
<?php submit_button('Очистить кэш и пересоздать файлы', 'primary', 'clear_cache'); ?>
|
||||
</form>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
// Функция очистки кэш-файлов и создания новых
|
||||
function clear_and_regenerate_cache() {
|
||||
$result = [
|
||||
'success' => true,
|
||||
'message' => '',
|
||||
'cleared_files' => [],
|
||||
'created_files' => []
|
||||
];
|
||||
|
||||
try {
|
||||
// Определяем пути к директориям
|
||||
$fpcache_dir = trailingslashit(wp_upload_dir()['basedir']) . 'fpcache/';
|
||||
$block_cache = trailingslashit(wp_upload_dir()['basedir']) . 'cached_template/';
|
||||
|
||||
// Массив файлов для очистки
|
||||
$cache_files = [
|
||||
$block_cache . 'template-parts/home/colon-item.html',
|
||||
$block_cache . 'template-parts/home/list-items.html',
|
||||
$block_cache . 'template-parts/home/main-item.html',
|
||||
$block_cache . 'template-parts/home/news.html',
|
||||
$fpcache_dir . 'regenerate/index.html'
|
||||
];
|
||||
|
||||
// Очищаем файлы кэша
|
||||
foreach ($cache_files as $file) {
|
||||
if (is_file($file) && unlink($file)) {
|
||||
$result['cleared_files'][] = $file;
|
||||
} elseif (is_file($file)) {
|
||||
$result['cleared_files'][] = $file . ' (не удалось удалить)';
|
||||
}
|
||||
}
|
||||
|
||||
// Создаем файлы last_modified с префиксами
|
||||
$prefixes = ['profile_article', 'anew', 'yellow'];
|
||||
$last_modified_dir = $fpcache_dir;
|
||||
|
||||
// Создаем директорию если она не существует
|
||||
if (!file_exists($last_modified_dir)) {
|
||||
wp_mkdir_p($last_modified_dir);
|
||||
}
|
||||
|
||||
// Создаем файлы для каждого префикса
|
||||
$create_files = [
|
||||
$last_modified_dir.'.last_modified',
|
||||
$last_modified_dir.'.last_modified_profile_article',
|
||||
$last_modified_dir.'.last_modified_anew',
|
||||
$last_modified_dir.'.last_modified_yellow'
|
||||
];
|
||||
|
||||
foreach ($create_files as $create_file) {
|
||||
|
||||
$res = touch($create_file);
|
||||
|
||||
if (!$res){
|
||||
$result['created_files'][] = $create_file . ' (не удалось создать)';
|
||||
} else {
|
||||
$result['created_files'][] = $create_file;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$result['message'] = 'Операция завершена успешно';
|
||||
|
||||
} catch (Exception $e) {
|
||||
$result['success'] = false;
|
||||
$result['message'] = $e->getMessage();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
?>
|
||||
14
inc/errors.php
Normal file
14
inc/errors.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
|
||||
// Для всех ошибок включая фатальные
|
||||
error_reporting(E_ALL);
|
||||
|
||||
// Или более конкретно:
|
||||
//error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR);
|
||||
|
||||
// Включение отображения ошибок
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
// Включение отображения ошибок запуска PHP
|
||||
ini_set('display_startup_errors', 1);
|
||||
@@ -1,5 +1,5 @@
|
||||
<!--[search]-->
|
||||
|
||||
<?php get_template_part("template-parts/search/search") ?>
|
||||
<?php get_template_part("template-parts/search/opensearch") ?>
|
||||
|
||||
<!--[/search]-->
|
||||
|
||||
@@ -32,6 +32,11 @@
|
||||
$terms
|
||||
);
|
||||
|
||||
|
||||
$posts_count = $wp_query->post_count;
|
||||
|
||||
if ( $posts_count > 10 ){
|
||||
|
||||
$index_alm_shortcode = '
|
||||
[ajax_load_more
|
||||
cache="true"
|
||||
@@ -52,6 +57,8 @@
|
||||
|
||||
echo do_shortcode( $index_alm_shortcode );
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!--[/archive/ajax-load-more/author]-->
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
<?php get_template_part("template-parts/header/uparrow") ?>
|
||||
|
||||
<?php get_template_part("template-parts/cell-promo") ?>
|
||||
<?php //get_template_part("template-parts/cell-promo") ?>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
<?php if ( is_single() ) :?>
|
||||
<?php if ( is_single() or is_author() ) :?>
|
||||
<div class="header__title header__title--black font-weight-bold m-0 ml-5">
|
||||
<?php get_template_part("template-parts/header/category-name") ?>
|
||||
</div>
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
<!--[search/search-list-item]-->
|
||||
|
||||
<div class="newslist__item"
|
||||
itemscope
|
||||
<?php if( get_post_type() == "profile_article"): ?>
|
||||
itemtype="https://schema.org/Article"
|
||||
<?php else: ?>
|
||||
itemtype="https://schema.org/NewsArticle"
|
||||
<?php endif; ?>
|
||||
>
|
||||
|
||||
<?php get_template_part("template-parts/micro/post"); ?>
|
||||
<div class="newslist__item">
|
||||
|
||||
<div class="d-flex">
|
||||
|
||||
|
||||
Reference in New Issue
Block a user