<?php
/*
* Plugin Name: my_shortcode_date_dayweek_server
* Description: Дата и День недели по-русски
* Version: 1
* Author: jurvrn
* Date: 22.08.2019
*/
add_shortcode ( 'my_shortcode_date_server', 'my_shortcode_date_server_func' );
function my_shortcode_date_server_func ( $attr, $content = null )
{
function UTimeToDateRus($utime, $year = true)
{
$m = (int)date('m', (int)$utime);
$d = date('d', (int)$utime);
$y = '';
if ($year)
$y = date('Y', (int)$utime);
$ms = array(
1 => 'января',
2 => 'февраля',
3 => 'марта',
4 => 'апреля',
5 => 'мая',
6 => 'июня',
7 => 'июля',
8 => 'августа',
9 => 'сентября',
10=> 'октября',
11=> 'ноября',
12=> 'декабря'
);
return $d.' '.$ms[$m].' '.$y;
}
//==== различные варианты
// function getDateRus()
// {
//-------------------------------------------------------
// $ts = time();
// $months=array('января','февраля','марта','апреля','мая','июня','июля','августа','сентября','октября','ноября','декабря');
// return date('d', $ts).' '.$months[(date('n', $ts))].date(' Y', $ts);
//---------------------------------------------------
// setlocale(LC_ALL, 'ru_RU.UTF-8');
// date_default_timezone_set('Europe/Moscow');
// $den = date('d'); //время цифрами - $den= date('H:i:s');
// $mes = mb_strtolower(strftime("%B")); //месяц по русский
// $god = date('Y');
// return $den . ' ' . $mes . ' ' . $god;
//-----------------------------------------------------------
// return date_i18n ( 'd F Y', false, false);
//--------------------------------------------------------------
// }
return "<div id='daterus'><div id='datestyle'><i class='fa fa-calendar fa-lg' aria-hidden='true'></i> <span id='fonsizdateitem'>Сегодня:</span> <span id='fonsizdat'>" . UTimeToDateRus(time()) . " г.</span></div></div>";
//return "<div id='daterus'><div id='datestyle'><i class='fa fa-calendar fa-lg' aria-hidden='true'></i> <span id='fonsizdateitem'>Сегодня:</span> <span id='fonsizdat'>" . getDateRus() . " г.</span></div></div>";
}
// add_shortcode ( 'my_shortcode_date_server', 'my_shortcode_date_server_func' );
// function my_shortcode_date_server_func ( $attr, $content = null )
// {
// function getDateRus()
// {
// $monthes = array(
// 1 => 'января', 2 => 'февраля', 3 => 'марта', 4 => 'апреля',
// 5 => 'мая', 6 => 'июня', 7 => 'июля', 8 => 'августа',
// 9 => 'сентября', 10 => 'октября', 11 => 'ноября', 12 => 'декабря'
// );
// return ((int)date('d') . ' ' . $monthes[(date('n'))] . date(' Y'));
// }
// return "<div id='daterus'><div id='datestyle'><i class='fa fa-calendar fa-lg' aria-hidden='true'></i> <span id='fonsizdateitem'>Сегодня:</span> <span id='fonsizdat'>" . getDateRus() . " г.</span></div></div>";
// }
// add_shortcode( 'my_shortcode_day_week_server', 'my_shortcode_day_week_server_func');
// function my_shortcode_day_week_server_func ( $attr, $content = null )
// {
// function getDayRus(){
// $days = array('Воскресенье', 'Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота');
// return $days[(date('w'))];
// }
// return "<span id='dayweekstyle'>" . getDayRus() . "</span>";
// }
add_shortcode( 'my_shortcode_day_week_server', 'my_shortcode_day_week_server_func');
function my_shortcode_day_week_server_func ($attr, $content = null)
{
setlocale(LC_ALL, 'ru_RU.UTF-8');
return "<span style='background-color: #e1ccf9; font-size: 14px;'>" . mb_strtolower(strftime("%A")) . "</span>";
}
// add_action('wp_head', 'f_wp_head_css');
// function f_wp_head_css() {
/* ?>
<!-- <style>
#dayweekstylee{ background-color: #e7ccf9; font-size: 14px;}
</style> -->
// <?php
//}*/
?>