WC_Shipping_Method::get_instance_option( string $key, mixed $empty_value = null )
Gets an option from the settings API, using defaults if necessary to prevent undefined notices.
Description Description
Parameters Parameters
- $key
-
(Required) Key.
- $empty_value
-
(Optional) Empty value.
Default value: null
Return Return
(mixed) The value specified for the option or a default value for the option.
Source Source
File: includes/abstracts/abstract-wc-shipping-method.php
public function get_instance_option( $key, $empty_value = null ) { if ( empty( $this->instance_settings ) ) { $this->init_instance_settings(); } // Get option default if unset. if ( ! isset( $this->instance_settings[ $key ] ) ) { $form_fields = $this->get_instance_form_fields(); $this->instance_settings[ $key ] = $this->get_field_default( $form_fields[ $key ] ); } if ( ! is_null( $empty_value ) && '' === $this->instance_settings[ $key ] ) { $this->instance_settings[ $key ] = $empty_value; } $instance_option = apply_filters( 'woocommerce_shipping_' . $this->id . '_instance_option', $this->instance_settings[ $key ], $key, $this ); return $instance_option; }