Skip to content

Instantly share code, notes, and snippets.

@Dimasmagadan
Created April 25, 2016 04:53
Show Gist options
  • Save Dimasmagadan/41b4e47a30138f6861a806802ae6eb51 to your computer and use it in GitHub Desktop.
Save Dimasmagadan/41b4e47a30138f6861a806802ae6eb51 to your computer and use it in GitHub Desktop.
<?php
/*
Plugin Name: MaxSite Russian Date & Russify Comments Number
Plugin URI: http://maxsite.org/
Description: Русские даты
Version: 1.0
Author: MAX & Alexander Ulizko
*/
function maxsite_the_russian_time($tdate = '') {
if ( substr_count($tdate , '---') > 0 ) return str_replace('---', '', $tdate);
$treplace = array (
"Январь" => "января",
"Февраль" => "февраля",
"Март" => "марта",
"Апрель" => "апреля",
"Май" => "мая",
"Июнь" => "июня",
"Июль" => "июля",
"Август" => "августа",
"Сентябрь" => "сентября",
"Октябрь" => "октября",
"Ноябрь" => "ноября",
"Декабрь" => "декабря",
"January" => "января",
"February" => "февраля",
"March" => "марта",
"April" => "апреля",
"May" => "мая",
"June" => "июня",
"July" => "июля",
"August" => "августа",
"September" => "сентября",
"October" => "октября",
"November" => "ноября",
"December" => "декабря",
"Sunday" => "воскресенье",
"Monday" => "понедельник",
"Tuesday" => "вторник",
"Wednesday" => "среда",
"Thursday" => "четверг",
"Friday" => "пятница",
"Saturday" => "суббота",
"Sun" => "воскресенье",
"Mon" => "понедельник",
"Tue" => "вторник",
"Wed" => "среда",
"Thu" => "четверг",
"Fri" => "пятница",
"Sat" => "суббота",
"th" => "",
"st" => "",
"nd" => "",
"rd" => ""
);
return strtr($tdate, $treplace);
}
add_filter('the_time', 'maxsite_the_russian_time');
add_filter('get_the_time', 'maxsite_the_russian_time');
add_filter('the_date', 'maxsite_the_russian_time');
add_filter('get_the_date', 'maxsite_the_russian_time');
add_filter('the_modified_time', 'maxsite_the_russian_time');
add_filter('get_the_modified_date', 'maxsite_the_russian_time');
add_filter('get_post_time', 'maxsite_the_russian_time');
add_filter('get_comment_date', 'maxsite_the_russian_time');
function russify_comments_number($zero = false, $one = false, $more = false, $deprecated = '') {
global $id;
$number = get_comments_number($id);
if ($number == 0) {
$output = 'Комментариев нет';
} elseif ($number == 1) {
$output = 'Один комментарий';
} elseif (($number > 20) && (($number % 10) == 1)) {
$output = str_replace('%', $number, '% комментарий');
} elseif ((($number >= 2) && ($number <= 4)) || ((($number % 10) >= 2) && (($number % 10) <= 4)) && ($number > 20)) {
$output = str_replace('%', $number, '% комментария');
} else {
$output = str_replace('%', $number, '% комментариев');
}
echo apply_filters('russify_comments_number', $output, $number);
}
add_filter('comments_number', 'russify_comments_number');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment