| @@ 410-426 (lines=17) @@ | ||
| 407 | * @param mixed $empty_value |
|
| 408 | * @return mixed The value specified for the option or a default value for the option. |
|
| 409 | */ |
|
| 410 | public function get_instance_option( $key, $empty_value = null ) { |
|
| 411 | if ( empty( $this->instance_settings ) ) { |
|
| 412 | $this->init_instance_settings(); |
|
| 413 | } |
|
| 414 | ||
| 415 | // Get option default if unset. |
|
| 416 | if ( ! isset( $this->instance_settings[ $key ] ) ) { |
|
| 417 | $form_fields = $this->get_instance_form_fields(); |
|
| 418 | $this->instance_settings[ $key ] = $this->get_field_default( $form_fields[ $key ] ); |
|
| 419 | } |
|
| 420 | ||
| 421 | if ( ! is_null( $empty_value ) && '' === $this->instance_settings[ $key ] ) { |
|
| 422 | $this->instance_settings[ $key ] = $empty_value; |
|
| 423 | } |
|
| 424 | ||
| 425 | return $this->instance_settings[ $key ]; |
|
| 426 | } |
|
| 427 | ||
| 428 | /** |
|
| 429 | * Get settings fields for instances of this shipping method (within zones). |
|
| @@ 231-247 (lines=17) @@ | ||
| 228 | * @param mixed $empty_value |
|
| 229 | * @return mixed The value specified for the option or a default value for the option. |
|
| 230 | */ |
|
| 231 | public function get_option( $key, $empty_value = null ) { |
|
| 232 | if ( empty( $this->settings ) ) { |
|
| 233 | $this->init_settings(); |
|
| 234 | } |
|
| 235 | ||
| 236 | // Get option default if unset. |
|
| 237 | if ( ! isset( $this->settings[ $key ] ) ) { |
|
| 238 | $form_fields = $this->get_form_fields(); |
|
| 239 | $this->settings[ $key ] = isset( $form_fields[ $key ] ) ? $this->get_field_default( $form_fields[ $key ] ) : ''; |
|
| 240 | } |
|
| 241 | ||
| 242 | if ( ! is_null( $empty_value ) && '' === $this->settings[ $key ] ) { |
|
| 243 | $this->settings[ $key ] = $empty_value; |
|
| 244 | } |
|
| 245 | ||
| 246 | return $this->settings[ $key ]; |
|
| 247 | } |
|
| 248 | ||
| 249 | /** |
|
| 250 | * Prefix key for settings. |
|