Skip to content

Instantly share code, notes, and snippets.

@Shoora
Shoora / nginx-wordpress.conf
Created May 3, 2024 12:07 — forked from nfsarmento/nginx-wordpress.conf
Harden wordpress security nginx
############ WordPress ####################
# Disable logging for favicon and robots.txt
location = /favicon.ico {
try_files /favicon.ico @empty;
access_log off;
log_not_found off;
expires max;
}
# Install dependencies
#
# * checkinstall: package the .deb
# * libpcre3, libpcre3-dev: required for HTTP rewrite module
# * zlib1g zlib1g-dbg zlib1g-dev: required for HTTP gzip module
apt-get install checkinstall libpcre3 libpcre3-dev zlib1g zlib1g-dbg zlib1g-dev && \
mkdir -p ~/sources/ && \
# Compile against OpenSSL to enable NPN
@Shoora
Shoora / ywactivitytracker.js
Last active April 7, 2024 22:22 — forked from dvygolov/ywactivitytracker.js
Script that measures interactions on your landing page. If the user is active for "checkTime" seconds - an interval is valid, if total count of valid seconds = totalTime - the goal is reached and sent to Yandex.Metrika.
class ActivityTracker {
constructor(totalTime, checkTime, metrikaId, debug = false) {
this.events = [
"touchmove",
"blur",
"focus",
"focusin",
"focusout",
"load",
"resize",
@Shoora
Shoora / jquery.inline.anchor.navigation.js
Last active April 7, 2024 22:11 — forked from glueckpress/jquery.inline.anchor.navigation.js
[JavaScript][jQuery] Inline Anchor Navigation: Adds a smooth scroll effect to URLs containing a hash (#). Excludes single hashes, #respond (WordPress comment forms), and orphaned hash characters at the end of a URL.
/**
* jQuery Inline Anchor Navigation
*
* Adds a smooth scroll effect to URLs containing a hash (#).
* Excludes single hashes, #respond (WordPress comment forms), and orphaned
* hash characters at the end of a URL.
*/
(function($) {
$('a[href*="#"]')
.not('a[href="#"]') // Excemption #1: dummy hrefs
@Shoora
Shoora / admin-redirect
Created March 25, 2024 05:05 — forked from miziomon/admin-redirect
WordPress user admin redirect
/**
*
* redirect to homepage if has non "edit_posts" capabilities
*/
add_filter("admin_init", function () {
if (!current_user_can('edit_posts')) {
wp_redirect(WP_HOME);
exit;
@Shoora
Shoora / index.html
Created November 13, 2019 15:14 — forked from onizuka17/index.html
Slider and Lightbox :: slider (swiper.js) & Lightbox gallery (photoswipe.js)
<h1>
<a title="swiper.js" href="http://idangero.us/swiper/" target="_blank">Swiper.js (4.3.5)</a>
&
<a title="photoswipe" href="http://photoswipe.com/" target="_blank">Photoswipe.js (4.1.1)</a>
- Mobile Native feel slider gallery
</h1>
<p>Combine two of the most powerfull JS plugins (Endless options / Great docs / Fast / Modern / Mobile freindly) - <a title="swiper.js" href="http://idangero.us/swiper/" target="_blank">SWIPER</a> IS PERFECT FOR THIS IDEA BEACUSE OF ITS unique <code>preventClicks</code> Parameter (Prevent accidental unwanted clicks on links during swiping) - <strong>Works like magic</strong>. Also its really <b>hard</b> to find - Code example of working photoswipe combination with any slider out there(slick, flickity, owl etc.) and in general slider & lightbox - so i hope this example be usefull for you.</p>
<!-- Slider main container -->
<div class="swiper-container">
@Shoora
Shoora / Preload CSS - Not blocking CSS.html
Created January 3, 2024 20:17 — forked from thedaviddias/Preload CSS - Not blocking CSS.html
Preload CSS and don't block the DOM with your CSS file request.
<link rel="preload" href="css/global.min.css" as="style" onload="this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="css/global.min.css"></noscript>
<script>
/*! loadCSS. [c]2017 Filament Group, Inc. MIT License */
!function(a){"use strict";var b=function(b,c,d){function j(a){if(e.body)return a();setTimeout(function(){j(a)})}function l(){f.addEventListener&&f.removeEventListener("load",l),f.media=d||"all"}var g,e=a.document,f=e.createElement("link");if(c)g=c;else{var h=(e.body||e.getElementsByTagName("head")[0]).childNodes;g=h[h.length-1]}var i=e.styleSheets;f.rel="stylesheet",f.href=b,f.media="only x",j(function(){g.parentNode.insertBefore(f,c?g:g.nextSibling)});var k=function(a){for(var b=f.href,c=i.length;c--;)if(i[c].href===b)return a();setTimeout(function(){k(a)})};return f.addEventListener&&f.addEventListener("load",l),f.onloadcssdefined=k,k(l),f};"undefined"!=typeof exports?exports.loadCSS=b:a.loadCSS=b}("undefined"!=typeof global?global:this);
/*! loadCSS rel=preload po
@Shoora
Shoora / wp-schema-pro-filter-blog-posting.php
Created January 3, 2024 17:18 — forked from mihdan/wp-schema-pro-filter-blog-posting.php
Расширяет микроразметку BlogPosting в плагине WP Schema Pro для получения контентной аналитики (дочитываемость, категории, автора, тематики) в Яндекс.Метрике
<?php
add_filter(
'wp_schema_pro_schema_article',
/**
* Расширяет микроразметку BlogPosting для Яндекс.Метрики.
*
* @link https://metrika.yandex.ru/support/metrica/publishers/schema-org/json-ld.html#json-ld__identifier-desc
*
* @param array $schema Схема.
* @param array $data Данные.
@Shoora
Shoora / waitForYm.js
Created January 3, 2024 16:48 — forked from kernusr/waitForYm.js
Ожидание загрузки счетчика Яндекс.Метрики
/** Ожидание загрузки счетчика Яндекс.Метрики
* @param {?(number|string)} ymCounterNum - номер счетчика, если известен
* @param {function} callback - получает аргументами объект и номер счетчика
* @param {number} interval - интервал проверки готовности счетчика
*/
function waitForYm(ymCounterNum, callback, interval) {
if (!callback) return;
if (!ymCounterNum) {
let metrikaObj = (window.Ya && (window.Ya.Metrika || window.Ya.Metrika2)) || null;
ymCounterNum = (metrikaObj && metrikaObj.counters && (metrikaObj.counters() || [0])[0].id) || 0;