| @@ 179-195 (lines=17) @@ | ||
| 176 | * @param mixed $empty_value |
|
| 177 | * @return mixed The value specified for the option or a default value for the option. |
|
| 178 | */ |
|
| 179 | public function get_option( $key, $empty_value = null ) { |
|
| 180 | if ( empty( $this->settings ) ) { |
|
| 181 | $this->init_settings(); |
|
| 182 | } |
|
| 183 | ||
| 184 | // Get option default if unset. |
|
| 185 | if ( ! isset( $this->settings[ $key ] ) ) { |
|
| 186 | $form_fields = $this->get_form_fields(); |
|
| 187 | $this->settings[ $key ] = isset( $form_fields[ $key ] ) ? $this->get_field_default( $form_fields[ $key ] ) : ''; |
|
| 188 | } |
|
| 189 | ||
| 190 | if ( ! is_null( $empty_value ) && '' === $this->settings[ $key ] ) { |
|
| 191 | $this->settings[ $key ] = $empty_value; |
|
| 192 | } |
|
| 193 | ||
| 194 | return $this->settings[ $key ]; |
|
| 195 | } |
|
| 196 | ||
| 197 | /** |
|
| 198 | * Prefix key for settings. |
|
| @@ 391-407 (lines=17) @@ | ||
| 388 | * @param mixed $empty_value |
|
| 389 | * @return mixed The value specified for the option or a default value for the option. |
|
| 390 | */ |
|
| 391 | public function get_instance_option( $key, $empty_value = null ) { |
|
| 392 | if ( empty( $this->instance_settings ) ) { |
|
| 393 | $this->init_instance_settings(); |
|
| 394 | } |
|
| 395 | ||
| 396 | // Get option default if unset. |
|
| 397 | if ( ! isset( $this->instance_settings[ $key ] ) ) { |
|
| 398 | $form_fields = $this->get_instance_form_fields(); |
|
| 399 | $this->instance_settings[ $key ] = $this->get_field_default( $form_fields[ $key ] ); |
|
| 400 | } |
|
| 401 | ||
| 402 | if ( ! is_null( $empty_value ) && '' === $this->instance_settings[ $key ] ) { |
|
| 403 | $this->instance_settings[ $key ] = $empty_value; |
|
| 404 | } |
|
| 405 | ||
| 406 | return $this->instance_settings[ $key ]; |
|
| 407 | } |
|
| 408 | ||
| 409 | /** |
|
| 410 | * Get settings fields for instances of this shipping method (within zones). |
|