Skip to content

Instantly share code, notes, and snippets.

@shirokoweb
shirokoweb / .htaccess
Created Oct 2, 2021
Resttrict wp-login to IP address
View .htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} ^(.*)?wp-login\.php(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^(.*)?wp-admin$
RewriteCond %{REMOTE_ADDR} !^10\.110\.20\.220$
RewriteCond %{REMOTE_ADDR} !^20\.220\.30\.330$
RewriteRule ^(.*)$ - [R=403,L]
</IfModule>
@shirokoweb
shirokoweb / shut.php
Created Sep 20, 2021
Exclude specifi page(s) from WordPress search results
View shut.php
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
function chut_search_filter( $query ) {
if ( ! $query->is_admin && $query->is_search && $query->is_main_query() ) {
$query->set( 'post__not_in', array( 1,10,110 ) );
}
View footer-scripts.php
View cpt.conf
### Begin Custom Post Type UI Debug Info ###
Multisite: No
SITE_URL: https://xxx.tld
HOME_URL: https://xxx.tld
WordPress Version: 5.4
Permalink Structure: /index.php/%year%/%monthnum%/%day%/%postname%/
View LSWP_cfg.data
eyJsaXRlc3BlZWQtY2FjaGUtY29uZiI6eyJ2ZXJzaW9uIjoiMi45LjkuMiIsInJhZGlvX3NlbGVjdCI6MSwiYXV0b191cGdyYWRlIjpmYWxzZSwibmV3cyI6ZmFsc2UsInB1cmdlX3VwZ3JhZGUiOnRydWUsImNhY2hlX3ByaXYiOmZhbHNlLCJjYWNoZV9jb21tZW50ZXIiOnRydWUsImNhY2hlX3Jlc3QiOnRydWUsImNhY2hlX3BhZ2VfbG9naW4iOnRydWUsInRpbWVkX3VybHMiOiIiLCJ0aW1lZF91cmxzX3RpbWUiOiIiLCJjYWNoZV9mYXZpY29uIjp0cnVlLCJjYWNoZV9yZXNvdXJjZXMiOnRydWUsIm1vYmlsZXZpZXdfZW5hYmxlZCI6ZmFsc2UsIm1vYmlsZXZpZXdfcnVsZXMiOiJNb2JpbGV8QW5kcm9pZHxTaWxrXC98S2luZGxlfEJsYWNrQmVycnl8T3BlcmFcXCBNaW5pfE9wZXJhXFwgTW9iaSIsImNhY2hlX29iamVjdCI6dHJ1ZSwiY2FjaGVfb2JqZWN0X2tpbmQiOnRydWUsImNhY2hlX29iamVjdF9ob3N0IjoiMTI3LjAuMC4xIiwiY2FjaGVfb2JqZWN0X3BvcnQiOiI2Mzc5IiwiY2FjaGVfb2JqZWN0X2xpZmUiOiIzNjAiLCJjYWNoZV9vYmplY3RfcGVyc2lzdGVudCI6dHJ1ZSwiY2FjaGVfb2JqZWN0X2FkbWluIjp0cnVlLCJjYWNoZV9vYmplY3RfdHJhbnNpZW50cyI6dHJ1ZSwiY2FjaGVfb2JqZWN0X2RiX2lkIjoiMCIsImNhY2hlX29iamVjdF91c2VyIjoiIiwiY2FjaGVfb2JqZWN0X3Bzd2QiOiIiLCJjYWNoZV9icm93c2VyIjp0cnVlLCJjYWNoZV9icm93c2VyX3R0bCI6MjU5MjAwMCwibG9naW5fY29va2llIjoiIiwiY2hlY2tfYWR2YW5jZWRj
@shirokoweb
shirokoweb / instockproducts.php
Last active Feb 23, 2020
Affiche uniquement les produits en stock WooCommerce (la case masquer les produits hors stock doit être décochée)
View instockproducts.php
<?php
/**
* @snippet Shortcode pour exclure les produits hors stock - WooCommerce
* @author-url https://webplus.agency
* @author Agence WebPlus
* @compatible WooCommerce 3.8
* @usage [in_stock_products]
* @wc-shortcodes https://github.com/woocommerce/woocommerce/blob/dc7aa3069466f1b7e23fd7ef468760a6a9ddd241/includes/class-wc-shortcodes.php
*/
View opti-plug.php
<?php
/**
* @snippet Conditional plugin load.
* @author Agence WebPlus
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
@shirokoweb
shirokoweb / tac.php
Last active Apr 10, 2021
MU-USE tarteauciron.js
View tac.php
<?php
// securiser l'accès au fichier
if ( ! defined( 'ABSPATH' ) ) exit;
// Chargement TAC
add_action( 'wp_enqueue_scripts', 'webplus_tac_load' );
function webplus_tac_load() {
wp_enqueue_script( 'tarteaucitron', 'https://cdn.jsdelivr.net/gh/AmauriC/tarteaucitron.js@1.3/tarteaucitron.min.js' );
View functions.php
<?php
/** Disable Ajax Call from WooCommerce on front page and posts*/
add_action( 'wp_enqueue_scripts', 'dequeue_woocommerce_cart_fragments', 11);
function dequeue_woocommerce_cart_fragments() {
if (is_front_page() || is_single() ) wp_dequeue_script('wc-cart-fragments');
}
@shirokoweb
shirokoweb / functions.php
Created Nov 30, 2019
WordPress shutdown hook to disable WooCommerce get_refreshed_fragments
View functions.php
<?php
/** Disable Ajax Call from WooCommerce on front page, posts, categories, and tags*/
add_action( 'shutdown', 'dequeue_woocommerce_cart_fragments');
function dequeue_woocommerce_cart_fragments() {
if (is_front_page() || is_single() || is_category() || is_tag() ) wp_dequeue_script('wc-cart-fragments');
}