@@ 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. |
@@ 375-391 (lines=17) @@ | ||
372 | * @param mixed $empty_value |
|
373 | * @return mixed The value specified for the option or a default value for the option. |
|
374 | */ |
|
375 | public function get_instance_option( $key, $empty_value = null ) { |
|
376 | if ( empty( $this->instance_settings ) ) { |
|
377 | $this->init_instance_settings(); |
|
378 | } |
|
379 | ||
380 | // Get option default if unset. |
|
381 | if ( ! isset( $this->instance_settings[ $key ] ) ) { |
|
382 | $form_fields = $this->get_instance_form_fields(); |
|
383 | $this->instance_settings[ $key ] = $this->get_field_default( $form_fields[ $key ] ); |
|
384 | } |
|
385 | ||
386 | if ( ! is_null( $empty_value ) && '' === $this->instance_settings[ $key ] ) { |
|
387 | $this->instance_settings[ $key ] = $empty_value; |
|
388 | } |
|
389 | ||
390 | return $this->instance_settings[ $key ]; |
|
391 | } |
|
392 | ||
393 | /** |
|
394 | * Get settings fields for instances of this shipping method (within zones). |