PHP Class Jetpack_Options, jetpack

显示文件 Open project: automattic/jetpack Class Usage Examples

Public Methods

Method Description
delete_option ( string | array $names ) : boolean Deletes the given option. May be passed multiple option names as an array.
get_option ( string $name, mixed $default = false ) : mixed Returns the requested option. Looks in jetpack_options or jetpack_$name as appropriate.
get_option_and_ensure_autoload ( string $name, mixed $default ) : mixed | void Returns the requested option, and ensures it's autoloaded in the future.
get_option_names ( string $type = 'compact' ) : array Returns an array of option names for a given type.
is_valid ( string $name, string | null $group = null ) : boolean Is the option name valid?
update_option ( string $name, mixed $value, string $autoload = null ) : boolean Updates the single given option. Updates jetpack_options or jetpack_$name as appropriate.
update_options ( array $array ) Updates the multiple given options. Updates jetpack_options and/or jetpack_$name as appropriate.

Private Methods

Method Description
delete_grouped_option ( $group, $names )
get_grouped_option ( $group, $name, $default )
update_grouped_option ( $group, $name, $value )

Method Details

delete_option() public static method

Updates jetpack_options and/or deletes jetpack_$name as appropriate.
public static delete_option ( string | array $names ) : boolean
$names string | array
return boolean Was the option successfully deleted?

get_option() public static method

Returns the requested option. Looks in jetpack_options or jetpack_$name as appropriate.
public static get_option ( string $name, mixed $default = false ) : mixed
$name string Option name
$default mixed (optional)
return mixed

get_option_and_ensure_autoload() public static method

This does _not_ adjust the prefix in any way (does not prefix jetpack_%)
public static get_option_and_ensure_autoload ( string $name, mixed $default ) : mixed | void
$name string Option name
$default mixed (optional)
return mixed | void

get_option_names() public static method

Returns an array of option names for a given type.
public static get_option_names ( string $type = 'compact' ) : array
$type string The type of option to return. Defaults to 'compact'.
return array

is_valid() public static method

Is the option name valid?
public static is_valid ( string $name, string | null $group = null ) : boolean
$name string The name of the option
$group string | null The name of the group that the option is in. Default to null, which will search non_compact.
return boolean Is the option name valid?

update_option() public static method

Updates the single given option. Updates jetpack_options or jetpack_$name as appropriate.
public static update_option ( string $name, mixed $value, string $autoload = null ) : boolean
$name string Option name
$value mixed Option value
$autoload string If not compact option, allows specifying whether to autoload or not.
return boolean Was the option successfully updated?

update_options() public static method

Updates the multiple given options. Updates jetpack_options and/or jetpack_$name as appropriate.
public static update_options ( array $array )
$array array array( option name => option value, ... )