This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_site_id_of_user( $user_id, $all = false ) { | |
global $wpdb; | |
$user_id = (int) $user_id; | |
// Logged out users can't have sites | |
if ( empty( $user_id ) ) { | |
return array(); | |
} | |
$keys = get_user_meta( $user_id ); | |
if ( empty( $keys ) ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Create table | |
Remove Table | |
Activate | |
Uninstall |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'get_user_metadata', function ( $value, $object_id, $meta_key, $single ) { | |
if ( 'admin_color' !== $meta_key || ! $single ) { | |
return $value; | |
} | |
if ( ! defined( 'WPCOM_IS_VIP_ENV' ) ) { | |
return $value; | |
} | |
switch ( WPCOM_IS_VIP_ENV ) { | |
case 'develop': |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function migrate1( $args, $assoc_args ) { | |
global $wpdb; | |
$user_list = $wpdb->get_col( "SELECT ID FROM $wpdb->users;" ); | |
// Number of users returned by query | |
$found_users = count( $user_list ); | |
// Generate progess bar | |
$progress = new \cli\progress\Bar( 'Progress', $found_users ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter( 's3_uploads_s3_client_params', function ( $params ) { | |
if ( defined( 'S3_UPLOADS_ENDPOINT' ) ) { | |
$params['endpoint'] = S3_UPLOADS_ENDPOINT; | |
} | |
return $params; | |
}, 5, 1 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('s3_uploads_s3_client_params', function($params){ | |
$params['endpoint'] = 'https://ams3.digitaloceanspaces.com'; | |
return $params; | |
}, 10, 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Force cookie constants to be local domain / path | |
* after multisite is loaded. | |
*/ | |
add_action( | |
'ms_loaded', function () { | |
$site = get_site(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; }); |