Compare commits

...

2 Commits

Author SHA1 Message Date
Profile Profile
ddf44fbfad add graphql types 2026-01-25 21:14:24 +03:00
Profile Profile
9ed823e0af add support menu color in graphql 2026-01-25 01:02:17 +03:00
3 changed files with 19 additions and 11 deletions

View File

@@ -9,17 +9,23 @@
* @param int $expire Время жизни кеша в секундах
* @return void
*/
function cached_get_template_part( $template, $name = null, $data = [] ) {
function cached_get_template_part( $template, $name = null, $data = [], $ttl = 3600 ) {
$fcache = CACHED_TEMPLATE.$template.'.html';
// Проверяем существование файла и его время жизни
if ( file_exists($fcache) ){
echo file_get_contents($fcache);
return true;
$cache_time = filemtime($fcache);
$current_time = time();
// Если кеш не истек, отдаем его
if ( ($current_time - $cache_time) < $ttl ) {
echo file_get_contents($fcache);
return true;
}
}
$file_directory = dirname($fcache);
ob_start();
get_template_part($template, $name, $data );
@@ -27,7 +33,6 @@ function cached_get_template_part( $template, $name = null, $data = [] ) {
echo $content;
if (!file_exists($file_directory)) {
if (!wp_mkdir_p($file_directory)) {
error_log('Не удалось создать директорию: ' . $file_directory);
@@ -41,9 +46,9 @@ function cached_get_template_part( $template, $name = null, $data = [] ) {
}
return true;
}
// Функция очистки кеша
function clear_template_cache ( $template ) {

View File

@@ -14,6 +14,9 @@ require "inc/meta_keywords.php";
require "inc/journal_issue.php"; //номера журналов
require "inc/rank-description.php";
//utils
require "utils/acf-category.php";
//scheduler
require "inc/schedule_async_post_processing.php";
if ( defined( 'WP_CLI' ) && WP_CLI ) {

View File

@@ -2,16 +2,16 @@
<?php //get_template_part("template-parts/home/news");
cached_get_template_part( 'template-parts/home/news' );?>
cached_get_template_part( 'template-parts/home/news' );?>
<div class="col-12 col-md-8 col-xl-6 float-left">
<?php //get_template_part("template-parts/home/main-item");
cached_get_template_part( 'template-parts/home/main-item' );
<?php get_template_part("template-parts/home/main-item");
//cached_get_template_part( 'template-parts/home/main-item' );
?>
<?php //get_template_part("template-parts/home/colon-item");
cached_get_template_part( 'template-parts/home/colon-item' );
<?php get_template_part("template-parts/home/colon-item");
//cached_get_template_part( 'template-parts/home/colon-item' );
?>
</div>