Skip to content

Instantly share code, notes, and snippets.

🥑
WordPress'in & React'in

Pierre Saikali psaikali

🥑
WordPress'in & React'in
Block or report user

Report or block psaikali

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@psaikali
psaikali / functions.php
Last active Aug 29, 2015
On enregistre un nouvel onglet ...
View functions.php
function msk_add_love_product_tab($tabs) {
$tabs['love_tab'] = array(
'title' => __('Popularity', 'msk'),
'priority' => 15,
'callback' => 'msk_add_love_product_tab_content'
);
return $tabs;
@psaikali
psaikali / functions.php
Created May 13, 2015
... puis on définit le contenu de ce nouvel onglet
View functions.php
function msk_add_love_product_tab_content() {
wc_get_template('single-product/tabs/love-product.php');
}
@psaikali
psaikali / love-product.php
Created May 13, 2015
... puis on définit le contenu de ce nouvel onglet
View love-product.php
<?php
/**
* "I absolutely love this product" tab
* yourtheme/woocommerce/single-product/tabs/love-product.php
* @author Mosaika
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
@psaikali
psaikali / functions.php
Last active Aug 29, 2015
On supprime l'onglet tab "Information complémentaire", on renomme l'onglet "Description" et "Avis" et on change l'ordre de la tab "Description"
View functions.php
function msk_remove_additionalinfo_tab($tabs) {
unset($tabs['additional_information']);
$tabs['description']['title'] = __('Details', 'msk');
$tabs['reviews']['title'] = __( 'Clients reviews', 'msk' );
$tabs['description']['priority'] = 50;
return $tabs;
}
add_filter('woocommerce_product_tabs', 'msk_remove_additionalinfo_tab', 10);
@psaikali
psaikali / woocommerce-input-helpers.php
Created Jun 4, 2015
Ajouter des champs aux produits WooCommerce : les fonctions helper à disposition pour générer les inputs. Résultat : http://img.saika.li/bWk6
View woocommerce-input-helpers.php
/*************************************************************************************************
* On ajoute des champs de test pour se repérer, dans l'onglet Général
* Résultat visuel : http://img.saika.li/bWk6
*************************************************************************************************/
function msk_add_test_field_data() {
echo '<div style="background:#f8fbca; padding:1em;">';
echo '<h4>Testons les différents types de champs</h4>';
// Champ de type text
@psaikali
psaikali / functions.php
Created Jun 4, 2015
On ajoute deux champs de type text à l'onglet "Avancé" de la metabox produit WooCommerce
View functions.php
/*************************************************************************************************
* On ajoute 2 champs (post meta ou custom field) aux produits WC dans l'onglet "Avancé"
*************************************************************************************************/
function msk_add_loves_hates_fields_to_product() {
woocommerce_wp_text_input(
array(
'id' => 'loves',
'data_type' => 'decimal',
'label' => __('Loves', 'msk'),
'placeholder' => __('Amount of love', 'msk'),
@psaikali
psaikali / functions.php
Created Jun 4, 2015
Enregistrer les valeurs des nouveaux champs produits WooCommerce
View functions.php
/*************************************************************************************************
* On enregistre les valeurs de LOVES & HATES lorsqu'on enregistre un post
*************************************************************************************************/
function msk_save_loves_hates_product_fields($product_id, $post, $update) {
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return;
if ($post->post_type == 'product') {
if (isset($_POST['loves'])) {
$loves = (int)$_POST['loves'];
update_post_meta($product_id, 'loves', $loves);
@psaikali
psaikali / sale-flash.php
Created Jun 27, 2015
WordPress WooCommerce : afficher le (plus grand) pourcentage de réduction dans le macaron de promo d'un produit (woocommerce/loop/sale-flash.php)
View sale-flash.php
<?php
/**
* Single Product Sale Flash
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 1.6.4
*/
if ( ! defined( 'ABSPATH' ) ) {
@psaikali
psaikali / delete_woocommerce_product_image_sizes.php
Last active Apr 2, 2017
Supprimer les tailles d'images media créées par WooCommerce sur les produits
View delete_woocommerce_product_image_sizes.php
/**
* Remove WC image sizes, useless
*/
function msk_wc_remove_image_sizes() {
remove_image_size('shop_thumbnail');
remove_image_size('shop_catalog');
remove_image_size('shop_single');
}
add_action('init', 'msk_wc_remove_image_sizes', 90);
@psaikali
psaikali / 0usage.php
Last active Apr 2, 2017
Utiliser des jolis templates d'e-mails dans WordPress et remplacer des mots par des variables
View 0usage.php
<?php
/*
* Usage de la fonction msk_send_mail
*/
$destinataire = 'pierre@mosaika.fr';
$data = array(
'prenom' => 'Bruce',
You can’t perform that action at this time.