Created
April 19, 2017 17:17
-
-
Save spacedmonkey/0628f785eef389e9403da9f96d764c84 to your computer and use it in GitHub Desktop.
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 | |
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 ){ | |
$value = $meta; | |
} | |
return $value | |
} | |
add_filter( 'pre_get_option', 'pre_get_option', 1, 2 ); | |
function updated_option( $option, $old_value, $value ){ | |
$blog_id = get_current_blog_id(); | |
update_blog_meta( $blog_id, $option, $value, $old_value ); | |
} | |
add_action( 'updated_option', 'updated_option', 10, 3 ); | |
function added_option( $option, $value ){ | |
$blog_id = get_current_blog_id(); | |
add_blog_meta( $blog_id, $option, $value, true ); | |
} | |
add_action( 'added_option','added_option', 10, 2 ); | |
function delete_option( $option ){ | |
$blog_id = get_current_blog_id(); | |
delete_blog_meta( $blog_id, $option ); | |
} | |
add_action( 'delete_option', 'delete_option', 10, 1 ); | |
function wp_upgrade( $wp_db_version ){ | |
$blog_id = get_current_blog_id(); | |
update_blog_meta( $blog_id, 'wp_db_version', $wp_db_version ); | |
} | |
add_action( 'wp_upgrade', 'wp_upgrade', 10, 1 ); | |
function pre_get_sites( $site_query ) { | |
if ( ! isset( $site_query->query_var_defaults['update_blog_meta_cache'] ) ) { | |
$site_query->query_var_defaults['update_blog_meta_cache'] = true; | |
} | |
} | |
add_action( 'pre_get_sites', 'pre_get_sites', 5, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment