WC_Settings_API::get_option( string $key, mixed $empty_value = null )
Get option from DB.
Description Description
Gets an option from the settings API, using defaults if necessary to prevent undefined notices.
Parameters Parameters
- $key
-
(Required) Option key.
- $empty_value
-
(Optional) Value when empty.
Default value: null
Return Return
(string) The value specified for the option or a default value for the option.
Source Source
File: includes/abstracts/abstract-wc-settings-api.php
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 | 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 ]; } |