| @@ -5,18 +5,24 @@ | ||
| 5 | 5 | |
| 6 | 6 | abstract class FrmValidate { |
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | - * @var int $form_id | |
| 9 | + * @var int | |
| 10 | 10 | */ |
| 11 | 11 | protected $form_id; |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * @var object $form | |
| 14 | + * @var object | |
| 15 | 15 | */ |
| 16 | 16 | protected $form; |
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | + * @since 6.21 | |
| 20 | + * @var string | |
| 21 | + */ | |
| 22 | + protected $option_type = 'form'; | |
| 23 | + | |
| 24 | + /** | |
| 19 | 25 | * @param int $form_id |
| 20 | 26 | */ |
| 21 | 27 | public function __construct( $form_id ) { |
| 22 | 28 | $this->form_id = $form_id; |
| @@ -25,9 +31,9 @@ | ||
| 25 | 31 | /** |
| 26 | 32 | * @return object $form |
| 27 | 33 | */ |
| 28 | 34 | protected function get_form() { |
| 29 | - if ( ! isset( $this->form ) ) { | |
| 35 | + if ( empty( $this->form ) ) { | |
| 30 | 36 | $this->form = FrmForm::getOne( $this->form_id ); |
| 31 | 37 | } |
| 32 | 38 | return $this->form; |
| 33 | 39 | } |
| @@ -35,15 +41,20 @@ | ||
| 35 | 41 | /** |
| 36 | 42 | * @return bool |
| 37 | 43 | */ |
| 38 | 44 | protected function is_option_on() { |
| 45 | + $key = $this->get_option_key(); | |
| 46 | + if ( 'global' === $this->option_type ) { | |
| 47 | + $frm_settings = FrmAppHelper::get_settings(); | |
| 48 | + return ! empty( $frm_settings->$key ); | |
| 49 | + } | |
| 50 | + | |
| 39 | 51 | $form = $this->get_form(); |
| 40 | - $key = $this->get_option_key(); | |
| 41 | 52 | return ! empty( $form->options[ $key ] ) && 'off' !== $form->options[ $key ]; |
| 42 | 53 | } |
| 43 | 54 | |
| 44 | 55 | /** |
| 45 | - * @return bool | |
| 56 | + * @return bool|string | |
| 46 | 57 | */ |
| 47 | 58 | abstract public function validate(); |
| 48 | 59 | |
| 49 | 60 | /** |