# persistent configuration
Your plugin may need to store some configuration information. In fact,
Blessing Skin itself also has a lot of configuration information and
options, which are all stored in the options
table in the database.
It is not recommended that you read the configuration directly by
reading the data table, but you should use the Option
Facade or
option
auxiliary function provided by Blessing Skin and Blessing Skin
is also used internally.
# application
Suppose your plugin needs to get information from an external URL, and
this URL can be modified by the user to switch between different
sources. We can set a configuration item called "data_source", then we
can get or set this configuration item through Option
Facade or
option
helper function.
When setting a configuration item, if the configuration item does not exist, it will be added automatically without manually modifying the database.
# Use Facade
You can use the Option
Facade to manipulate your configuration items.
use Option ;
// Get the value of `data_source`
Option ::get( ' data_source ' ) ;
// It is also allowed to return the default value, if the configuration item does not exist or the value is empty
Option::get( ' data_source ' , 'http://xxx/' ) ;
// update configuration
itemOption ::set( 'data_source' , 'http://xxx/' ) ;
# Use helper functions
Auxiliary functions are available globally and do not need to be imported like Facade before use, so it is easier to use.
For detailed usage, please read option
Functions
and option_localized
function .