Skip to content

Instantly share code, notes, and snippets.

🥑
WordPress'ing

Pierre Saikali psaikali

View GitHub Profile
@psaikali
psaikali / as3cf-update_products_downloadable_files.php
Last active Apr 18, 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 / 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 / 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 / 8fields_update_erase_data.php
Created Mar 4, 2018
Ne pas enregistrer la valeur d'un champ ACF
View 8fields_update_erase_data.php
<?php
// Article/tutoriel complet sur https://mosaika.fr/astuces-developpement-acf/
// Documentation officielle https://www.advancedcustomfields.com/resources/acf-update_value/
/**
* Comparer la valeur de 2 champs pour accepter/refuser leur validation
* Filtre : acf/update_value
*/
@psaikali
psaikali / 7fields_update_save_data_elsewhere.php
Created Mar 4, 2018
Enregistrer d'autres champs metas lorsque ACF enregistre un post
View 7fields_update_save_data_elsewhere.php
<?php
// Article/tutoriel complet sur https://mosaika.fr/astuces-developpement-acf/
// Documentation officielle https://www.advancedcustomfields.com/resources/acf-save_post/
/**
* Enregistrer la variable d'un champ dans un autre champ du post
* Filtre : acf/save_post
*/
@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.