WC_Shipping_Method::get_instance_option PHP Method

get_instance_option() public method

Gets an option from the settings API, using defaults if necessary to prevent undefined notices.
public get_instance_option ( string $key, mixed $empty_value = null ) : mixed
$key string
$empty_value mixed
return mixed The value specified for the option or a default value for the option.
    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;
        }
        return $this->instance_settings[$key];
    }