| @@ -1,167 +1,170 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -/** | |
| 4 | - * Form template abstract class | |
| 5 | - * | |
| 6 | - * @since 1.1.0 | |
| 7 | - */ | |
| 8 | -abstract class WeForms_Form_Template { | |
| 9 | - | |
| 10 | - /** | |
| 11 | - * If the form is enabled | |
| 12 | - * | |
| 13 | - * @var bool | |
| 14 | - */ | |
| 15 | - public $enabled = true; | |
| 16 | - | |
| 17 | - /** | |
| 18 | - * Template title | |
| 19 | - * | |
| 20 | - * @var string | |
| 21 | - */ | |
| 22 | - public $title; | |
| 23 | - | |
| 24 | - /** | |
| 25 | - * Template description | |
| 26 | - * | |
| 27 | - * @var string | |
| 28 | - */ | |
| 29 | - public $description; | |
| 30 | - | |
| 31 | - /** | |
| 32 | - * Conditional logic | |
| 33 | - * | |
| 34 | - * @var array | |
| 35 | - */ | |
| 36 | - protected $conditionals; | |
| 37 | - | |
| 38 | - /** | |
| 39 | - * Form fields | |
| 40 | - * | |
| 41 | - * @var array | |
| 42 | - */ | |
| 43 | - protected $form_fields; | |
| 44 | - | |
| 45 | - /** | |
| 46 | - * Form settings | |
| 47 | - * | |
| 48 | - * @var array | |
| 49 | - */ | |
| 50 | - protected $form_settings; | |
| 51 | - | |
| 52 | - /** | |
| 53 | - * Form Template Category | |
| 54 | - * | |
| 55 | - * @var array | |
| 56 | - */ | |
| 57 | - public $category = 'default'; | |
| 58 | - | |
| 59 | - /** | |
| 60 | - * Form Template Image | |
| 61 | - * | |
| 62 | - * @var array | |
| 63 | - */ | |
| 64 | - public $image; | |
| 65 | - | |
| 66 | - /** | |
| 67 | - * Form notifications | |
| 68 | - * | |
| 69 | - * @since 2.5.2 | |
| 70 | - * | |
| 71 | - * @var array | |
| 72 | - */ | |
| 73 | - protected $form_notifications; | |
| 74 | - | |
| 75 | - public function __construct() { | |
| 76 | - $this->conditionals = [ | |
| 77 | - 'condition_status' => 'no', | |
| 78 | - 'cond_field' => [], | |
| 79 | - 'cond_operator' => [ '=' ], | |
| 80 | - 'cond_option' => [ '- select -' ], | |
| 81 | - 'cond_logic' => 'all', | |
| 82 | - ]; | |
| 83 | - } | |
| 84 | - | |
| 85 | - /** | |
| 86 | - * Get the template title | |
| 87 | - * | |
| 88 | - * @return string | |
| 89 | - */ | |
| 90 | - public function get_title() { | |
| 91 | - return $this->title; | |
| 92 | - } | |
| 93 | - | |
| 94 | - /** | |
| 95 | - * Get the description | |
| 96 | - * | |
| 97 | - * @return string | |
| 98 | - */ | |
| 99 | - public function get_description() { | |
| 100 | - return $this->description; | |
| 101 | - } | |
| 102 | - | |
| 103 | - /** | |
| 104 | - * Get the form fields | |
| 105 | - * | |
| 106 | - * @return array | |
| 107 | - */ | |
| 108 | - public function get_form_fields() { | |
| 109 | - return $this->form_fields; | |
| 110 | - } | |
| 111 | - | |
| 112 | - /** | |
| 113 | - * Get all available fields | |
| 114 | - * | |
| 115 | - * @return array | |
| 116 | - */ | |
| 117 | - public function get_available_fields() { | |
| 118 | - return weforms()->fields->get_fields(); | |
| 119 | - } | |
| 120 | - | |
| 121 | - /** | |
| 122 | - * Get the form settings | |
| 123 | - * | |
| 124 | - * @return array | |
| 125 | - */ | |
| 126 | - public function get_form_settings() { | |
| 127 | - return $this->get_default_settings(); | |
| 128 | - } | |
| 129 | - | |
| 130 | - /** | |
| 131 | - * Get form notifications | |
| 132 | - * | |
| 133 | - * @since 2.5.2 | |
| 134 | - * | |
| 135 | - * @return array | |
| 136 | - */ | |
| 137 | - public function get_form_notifications() { | |
| 138 | - return $this->get_default_notification(); | |
| 139 | - } | |
| 140 | - | |
| 141 | - /** | |
| 142 | - * Check if the template is enabled | |
| 143 | - * | |
| 144 | - * @return bool | |
| 145 | - */ | |
| 146 | - public function is_enabled() { | |
| 147 | - return $this->enabled; | |
| 148 | - } | |
| 149 | - | |
| 150 | - /** | |
| 151 | - * Get default settings | |
| 152 | - * | |
| 153 | - * @return array | |
| 154 | - */ | |
| 155 | - public function get_default_settings() { | |
| 156 | - return weforms_get_default_form_settings(); | |
| 157 | - } | |
| 158 | - | |
| 159 | - /** | |
| 160 | - * Get notifications of contact form template | |
| 161 | - * | |
| 162 | - * @return array | |
| 163 | - */ | |
| 164 | - public function get_default_notification() { | |
| 165 | - return [ weforms_get_default_form_notification() ]; | |
| 166 | - } | |
| 167 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Form template abstract class | |
| 5 | + * | |
| 6 | + * @since 1.1.0 | |
| 7 | + */ | |
| 8 | +abstract class WeForms_Form_Template { | |
| 9 | + | |
| 10 | + /** | |
| 11 | + * If the form is enabled | |
| 12 | + * | |
| 13 | + * @var boolean | |
| 14 | + */ | |
| 15 | + public $enabled = true; | |
| 16 | + | |
| 17 | + /** | |
| 18 | + * Template title | |
| 19 | + * | |
| 20 | + * @var string | |
| 21 | + */ | |
| 22 | + public $title; | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * Template description | |
| 26 | + * | |
| 27 | + * @var string | |
| 28 | + */ | |
| 29 | + public $description; | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * Conditional logic | |
| 33 | + * | |
| 34 | + * @var array | |
| 35 | + */ | |
| 36 | + protected $conditionals; | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * Form fields | |
| 40 | + * | |
| 41 | + * @var array | |
| 42 | + */ | |
| 43 | + protected $form_fields; | |
| 44 | + | |
| 45 | + /** | |
| 46 | + * Form settings | |
| 47 | + * | |
| 48 | + * @var array | |
| 49 | + */ | |
| 50 | + protected $form_settings; | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * Form Template Category | |
| 54 | + * | |
| 55 | + * @var array | |
| 56 | + */ | |
| 57 | + public $category = 'default'; | |
| 58 | + | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * Form Template Image | |
| 62 | + * | |
| 63 | + * @var array | |
| 64 | + */ | |
| 65 | + public $image; | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * Form notifications | |
| 69 | + * | |
| 70 | + * @since 2.5.2 | |
| 71 | + * | |
| 72 | + * @var array | |
| 73 | + */ | |
| 74 | + protected $form_notifications; | |
| 75 | + | |
| 76 | + public function __construct() { | |
| 77 | + $this->conditionals = array( | |
| 78 | + 'condition_status' => 'no', | |
| 79 | + 'cond_field' => array(), | |
| 80 | + 'cond_operator' => array( '=' ), | |
| 81 | + 'cond_option' => array( '- select -' ), | |
| 82 | + 'cond_logic' => 'all' | |
| 83 | + ); | |
| 84 | + } | |
| 85 | + | |
| 86 | + /** | |
| 87 | + * Get the template title | |
| 88 | + * | |
| 89 | + * @return string | |
| 90 | + */ | |
| 91 | + public function get_title() { | |
| 92 | + return $this->title; | |
| 93 | + } | |
| 94 | + | |
| 95 | + /** | |
| 96 | + * Get the description | |
| 97 | + * | |
| 98 | + * @return string | |
| 99 | + */ | |
| 100 | + public function get_description() { | |
| 101 | + return $this->description; | |
| 102 | + } | |
| 103 | + | |
| 104 | + /** | |
| 105 | + * Get the form fields | |
| 106 | + * | |
| 107 | + * @return array | |
| 108 | + */ | |
| 109 | + public function get_form_fields() { | |
| 110 | + return $this->form_fields; | |
| 111 | + } | |
| 112 | + | |
| 113 | + /** | |
| 114 | + * Get all available fields | |
| 115 | + * | |
| 116 | + * @return array | |
| 117 | + */ | |
| 118 | + public function get_available_fields() { | |
| 119 | + return weforms()->fields->get_fields(); | |
| 120 | + } | |
| 121 | + | |
| 122 | + /** | |
| 123 | + * Get the form settings | |
| 124 | + * | |
| 125 | + * @return array | |
| 126 | + */ | |
| 127 | + public function get_form_settings() { | |
| 128 | + return $this->get_default_settings(); | |
| 129 | + } | |
| 130 | + | |
| 131 | + /** | |
| 132 | + * Get form notifications | |
| 133 | + * | |
| 134 | + * @since 2.5.2 | |
| 135 | + * | |
| 136 | + * @return array | |
| 137 | + */ | |
| 138 | + public function get_form_notifications() { | |
| 139 | + return $this->get_default_notification(); | |
| 140 | + } | |
| 141 | + | |
| 142 | + /** | |
| 143 | + * Check if the template is enabled | |
| 144 | + * | |
| 145 | + * @return boolean | |
| 146 | + */ | |
| 147 | + public function is_enabled() { | |
| 148 | + return $this->enabled; | |
| 149 | + } | |
| 150 | + | |
| 151 | + /** | |
| 152 | + * Get default settings | |
| 153 | + * | |
| 154 | + * @return array | |
| 155 | + */ | |
| 156 | + public function get_default_settings() { | |
| 157 | + return weforms_get_default_form_settings(); | |
| 158 | + } | |
| 159 | + | |
| 160 | + /** | |
| 161 | + * Get notifications of contact form template | |
| 162 | + * | |
| 163 | + * @return array | |
| 164 | + */ | |
| 165 | + function get_default_notification() { | |
| 166 | + return array( weforms_get_default_form_notification() ); | |
| 167 | + } | |
| 168 | + | |
| 169 | +} | |
| 170 | + | |