Skip to content

Instantly share code, notes, and snippets.

@Glinkfr
Glinkfr / function.php
Last active June 27, 2023 12:03
Création du shortcode pour afficher l'année en cours par exemple dans le footer
/**
* Création du shortcode Année en cours.
*/
// utilisez [year] dans vos widgets, pages, articles ou votre footer
function shortcode_year() {
$year = date('Y');
return $year;
}
add_shortcode('year', 'shortcode_year');
@Glinkfr
Glinkfr / function.php
Created May 3, 2023 11:09
function.php Modifie l'apparence de l'administration pour les administrateurs sauf pour un seul administrateur dont le pseudonyme est CHANGE_PSEUDONYME)
<?php
/**
* Modifie l'apparence de l'administration pour les administrateurs sauf pour un seul administrateur (CHANGE_PSEUDONYME)
*/
//On récupère les infos sur l'utilisateur
$current_user = wp_get_current_user();
//On verifie que l'utilisateur connecté est un administrateur dont le pseudonyme n'est pas 'CHANGE_PSEUDONYME'
if (
@Glinkfr
Glinkfr / function.php
Created May 3, 2023 10:47
Function.php Snippets to Modify admin area Administrator rights and appearance except for a specific Administrator username (CHANGE_USERNAME)
<?php
/**
* Modify admin rights and appearance except for a specific administrator username (CHANGE_USERNAME)
*/
$current_user = wp_get_current_user();
//Checking if the current user has the 'administrator' role and their username is not 'CHANGE_USERNAME'
if (
in_array("administrator", $current_user->roles) &&
$current_user->user_login !== "CHANGE_USERNAME"
) {
@Glinkfr
Glinkfr / function.php
Created November 23, 2022 08:14
Code à ajouter au fichier function du theme enfant afin de régler le problème d'affichage des boutons PayPal avec WooCommerce et Divi
add_filter('woocommerce_paypal_payments_single_product_renderer_hook', function() {
return 'woocommerce_after_add_to_cart_form';
});
@Glinkfr
Glinkfr / function.php
Created November 23, 2022 07:56
Position par défaut des boutons PayPal sur la page du produit
add_filter('woocommerce_paypal_payments_single_product_renderer_hook', function() {
return 'woocommerce_after_add_to_cart_button';
});
@Glinkfr
Glinkfr / function.php
Created November 23, 2022 06:29
Creation d'un shortcode wordpress pour pour utiliser le fil d'Ariane du plugin NavXT Breadcrumb
function glink_bcn() {
echo '<div class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">';
echo bcn_display() . '</div>';
}
add_shortcode('glink_bcn', 'glink_bcn');
<?php
/**
* @since 3.6.5
*/
class WPBDP_NavXT_Integration{
private $state = array();
private $doing = '';
@Glinkfr
Glinkfr / wpbdp-navxt-integration.php
Created May 25, 2020 09:31
Plugin pour Intégrer NavXT Breadcrumb Plugin à Business Directory Plugin
<?php
/*
Plugin Name: wpbdp navxt integration
Plugin URI: https://www.glink.fr
Version: 1.0.0
Author: L. Perderiset and Business Directory Team
Description: Better integration of NavXT Breadcrumb Plugin with Business Directory Plugin
Author URI: https://www.glink.fr
*/
// ajoute la nouvelle class au plugin BD APRES la suppression grâce à la priorité 999
add_action('wpbdp_loaded', function(){new WPBDP_NavXT_Integration_glink();}, 999);
// supprime toutes les actions de BD sur le plugin NavXT
add_action( 'wpbdp_loaded', function(){
remove_all_actions('bcn_before_fill');
remove_all_actions('bcn_after_fill');
});