| @@ 385-401 (lines=17) @@ | ||
| 382 | * @param mixed $empty_value |
|
| 383 | * @return mixed The value specified for the option or a default value for the option. |
|
| 384 | */ |
|
| 385 | public function get_instance_option( $key, $empty_value = null ) { |
|
| 386 | if ( empty( $this->instance_settings ) ) { |
|
| 387 | $this->init_instance_settings(); |
|
| 388 | } |
|
| 389 | ||
| 390 | // Get option default if unset. |
|
| 391 | if ( ! isset( $this->instance_settings[ $key ] ) ) { |
|
| 392 | $form_fields = $this->get_instance_form_fields(); |
|
| 393 | $this->instance_settings[ $key ] = $this->get_field_default( $form_fields[ $key ] ); |
|
| 394 | } |
|
| 395 | ||
| 396 | if ( ! is_null( $empty_value ) && '' === $this->instance_settings[ $key ] ) { |
|
| 397 | $this->instance_settings[ $key ] = $empty_value; |
|
| 398 | } |
|
| 399 | ||
| 400 | return $this->instance_settings[ $key ]; |
|
| 401 | } |
|
| 402 | ||
| 403 | /** |
|
| 404 | * Get settings fields for instances of this shipping method (within zones). |
|
| @@ 190-206 (lines=17) @@ | ||
| 187 | * @param mixed $empty_value |
|
| 188 | * @return mixed The value specified for the option or a default value for the option. |
|
| 189 | */ |
|
| 190 | public function get_option( $key, $empty_value = null ) { |
|
| 191 | if ( empty( $this->settings ) ) { |
|
| 192 | $this->init_settings(); |
|
| 193 | } |
|
| 194 | ||
| 195 | // Get option default if unset. |
|
| 196 | if ( ! isset( $this->settings[ $key ] ) ) { |
|
| 197 | $form_fields = $this->get_form_fields(); |
|
| 198 | $this->settings[ $key ] = isset( $form_fields[ $key ] ) ? $this->get_field_default( $form_fields[ $key ] ) : ''; |
|
| 199 | } |
|
| 200 | ||
| 201 | if ( ! is_null( $empty_value ) && '' === $this->settings[ $key ] ) { |
|
| 202 | $this->settings[ $key ] = $empty_value; |
|
| 203 | } |
|
| 204 | ||
| 205 | return $this->settings[ $key ]; |
|
| 206 | } |
|
| 207 | ||
| 208 | /** |
|
| 209 | * Prefix key for settings. |
|