add calendar events
This commit is contained in:
@@ -23,7 +23,7 @@ if( $posts ):
|
||||
<div class="right_archive">
|
||||
<a href="<?php the_permalink(); ?>"><img width="280" class="right_archive_img" src="<?php echo get_the_post_thumbnail_url($post, 'fil');?>" alt="<?the_title();?>"></a>
|
||||
<div class="right_archive_text"><a href="<?php the_permalink(); ?>">Читать газету<br>«Ветеринария и Жизнь»</a></div>
|
||||
<div class="right_archive_link"><a href="<?php the_permalink(); ?>">cвежий номер</a></div>
|
||||
<div class="right_archive_link"><a href="<?php the_permalink(); ?>"><?=the_title();?></a></div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php echo calend_block(date('m'), date('Y'), true);
|
||||
|
||||
# три последних эвента
|
||||
|
||||
@@ -6,12 +6,16 @@ $posts = get_posts( array(
|
||||
'numberposts' => 3,
|
||||
'category' => 61, // 61 - мероприятия
|
||||
'orderby' => 'date',
|
||||
'order' => 'DESC',
|
||||
'include' => array(),
|
||||
'exclude' => array(),
|
||||
'meta_key' => '',
|
||||
'meta_value' =>'',
|
||||
'order' => 'ASC',
|
||||
|
||||
'date_query' => array(
|
||||
array(
|
||||
'after' => '3 days ago',
|
||||
),
|
||||
),
|
||||
|
||||
'post_type' => 'post',
|
||||
'post_status' => 'publish, future',
|
||||
'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
|
||||
) );
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
$mosts = get_posts( array(
|
||||
'numberposts' => 3,
|
||||
'category' => 2, // пока без категории
|
||||
'post__in' => get_option( 'sticky_posts' ),
|
||||
'orderby' => 'date',
|
||||
'order' => 'DESC',
|
||||
'include' => array(),
|
||||
|
||||
89
category-votes.php
Normal file
89
category-votes.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* The main template file.
|
||||
*
|
||||
*/
|
||||
|
||||
get_header();
|
||||
$nn = 0;
|
||||
$ids = [];
|
||||
|
||||
$votes_file = '/vhosts/beta/wp-content/themes/vij/golos.json';
|
||||
|
||||
if (file_exists($votes_file)){
|
||||
$votes = json_decode(file_get_contents($votes_file, true));
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<div id="content">
|
||||
|
||||
<ul id="nav_content">
|
||||
<li><a href="http://beta.vetandlife.ru">Главная</li>
|
||||
<li> - <?single_cat_title()?></li>
|
||||
</ul>
|
||||
|
||||
<h1 class="my-4"><?=single_cat_title()?></h1>
|
||||
|
||||
<?php if(have_posts()) :?>
|
||||
<div class="search-card-box">
|
||||
|
||||
<?php while(have_posts()) : the_post();?>
|
||||
<?$curr_id = get_the_id()?>
|
||||
|
||||
<div class="search-card">
|
||||
|
||||
<!--<div class="search-card-title"><a href="<?the_permalink();?>"><?the_title();?></a></div>-->
|
||||
<?if ( has_post_thumbnail() ) :?>
|
||||
<a href="<?the_permalink();?>">
|
||||
<img class="search-card-img" src="<?php echo get_the_post_thumbnail_url(null, 'full'); ?>" width="180" alt="<?the_title();?>">
|
||||
</a>
|
||||
<?endif?>
|
||||
<div><a href="<?the_permalink();?>"><strong><?the_title();?></strong></a></div>
|
||||
|
||||
<?if (!isset($_COOKIE[COOK_GOLOS])):?>
|
||||
|
||||
<div id="golos-<?=get_the_id()?>">
|
||||
<br><button style="padding: 8px; cursor: pointer;" id="golos" onclick="javascript:add_golos(<?=get_the_id();?>, 'golos-<?=get_the_id()?>');">Проголосовать</button>
|
||||
</div>
|
||||
|
||||
<?endif?>
|
||||
|
||||
<?if (isset($_COOKIE["vec_$curr_id"])):?>
|
||||
<p>Спасибо за Ваш голос</p>
|
||||
<?endif?>
|
||||
|
||||
|
||||
<div id="count-<?=$ID?>" style="margin-top: 12px;">
|
||||
<i class="far fa-thumbs-up"></i> <?=$votes->$curr_id?>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mini-card-body">
|
||||
<div class="news_date"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<?php endwhile;?>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<?get_template_part( '/blocks/paginator');?>
|
||||
|
||||
|
||||
<?else:?>
|
||||
|
||||
Здесь пока нет публикаций
|
||||
|
||||
<?php endif;?>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<?php get_footer(); ?>
|
||||
@@ -14,7 +14,7 @@ $nn = 0;?>
|
||||
|
||||
|
||||
<ul id="nav_content">
|
||||
<li><a href="http://beta.vetandlife.ru">Главная</li>
|
||||
<li><a href="<?=get_home_url()?>">Главная</li>
|
||||
<li> - <?single_cat_title()?></li>
|
||||
</ul>
|
||||
|
||||
|
||||
28
footer.php
28
footer.php
@@ -21,6 +21,20 @@
|
||||
<?php //get_template_part( '/blocks/citata', null, ['subclass' => '']);?>
|
||||
<?php get_template_part( '/blocks/events');?>
|
||||
|
||||
<div class="right-info">
|
||||
<a href="https://vetandlife.ru/vetspetsialist-sportsmenka-i-prosto-kras/">
|
||||
<img src="https://vetandlife.ru/wp-content/uploads/2021/10/konkurs_240x200.jpg" width="240" height="200" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="right-info">
|
||||
<a href="https://www.youtube.com/channel/UCOXOjXmMNl8eVO4ldrv5c5Q" target="_blank">
|
||||
<img src="https://vetandlife.ru/wp-content/uploads/2021/10/melano-live.png" width="240" height="200" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
@@ -59,11 +73,21 @@
|
||||
</div>
|
||||
|
||||
<div class="right-info">
|
||||
<a href="https://vetandlife.ru/consumer/proizvoditelej-i-retejl-ulichili-v-prodazhe-nebezopasnyh-i-falsificirovannyh-konservov/?utm_medium=banner&utm_campaign=mainpage&utm_source=site">
|
||||
<img src="https://vetandlife.ru/wp-content/uploads/2021/10/chestno-240x400-1.jpg" width="240" height="400" />
|
||||
<a href="https://vetandlife.ru/category/sdelano-chestno/?utm_medium=banner&utm_campaign=mainpage&utm_source=site">
|
||||
<img src="https://vetandlife.ru/wp-content/uploads/2021/10/chestno-240x400-1.jpg" width="240" height="400" alt="Сделано честно"/>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="right-info">
|
||||
<a href="https://vetandlife.ru/parthers/fgbu-vgnki-okazyvaet-uslugi-po-issledova/">
|
||||
<img src="https://vetandlife.ru/wp-content/uploads/2021/10/vgnki_240x400.jpg" width="240" height="400" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="right-info">
|
||||
<a href="https://women.agrotrend.ru" terget='_blank"'>
|
||||
<img src="https://vetandlife.ru/wp-content/uploads/2021/10/women-argo.jpg" width="240" height="400" />
|
||||
</a>
|
||||
</div>
|
||||
<?get_template_part( '/blocks/mosts', null, ['subclass' => '']);?>
|
||||
</div>
|
||||
</div><!-- end main -->
|
||||
|
||||
134
functions.php
134
functions.php
@@ -1,6 +1,11 @@
|
||||
<?php
|
||||
|
||||
define('IMGURL', 'http://img.vetandlife.ru/');
|
||||
define("COOK_GOLOS", "_ya_id_76543_w");
|
||||
define("COOK_VALUE", "7895");
|
||||
|
||||
require get_template_directory().'/src/calend-block.php';
|
||||
require get_template_directory().'/src/calendar.php';
|
||||
|
||||
# регистрируем меню
|
||||
register_nav_menus(array(
|
||||
@@ -83,29 +88,35 @@ function _U2RFC822($date) {
|
||||
}
|
||||
|
||||
|
||||
add_action( 'save_post', 'prefix_save_post' );
|
||||
|
||||
function prefix_save_post( $post_id ){
|
||||
/**
|
||||
* плагин перевода в латиницу
|
||||
*/
|
||||
|
||||
if ($post_id < 15765)
|
||||
return; // старье не трогаем
|
||||
add_action( 'save_post', 'lat_slug' );
|
||||
|
||||
if ( wp_is_post_revision( $post_id ))
|
||||
return;
|
||||
function lat_slug( $post_id ){
|
||||
|
||||
remove_action( 'save_post_insert', 'prefix_save_post' );
|
||||
if ($post_id < 15789)
|
||||
return; // залитое старье не трогаем
|
||||
|
||||
// только публикованные
|
||||
if ( wp_is_post_revision( $post_id ) || get_post($post_id)->post_status != 'publish' )
|
||||
return;
|
||||
|
||||
$post = get_posts($post_id);
|
||||
$name = $post[0]->post_name;
|
||||
// $newname = vij_slug($name);
|
||||
$name = urldecode($post[0]->post_name);
|
||||
|
||||
file_put_contents("/vhosts/logs/translit.log", "$post_id: $name\n", FILE_APPEND);
|
||||
if (isContainsRussianLetters($name)) { //если есть русские буковки
|
||||
$title = express_slug($post[0]->post_title);
|
||||
$latname = vij_slug($title);
|
||||
remove_action( 'save_post', 'lat_slug' ); // избегаем зацикливания
|
||||
wp_update_post( array( 'ID' => $post_id, 'post_name' => $latname ) );
|
||||
add_action( 'save_post', 'lat_slug' );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function vij_slug($slug) {
|
||||
$replace = array(
|
||||
@@ -144,22 +155,100 @@ function vij_slug($slug) {
|
||||
'Я' => 'Ya', 'я' => 'ya'
|
||||
);
|
||||
|
||||
$newslug = strtr($slug, $replace);
|
||||
|
||||
|
||||
|
||||
|
||||
return $newslug;
|
||||
|
||||
//return strtr($slug, $replace);
|
||||
return strtr($slug, $replace);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function isContainsRussianLetters($text = false) {
|
||||
if ($text !== "") {
|
||||
$len = strlen($text)-1;
|
||||
for ($i=0;$i<=$len;$i++) {
|
||||
if (($i < $len) and (((($ord = ord(substr($text,$i,1))) == 208)
|
||||
and (($ord2 = ord(substr($text,($i+1),1))) == 129)
|
||||
or (($ord2 >= 144) and ($ord2 <= 191)))
|
||||
or ((($ord = ord(substr($text,$i,1))) == 209)
|
||||
and ($ord2 == 145) or (($ord2 >= 128)
|
||||
and ($ord2 <= 143))))) {
|
||||
//Поиск русских букв в UTF-8
|
||||
return true;
|
||||
} elseif (((($ord = ord(substr($text,$i,1))) >= 192)
|
||||
and (($ord <= 255)) or ($ord == 168) or ($ord == 184))) {
|
||||
//Поиск русских букв в ANSI
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function view ($view, $data = array(), $layer = null){
|
||||
function express_slug($value){
|
||||
|
||||
|
||||
$result = mb_strtolower(trim($value));
|
||||
|
||||
$arr = [
|
||||
'$' => '',
|
||||
' ' => '-',
|
||||
'.' => '',
|
||||
'+' => '',
|
||||
'!' => '',
|
||||
'*' => '',
|
||||
'(' => '',
|
||||
')' => '',
|
||||
',' => '-',
|
||||
'{' => '',
|
||||
'}' => '',
|
||||
'|' => '-',
|
||||
'^' => '',
|
||||
'~' => '',
|
||||
'[' => '-',
|
||||
']' => '-',
|
||||
'`' => '',
|
||||
'<' => '',
|
||||
'>' => '',
|
||||
'#' => '',
|
||||
'%' => '',
|
||||
'"' => '',
|
||||
';' => '',
|
||||
'/' => '',
|
||||
'?' => '',
|
||||
':' => '',
|
||||
'@' => '',
|
||||
'&' => '',
|
||||
'=' => '',
|
||||
'.' => '',
|
||||
'«' => '',
|
||||
'»' => '',
|
||||
"'"=> ''
|
||||
];
|
||||
|
||||
$result = strtr($result, $arr);
|
||||
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function eventdate($val){
|
||||
$posT = strpos($val, 'T');
|
||||
|
||||
if ($posT)
|
||||
|
||||
return $val;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
if (!function_exists('view')){
|
||||
function view ($view, $data = array(), $layer = null){
|
||||
|
||||
ob_start();
|
||||
|
||||
@@ -174,4 +263,5 @@ function view ($view, $data = array(), $layer = null){
|
||||
|
||||
return trim(ob_get_clean());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,15 @@
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<title><?php wp_title('|', true, 'right');?><?=get_bloginfo('name')?></title>
|
||||
<link rel="stylesheet" href="<?php echo get_stylesheet_uri();?>?ver=22">
|
||||
<link rel="stylesheet" href="<?php echo get_stylesheet_uri();?>?ver=40">
|
||||
<link href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" rel="stylesheet">
|
||||
<script type='text/javascript' src="<?php echo get_stylesheet_directory_uri()?>/scripts/jquery-3.6.0.min.js"></script>
|
||||
<script type='text/javascript' src="<?php echo get_stylesheet_directory_uri()?>/scripts/burger-menu.js?ver=9"></script>
|
||||
<script type='text/javascript' src="<?php echo get_stylesheet_directory_uri()?>/scripts/golos.js"></script>
|
||||
<meta property="og:title" content="<?php wp_title('|', true, 'right');?><?=get_bloginfo('name')?>" />
|
||||
<link rel="icon" href="https://vetandlife.ru/favicon.ico" type="image/x-icon">
|
||||
<?if (isset($post->ID)):?>
|
||||
<meta property="og:description" content="<?=get_the_excerpt( $post->ID )?>" />
|
||||
<meta property="og:description" content="<?=strip_tags(get_the_excerpt( $post->ID ))?>" />
|
||||
<?if( has_post_thumbnail()):
|
||||
$thumb_id = get_post_thumbnail_id($post->ID);
|
||||
$thumb_url = wp_get_attachment_image_src($thumb_id,'large', false);?>
|
||||
@@ -30,7 +32,7 @@
|
||||
<header>
|
||||
|
||||
<div id="mainlogo">
|
||||
<a href="<?php echo home_url(); ?>"><img src = "<?=get_stylesheet_directory_uri()?>/pub/logo/vij-logo-220.png" alt = "Ветеринария и жизнь. Газета и сайт" /></a>
|
||||
<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">
|
||||
|
||||
12
index.php
12
index.php
@@ -37,11 +37,18 @@ $nn = 0;?>
|
||||
|
||||
<?php while($query->have_posts()) : $query->the_post();?>
|
||||
|
||||
<?$nn++?>
|
||||
|
||||
<?if ($nn == 2){
|
||||
get_template_part( '/blocks/krasavica');
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<div class="mini-card">
|
||||
<?if ( has_post_thumbnail() ) :?>
|
||||
<div class="mini-card-img">
|
||||
<a href="<?the_permalink();?>"><img class="mini-card-img" src="<?php echo get_the_post_thumbnail_url(null, 'full'); ?>" alt="<?the_title();?>"></a>
|
||||
<a href="<?the_permalink();?>"><img class="mini-card-img" src="<?php echo get_the_post_thumbnail_url(null, 'large'); ?>" alt="<?the_title();?>"></a>
|
||||
</div>
|
||||
<?endif?>
|
||||
<h2 class="mini-card-title"><a href="<?the_permalink();?>"><?the_title();?></a></h2>
|
||||
@@ -57,6 +64,7 @@ $nn = 0;?>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php endif;?>
|
||||
|
||||
<?php wp_reset_postdata();?>
|
||||
@@ -65,7 +73,7 @@ $nn = 0;?>
|
||||
<?get_template_part( '/blocks/citata', null, ['subclass' => 'mob-lite']);?>
|
||||
<?get_template_part( '/blocks/mosts', null, ['subclass' => 'mob-lite']);?>
|
||||
|
||||
<div class="publ-to-main"><a href="<?=get_site_url()?>/category/sobytiya"> <span class="arrow-go-main"><</span> <span class="go-to-main">Все события</span></a></div>
|
||||
<div class="publ-to-main"><a href="<?=get_category_link(2)?>/page/2"><span class="go-to-main">Показать ещe</span></a></div>
|
||||
|
||||
|
||||
</div> <!-- end content -->
|
||||
|
||||
13
search.php
13
search.php
@@ -23,8 +23,15 @@ get_header();?>
|
||||
|
||||
<?if (trim($s) !== ''):?>
|
||||
|
||||
<?$params = [
|
||||
'post_type' => 'post',
|
||||
's' => $s,
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => 20
|
||||
]?>
|
||||
|
||||
<p class="search-result">По запросу «<?php
|
||||
$allsearch = new WP_Query("s=$s&showposts=-1");
|
||||
$allsearch = new WP_Query($params);
|
||||
$key = esc_html($s, 1);
|
||||
$count = $allsearch->post_count; _e('');
|
||||
_e('<span class="search-terms">');
|
||||
@@ -38,7 +45,7 @@ else:
|
||||
echo $count . ' '; _e('результата');
|
||||
endif;
|
||||
endif;
|
||||
wp_reset_query(); ?></p>
|
||||
//wp_reset_query(); ?></p>
|
||||
|
||||
<?php if(have_posts()) :?>
|
||||
<div class="search-card-box">
|
||||
@@ -72,6 +79,8 @@ wp_reset_query(); ?></p>
|
||||
|
||||
<?php endif;?>
|
||||
|
||||
<?wp_reset_postdata();?>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<img class="img-fluid rounded" width="180" src="<?php echo get_the_post_thumbnail_url(null, 'full');?>" alt="<?the_title();?>">
|
||||
</div>
|
||||
<?endif?>
|
||||
<div><?the_content();?></div>
|
||||
<div class="fulltext"><?the_content();?></div>
|
||||
<!--<p><small class="text-muted"><?php the_tags('');?></small></p> -->
|
||||
<?//endwhile;?>
|
||||
|
||||
|
||||
104
src/calend-block.php
Normal file
104
src/calend-block.php
Normal file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
function calend_block($month, $year, $script=false){
|
||||
|
||||
$args = array(
|
||||
'numberposts' => -1,
|
||||
'category' => 61, // 61 - мероприятия
|
||||
'orderby' => 'date',
|
||||
'order' => 'ASC',
|
||||
|
||||
'date_query' => array(
|
||||
array(
|
||||
'after' => array( // после этой даты
|
||||
'year' => $year,
|
||||
'month' => $month,
|
||||
'day' => 1,
|
||||
),
|
||||
'before' => array( // до этой даты
|
||||
'year' => $year,
|
||||
'month' => $month,
|
||||
'day' => 31,
|
||||
),
|
||||
// 'inclusive'=> true
|
||||
)
|
||||
),
|
||||
|
||||
'post_type' => 'post',
|
||||
'post_status' => 'publish, future',
|
||||
'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
|
||||
);
|
||||
|
||||
$posts = get_posts($args);
|
||||
|
||||
$events = [];
|
||||
|
||||
foreach ($posts as $post){
|
||||
$key = date('d.m.Y', strtotime($post->post_date));
|
||||
$events[$key]['text'] = $post->post_title;
|
||||
$events[$key]['link'] = get_permalink($post->ID);
|
||||
|
||||
}?>
|
||||
|
||||
<div id="event-calendar">
|
||||
<?=Calendar::getMonth(date($month), date($year), $events);?>
|
||||
</div>
|
||||
|
||||
<?php if ($script){?>
|
||||
<script>
|
||||
|
||||
var calend_link_base = "<?=get_site_url()?>/wp-content/themes/vij/src/eventcalendar.php";
|
||||
var calend_curr_year = "<?=$year?>";
|
||||
var calend_curr_month = "<?=$month?>";
|
||||
|
||||
|
||||
function calend_prev_month(){
|
||||
load_calendar_month(type = 'prev');
|
||||
}
|
||||
|
||||
function calend_next_month(){
|
||||
load_calendar_month(type = 'next');
|
||||
}
|
||||
|
||||
|
||||
function load_calendar_month(type = 'next'){
|
||||
|
||||
if (type == 'next'){
|
||||
|
||||
if (calend_curr_month == 12 ){
|
||||
calend_curr_month = 1;
|
||||
calend_curr_year = parseInt(calend_curr_year) + 1;
|
||||
}
|
||||
else {
|
||||
calend_curr_month = parseInt(calend_curr_month) + 1;
|
||||
}
|
||||
|
||||
}
|
||||
else if (type == 'prev'){
|
||||
|
||||
if (calend_curr_month == 1 ){
|
||||
calend_curr_month = 12;
|
||||
calend_curr_year = parseInt(calend_curr_year) - 1;
|
||||
}
|
||||
else {
|
||||
calend_curr_month = parseInt(calend_curr_month) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
$currlink = calend_link_base + '?year=' + calend_curr_year + '&month=' + calend_curr_month;
|
||||
|
||||
fetch($currlink).then(function (response) {
|
||||
return response.text();
|
||||
}).then(function (html) {
|
||||
document.getElementById('event-calendar').innerHTML = html;
|
||||
}).catch(function (err) {
|
||||
console.warn('Something went wrong.', err);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<?}
|
||||
|
||||
}
|
||||
158
src/calendar.php
Normal file
158
src/calendar.php
Normal file
@@ -0,0 +1,158 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Calendar
|
||||
{
|
||||
|
||||
/**
|
||||
* Вывод календаря на один месяц.
|
||||
*/
|
||||
public static function getMonth($month, $year, $events = array())
|
||||
{
|
||||
$months = array(
|
||||
1 => 'Январь',
|
||||
2 => 'Февраль',
|
||||
3 => 'Март',
|
||||
4 => 'Апрель',
|
||||
5 => 'Май',
|
||||
6 => 'Июнь',
|
||||
7 => 'Июль',
|
||||
8 => 'Август',
|
||||
9 => 'Сентябрь',
|
||||
10 => 'Октябрь',
|
||||
11 => 'Ноябрь',
|
||||
12 => 'Декабрь'
|
||||
);
|
||||
|
||||
$month = intval($month);
|
||||
|
||||
|
||||
$out = '
|
||||
<div id="calendar-item">
|
||||
<div class="calendar-title">Календарь событий</div>
|
||||
<div class="calendar-head">
|
||||
<div class="calendar-prev"><a id="calendar-arrow-prev" onclick="load_calendar_month('."'prev'".');"><</a></div>
|
||||
<div class="calendar-head-text">' . $months[$month] . ' ' . $year . '</div>
|
||||
<div class="calendar-next"><a id="calendar-arrow-next" onclick="load_calendar_month('."'next'".');">></a></div>
|
||||
</div>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Пн</th>
|
||||
<th>Вт</th>
|
||||
<th>Ср</th>
|
||||
<th>Чт</th>
|
||||
<th>Пт</th>
|
||||
<th>Сб</th>
|
||||
<th>Вс</th>
|
||||
</tr>';
|
||||
|
||||
$day_week = date('N', mktime(0, 0, 0, $month, 1, $year));
|
||||
$day_week--;
|
||||
|
||||
$out.= '<tr>';
|
||||
|
||||
for ($x = 0; $x < $day_week; $x++) {
|
||||
$out.= '<td></td>';
|
||||
}
|
||||
|
||||
$days_counter = 0;
|
||||
$days_month = date('t', mktime(0, 0, 0, $month, 1, $year));
|
||||
|
||||
for ($day = 1; $day <= $days_month; $day++) {
|
||||
if (date('j.n.Y') == $day . '.' . $month . '.' . $year) {
|
||||
$class = 'today';
|
||||
} elseif (time() > strtotime($day . '.' . $month . '.' . $year)) {
|
||||
$class = 'last';
|
||||
} else {
|
||||
$class = '';
|
||||
}
|
||||
|
||||
$event_show = false;
|
||||
$event_text = '';
|
||||
$event_link = '';
|
||||
if (!empty($events)) {
|
||||
foreach ($events as $date => $text) {
|
||||
$date = explode('.', $date);
|
||||
if (count($date) == 3) {
|
||||
$y = explode(' ', $date[2]);
|
||||
if (count($y) == 2) {
|
||||
$date[2] = $y[0];
|
||||
}
|
||||
|
||||
if ($day == intval($date[0]) && $month == intval($date[1]) && $year == $date[2]) {
|
||||
$event_show = true;
|
||||
$event_text = $text['text'];
|
||||
$event_link = $text['link'];
|
||||
}
|
||||
} elseif (count($date) == 2) {
|
||||
if ($day == intval($date[0]) && $month == intval($date[1])) {
|
||||
$event_show = true;
|
||||
$event_text = $text['text'];
|
||||
$event_link = $text['link'];
|
||||
}
|
||||
} elseif ($day == intval($date[0])) {
|
||||
$event_show = true;
|
||||
$event_text = $text['text'];
|
||||
$event_link = $text['link'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($event_show) {
|
||||
|
||||
$out.= '<td class="calendar-day ' . $class . ' calendar-event">';
|
||||
if (!empty($event_text)) {
|
||||
$out.= '<div class="calendar-popup" ><a href="'.$event_link.'" title="'.$event_text.'">'.$day.'</a></div>';
|
||||
}
|
||||
$out.= '</td>';
|
||||
} else {
|
||||
$out.= '<td class="calendar-day ' . $class . '">' . $day . '</td>';
|
||||
}
|
||||
|
||||
if ($day_week == 6) {
|
||||
$out.= '</tr>';
|
||||
if (($days_counter + 1) != $days_month) {
|
||||
$out.= '<tr>';
|
||||
}
|
||||
$day_week = -1;
|
||||
}
|
||||
|
||||
$day_week++;
|
||||
$days_counter++;
|
||||
}
|
||||
|
||||
$out .= '</tr></table></div>';
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Вывод календаря на несколько месяцев.
|
||||
*/
|
||||
public static function getInterval($start, $end, $events = array())
|
||||
{
|
||||
$curent = explode('.', $start);
|
||||
$curent[0] = intval($curent[0]);
|
||||
|
||||
$end = explode('.', $end);
|
||||
$end[0] = intval($end[0]);
|
||||
|
||||
$begin = true;
|
||||
$out = '<div class="calendar-wrp">';
|
||||
do {
|
||||
$out .= self::getMonth($curent[0], $curent[1], $events);
|
||||
|
||||
if ($curent[0] == $end[0] && $curent[1] == $end[1]) {
|
||||
$begin = false;
|
||||
}
|
||||
|
||||
$curent[0]++;
|
||||
if ($curent[0] == 13) {
|
||||
$curent[0] = 1;
|
||||
$curent[1]++;
|
||||
}
|
||||
} while ($begin == true);
|
||||
|
||||
$out .= '</div>';
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
14
src/eventcalendar.php
Normal file
14
src/eventcalendar.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
ini_set('display_errors','on');
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require '/vhosts/beta/wp-load.php';
|
||||
//require '/thosts/vij/wp/wp-load.php';
|
||||
|
||||
|
||||
|
||||
if (isset($_GET['month']) and $_GET['year']){
|
||||
calend_block($_GET['month'], $_GET['year']);
|
||||
}
|
||||
|
||||
159
style.css
159
style.css
@@ -129,7 +129,7 @@ a{
|
||||
|
||||
#mainlogo{
|
||||
margin-left: 12px;
|
||||
width: 340px;
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
.right-info{
|
||||
@@ -262,7 +262,10 @@ a{
|
||||
max-width: 239px;
|
||||
}
|
||||
|
||||
|
||||
.mobile-info{
|
||||
display: none;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/** #vert-title div{
|
||||
|
||||
@@ -442,10 +445,52 @@ a{
|
||||
color: #2D9CDB;
|
||||
}
|
||||
|
||||
.fulltext > ul{
|
||||
list-style: square outside;
|
||||
}
|
||||
|
||||
.fulltext > ul li{
|
||||
|
||||
margin-top: 4px;
|
||||
margin-bottom: 4px;
|
||||
|
||||
}
|
||||
|
||||
.wp-block-image figcaption {
|
||||
font-size: .9em;
|
||||
}
|
||||
|
||||
figcaption {
|
||||
|
||||
/*font-size: .9em;*/
|
||||
color: #909294;
|
||||
text-align: center;
|
||||
padding: 12px 0 12px 0;
|
||||
|
||||
}
|
||||
|
||||
.sp-button{
|
||||
color: orange;
|
||||
}
|
||||
|
||||
#fulltext img,
|
||||
.wp-block-image img
|
||||
{
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
blockquote{
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
padding-top: 8px;
|
||||
padding-left: 8px;
|
||||
margin-top: 22px;
|
||||
margin-bottom: 22px;
|
||||
border-top: 1px solid #E9EAEB;
|
||||
border-bottom: 1px solid #E9EAEB;
|
||||
|
||||
}
|
||||
|
||||
/** - menus -- */
|
||||
ul.menu_main{
|
||||
@@ -591,9 +636,16 @@ a{
|
||||
}
|
||||
|
||||
#content IMG{
|
||||
max-width: 700px;
|
||||
max-width: 100%;
|
||||
|
||||
}
|
||||
|
||||
.wp-block-image IMG{
|
||||
/** object-fit: cover; */
|
||||
|
||||
}
|
||||
|
||||
|
||||
#post-img{
|
||||
text-align: center;
|
||||
/**background: #F5F5F5;*/
|
||||
@@ -831,6 +883,10 @@ a{
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
|
||||
.publ_expert a{
|
||||
color: #2D9CDB;
|
||||
}
|
||||
|
||||
.post_info{
|
||||
font-size: 14px;
|
||||
color: #444444;
|
||||
@@ -958,11 +1014,17 @@ a{
|
||||
|
||||
.right_archive{
|
||||
margin-bottom: 22px;
|
||||
background: #FFFFFF;
|
||||
box-shadow: 0px 14px 27px rgb(242, 242, 242);
|
||||
text-align: center;
|
||||
margin: 22px;
|
||||
padding-top: 22px;
|
||||
padding-bottom: 22px;
|
||||
}
|
||||
|
||||
.right_archive_img{
|
||||
margin-bottom: 12px;
|
||||
width: 202px;
|
||||
}
|
||||
|
||||
.right_archive_text{
|
||||
@@ -977,6 +1039,8 @@ a{
|
||||
font-size: 15px;
|
||||
line-height: 130%;
|
||||
text-align: center;
|
||||
margin-top: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.right_archive_link a{
|
||||
@@ -1144,8 +1208,85 @@ a{
|
||||
}
|
||||
|
||||
|
||||
#calendar-item{
|
||||
background-color: #2571A6;
|
||||
color: rgba(255, 255, 255, 0.28);
|
||||
text-transform: uppercase;
|
||||
box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.07);
|
||||
font-size: 13px;
|
||||
padding: 22px;
|
||||
}
|
||||
|
||||
.calendar-head {
|
||||
display: flex;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
color: #FFFFFF;
|
||||
font-weight: bold;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.calendar-head a{
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
|
||||
#calendar-arrow-prev,
|
||||
#calendar-arrow-next {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.calendar-title{
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
color: #FFFFFF;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20px;
|
||||
|
||||
}
|
||||
|
||||
#calendar-item th {
|
||||
font-size: 10px;
|
||||
padding: 6px 7px;
|
||||
text-align: center;
|
||||
color: #FFFFFF;
|
||||
font-weight: bold;
|
||||
line-height: 14px;
|
||||
}
|
||||
|
||||
#calendar-item td {
|
||||
font-size: 13px;
|
||||
padding: 6px 8px;
|
||||
text-align: center;
|
||||
|
||||
}
|
||||
|
||||
.calendar-item table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.calendar-head{
|
||||
border-top: 1px solid rgba(0, 70, 106, 0.18);
|
||||
border-bottom: 1px solid rgba(0, 70, 106, 0.18);
|
||||
padding-top: 12px;
|
||||
padding-bottom: 12px;
|
||||
}
|
||||
|
||||
|
||||
.calendar-popup a{
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.calendar-head-text{
|
||||
margin-right: 12px;
|
||||
margin-left: 12px;
|
||||
width: 90%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/** socials */
|
||||
|
||||
#socials{
|
||||
display: flex;
|
||||
@@ -1364,6 +1505,9 @@ img-fluid{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.mobile-info{
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1412,8 +1556,8 @@ img-fluid{
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.fulltext IMG{
|
||||
width: 100%;
|
||||
.fulltext > IMG{
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
#footer{
|
||||
@@ -1437,6 +1581,9 @@ and (max-device-width : 667px) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.mobile-info{
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
.mini-card{
|
||||
|
||||
@@ -79,9 +79,9 @@
|
||||
<tr>
|
||||
<td width="38%" valign="top" style="font-size:0px;line-height:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0" align="left">
|
||||
<div style="max-width:<?=$news_img_w?>px;min-width:<?=$news_img_w?>px">
|
||||
<?if (has_post_thumbnail($item->ID)):?>
|
||||
<a style="border:0;outline:0;text-decoration:none" href="<?=get_permalink($item->ID);?>" target="_blank">
|
||||
<img width="<?=$news_img_w?>" height="<?=$news_img_h?>" tyle="margin:0;background-color:#eaeaea;border:0;font-family:Arial,sans-serif;font-size:13px;line-height:14px;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;outline:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;text-decoration:none;width:100%" src="<?=get_the_post_thumbnail_url($item->ID, 'subscripts')?>" alt="<?=$item->post_title?>">
|
||||
<?if (has_post_thumbnail($item['ID'])):?>
|
||||
<a style="border:0;outline:0;text-decoration:none" href="<?=get_permalink($item['ID']);?>" target="_blank">
|
||||
<img width="<?=$news_img_w?>" height="<?=$news_img_h?>" tyle="margin:0;background-color:#eaeaea;border:0;font-family:Arial,sans-serif;font-size:13px;line-height:14px;margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;outline:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;text-decoration:none;width:100%" src="<?=get_the_post_thumbnail_url($item['ID'], 'subscripts')?>" alt="<?=$item['post_title']?>">
|
||||
</a>
|
||||
<?endif?>
|
||||
</div>
|
||||
@@ -96,14 +96,14 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="font-family:Arial,sans-serif;font-size:14px;line-height:20px;border:0;outline:0;text-decoration:none">
|
||||
<a style="color:<?=$text_color?>;font-family:Arial,sans-serif;font-size:22px;line-height:120%;border:0;outline:0;text-decoration:none" href="<?=get_permalink($item->ID)?>" target="_blank" ><?=$item->post_title?></a>
|
||||
<a style="color:<?=$text_color?>;font-family:Arial,sans-serif;font-size:22px;line-height:120%;border:0;outline:0;text-decoration:none" href="<?=get_permalink($item['ID'])?>" target="_blank" ><?=$item['post_title']?></a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="font-size:0px;line-height:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0" height="15"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="color:<?=$text_color?>;font-family:Arial,sans-serif;font-size:10px;line-height:14px;border:0;outline:0;text-decoration:none;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0" align="left"><a style="width:110px;height:35px;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;border:0;outline:0;text-decoration:none;letter-spacing:0.8px" href="<?=get_permalink($item->ID)?>" target="_blank">
|
||||
<td style="color:<?=$text_color?>;font-family:Arial,sans-serif;font-size:10px;line-height:14px;border:0;outline:0;text-decoration:none;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0" align="left"><a style="width:110px;height:35px;padding-bottom:0;padding-left:0;padding-right:0;padding-top:0;border:0;outline:0;text-decoration:none;letter-spacing:0.8px" href="<?=get_permalink($item['ID'])?>" target="_blank">
|
||||
<img width="110" style="display:block;border:0" src="<?=PUBLINK?>readmore.png" height="35" border="0"></a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user