add_site_option should not update existing options, should return a boolean and should only run actions on success. fixes #18422
git-svn-id: http://svn.automattic.com/wordpress/trunk@18587 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fdedc8a500
commit
56f6f97125
|
@ -569,11 +569,10 @@ function update_option( $option, $newvalue ) {
|
||||||
* it will be serialized before it is inserted into the database. Remember,
|
* it will be serialized before it is inserted into the database. Remember,
|
||||||
* resources can not be serialized or added as an option.
|
* resources can not be serialized or added as an option.
|
||||||
*
|
*
|
||||||
* You can create options without values and then add values later. Does not
|
* You can create options without values and then update the values later.
|
||||||
* check whether the option has already been added, but does check that you
|
* Existing options will not be updated and checks are performed to ensure that you
|
||||||
* aren't adding a protected WordPress option. Care should be taken to not name
|
* aren't adding a protected WordPress option. Care should be taken to not name
|
||||||
* options the same as the ones which are protected and to not add options
|
* options the same as the ones which are protected.
|
||||||
* that were already added.
|
|
||||||
*
|
*
|
||||||
* @package WordPress
|
* @package WordPress
|
||||||
* @subpackage Option
|
* @subpackage Option
|
||||||
|
@ -3775,6 +3774,8 @@ function get_site_option( $option, $default = false, $use_cache = true ) {
|
||||||
/**
|
/**
|
||||||
* Add a new site option.
|
* Add a new site option.
|
||||||
*
|
*
|
||||||
|
* Existing options will not be updated. Note that prior to 3.3 this wasn't the case.
|
||||||
|
*
|
||||||
* @see add_option()
|
* @see add_option()
|
||||||
* @package WordPress
|
* @package WordPress
|
||||||
* @subpackage Option
|
* @subpackage Option
|
||||||
|
@ -3799,7 +3800,7 @@ function add_site_option( $option, $value ) {
|
||||||
$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 ( $wpdb->get_row( $wpdb->prepare( "SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) ) )
|
||||||
return update_site_option( $option, $value );
|
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' );
|
||||||
|
@ -3810,10 +3811,12 @@ function add_site_option( $option, $value ) {
|
||||||
$value = $_value;
|
$value = $_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( $result ) {
|
||||||
do_action( "add_site_option_{$option}", $option, $value );
|
do_action( "add_site_option_{$option}", $option, $value );
|
||||||
do_action( "add_site_option", $option, $value );
|
do_action( "add_site_option", $option, $value );
|
||||||
|
return true;
|
||||||
return $result;
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue