Skip to content

Instantly share code, notes, and snippets.

View spacedmonkey's full-sized avatar
🖐️
Open for work

Jonny Harris spacedmonkey

🖐️
Open for work
View GitHub Profile
<?php
if( ! is_multisite() ){
return;
}
function pre_get_option( $value, $option ){
$blog_id = get_current_blog_id();
$meta = get_blog_meta( $blog_id, $option, true );
if( false != $meta ){
<?php
/**
* Loop through all options and save in the blog meta table
*/
class Blog_Meta_Migration extends WP_CLI_Command {
/**
* Loop through all options and save in the blog meta table
*
'stylesheet',
'show_on_front',
'blog_charset',
'template',
'WPLANG',
'cron',
'blogname',
'siteurl',
'post_count',
'home',
<?php
/**
* Sync key options with blog meta
*
* @package Blog_Meta_Sync
* @author Jonathan Harris <[email protected]>
* @license GPL-2.0+
* @link http://www.jonathandavidharris.co.uk/
* @copyright 2017 Spacedmonkey
*
<?php
/**
* Sync key options with blog meta
*
* @package Blog_Meta_Sync
* @author Jonathan Harris <[email protected]>
* @license GPL-2.0+
* @link http://www.jonathandavidharris.co.uk/
* @copyright 2017 Spacedmonkey
*
add_filter('pre_option_blog_charset', function(){ return 'UTF-8'; });
add_filter('pre_option_html_type', function(){ return 'text/html'; });
add_filter('pre_option_link_manager_enabled', '__return_true');
add_filter('pre_option_use_smilies', '__return_true');
add_filter('pre_option_timezone_string', '__return_null');
add_filter( 'pre_option_category_base', '__return_empty_string' );
add_filter( 'pre_option_tag_base', '__return_empty_string' );
add_filter( 'pre_option_avatar_default', function(){ return 'mystery'; });
add_filter( 'pre_option_avatar_rating', function(){ return 'G'; });
add_filter( 'pre_option_show_avatars', function(){ return '1'; });
class WP_Short_Circuit_Result {
private $name = null;
private $value = null;
public $has_changed = false;
public function __construct( $name = null, $value = null ) {
$this->name = $name;
$properties = array( 'blogname', 'siteurl', 'post_count', 'home' );
foreach ( $properties as $property ) {
add_action("add_option_".$property,"add_option_site_meta" 99, 2);
add_action("delete_option_".$property,"delete_option_site_meta" 99, 1);
add_action("update_option_".$property,"update_option_site_meta" 99, 3);
}
function delete_option_site_meta( $option ){
delete_site_meta(get_current_blog_id(), $option);
}
<?php
/**
* Force cookie constants to be local domain / path
* after multisite is loaded.
*/
add_action(
'ms_loaded', function () {
$site = get_site();
@spacedmonkey
spacedmonkey / gist:be74fb8160d5746f43614774db4d877b
Created December 24, 2017 17:58
Using S3 Uploads with digital ocean spaces
add_filter('s3_uploads_s3_client_params', function($params){
$params['endpoint'] = 'https://ams3.digitaloceanspaces.com';
return $params;
}, 10, 1);