Use get_site_option in add/update_site_option for caching and filtering benefits. fixes #18478
git-svn-id: http://svn.automattic.com/wordpress/trunk@18588 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
56f6f97125
commit
7213d24276
|
@ -3799,14 +3799,14 @@ function add_site_option( $option, $value ) {
|
||||||
} else {
|
} else {
|
||||||
$cache_key = "{$wpdb->siteid}:$option";
|
$cache_key = "{$wpdb->siteid}:$option";
|
||||||
|
|
||||||
if ( $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) ) )
|
if ( false !== get_site_option( $option ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$value = sanitize_option( $option, $value );
|
$value = sanitize_option( $option, $value );
|
||||||
wp_cache_set( $cache_key, $value, 'site-options' );
|
wp_cache_set( $cache_key, $value, 'site-options' );
|
||||||
|
|
||||||
$_value = $value;
|
$_value = $value;
|
||||||
$value = maybe_serialize($value);
|
$value = maybe_serialize( $value );
|
||||||
$result = $wpdb->insert( $wpdb->sitemeta, array('site_id' => $wpdb->siteid, 'meta_key' => $option, 'meta_value' => $value ) );
|
$result = $wpdb->insert( $wpdb->sitemeta, array('site_id' => $wpdb->siteid, 'meta_key' => $option, 'meta_value' => $value ) );
|
||||||
$value = $_value;
|
$value = $_value;
|
||||||
}
|
}
|
||||||
|
@ -3886,14 +3886,14 @@ function update_site_option( $option, $value ) {
|
||||||
if ( $value === $oldvalue )
|
if ( $value === $oldvalue )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if ( $value && false === $oldvalue )
|
||||||
|
return add_site_option( $option, $value );
|
||||||
|
|
||||||
if ( !is_multisite() ) {
|
if ( !is_multisite() ) {
|
||||||
$result = update_option( $option, $value );
|
$result = update_option( $option, $value );
|
||||||
} else {
|
} else {
|
||||||
$cache_key = "{$wpdb->siteid}:$option";
|
|
||||||
|
|
||||||
if ( $value && !$wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) ) )
|
|
||||||
return add_site_option( $option, $value );
|
|
||||||
$value = sanitize_option( $option, $value );
|
$value = sanitize_option( $option, $value );
|
||||||
|
$cache_key = "{$wpdb->siteid}:$option";
|
||||||
wp_cache_set( $cache_key, $value, 'site-options' );
|
wp_cache_set( $cache_key, $value, 'site-options' );
|
||||||
|
|
||||||
$_value = $value;
|
$_value = $value;
|
||||||
|
|
Loading…
Reference in New Issue