Advertisements

update_site_option

Definition:
function update_site_option( $option, $value ) {}

Update the value of a site option that was already added.

Parameters

  • string $option: Name of option. Expected to not be SQL-escaped.
  • mixed $value: Option value. Expected to not be SQL-escaped.

Return values

returns:False if value was not updated and true if value was updated.

Defined filters

  • pre_update_site_option_$option
    apply_filters( 'pre_update_site_option_' . $option, $value, $oldvalue )

Source code

function update_site_option( $option, $value ) {

	global $wpdb;



	$oldvalue = get_site_option( $option );

	$value = apply_filters( 'pre_update_site_option_' . $option, $value, $oldvalue );



	if ( $value === $oldvalue )

		return false;



	if ( false === $oldvalue )

		return add_site_option( $option, $value );



	if ( !is_multisite() ) {

		$result = update_option( $option, $value );

	} else {

		$value = sanitize_option( $option, $value );

		$cache_key = "{$wpdb->siteid}:$option";

		wp_cache_set( $cache_key, $value, 'site-options' );



		$_value = $value;

		$value = maybe_serialize( $value );

		$result = $wpdb->update( $wpdb->sitemeta, array( 'meta_value' => $value ), array( 'site_id' => $wpdb->siteid, 'meta_key' => $option ) );

		$value = $_value;

	}

3205

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: