add cache blocks

This commit is contained in:
arlemp@selectel.ru
2021-11-03 00:08:16 +03:00
parent 2d174073fd
commit dfcd1458ab
8 changed files with 121 additions and 48 deletions

37
blocks/header.php Normal file
View File

@@ -0,0 +1,37 @@
<header>
<div id="mainlogo">
<a href="<?php echo home_url(); ?>"><img width="240" src = "<?=get_stylesheet_directory_uri()?>/pub/logo/vij_logo.svg" alt = "Ветеринария и жизнь. Газета и сайт" /></a>
</div>
<div id="mainmenu">
<?php
wp_nav_menu( array(
'menu_class'=>'menu_main',
'theme_location'=>'top'
) );?>
</div>
<div id="header-contact">
<div id="head_tel"><a href="tel:79250634">+7 (495) 925 06 34</a></div>
<div id="head_mail"><a href="mailto:info@vetandlife.ru">info@vetandlife.ru</a></div>
</div>
<ul id="header_icons">
<a href="<?=get_site_url()?>?s="><li class="btn_search"></li></a>
<a href="<?=get_site_url()?>/feed"><li class="btn_rss"></li></a>
<li class="toggle-nav"></li>
</ul>
<nav class="menu main">
<?php wp_nav_menu( array(
'container_class' => 'main_main',
'theme_location' => 'top',
'menu_id' => 'gamburer_menu'
) ); ?>
</nav>
</header>

4
blocks/leftmenu.php Normal file
View File

@@ -0,0 +1,4 @@
<?php wp_nav_menu( array(
'menu_class'=>'menu_left',
'theme_location'=>'left'
));?>

View File

@@ -5,21 +5,15 @@
?>
<div id="left">
<?php include VIJ_CACHE.'leftmenu.html';?>
<?php wp_nav_menu( array(
'menu_class'=>'menu_left',
'theme_location'=>'left'
));?>
<?php get_template_part( '/blocks/opinion', null, ['subclass' => '']);?>
<?php // get_template_part( '/blocks/opinion', null, ['subclass' => '']);?>
<?php include VIJ_CACHE.'opinion.html';?>
<?php //get_template_part( '/blocks/citata', null, ['subclass' => '']);?>
<?php get_template_part( '/blocks/events');?>
<?php //include VIJ_CACHE.'events.html';?>
<div class="right-info">
<a href="https://vetandlife.ru/vetspetsialist-sportsmenka-i-prosto-kras/">
@@ -57,7 +51,8 @@
<div class="soc_btn soc_instagram"></div> -->
</div>
<?php include get_template_directory().'/blocks/archive.php';?>
<?php //include get_template_directory().'/blocks/archive.php';?>
<?php include VIJ_CACHE.'archive.html'?>
<div id="subscript_box">
<div id="convert"></div>
@@ -90,8 +85,10 @@
</div>
<?php get_template_part( '/blocks/zakons');?>
<?php //include VIJ_CACHE.'zakons.html';?>
<?get_template_part( '/blocks/mosts', null, ['subclass' => '']);?>
<?//get_template_part( '/blocks/mosts', null, ['subclass' => '']);?>
<?php include VIJ_CACHE.'mosts.html';?>
</div>
</div><!-- end main -->
<footer>

View File

@@ -3,6 +3,9 @@
define('IMGURL', 'http://img.vetandlife.ru/');
define("COOK_GOLOS", "_ya_id_76543_w");
define("COOK_VALUE", "7895");
define('VIJ_CACHE', ABSPATH.'wp-content/themes/vij/cache/');
define('BASE_VIJ', ABSPATH.'wp-content/themes/vij/');
require get_template_directory().'/src/calend-block.php';
require get_template_directory().'/src/calendar.php';

View File

@@ -29,43 +29,8 @@
&noscript=1"/>
</noscript>
<!-- End Facebook Pixel Code -->
<header>
<div id="mainlogo">
<a href="<?php echo home_url(); ?>"><img width="240" src = "<?=get_stylesheet_directory_uri()?>/pub/logo/vij_logo.svg" alt = "Ветеринария и жизнь. Газета и сайт" /></a>
</div>
<div id="mainmenu">
<?php
wp_nav_menu( array(
'menu_class'=>'menu_main',
'theme_location'=>'top'
) );?>
</div>
<div id="header-contact">
<div id="head_tel"><a href="tel:79250634">+7 (495) 925 06 34</a></div>
<div id="head_mail"><a href="mailto:info@vetandlife.ru">info@vetandlife.ru</a></div>
</div>
<ul id="header_icons">
<a href="<?=get_site_url()?>?s="><li class="btn_search"></li></a>
<a href="<?=get_site_url()?>/feed"><li class="btn_rss"></li></a>
<li class="toggle-nav"></li>
</ul>
<nav class="menu main">
<?php wp_nav_menu( array(
'container_class' => 'main_main',
'theme_location' => 'top',
'menu_id' => 'gamburer_menu'
) ); ?>
</nav>
</header>
<?php include VIJ_CACHE.'header.html'?>
<?php $subclass = ''; ?>

25
src/blocks_min.php Normal file
View File

@@ -0,0 +1,25 @@
<?php
ini_set('display_errors', '1');
require '/thosts/vij/wp/wp-load.php';
require 'createblock.php';
echo "block events\n";
echo create_block('events');
echo "block events\n";
echo create_block('archive');
echo "block zakons\n";
echo create_block('zakons');
echo "block opinion\n";
echo create_block('opinion');
echo "block mosts\n";
echo create_block('mosts');

16
src/cacheblock.php Normal file
View File

@@ -0,0 +1,16 @@
<?php
//ini_set('display_errors', '1');
require '/thosts/vij/wp/wp-load.php';
require 'createblock.php';
if (!isset($_GET['block'])){
exit;
}
create_block($_GET['block']);

26
src/createblock.php Normal file
View File

@@ -0,0 +1,26 @@
<?php
function create_block($block){
$blockfile = BASE_VIJ.'blocks/'.$blockpath.$block.'.php';
if (!file_exists($blockfile))
return false;
$cachefile = VIJ_CACHE.$block.'.html';
ob_start();
include $blockfile;
$html = ob_get_contents();
ob_end_clean();
return file_put_contents($cachefile, $html);
}