@@ 231-247 (lines=17) @@ | ||
228 | * @param mixed $empty_value |
|
229 | * @return string 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. |
@@ 431-447 (lines=17) @@ | ||
428 | * @param mixed $empty_value |
|
429 | * @return mixed The value specified for the option or a default value for the option. |
|
430 | */ |
|
431 | public function get_instance_option( $key, $empty_value = null ) { |
|
432 | if ( empty( $this->instance_settings ) ) { |
|
433 | $this->init_instance_settings(); |
|
434 | } |
|
435 | ||
436 | // Get option default if unset. |
|
437 | if ( ! isset( $this->instance_settings[ $key ] ) ) { |
|
438 | $form_fields = $this->get_instance_form_fields(); |
|
439 | $this->instance_settings[ $key ] = $this->get_field_default( $form_fields[ $key ] ); |
|
440 | } |
|
441 | ||
442 | if ( ! is_null( $empty_value ) && '' === $this->instance_settings[ $key ] ) { |
|
443 | $this->instance_settings[ $key ] = $empty_value; |
|
444 | } |
|
445 | ||
446 | return $this->instance_settings[ $key ]; |
|
447 | } |
|
448 | ||
449 | /** |
|
450 | * Get settings fields for instances of this shipping method (within zones). |