Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Amaury Balmer herewithme

Block or report user

Report or block herewithme

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
@herewithme
herewithme / wpcli-db-charset.sh
Created Feb 20, 2019
Convert all WordPress tables to UTF8MB4 with WP-CLI
View wpcli-db-charset.sh
#!/usr/bin/env bash
# Author Amaury Balmer - BEAPI.fr
# See: https://wordpress.stackexchange.com/questions/195046/relaunch-4-2-utf8mb4-databse-upgrade/244992#244992
# Purpose - Convert all tables to UTF8MB4 with WP-CLI
# Create array of all tables
WPTABLES=($(wp db tables --all-tables))
# loop through array and alter tables
for WPTABLE in ${WPTABLES[@]}
@herewithme
herewithme / script.sh
Created Nov 19, 2018
Set a role for each users for all sites for WordPress Multisite
View script.sh
for url in $( wp site list --allow-root --field="url" --url="https://XXX" );
do
echo $url;
wp --allow-root user list --network --url="https://XXX" --field=id | xargs -I % wp --allow-root user set-role % administrator --url=$url
done;
@herewithme
herewithme / wpforms-pattern-french-phone.php
Last active Nov 9, 2018
An addon for WPForms plugin, allow to force and valid french format phone number for the field with the class: "wp-forms-check-phone-number"
View wpforms-pattern-french-phone.php
<?php
/**
* Plugin Name: WPforms - French Phone Validation
* Plugin URI: https://beapi.fr
* Description: Add JS and PHP check for validate french number, supported formats : +33123456789 and 0123456789
* Version: 0.2
* Author: BE API
* Author URI: https://beapi.fr
*/
@herewithme
herewithme / acf-functions-helper.php
Last active Feb 14, 2018
ACF template helper - Checks if at least one field is completed by BO for display or not a block
View acf-functions-helper.php
<?php
/**
* This function checks if at least one field is completed by BO
*
* @param array|string $fields the list of ACF fields to test, an array or a string of text separated by a comma
* @param mixed $object the post_id of which the value is saved against
* @param bool $is_sub_field
*
* @return bool
*/
@herewithme
herewithme / bench-memcached.php
Created Dec 3, 2015
Benchmark for test memcached performance
View bench-memcached.php
<?php
// Initialize values: 1000000 keys of 20 bytes with 40 bytes of data
$c = 1000000;
$values = array();
for ($i=0;$i<$c;$i++) $values[sprintf('%020s',$i)]=sha1($i);
// Memcached
$m = new Memcached();
$m->addServer('10.0.101.82', 11211);
$start = microtime(true);
@herewithme
herewithme / force-domain-mapping.php
Last active Dec 1, 2015
Force replace original domain by mapped domain for WPMU Domain Mapping
View force-domain-mapping.php
<?php
/*
Plugin Name: BEA Domain Mapping
Description: Always force replace original domain by mapping domain
Plugin URI: http://www.beapi.fr
Version: 1.0
Author: BeAPI
Author URI: http://www.beapi.fr
/*
@herewithme
herewithme / prod-images.php
Last active Mar 31, 2019
This plugin allow to build development environnement without copy data from uploads folder. Manage an failback with PHP and production assets.
View prod-images.php
<?php
/*
* Plugin Name: BEA - Prod images
* Version: 0.1
* Plugin URI: http://www.beapi.fr
* Description: This plugin allow to build development environnement without copy data from uploads folder. Manage an failback with PHP and production assets.
* Author: BeAPI
* Author URI: http://www.beapi.fr
* Domain Path: languages
* Network: false
@herewithme
herewithme / wp-rocket-purge-all.php
Last active Feb 4, 2019
Purge all WP rocket cache when a post is modified/edited
View wp-rocket-purge-all.php
<?php
/*
Plugin Name: Purge all WP Rocket cache
Plugin URI: http://www.beapi.fr
Description: Purge all WP rocket cache when a post is modified/edited
Version: 1.0
Author: BeAPI
Author URI: http://www.beapi.fr
Network: true
*/
@herewithme
herewithme / varnish-purge-all.php
Last active Feb 16, 2016
Internal usage -- Purge all varnish when WP changes any content
View varnish-purge-all.php
<?php
/*
Plugin Name: Purge all varnish
Plugin URI: http://www.beapi.fr
Description: Purge all varnish cache when a post is modified/edited
Version: 1.3
Author: BeAPI
Author URI: http://www.beapi.fr
Network: true
*/
@herewithme
herewithme / gist:fb65d93ca9c8a2c5cf1b
Created Jun 2, 2015
Force english on WP admin !
View gist:fb65d93ca9c8a2c5cf1b
<?php
/*
Plugin Name: Languages Admin
Plugin URI: http://www.beapi.fr
Description: Force English on WP admin
Author: BeAPI
Author URI: http://www.beapi.fr
Version: 0.1
Text Domain: bea-languages
You can’t perform that action at this time.