This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Чинит склонение русских названий месяцев. | |
* Всё со строчной, потому что так диктует русская типографическая традиция. | |
* | |
* @param string $string Форматированная дата | |
* @return string Починенная строка. | |
*/ | |
function md_rumonth($string) { | |
$months = array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Функция возвращает окончание для множественного числа слова на основании числа и массива окончаний | |
* @param integer $number Число на основе которого нужно сформировать окончание | |
* @param array $endingArray Массив слов или окончаний для чисел (1, 4, 5), например array('яблоко', 'яблока', 'яблок') | |
* @return string $ending | |
*/ | |
function get_num_endings($number, $endingArray) { | |
$number = $number % 100; | |
if ($number>=11 && $number<=19) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists(get_excerpt_by_id)) { | |
/** | |
* Returns excerpt by ID. WP_Post->post_excerpt if it presents, wp_trim_words on other case. | |
* @param mixed $post WP_Post object or post ID. Accepts WP_Post object or post ID (integer or string); | |
* @return string Excerpt | |
*/ | |
function get_excerpt_by_id($post) { | |
$return_excerpt = function($post) { | |
if ($post->post_excerpt == '') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Completely removes jQuery from the front. | |
*/ | |
function remove_jquery() { | |
if (!is_admin()) { | |
wp_deregister_script('jquery'); | |
wp_deregister_script('jquery-migrate'); | |
wp_register_script('jquery', '', false, '1.11.3', true); | |
wp_enqueue_script('jquery'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Returns urls of all sizes of the post thumbnail (featured image). | |
* @param integer $post_id Post ID | |
* @return array Key-value array of sizes and urls. | |
*/ | |
function md_post_thumbnail_urls($post_id) { | |
$thumbnail_id = get_post_thumbnail_id( $post_id ); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This function can be used to return (instead of echoing) results | |
* of build-in functions, that cannot return, just echo. | |
* @return mixed Results of called function. | |
*/ | |
function md_rioe() { | |
if (func_num_args() === 0) { | |
trigger_error('Nothing to call', E_USER_WARNING); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function reverseString(string) { | |
var arr = new Array(string.length), | |
middle = Math.ceil(string.length / 2); | |
for (var x = 0, y = string.length - 1; x <= middle; x++, y--) { | |
arr[x] = string[y]; | |
arr[y] = string[x]; | |
} | |
return arr.join(''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Example #1 */ | |
// Store.js | |
// `Atom()` - create new stream | |
const a = Atom(0); | |
const b = Atom(0); | |
OlderNewer