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
//Пример фрагмента .htaccess (из плагина FastestCache) для решения ошибки "Задайте правила эффективного использования кеша для статических объектов" в PageSpeed | |
//это просто пример! не копируйте его на свой сайт! | |
//в данном примере задано время кеширования 1 Год | |
// обычно это даёт + 2-4 балла по PageSpeed | |
//© Калинский Евгений aka seojacky (https://t.me/big_jacky) | |
//По вопросам оптимизации сайтов по требованиям PageSpeed пишите в Telegram https://t.me/big_jacky | |
/* | |
* Мои плагины для ускорения сайта: | |
* True Lazy Analytics https://wordpress.org/plugins/true-lazy-analytics/ |
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
//Пассивные прослушиватели событий не используются для улучшения производительности при прокрутке | |
//© Калинский Евгений aka seojacky (https://t.me/big_jacky) | |
add_action( 'wp_footer', 'script_passive_event_listeners', 99 ); | |
function script_passive_event_listeners(){ | |
?> | |
<script> | |
(function () { | |
var supportsPassive = eventListenerOptionsSupported(); | |
if (supportsPassive) { |
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
<html lang="ru-RU" itemscope="" itemtype="http://schema.org/WebSite" prefix="og: http://ogp.me/ns#"><!--<![endif]--><head><script src="http://web.archive.org/web/20161202145255js_/https://pagead2.googlesyndication.com/pub-config/r20160913/ca-pub-8922023647388553.js"></script><script async="" src="http://web.archive.org/web/20161202145255/https://www.google-analytics.com/analytics.js"></script><script src="http://web.archive.org/web/20161202145255js_/https://apis.google.com/_/scs/apps-static/_/js/k=oz.gapi.en_US.DCqkg4_f1cE.O/m=plusone/rt=j/sv=1/d=1/ed=1/am=AQ/rs=AGLTcCN29Itx_77YsW7KCcAVebosjZAOGA/cb=gapi.loaded_0" async=""></script><script src="//archive.org/includes/analytics.js?v=cf34f82" type="text/javascript"></script> | |
<script type="text/javascript">window.addEventListener('DOMContentLoaded',function(){var v=archive_analytics.values;v.service='wb';v.server_name='wwwb-app58.us.archive.org';v.server_ms=454;archive_analytics.send_pageview({});});</script><script type="text/javascript" src="/_static/js/playba |
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
<p itemscope itemtype="http://schema.org/ImageObject"> | |
<img itemprop="contentUrl" srcset="1.jpg 1920w, 1-370.jpg 370w, 1-600.jpg 600w" sizes="(max-width: 991px) 370px, 600px" src="1.jpg" alt="Чашка "Победа""> | |
<meta itemprop="width" content="1920px"> | |
<meta itemprop="height" content="1440px"> | |
<meta itemprop="thumbnail" content="http://site.com/cup/1-600.jpg"> | |
<meta itemprop="thumbnail" content="http://site.com/cup/1-370.jpg"> | |
</p> |
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
<p itemscope itemtype="http://schema.org/ImageObject"> | |
<img itemprop="contentUrl" srcset="1.jpg 1920w, 1-370.jpg 370w, 1-600.jpg 600w" sizes="(max-width: 991px) 370px, 600px" src="1.jpg" alt="Чашка "Победа""> | |
<meta itemprop="width" content="1920px"> | |
<meta itemprop="height" content="1440px"> | |
<link sizes="600x600" href="http://site.com/cup/1-600.jpg" type="image/jpg"> | |
<link sizes="370x370" href="http://site.com/cup/1-370.jpg" type="image/jpg"> | |
</p> | |
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
add_filter( 'the_title', 'add_version_to_title', 10); | |
function add_version_to_title( $title ){ | |
$post = get_post(); | |
$title .= " моё какое-то слово" ; | |
return $title; | |
} | |
//И тут внезапно следующая функция дописывает в альт title вложенного изображения + то самое " моё какое-то слово" |
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
/* Делаем alt для Превью поста | |
* Функция автозаполнения alt должна быть отключена в плагинах типа | |
* Webcraftic Clearfy или любом другом, который устанавливает alt автоматически, так как там всегда генерирует на основе заголовка | |
* В некоторых темах, например OceanWP alt прописан как заголовок статьи в самой теме, и там нужно дополнительно кодить | |
* в Astra всё нормально работает | |
*/ | |
add_filter( 'wp_get_attachment_image_attributes', 'add_best_alt_attachment_image', 90, 2 ); | |
function add_best_alt_attachment_image( $attr, $attachment ) { | |
//проверяем не заполнен ли уже alt |
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
add_filter( 'wp_get_attachment_image_attributes', 'xxx_attachment_image', 90, 2 ); | |
function xxx_attachment_image( $attr, $attachment ) { | |
$custom_logo_id = get_theme_mod( 'custom_logo' ); | |
if($attachment->ID == $custom_logo_id) { | |
$attr['data-class'] = $custom_logo_id; | |
$attr['data-hey'] = 'hey'; |
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
//ВАРИАНТ №1 | |
//автозаполнение полей при вставке медиафайлов start | |
function wph_auto_alt_title_caption($attachment_ID) { | |
$filename = $_REQUEST['name']; | |
$withoutExt = preg_replace('/\\.[^.\\s]{3,4}$/', '', $filename); | |
$withoutExt = str_replace(array('-','_'), ' ', $withoutExt); | |
/* Автозаполнение подписи и описания - мне не пригодилось | |
$my_post = array( |
OlderNewer