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 | |
function plural($number, $titles) { | |
$cases = array (2, 0, 1, 1, 1, 2); | |
return $titles[ ($number % 100 > 4 && $number % 100 < 20) ? 2 : $cases[min($number % 10, 5)] ]; | |
} |
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
#добавлем в конец url слеш | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-l | |
RewriteCond %{REQUEST_FILENAME} !-d | |
RewriteCond %{REQUEST_URI} ^(.*/[^/\.]+)$ | |
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [R=301,L] |
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
В result_modifier.php шаблона вставляем: | |
<? | |
// сортировку берем из параметров компонента | |
$arSort = array( | |
$arParams["SORT_BY1"]=>$arParams["SORT_ORDER1"], | |
$arParams["SORT_BY2"]=>$arParams["SORT_ORDER2"], | |
); | |
// выбрать нужно id элемента, его имя и ссылку. Можно добавить любые другие поля, например PREVIEW_PICTURE или PREVIEW_TEXT | |
$arSelect = 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 | |
$cacheId = 'uniqueCacheId'; | |
$cacheTtl = '3600'; | |
$cache = \Bitrix\Main\Application::getInstance()->getManagedCache(); | |
if ($cache->read($cacheTtl, $cacheId)) { | |
$data = $cache->get($cacheId); // get our data | |
} else { | |
$data = '12345678'; |
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 | |
$query = array( | |
'access_token' => 'token', | |
'count' => 6 | |
); | |
$url = 'https://api.instagram.com/v1/users/[user-id]/media/recent/?' . http_build_query($query); | |
try { | |
$curl_connection = curl_init($url); | |
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30); | |
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true); |
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
UPDATE wp_options SET option_value = replace(option_value, 'http://domain.ru', 'http://newdomain.ru') WHERE option_name = 'home' OR option_name = 'siteurl'; | |
UPDATE wp_posts SET guid = replace(guid, 'http://domain.ru','http://newdomain.ru'); | |
UPDATE wp_posts SET post_content = replace(post_content, 'http://domain.ru', 'http://newdomain.ru'); |
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 number_format(number, decimals, dec_point, thousands_sep) { | |
var i, j, kw, kd, km; | |
// input sanitation & defaults | |
if (isNaN(decimals = Math.abs(decimals))) { | |
decimals = 2; | |
} | |
if (dec_point == undefined) { | |
dec_point = ","; |
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 getChar(event) { | |
if (event.which == null) { // IE | |
if (event.keyCode < 32) return null; // спец. символ | |
return String.fromCharCode(event.keyCode) | |
} | |
if (event.which != 0 && event.charCode != 0) { // все кроме IE | |
if (event.which < 32) return null; // спец. символ | |
return String.fromCharCode(event.which); // остальные | |
} |
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
$('.content iframe').wrap('<div class="video-wrap"></div>'); | |
.video-wrap { | |
height: 0; | |
overflow: hidden; | |
padding-bottom: 56.25%; | |
position: relative; | |
} | |
.video-wrap iframe, .video-wrap object, .video-wrap embed { |