Skip to content

Instantly share code, notes, and snippets.

Guillaume Molter guillaumemolter

Block or report user

Report or block guillaumemolter

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
@guillaumemolter
guillaumemolter / composer.json
Created Aug 5, 2019
WordPress management Composer workflow
View composer.json
{
"name": "",
"description": "",
"type": "project",
"repositories": [
{
"type": "composer",
"url": "https://wpackagist.org"
}
],
@guillaumemolter
guillaumemolter / stats.php
Created Jul 15, 2019
WordPress multisite content freshness report
View stats.php
<?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 Feb 24, 2019
Adding multisite taxonomy support to custom post types.
View tagging_topics_post_types.php
<?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 );
View gist:400f88b00a2ba064c5a30d4eb6c4b66f
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
View gist:884e841b98ae3e017127bbb0714a8294
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 Nov 6, 2018 — forked from sumardi/nginx.default.conf
Install PHP-FPM and Nginx on EC2 with Amazon Linux AMI
View nginx.default.conf
# 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 Mar 9, 2017
A list of usefull commands to maitain a WordPress multisite install using WP-CLI
View wp-cli-multisite-cheat-sheet.sh
# 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 Mar 3, 2017
Syncing Visual Code extensions
View code-exention-sync.sh
#!/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 Nov 11, 2015
Disable WordPress default routes and endpoints REST API V2 - Correct way
View snippet.php
<?php
remove_action( 'rest_api_init', 'create_initial_rest_routes', 0 );
@guillaumemolter
guillaumemolter / gist:53c9a6fb8610beec19a5
Last active Nov 11, 2015
Disable WordPress default routes and endpoints REST API V1
View gist:53c9a6fb8610beec19a5
<?php
function remove_wp_endpoints($default_routes){
$new_routes["/"] = $default_routes["/"];
return $new_routes;
}
add_filter('json_endpoints', 'remove_wp_endpoints', 20, 3);
You can’t perform that action at this time.