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