diff --git a/admin-footer.php b/admin-footer.php index 11ee4cf..4fb67a5 100644 --- a/admin-footer.php +++ b/admin-footer.php @@ -49,37 +49,9 @@ if ( in_array( 'corrector', (array) $user->roles ) && !in_array(get_post_status( - - - + '; //return; - } + //} echo << 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 ) { - 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', 'НЕЛЬЗЯ СОЗДАВАТЬ МЕТКИ!' ); + // Таксономия будет 'post_tag' + if ( $taxonomy === 'post_tag' ) { + if ( !user_has_role(get_current_user_id(),'administrator') && !user_has_role(get_current_user_id(),'chief_editor') ) { + 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', - - - - - - - diff --git a/inc/cache-cleaner-home.php b/inc/cache-cleaner-home.php new file mode 100644 index 0000000..b8d57ec --- /dev/null +++ b/inc/cache-cleaner-home.php @@ -0,0 +1,138 @@ + +
+

Очистка кэша главной страницы

+ + '; + echo '

Кэш очищен и файлы пересозданы!

'; + + if (!empty($result['cleared_files'])) { + echo '

Удалены следующие файлы:

'; + echo ''; + } + + if (!empty($result['created_files'])) { + echo '

Созданы следующие файлы:

'; + echo ''; + } + + echo '
'; + } else { + echo '
'; + echo '

Ошибка: ' . esc_html($result['message']) . '

'; + echo '
'; + } + } + ?> + +
+

Нажмите кнопку ниже для очистки кэша главной страницы и пересоздания файлов:

+ +
+ + 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; +} +?> \ No newline at end of file diff --git a/inc/errors.php b/inc/errors.php new file mode 100644 index 0000000..936e605 --- /dev/null +++ b/inc/errors.php @@ -0,0 +1,14 @@ + - + diff --git a/template-parts/archive/ajax-load-more/author.php b/template-parts/archive/ajax-load-more/author.php index 4ecca67..71a24b1 100644 --- a/template-parts/archive/ajax-load-more/author.php +++ b/template-parts/archive/ajax-load-more/author.php @@ -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 ); +} + ?> \ No newline at end of file diff --git a/template-parts/header/header.php b/template-parts/header/header.php index 923e20b..c358545 100644 --- a/template-parts/header/header.php +++ b/template-parts/header/header.php @@ -23,7 +23,7 @@ - + diff --git a/template-parts/home/index.php b/template-parts/home/index.php index a1b855f..614ed43 100644 --- a/template-parts/home/index.php +++ b/template-parts/home/index.php @@ -7,11 +7,11 @@
diff --git a/template-parts/nav/header-nav.php b/template-parts/nav/header-nav.php index 2d9a2a8..55d4596 100644 --- a/template-parts/nav/header-nav.php +++ b/template-parts/nav/header-nav.php @@ -48,7 +48,7 @@ - +
diff --git a/template-parts/search/search-list-item.php b/template-parts/search/search-list-item.php index 1d42325..f634ee0 100644 --- a/template-parts/search/search-list-item.php +++ b/template-parts/search/search-list-item.php @@ -1,15 +1,6 @@ -
- itemtype="https://schema.org/Article" - - itemtype="https://schema.org/NewsArticle" - -> - - +