WC_Settings_API::get_option()
Get option from DB.
Gets an option from the settings API, using defaults if necessary to prevent undefined notices.
Метод класса: WC_Settings_API{}
Хуков нет.
Возвращает
Строку
. The value specified for the option or a default value for the option.
Использование
$WC_Settings_API = new WC_Settings_API(); $WC_Settings_API->get_option( $key, $empty_value );
- $key(строка) (обязательный)
- Option key.
- $empty_value(разное)
- Value when empty.
По умолчанию: null
Код WC_Settings_API::get_option() WC Settings API::get option WC 8.7.0
public function get_option( $key, $empty_value = null ) { if ( empty( $this->settings ) ) { $this->init_settings(); } // Get option default if unset. if ( ! isset( $this->settings[ $key ] ) ) { $form_fields = $this->get_form_fields(); $this->settings[ $key ] = isset( $form_fields[ $key ] ) ? $this->get_field_default( $form_fields[ $key ] ) : ''; } if ( ! is_null( $empty_value ) && '' === $this->settings[ $key ] ) { $this->settings[ $key ] = $empty_value; } return $this->settings[ $key ]; }