Skip to content

Instantly share code, notes, and snippets.

<?php
add_filter('seopress_schemas_mapping_select', 'sp_schemas_mapping_select');
function sp_schemas_mapping_select($select) {
// Add the new group option + option to the list
$select['Custom variables'] = [
'my_custom_var_key' => __('My super custom var', 'wp-seopress-pro'),
'my_repeater_field' => __('ACF Repeater Field', 'wp-seopress-pro'),
];
// Get the ACF repeater field data
@shirokoweb
shirokoweb / .htaccess
Created October 2, 2021 19:45
Resttrict wp-login to IP address
<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 September 20, 2021 17:53
Exclude specifi page(s) from WordPress search results
<?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 ) );
}
@shirokoweb
shirokoweb / footer-scripts.php
Last active April 30, 2020 20:48
mu-footer
@shirokoweb
shirokoweb / cpt.conf
Created April 10, 2020 01:05
YTP debug info
### 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%/
eyJsaXRlc3BlZWQtY2FjaGUtY29uZiI6eyJ2ZXJzaW9uIjoiMi45LjkuMiIsInJhZGlvX3NlbGVjdCI6MSwiYXV0b191cGdyYWRlIjpmYWxzZSwibmV3cyI6ZmFsc2UsInB1cmdlX3VwZ3JhZGUiOnRydWUsImNhY2hlX3ByaXYiOmZhbHNlLCJjYWNoZV9jb21tZW50ZXIiOnRydWUsImNhY2hlX3Jlc3QiOnRydWUsImNhY2hlX3BhZ2VfbG9naW4iOnRydWUsInRpbWVkX3VybHMiOiIiLCJ0aW1lZF91cmxzX3RpbWUiOiIiLCJjYWNoZV9mYXZpY29uIjp0cnVlLCJjYWNoZV9yZXNvdXJjZXMiOnRydWUsIm1vYmlsZXZpZXdfZW5hYmxlZCI6ZmFsc2UsIm1vYmlsZXZpZXdfcnVsZXMiOiJNb2JpbGV8QW5kcm9pZHxTaWxrXC98S2luZGxlfEJsYWNrQmVycnl8T3BlcmFcXCBNaW5pfE9wZXJhXFwgTW9iaSIsImNhY2hlX29iamVjdCI6dHJ1ZSwiY2FjaGVfb2JqZWN0X2tpbmQiOnRydWUsImNhY2hlX29iamVjdF9ob3N0IjoiMTI3LjAuMC4xIiwiY2FjaGVfb2JqZWN0X3BvcnQiOiI2Mzc5IiwiY2FjaGVfb2JqZWN0X2xpZmUiOiIzNjAiLCJjYWNoZV9vYmplY3RfcGVyc2lzdGVudCI6dHJ1ZSwiY2FjaGVfb2JqZWN0X2FkbWluIjp0cnVlLCJjYWNoZV9vYmplY3RfdHJhbnNpZW50cyI6dHJ1ZSwiY2FjaGVfb2JqZWN0X2RiX2lkIjoiMCIsImNhY2hlX29iamVjdF91c2VyIjoiIiwiY2FjaGVfb2JqZWN0X3Bzd2QiOiIiLCJjYWNoZV9icm93c2VyIjp0cnVlLCJjYWNoZV9icm93c2VyX3R0bCI6MjU5MjAwMCwibG9naW5fY29va2llIjoiIiwiY2hlY2tfYWR2YW5jZWRj
@shirokoweb
shirokoweb / instockproducts.php
Last active February 23, 2020 02:01
Affiche uniquement les produits en stock WooCommerce (la case masquer les produits hors stock doit être décochée)
<?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
*/
@shirokoweb
shirokoweb / opti-plug.php
Last active April 30, 2020 21:13
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 April 10, 2021 11:06
MU-USE tarteauciron.js
<?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' );
@shirokoweb
shirokoweb / functions.php
Created November 30, 2019 19:05
WP Rocket's way
<?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');
}