add_site_option( string $option, mixed $value )
Add a new option for the current network.
Contents
Description Description
Existing options will not be updated. Note that prior to 3.3 this wasn’t the case.
See also See also
Parameters Parameters
- $option
-
(string) (Required) Name of option to add. Expected to not be SQL-escaped.
- $value
-
(mixed) (Required) Option value, can be anything. Expected to not be SQL-escaped.
Return Return
(bool) False if the option was not added. True if the option was added.
Source Source
File: wp-includes/option.php
function add_site_option( $option, $value ) {
return add_network_option( null, $option, $value );
}
Expand full source code Collapse full source code View on Trac
Changelog Changelog
| Version | Description |
|---|---|
| 4.4.0 | Modified into wrapper for add_network_option() |
| 2.8.0 | Introduced. |
User Contributed Notes User Contributed Notes
You must log in before being able to contribute a note or feedback.
Examples
Default usage:
Behavior if the option already exists:
echo get_site_option( 'i_exist_already' ); // Output: 'some_value' if ( add_site_option( 'i_exist_already', 'new_value' ) ) { echo get_site_option( 'i_exist_already' ); } else { echo __( 'Already exists', 'textdomain' ); }Parameter $value is listed as optional. It is not optional; it is required.