PluginProbe
Quill Forms | Conversational Multi Step Forms, Surveys & quizzes / trunk
Quill Forms | Conversational Multi Step Forms, Surveys & quizzes vtrunk
5.7.3 5.7.2 5.7.1 1.8.1 1.8.10 1.8.11 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 2.0.0 2.1.0 2.10.0 2.11.0 2.12.0 2.12.1 2.13.0 2.13.1 2.13.2 2.13.3 All 146 releases
quillforms / includes / class-quillforms.php

class-quillforms.php in Quill Forms | Conversational Multi Step Forms, Surveys & quizzes trunk, at includes/class-quillforms.php

257 lines 7.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Main class: class QuillForms
4 *
5 * @since 1.0.0
6 * @package QuillForms
7 */
8
9 namespace QuillForms;
10
11 use QuillForms\Admin\Admin;
12 use QuillForms\Admin\Admin_Loader;
13 use QuillForms\Log_Handlers\Log_Handler_DB;
14 use QuillForms\Render\Form_Renderer;
15 use QuillForms\REST_API\REST_API;
16 use QuillForms\Site\Site;
17 use QuillForms\Entries\Entries;
18
19 /**
20 * QuillForms Main Class.
21 * The main class that's responsible for loading all dependencies
22 *
23 * @since 1.0.0
24 *
25 * @property-read Tasks $tasks
26 */
27 final class QuillForms {
28
29
30 /**
31 * Tasks
32 *
33 * @since 1.6.0
34 *
35 * @var Tasks
36 */
37 private $tasks;
38
39 /**
40 * Class Instance.
41 *
42 * @since 1.0.0
43 *
44 * @var QuillForms
45 */
46 private static $instance;
47
48 /**
49 * QuillForms Instance.
50 *
51 * Instantiates or reuses an instance of QuillForms.
52 *
53 * @since 1.0.0
54 * @static
55 *
56 * @return self - Single instance
57 */
58 public static function instance() {
59 if ( ! self::$instance ) {
60 self::$instance = new self();
61 }
62 return self::$instance;
63 }
64
65 /**
66 * Constructor.
67 *
68 * @since 1.0.0
69 */
70 private function __construct() {
71 $this->load_dependencies();
72 $this->init_objects();
73 $this->init_hooks();
74 }
75
76 /**
77 * Get readonly property
78 *
79 * @param string $name Property name.
80 * @return mixed
81 */
82 public function __get( $name ) {
83 return $this->$name;
84 }
85
86 /**
87 * Isset for readonly property
88 *
89 * @param string $name Property name.
90 * @return boolean
91 */
92 public function __isset( $name ) {
93 return isset( $this->$name );
94 }
95
96 /**
97 * Dependencies Loader.
98 *
99 * @since 1.0.0
100 */
101 private function load_dependencies() {
102 // functions.
103 include_once QUILLFORMS_PLUGIN_DIR . 'includes/functions.php';
104
105 // blocks.
106 foreach ( glob( QUILLFORMS_PLUGIN_DIR . 'includes/blocks/**/*.php' ) as $block ) {
107 include_once $block;
108 }
109
110 // client assets.
111 include_once QUILLFORMS_PLUGIN_DIR . 'lib/client-assets.php';
112
113 // Caching plugins compatibility.
114 include_once QUILLFORMS_PLUGIN_DIR . 'includes/compatibility/cache/autoptimize/class-autoptimize-compatibility.php';
115 include_once QUILLFORMS_PLUGIN_DIR . 'includes/compatibility/cache/wpoptimize/class-wpoptimize-compatibility.php';
116 include_once QUILLFORMS_PLUGIN_DIR . 'includes/compatibility/cache/sg-optimize/class-sg-optimize-compatibility.php';
117 include_once QUILLFORMS_PLUGIN_DIR . 'includes/compatibility/cache/wp-rocket/class-wp-rocket-compatibility.php';
118
119 // Translation plugins compatibility.
120 if ( defined( 'WEGLOT_VERSION' ) ) {
121 include_once QUILLFORMS_PLUGIN_DIR . 'includes/compatibility/translation/weglot/class-weglot-compatability.php';
122 }
123
124 // Form Templates
125 include_once QUILLFORMS_PLUGIN_DIR . 'includes/templates/simple-contact-form/class-simple-contact-form-template.php';
126 include_once QUILLFORMS_PLUGIN_DIR . 'includes/templates/newsletter-subscription-form/class-newsletter-subscription-form-template.php';
127 include_once QUILLFORMS_PLUGIN_DIR . 'includes/templates/simple-donation-form/class-simple-donation-form-template.php';
128 include_once QUILLFORMS_PLUGIN_DIR . 'includes/templates/customer-satisfaction-survey/class-customer-satisfaction-survey-template.php';
129 include_once QUILLFORMS_PLUGIN_DIR . 'includes/templates/web-design-cost-calculator/class-web-design-cost-calculator-template.php';
130 include_once QUILLFORMS_PLUGIN_DIR . 'includes/templates/science-quiz/class-science-quiz-template.php';
131 include_once QUILLFORMS_PLUGIN_DIR . 'includes/templates/personality-quiz/class-personality-quiz-template.php';
132 include_once QUILLFORMS_PLUGIN_DIR . 'includes/templates/trivia-quiz/class-trivia-quiz-template.php';
133 include_once QUILLFORMS_PLUGIN_DIR . 'includes/templates/job-application-form/class-job-application-form-template.php';
134 include_once QUILLFORMS_PLUGIN_DIR . 'includes/templates/course-evaluation-survey/class-course-evaluation-survey-template.php';
135 include_once QUILLFORMS_PLUGIN_DIR . 'includes/templates/event-registration/class-event-registration-template.php';
136 include_once QUILLFORMS_PLUGIN_DIR . 'includes/templates/paid-workshop-registration/class-paid-workshop-registration-template.php';
137
138 }
139
140 /**
141 * Initialize instances from classes loaded.
142 *
143 * @since 1.0.0
144 */
145 private function init_objects() {
146 $this->tasks = new Tasks( 'quillforms' );
147
148 Admin_Loader::instance();
149 Install::init();
150 Merge_Tags::instance();
151 Entry_Record_Types::instance();
152 Form_Renderer::instance();
153 Form_Submission::instance();
154 Honeypot::instance();
155 Discount_Coupons::instance();
156 Admin::instance();
157 REST_API::instance();
158 Site::instance();
159 Shortcode::instance();
160 Entries::instance();
161
162 // MCP server. Everything behind this is additive and gated: it needs
163 // the WordPress Abilities API (6.9+) and an explicit admin opt-in, so
164 // on an older or un-opted-in site nothing is registered.
165 MCP\Abilities\Bootstrap::init();
166 }
167
168 /**
169 * Initialize hooks
170 *
171 * @since 1.0.0
172 */
173 private function init_hooks() {
174 add_filter( 'quillforms_register_log_handlers', array( $this, 'register_log_handlers' ) );
175 add_action( 'init', array( Capabilities::class, 'assign_capabilities_for_user_roles' ) );
176 add_action( 'init', array( Core::class, 'register_quillforms_post_type' ) );
177 add_action( 'init', array( $this, 'register_rest_fields' ) );
178 add_action( 'init', array( $this, 'flush_rewrite_rules' ), 9999999 );
179 add_action(
180 'init',
181 function() {
182 if ( in_array( 'elementor/elementor.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
183
184 // Require the widget class file
185 require_once( QUILLFORMS_PLUGIN_DIR . 'includes/page-builders/elementor/widget.php' );
186 // Require the popup class file
187 require_once( QUILLFORMS_PLUGIN_DIR . 'includes/page-builders/elementor/popup.php' );
188
189 // Register the widget
190 add_action(
191 'elementor/widgets/widgets_registered',
192 function () {
193 $widget_manager = \Elementor\Plugin::instance()->widgets_manager;
194 $widget = new \QuillForms\PageBuilders\Elementor\QuillForms_Widget();
195 $popup_widget = new \QuillForms\PageBuilders\Elementor\QuillForms_Popup_Widget();
196 $widget_manager->register_widget_type( $widget );
197 $widget_manager->register_widget_type( $popup_widget );
198 }
199 );
200 }
201 }
202 );
203 }
204
205 /**
206 * Register log handlers
207 *
208 * @param array $handlers Handlers array to filter.
209 * @return array
210 */
211 public function register_log_handlers( $handlers ) {
212 $handlers[] = new Log_Handler_DB();
213 return $handlers;
214 }
215
216 /**
217 * Flush rewrite rules
218 *
219 * @since 2.13.3
220 */
221 public function flush_rewrite_rules() {
222
223 if ( ! $option = get_option( 'quillforms-flush-rewrite-rules' ) ) {
224 return false;
225 }
226
227 if ( $option == 1 ) {
228
229 flush_rewrite_rules();
230 update_option( 'quillforms-flush-rewrite-rules', 0 );
231
232 }
233
234 return true;
235
236 }
237
238
239 /**
240 * Register REST fields.
241 *
242 * @return void
243 */
244 public function register_rest_fields() {
245 include_once QUILLFORMS_PLUGIN_DIR . 'includes/rest-fields/blocks.php';
246 include_once QUILLFORMS_PLUGIN_DIR . 'includes/rest-fields/custom-css.php';
247 include_once QUILLFORMS_PLUGIN_DIR . 'includes/rest-fields/messages.php';
248 include_once QUILLFORMS_PLUGIN_DIR . 'includes/rest-fields/notifications.php';
249 include_once QUILLFORMS_PLUGIN_DIR . 'includes/rest-fields/payments.php';
250 include_once QUILLFORMS_PLUGIN_DIR . 'includes/rest-fields/products.php';
251 include_once QUILLFORMS_PLUGIN_DIR . 'includes/rest-fields/theme.php';
252 include_once QUILLFORMS_PLUGIN_DIR . 'includes/rest-fields/settings.php';
253 include_once QUILLFORMS_PLUGIN_DIR . 'includes/rest-fields/quiz.php';
254 include_once QUILLFORMS_PLUGIN_DIR . 'includes/rest-fields/responses-count.php';
255 }
256 }
257