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 / woocommerce-custom-checkout-fields.php
Created Dec 28, 2019
Add custom WooCommerce checkout fields, add an extra fee to the cart, validate the fields before processing the order and save them on the order metadata.
View woocommerce-custom-checkout-fields.php
<?php
/**
* Plugin Name: WooCommerce Custom Checkout Fields
* Description: Add some custom "emergency level" extra fields on the WooCommerce Checkout page. Save this custom data in each order metadata.
* Author: Pierre Saïkali
* Author URI: https://saika.li
* Text Domain: wc_ccf
* Domain Path: /languages/
* Version: 1.0.0
* Full Tutorial: https://mosaika.fr/personnaliser-tunnel-commande-woocommerce/
@psaikali
psaikali / cf7-woocommerce-order-field.php
Created Dec 27, 2019
Create a new [wc_order] Contact Form 7 field tag which can only accept a valid WooCommerce order number.
View cf7-woocommerce-order-field.php
<?php
/**
* Plugin Name: Contact Form 7 WooCommerce Order Select Field
* Description: Use the <code>[wc_order]</code> field in CF7 forms
* Author: Pierre Saïkali
* Author URI: https://saika.li
* Text Domain: cf7wcp
* Domain Path: /languages/
* Version: 1.0.0
*/
@psaikali
psaikali / acf-gravity-forms-field.php
Created Jan 4, 2019
Populate ACF select field options with Gravity Forms to select a specific form
View acf-gravity-forms-field.php
<?php
/**
* Populate ACF select field options with Gravity Forms forms
*/
function acf_populate_gf_forms_ids( $field ) {
if ( class_exists( 'GFFormsModel' ) ) {
$choices = [];
foreach ( \GFFormsModel::get_forms() as $form ) {
$choices[ $form->id ] = $form->title;
@psaikali
psaikali / as3cf-update_products_downloadable_files.php
Last active May 21, 2019
Process WooCommerce products and set correct downloadable files if they've been offloaded by WP Offload Media
View as3cf-update_products_downloadable_files.php
<?php
namespace Mosaika;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Register our custom commands.
@psaikali
psaikali / custom_wc_get_products_parameters.php
Last active Mar 3, 2019
Ajouter de nouveaux paramètres de requête à wc_get_products()
View custom_wc_get_products_parameters.php
<?php
namespace Mosaika;
/**
* Handle a custom 'vendor' query var to get products of a specific Vendor.
* Handle a custom 'featured_by_vendor' query var to get featured products of a specific Vendor.
*
* @param array $query_args - WP_Query args
* @param array $query_vars - WC_Product_Query args
@psaikali
psaikali / 1mailchimp-wp-fonction.php
Last active Jan 20, 2019
WordPress : comment inscrire un nouvel utilisateur dans une liste MailChimp ?
View 1mailchimp-wp-fonction.php
<?php
namespace MSK\Blog\Mailchimp;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Inscrit un utilisateur dans une liste MailChimp
*
@psaikali
psaikali / inspect-wordpress-hooks.php
Last active Jan 5, 2019
List all functions hooked on a specific hook. No need to have the specific hook name, just pass one or multiple strings contained in the hook name.
View inspect-wordpress-hooks.php
<?php
/**
* Inspect/list functions called on hooks containing specific term
*
* @param array Array of terms that the hook should contain
* @return array
*/
function inspect_hooks( $terms = [ 'wp_' ] ) {
global $wp_filter;
$related_hooks = [];
@psaikali
psaikali / gravity-forms-process-form-if-matches-acf-option.php
Created Jan 4, 2019
Intercept specific Gravity Forms form submission and process it only if it's the one we want
View gravity-forms-process-form-if-matches-acf-option.php
<?php
/**
* Intercept form submission and process it
*/
function gf_intercept_form_submission( $data, $form ) {
if ( (int) $form['id'] !== (int) get_field( 'submit_project_gf_form_id', 'option' ) ) {
return;
}
// Do something with $data
@psaikali
psaikali / fix-wordpress-permissions.sh
Last active Apr 25, 2018 — forked from Adirael/fix-wordpress-permissions.sh
Fix wordpress file permissions
View fix-wordpress-permissions.sh
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
@psaikali
psaikali / 6fields_update_sanitize_wysiwyg.php
Last active Mar 5, 2018
Nettoyer la valeur des WYSIWYG de champs ACF avant leur enregistrement dans la base de données
View 6fields_update_sanitize_wysiwyg.php
<?php
// Article/tutoriel complet sur https://mosaika.fr/astuces-developpement-acf/
// Documentation officielle https://www.advancedcustomfields.com/resources/acf-validate_value/
/**
* Nettoyer/sécuriser la valeur d'un champ WYSIWYG
* Filtre : acf/update_value
*/
You can’t perform that action at this time.