Skip to content

Instantly share code, notes, and snippets.

View guillaumemolter's full-sized avatar

Guillaume Molter guillaumemolter

View GitHub Profile
@guillaumemolter
guillaumemolter / plugin.php
Last active January 30, 2020 16:04
ACF JSON Example
<?php
define( 'HSPH_PLUGIN_ASSETS_PATH', plugin_dir_path( __FILE__ ) . 'assets/' );
/**
* Saving ACF fields to assets folder.
*
* @return String The path where to save ACF json fields.
*/
add_filter(
@guillaumemolter
guillaumemolter / composer.json
Created August 5, 2019 18:32
WordPress management Composer workflow
{
"name": "",
"description": "",
"type": "project",
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
}
],
@guillaumemolter
guillaumemolter / stats.php
Created July 15, 2019 18:07
WordPress multisite content freshness report
<?php
// To run it, place into web root and then `wp eval-file stats.php > ~/stats.csv`
global $wpdb;
$sites = $wpdb->get_results( "SELECT blog_id,domain,path,last_updated FROM {$wpdb->prefix}blogs",'ARRAY_A' );
foreach( $sites as &$site){
if($site['blog_id'] === '1'){
$post_table = $wpdb->prefix . 'posts';
} else {
$post_table = $wpdb->prefix . absint($site['blog_id']) . '_posts';
}
@guillaumemolter
guillaumemolter / tagging_topics_post_types.php
Last active February 24, 2019 13:33
Adding multisite taxonomy support to custom post types.
<?php
add_filter( 'hsph_plugin_tagging_topics_post_types', 'cchange_register_cpt_for_tagging' );
add_filter( 'hsph_plugin_tagging_cchange_issues_post_types', 'cchange_register_cpt_for_tagging' );
add_filter( 'hsph_plugin_tagging_cchange_subtopics_post_types', 'cchange_register_cpt_for_tagging' );
function cchange_register_cpt_for_tagging( $post_types = array() ) {
// Array of custom post types.
$cutom_post_types = array( 'cchange_article', 'cchange_issue', 'cchange_subtopic', 'cchange_bio', 'cchange_class', 'cchange_event' );
// Merging default post types and custom post types.
$post_types = array_merge( $post_types, $cutom_post_types );
vagrant up
Bringing machine 'homestead-7' up with 'virtualbox' provider...
==> homestead-7: Importing base box 'laravel/homestead'...
==> homestead-7: Matching MAC address for NAT networking...
==> homestead-7: Checking if box 'laravel/homestead' version '7.0.0' is up to date...
==> homestead-7: Setting the name of the VM: homestead-7
==> homestead-7: Clearing any previously set network interfaces...
==> homestead-7: Preparing network interfaces based on configuration...
homestead-7: Adapter 1: nat
homestead-7: Adapter 2: hostonly
homestead $ vagrant destroy
==> homestead-7: Running triggers before destroy ...
==> homestead-7: Running trigger...
==> homestead-7: Backing up mysql database socket_wrench...
homestead-7: Running: inline script
==> homestead-7: Running trigger...
==> homestead-7: Backing up postgres database socket_wrench...
homestead-7: Running: inline script
==> homestead-7: Running trigger...
==> homestead-7: Backing up mysql database labpoint...
@guillaumemolter
guillaumemolter / nginx.default.conf
Last active November 6, 2018 20:32 — forked from sumardi/nginx.default.conf
Install PHP-FPM and Nginx on EC2 with Amazon Linux AMI
# Install linux update, followed by GCC and Make
sudo yum -y update
# Install Nginx and PHP-FPM
sudo yum install -y nginx php-fpm
# Install PHP extensions
sudo yum install -y php-mysql php-pdo \
php-mbstring php-cli \
php-imap php-gd php-xml php-openssl php-tokenizer
@guillaumemolter
guillaumemolter / wp-cli-multisite-cheat-sheet.sh
Created March 9, 2017 20:22
A list of usefull commands to maitain a WordPress multisite install using WP-CLI
# Network wide search and replace
wp search-replace 'NEEDLE' 'HAYSTACK' --network --verbose
# Network wide search and replace for domain (ie: prod to dev DB migration)
wp search-replace 'old.domain.com' 'new.domain.com' --network --verbose --url=old.domain.com
# Network wide rewrite rules and permalinks flush
wp site list --field=url | xargs -n1 -I % wp rewrite flush --url=%
@guillaumemolter
guillaumemolter / code-exention-sync.sh
Last active March 3, 2017 15:58
Syncing Visual Code extensions
#!/bin/bash
#Update this with your own path. Mine is in dropbox because I use Tom McFarlin's trick to sync https://tommcfarlin.com/sharing-visual-studio-code-settings/
CODE_PREFS_PATH='/Users/guillaumemolter/Dropbox/Apps/Code/User/extensions.conf'
EXTENSIONS=`cat $CODE_PREFS_PATH`
for EXTENSION in ${EXTENSIONS[@]}
do
code --install-extension $EXTENSION
done
# then add to your .bash_profile :
@guillaumemolter
guillaumemolter / snippet.php
Created November 11, 2015 16:13
Disable WordPress default routes and endpoints REST API V2 - Correct way
<?php
remove_action( 'rest_api_init', 'create_initial_rest_routes', 0 );