(☞ຈل͜ຈ)☞ Главная  Статьи  Загрузчик Домой

Ok!
Ok!
216
/**
 * @param $limit
 * @return string|string[]
 * обрезает контент до числа слов
 */
function content($limit, $pid = null) {
  $content = explode(' ', get_the_content($pid), $limit);
  if (count($content)>=$limit) {
    array_pop($content);
    $content = implode(" ",$content).'...';
  } else {
    $content = implode(" ",$content);
  }
  $content = preg_replace('/[.+]/','', $content);
  $content = apply_filters('the_content', $content);
  $content = str_replace(']]>', ']]>', $content);
  return $content;
}
контент, образает, WP1001обрезает контент до числа слов
35
$page = file_get_contents('http://touch.facebook.com');
$doc = new DOMDocument();
$doc->loadHTML($page);
$divs = $doc->getElementsByTagName('div');
foreach($divs as $div) {
    if ($div->getAttribute('id') === 'content') {
         echo $div->nodeValue;
    }
}
parse, php, parser1000Парсер страницы или блока страницы
263
https://api.wordpress.org/secret-key/1.1/salt/
ключи, WP985Сгенерировать ключи Вордпресс
57
require_once("wp-load.php");
wp, native functions, include980All important WordPress file that I needed to include in my custom PHP file was "wp-load.php"
117
SELECT  * FROM news
UNION 
SELECT  * FROM news1
WHERE date = \'03.12.2015\'
GROUP BY region ORDER BY id DESC
union, mysql980Объединить в один запрос выборку из двух баз с одинаковой структурой
253
$iterator = CIBlockElement::GetList(
				array("ID"=>"DESC"),
				array('IBLOCK_ID' => 26, '=ACTIVE' => 'Y', 'IBLOCK_SECTION_ID', ['LOGIC' => 'OR', 'PREVIEW_TEXT' => false, 'DETAIL_TEXT' => false]),
				false,
				false,
				array('ID', 'NAME', 'CODE', 'IBLOCK_SECTION_ID')
			);


while($item = $iterator->Fetch()) { 
	$was_id = 0; 
	$nav = CIBlockSection::GetNavChain(false, $item['IBLOCK_SECTION_ID'], array(), false);
	$url = "";
	while($nav->Fetch()){
		if($was_id != $item['ID']){
			$url_length = count($nav->arResult);
	
	
			$url .= $nav->arResult[$url_length - 1]['CODE'] . "/";
	
	
			echo $item['ID'] . ';"' . $item['NAME'] . '";"https://lamaree.ru/catalog/' . $url . $item['CODE'] . '/"' . "
";
			$was_id = $item['ID'];
		}
	}
}
url, bitrix, catalog980Выбрать из каталога Битрикс товары без описаний с URL
58
UPDATE table_name SET `column_name` = LOWER( `column_name` )
замена, mysql, строчные, нижний регистр907Приведение, замена записей mysql к нижнему регистру
24
$rs_Section = CIBlockSection::GetList(
	array('DEPTH_LEVEL' => 'desc'),
	$ar_Filter,
	false,
	array('ID', 'NAME', 'IBLOCK_SECTION_ID', 'DEPTH_LEVEL', 'SORT')
);
$ar_SectionList = array();
$ar_DepthLavel = array();
while($ar_Section = $rs_Section->GetNext(true, false))
{
	$ar_SectionList[$ar_Section['ID']] = $ar_Section;
	$ar_DepthLavel[] = $ar_Section['DEPTH_LEVEL'];
}

$ar_DepthLavelResult = array_unique($ar_DepthLavel);
rsort($ar_DepthLavelResult);

$i_MaxDepthLevel = $ar_DepthLavelResult[0];

for( $i = $i_MaxDepthLevel; $i > 1; $i-- )
{
	foreach ( $ar_SectionList as $i_SectionID => $ar_Value )
	{
		if( $ar_Value['DEPTH_LEVEL'] == $i )
		{
			$ar_SectionList[$ar_Value['IBLOCK_SECTION_ID']]['SUB_SECTION'][] = $ar_Value;
			unset( $ar_SectionList[$i_SectionID] );
		}
	}
}

function __sectionSort($a, $b)
{
	if ($a['SORT'] == $b['SORT']) {
		return 0;
	}
	return ($a['SORT'] < $b['SORT']) ? -1 : 1;
}

usort($ar_SectionList, "__sectionSort");
битрикс, массив, перебор780Перебор массива Битрикс в виде дерева
110
echo GetCountryByID (  GetCountryIdByCode("NL") );
битрикс, страна780Вывести название страны по ее коду
104
width: expression(((document.documentElement.clientWidth || document.body.clientWidth) < 1050)? "1050px" : "100%");
expression, css690Применение expression в css
52
add_filter( 'jpeg_quality', function ( $arg ) {
	return 100;
} );
качество jpg, wp, jpg quality670Отменить кадрирование в вордпресс, установить качество 100:
254
document.addEventListener("DOMContentLoaded", ()=>{
	document.querySelector("#get_data_by_inn").addEventListener("click", ()=> {


		(async function get_jur_data() {
			let url = "https://' . $_SERVER['HTTP_HOST'] .'/test/inn.json";
			

			fetch(url, {
				headers: {
					Authentication: "secret"
				}})
				.then((response) => {
					return response.json();
				})
				.then((data) => {
					console.log(data);
				});


		})()
	});
});
json, fetch, js670Запрос json через javascript
59
$protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://";
protocol, https650Определить протокол
255
class Foo extends \stdClass
// to fix Deprecated: Creation of dynamic property
php, deprecation, dynamic650Исправление ошибки создания динамически свойства в php8.2
53
remove_image_size('large');
remove_image_size('medium');
add_filter( 'wp_calculate_image_srcset_meta', '__return_null' );

Другое решение, сработало в другом месте
add_filter( 'max_srcset_image_width', create_function( '', 'return 1;' ) );
srcset, отменить srcset, wp590Отменить srcset в Вордпрессе
105
<a id="ajaxaction=add&ajaxaddid=<?=$ar_fields['ID'];?>" rel="nofollow" class="catalog-item-buy input-basket-submit" href="?action=ADD2BASKET&id=<?=$ar_fields['ID'];?>">В корзину</a>
bitrix, в корзину560Код кнопки добавления в корзину итрикс
108
$row['cat_url'] = sb_check_chpu('', '', $row['cat_title'], 'sb_categs', 'cat_url', 'cat_id');
чпу, сбилдер, sbuilder560Получить адрес категории в SBuilder
193
RedirectMatch 301 /(.*)/$ /$1.html
редирект, html560Редирект с папки на файл .html
265
https://demo.flyimg.io/upload/w_1600,h_1067,c_1,o_jpg/https://modernfotostudio.ru/images/img1-home-top.jpg
afif, url, convert510Конвертер в афиф формал, но сохраняет в жпег формате. Много легче оригинала
103
$data = preg_replace('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $data);
var_dump(unserialize($data));
replace, serialized510recalculating the length of the elements in serialized array
1 2 3 4 5 6 7 8 9 10 11 12 13 14