WC_Settings_API::init_settings
Initialise Settings.
Store all settings in a single database entry and make sure the $settings array is either the default or the settings stored in the database.
Method of the class: WC_Settings_API{}
No Hooks.
Returns
null
. Nothing (null).
Usage
$WC_Settings_API = new WC_Settings_API(); $WC_Settings_API->init_settings();
Changelog
Since 1.0.0 | Introduced. |
WC_Settings_API::init_settings() WC Settings API::init settings code WC 9.9.4
public function init_settings() { $this->settings = get_option( $this->get_option_key(), null ); // If there are no settings defined, use defaults. if ( ! is_array( $this->settings ) ) { $form_fields = $this->get_form_fields(); $this->settings = array_merge( array_fill_keys( array_keys( $form_fields ), '' ), wp_list_pluck( $form_fields, 'default' ) ); } }