| @@ 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. |
|
| @@ 362-378 (lines=17) @@ | ||
| 359 | * @param mixed $empty_value |
|
| 360 | * @return mixed The value specified for the option or a default value for the option. |
|
| 361 | */ |
|
| 362 | public function get_instance_option( $key, $empty_value = null ) { |
|
| 363 | if ( empty( $this->instance_settings ) ) { |
|
| 364 | $this->init_instance_settings(); |
|
| 365 | } |
|
| 366 | ||
| 367 | // Get option default if unset. |
|
| 368 | if ( ! isset( $this->instance_settings[ $key ] ) ) { |
|
| 369 | $form_fields = $this->get_instance_form_fields(); |
|
| 370 | $this->instance_settings[ $key ] = $this->get_field_default( $form_fields[ $key ] ); |
|
| 371 | } |
|
| 372 | ||
| 373 | if ( ! is_null( $empty_value ) && '' === $this->instance_settings[ $key ] ) { |
|
| 374 | $this->instance_settings[ $key ] = $empty_value; |
|
| 375 | } |
|
| 376 | ||
| 377 | return $this->instance_settings[ $key ]; |
|
| 378 | } |
|
| 379 | ||
| 380 | /** |
|
| 381 | * Get settings fields for instances of this shipping method (within zones). |
|