Skip to content

Instantly share code, notes, and snippets.

View renakdup's full-sized avatar
I'm Yoda

Andrei Pisarevskii renakdup

I'm Yoda
View GitHub Profile
@renakdup
renakdup / detect-swipe-event.js
Last active December 12, 2022 23:57
JavaScript
// Detect swipe event. Detect touch swipe event.
// Example
detectSwipeEvent(document.getElementsByClassName('js-mobile-nav__background')[0], function (orientation) {
console.log(orientation)
});
/**
* @param element js element
* @param callback Your callback invoke on swipe event. Attribute "swipe orientation" transfer to callback.
*/
@renakdup
renakdup / disable-comments.php
Last active December 12, 2022 23:59
WordPress
<?php
// Wordpress Disable Comments (add to function.php)
add_action('admin_init', function () {
// Redirect any user trying to access comments page
global $pagenow;
if ($pagenow === 'edit-comments.php') {
wp_redirect(admin_url());
@renakdup
renakdup / register_cpt_and_taxonomy.php
Last active December 12, 2022 23:42
WordPress entities
<?php
// Register Custom Post Type
function product_post_type() {
$labels = array(
'name' => _x( 'Каталог мебели', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Товар', 'Post Type Singular Name', 'text_domain' ),
'menu_name' => __( 'Товары', 'text_domain' ),
'parent_item_colon' => __( '!!!', 'text_domain' ),
@renakdup
renakdup / Instructions.sh
Last active December 26, 2019 22:10 — forked from GhazanfarMir/Instructions.sh
Install PHP7.2 NGINX and PHP7.2-FPM on Ubuntu 16.04
########## Install NGINX ##############
# Install software-properties-common package to give us add-apt-repository package
sudo apt-get install -y software-properties-common
# Install latest nginx version from community maintained ppa
sudo add-apt-repository ppa:nginx/stable
# Update packages after adding ppa
for ($i=0; $i<100; $i++) {
echo "\r"; # The main character for console.
echo "$i/100";
}
@renakdup
renakdup / phpcs.xml
Last active December 12, 2022 23:46
WordPress tooling
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards">
<description>A custom set of code standard rules to check for WordPress plugins.</description>
<config name="testVersion" value="7.3"/>
<!-- How to scan -->
<!-- Show sniff and progress -->
<arg value="sp"/>
<!-- Strip the file paths down to the relevant bit -->
<arg name="basepath" value="./"/>
@renakdup
renakdup / adminpanel-env-color.php
Last active March 17, 2024 12:53
Adminpanel environment color for WordPress.
<?php
/**
* Adminpanel environment color for WordPress.
* It helps to highlight environments in color. Developers, Content Managers,
* and others will never confuse the environment where they work.
*
* Author: Andrei Pisarevskii
* Author Email: renakdup@gmail.com
* Author Site: https://wp-yoda.com/en/
*