Definition:
function add_site_option( $option, $value ) {}
Add a new site option.
Existing options will not be updated. Note that prior to 3.3 this wasn’t the case.
Parameters
- string $option: Name of option to add. Expected to not be SQL-escaped.
- mixed $value: Optional. Option value, can be anything. Expected to not be SQL-escaped.
Return values
returns:False if option was not added and true if option was added.
Defined filters
- pre_add_site_option_$option
apply_filters( 'pre_add_site_option_' . $option, $value )
Source code
function add_site_option( $option, $value ) { global $wpdb; $value = apply_filters( 'pre_add_site_option_' . $option, $value ); if ( !is_multisite() ) { $result = add_option( $option, $value ); } else { $cache_key = "{$wpdb->siteid}:$option"; if ( false !== get_site_option( $option ) ) return false; $value = sanitize_option( $option, $value ); wp_cache_set( $cache_key, $value, 'site-options' ); $_value = $value; $value = maybe_serialize( $value ); $result = $wpdb->insert( $wpdb->sitemeta, array('site_id' => $wpdb->siteid, 'meta_key' => $option, 'meta_value' => $value ) ); $value = $_value; }
367
No comments yet... Be the first to leave a reply!