PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.21
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.21
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / classes / models / FrmValidate.php

FrmValidate.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.21, at classes/models/FrmValidate.php

67 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( 'You are not allowed to call this page directly.' );
4 }
5
6 abstract class FrmValidate {
7
8 /**
9 * @var int
10 */
11 protected $form_id;
12
13 /**
14 * @var object
15 */
16 protected $form;
17
18 /**
19 * @since 6.21
20 * @var string
21 */
22 protected $option_type = 'form';
23
24 /**
25 * @param int $form_id
26 */
27 public function __construct( $form_id ) {
28 $this->form_id = $form_id;
29 }
30
31 /**
32 * @return object $form
33 */
34 protected function get_form() {
35 if ( empty( $this->form ) ) {
36 $this->form = FrmForm::getOne( $this->form_id );
37 }
38 return $this->form;
39 }
40
41 /**
42 * @return bool
43 */
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
51 $form = $this->get_form();
52 return ! empty( $form->options[ $key ] ) && 'off' !== $form->options[ $key ];
53 }
54
55 /**
56 * @return bool|string
57 */
58 abstract public function validate();
59
60 /**
61 * Track the form option key used for is_option_on function.
62 *
63 * @return string
64 */
65 abstract protected function get_option_key();
66 }
67