OPTIONS

Options

Options are the way to store extension-related settings that have an impact on a company. All the data is stored in the options table and mapped with the company_id. Here is the columns options table has.

Structure of the miniCal options Table

The options table has a similar structure to the metadata tables. It has five fields:

  • option_ID

  • company_id- Current company id.

  • option_name- Name of an option (key).

  • option_value- Value of option (value).

  • autoload - Whether to load the option when extension starts up. Default is enabled. The boolean value true/false.

Each record in the option_name field will be a unique value: if you add more than one value to an option, miniCal stores this in an array in the option_value field.

// Add a new option.
add_option(string $option, $value = '', bool $autoload = true)

// Removes option by name.
delete_option( string $option )

// Retrieves an option value based on an option name.
get_option( string $option, bool $default = false)

// Update the value of an option that was already added.
update_option( string $option, $value = '', bool $autoload = true )

Using the Options

The Options consists of four functions that allow you to add, get, update or delete options:

MethodDescriptionParameters DescriptionReturn value

add_option()

Adds a new option value.

add_option(string $option, $value = '', bool $autoload = true) 1. string $option (Required) Name of the option to add. 2. mixed $value (Optional) Option value. 3. bool $autoload (Optional) Whether to load the option when extension starts up. Default is enabled.

bool True if the option was added, null otherwise.

get_option()

Get option value.

get_option( string $option, bool $default = false) 1. string $option (Required) Name of the option to add. 2. bool $default (Optional) Default value to return if the option does not exist.

bool Value of the option. A value of any type may be returned, If there is no option in the database, boolean false is returned

update_option()

Update option value.

update_option( string $option, $value = '', bool $autoload = true ) 1. string $option (Required) Name of the option to update. 2. mixed $value (Required) Option value. 3. bool $autoload (Optional) Whether to load the option when extension starts up. Default is enabled.

bool True if the value was updated, false otherwise.

delete_option()

delete option value.

delete_option( string $option ) 1. string $option (Required) Name of the option to delete.

bool True if the option was deleted, false otherwise.

Last updated