Skip to content

Instantly share code, notes, and snippets.

View pierre-dargham's full-sized avatar

Pierre Dargham pierre-dargham

View GitHub Profile
@pierre-dargham
pierre-dargham / gist:77602c53c8e50ac32c7b
Last active August 29, 2015 14:26 — forked from corsonr/gist:6367944
WooCommerce - Get featured products IDs
/**
* Function that returns an array containing the IDs of the featured products.
*
* @since 2.0
* @access public
* @return array
*/
function woo_get_featured_product_ids() {
// Load from cache
$featured_product_ids = get_transient( 'wc_featured_products' );
@pierre-dargham
pierre-dargham / ships.oz
Last active June 16, 2016 15:00
Oz Constraint logic programming : 2016-03-21 Exercice 1 (Ships)
% Author: Pierre Dargham
% Author-URI : https://github.com/pierre-dargham
declare
fun {Transport Fleet Number DailyDelayCost}
% Types of ships
Types = {Record.arity Fleet}
proc {Script Solution}
@pierre-dargham
pierre-dargham / queens.oz
Created June 17, 2016 13:53
Oz Constraint logic programming : 2016-03-21 Exercice 2 (Queens)
% Author: Pierre Dargham
% Author-URI : https://github.com/pierre-dargham
declare
fun {Board Width}
proc {Script Solution}
% Board and Cells
@pierre-dargham
pierre-dargham / acf-add-group-field-position-before-title.php
Created October 17, 2016 17:11
ACF Before Title : Adds a choice "High (before title) to ACF field groups position drop-down"
<?php
/*
Plugin Name: ACF Before Title
Description: Adds a choice "High (before title) to ACF field groups position drop-down"
Author: Pierre Dargham
Author URI: https://github.com/pierre-dargham/
Version: 1.0
*/
<?php
/*
Plugin Name: WPG Environment Informations
Description: WPG Environment Informations
Version: 0.1.0
*/
namespace Globalis\EnvironmentInfo;
add_action('admin_bar_menu', __NAMESPACE__.'\\add_environment_info', 10);

La vraie chanson française

Par ordre alphabétique des artistes

Richard Anthony

  • Amoureux de ma femme
  • Et j'entends siffler le train

Hugues Aufray

  • Céline
@pierre-dargham
pierre-dargham / acf-translate-field-groups.php
Last active May 17, 2017 08:08
acf-translate-field-groups.php
<?php
namespace Globalis\ACF;
add_filter('acf/get_field_group', __NAMESPACE__ . '\\acf_translate_field_group');
add_filter('acf/load_field', __NAMESPACE__ . '\\acf_translate_field');
function acf_translate_field_group($field_group) {
if(is_acf_admin()) {
return $field_group;
@pierre-dargham
pierre-dargham / wpg-disable-dopings.php
Created June 30, 2017 14:12
wpg-disable-dopings.php
<?php
namespace Globalis\WP\DisableDoPings;
if (isset($_GET['doing_wp_cron'])) {
remove_action('do_pings', 'do_all_pings');
wp_clear_scheduled_hook('do_pings');
}
@pierre-dargham
pierre-dargham / wp-cubi-helpers.php
Last active August 9, 2017 16:10
wp-cubi-helpers.php
<?php
namespace Globalis\WP\Cubi;
function get_permalink_by_template($template, $default = false)
{
$pages = new \WP_Query([
'posts_per_page' => 1,
'post_type' => 'page',
'post_status' => 'publish',
@pierre-dargham
pierre-dargham / try_retry.php
Last active March 14, 2018 16:19
try / retry (WP)
<?php
namespace Globalis\WP\Retry;
// @todo:
// 1. POO style
// 2. if last try, and fail -> do_action
// 3. if last try : try / catch exception ? if $on_exception : throws exception ?
add_action('event_retry', __NAMESPACE . '\\_try', 10, 7);