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 / functions.php
Last active August 24, 2022 13:10
Sample functions.php
<?php
// remove API access
// https://developer.wordpress.org/rest-api/using-the-rest-api/frequently-asked-questions/
add_filter( 'rest_authentication_errors', function( $result ) {
if ( ! empty( $result ) ) {
return $result;
}
if ( ! is_user_logged_in() ) {
return new WP_Error( 'rest_not_logged_in', 'You are not currently logged in.', array( 'status' => 401 ) );
@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 / 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' );
<script>
var et_site_url = 'http://webhostingdivi.site';
var et_post_id = '193';
function et_core_page_resource_fallback(a, b) {
"undefined" === typeof b && (b = a.sheet.cssRules && 0 === a.sheet.cssRules.length);
b && (a.onerror = null, a.onload = null, a.href ? a.href = et_site_url + "/?et_core_page_resource=" + a.id + et_post_id : a.src && (a.src = et_site_url + "/?et_core_page_resource=" + a.id + et_post_id))
}
</script>
<title>Divi hosting home | Premium Divi Web Hosting</title>
@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 / 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%/
@shirokoweb
shirokoweb / videomodule.html
Last active March 5, 2020 23:33
Code Module for YT videos
<a class="ppyt" href="https://www.youtube.com/watch?v=s1T9bWKJW_g">
<img src="http://webplus.odns.fr/wp-content/uploads/2018/02/video-overlay.jpg" width="800" height="534" alt="" class="" />
</a>