WC_Settings_API::init_settings()publicWC 1.0.0

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.

Метод класса: WC_Settings_API{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WC_Settings_API = new WC_Settings_API();
$WC_Settings_API->init_settings();

Список изменений

С версии 1.0.0 Введена.

Код WC_Settings_API::init_settings() WC 8.7.0

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' ) );
	}
}