PluginProbe ʕ •ᴥ•ʔ
WPForms – Easy Form Builder for WordPress – Contact Forms, Payment Forms, Surveys, & More / 1.5.0.4
WPForms – Easy Form Builder for WordPress – Contact Forms, Payment Forms, Surveys, & More v1.5.0.4
1.10.1.1 1.10.1 1.10.0.5 trunk 1.1.4 1.1.4.2 1.1.5 1.1.5.1 1.1.6 1.1.6.1 1.1.7 1.1.7.1 1.1.7.2 1.1.8 1.1.8.1 1.1.8.2 1.1.8.3 1.1.8.4 1.10.0.1 1.10.0.2 1.10.0.3 1.10.0.4 1.2.0 1.2.0.1 1.2.1 1.2.2 1.2.2.1 1.2.2.2 1.2.3 1.2.3.1 1.2.3.2 1.2.4 1.2.4.1 1.2.5 1.2.5.1 1.2.6 1.2.7 1.2.8 1.2.8.1 1.2.9 1.3.0 1.3.1 1.3.1.1 1.3.1.2 1.3.2 1.3.3 1.3.5 1.3.6 1.3.6.1 1.3.6.2 1.3.7.2 1.3.7.3 1.3.7.4 1.3.8 1.3.9.1 1.4.0.1 1.4.1.1 1.4.2 1.4.2.1 1.4.2.2 1.4.3 1.4.4 1.4.4.1 1.4.5 1.4.5.1 1.4.5.2 1.4.5.3 1.4.6 1.4.7.1 1.4.7.2 1.4.8.1 1.4.9 1.5.0.1 1.5.0.3 1.5.0.4 1.5.1 1.5.1.1 1.5.1.3 1.5.2.1 1.5.2.2 1.5.2.3 1.5.3 1.5.3.1 1.5.4.1 1.5.4.2 1.5.5 1.5.5.1 1.5.6 1.5.6.2 1.5.7 1.5.8.2 1.5.9.1 1.5.9.4 1.5.9.5 1.6.0.1 1.6.0.2 1.6.1 1.6.2.2 1.6.2.3 1.6.3.1 1.6.4 1.6.4.1 1.6.5 1.6.6 1.6.7 1.6.7.1 1.6.7.2 1.6.7.3 1.6.8 1.6.8.1 1.6.9 1.7.0 1.7.1.1 1.7.1.2 1.7.2 1.7.2.1 1.7.3 1.7.4 1.7.4.1 1.7.4.2 1.7.5.1 1.7.5.2 1.7.5.3 1.7.5.5 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.7.9.1 1.8.0.1 1.8.0.2 1.8.1.1 1.8.1.2 1.8.1.3 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.3.1 1.8.4 1.8.4.1 1.8.5.2 1.8.5.3 1.8.5.4 1.8.6.2 1.8.6.3 1.8.6.4 1.8.7.2 1.8.8.2 1.8.8.3 1.8.9.1 1.8.9.2 1.8.9.4 1.8.9.5 1.8.9.6 1.9.0.1 1.9.0.2 1.9.0.3 1.9.0.4 1.9.1.1 1.9.1.2 1.9.1.3 1.9.1.4 1.9.1.5 1.9.1.6 1.9.2.1 1.9.2.2 1.9.2.3 1.9.3.1 1.9.3.2 1.9.4.1 1.9.4.2 1.9.5 1.9.5.1 1.9.5.2 1.9.6 1.9.6.1 1.9.6.2 1.9.7.1 1.9.7.2 1.9.7.3 1.9.8.1 1.9.8.2 1.9.8.4 1.9.8.7 1.9.9.2 1.9.9.3 1.9.9.4
wpforms-lite / src / WPForms.php
wpforms-lite / src Last commit date
Admin 7 years ago Integrations 7 years ago Lite 7 years ago Providers 7 years ago WPForms.php 7 years ago
WPForms.php
341 lines
1 <?php
2
3 namespace WPForms {
4
5 /**
6 * Main WPForms class.
7 *
8 * @since 1.0.0
9 *
10 * @package WPForms
11 */
12 final class WPForms {
13
14 /**
15 * One is the loneliest number that you'll ever do.
16 *
17 * @since 1.0.0
18 *
19 * @var \WPForms\WPForms
20 */
21 private static $instance;
22
23 /**
24 * Plugin version for enqueueing, etc.
25 * The value is got from WPFORMS_VERSION constant.
26 *
27 * @since 1.0.0
28 *
29 * @var string
30 */
31 public $version = '';
32
33 /**
34 * The form data handler instance.
35 *
36 * @since 1.0.0
37 *
38 * @var \WPForms_Form_Handler
39 */
40 public $form;
41
42 /**
43 * The entry data handler instance (Pro).
44 *
45 * @since 1.0.0
46 *
47 * @var \WPForms_Entry_Handler
48 */
49 public $entry;
50
51 /**
52 * The entry fields data handler instance (Pro).
53 *
54 * @since 1.4.3
55 *
56 * @var \WPForms_Entry_Fields_Handler
57 */
58 public $entry_fields;
59
60 /**
61 * The entry meta data handler instance (Pro).
62 *
63 * @since 1.1.6
64 *
65 * @var \WPForms_Entry_Meta_Handler
66 */
67 public $entry_meta;
68
69 /**
70 * The front-end instance.
71 *
72 * @since 1.0.0
73 *
74 * @var \WPForms_Frontend
75 */
76 public $frontend;
77
78 /**
79 * The process instance.
80 *
81 * @since 1.0.0
82 *
83 * @var \WPForms_Process
84 */
85 public $process;
86
87 /**
88 * The smart tags instance.
89 *
90 * @since 1.0.0
91 *
92 * @var \WPForms_Smart_Tags
93 */
94 public $smart_tags;
95
96 /**
97 * The Logging instance.
98 *
99 * @since 1.0.0
100 *
101 * @var \WPForms_Logging
102 */
103 public $logs;
104
105 /**
106 * The Preview instance.
107 *
108 * @since 1.1.9
109 *
110 * @var \WPForms_Preview
111 */
112 public $preview;
113
114 /**
115 * The License class instance (Pro).
116 *
117 * @since 1.0.0
118 *
119 * @var \WPForms_License
120 */
121 public $license;
122
123 /**
124 * Paid returns true, free (Lite) returns false.
125 *
126 * @since 1.3.9
127 *
128 * @var boolean
129 */
130 public $pro = false;
131
132 /**
133 * Main WPForms Instance.
134 *
135 * Insures that only one instance of WPForms exists in memory at any one
136 * time. Also prevents needing to define globals all over the place.
137 *
138 * @since 1.0.0
139 *
140 * @return WPForms
141 */
142 public static function instance() {
143
144 if (
145 null === self::$instance ||
146 ! self::$instance instanceof self
147 ) {
148
149 self::$instance = new self();
150 self::$instance->constants();
151 self::$instance->conditional_logic_addon_check();
152 self::$instance->includes();
153
154 // Load Pro or Lite specific files.
155 if ( self::$instance->pro ) {
156 require_once WPFORMS_PLUGIN_DIR . 'pro/wpforms-pro.php';
157 } else {
158 require_once WPFORMS_PLUGIN_DIR . 'lite/wpforms-lite.php';
159 }
160
161 add_action( 'plugins_loaded', array( self::$instance, 'load_textdomain' ), 10 );
162 add_action( 'plugins_loaded', array( self::$instance, 'objects' ), 10 );
163 }
164
165 return self::$instance;
166 }
167
168 /**
169 * Setup plugin constants.
170 * All the path/URL related constants are defined in main plugin file.
171 *
172 * @since 1.0.0
173 */
174 private function constants() {
175
176 $this->version = WPFORMS_VERSION;
177
178 // Plugin Slug - Determine plugin type and set slug accordingly.
179 if ( apply_filters( 'wpforms_allow_pro_version', file_exists( WPFORMS_PLUGIN_DIR . 'pro/wpforms-pro.php' ) ) ) {
180 $this->pro = true;
181 define( 'WPFORMS_PLUGIN_SLUG', 'wpforms' );
182 } else {
183 define( 'WPFORMS_PLUGIN_SLUG', 'wpforms-lite' );
184 }
185 }
186
187 /**
188 * Loads the plugin language files.
189 *
190 * @since 1.0.0
191 * @since 1.5.0 Load only the lite translation.
192 */
193 public function load_textdomain() {
194 load_plugin_textdomain( 'wpforms-lite', false, dirname( plugin_basename( WPFORMS_PLUGIN_FILE ) ) . '/languages/' );
195 }
196
197 /**
198 * Check to see if the conditional logic addon is running, if so then
199 * deactivate the plugin to prevent conflicts.
200 *
201 * @since 1.3.8
202 */
203 private function conditional_logic_addon_check() {
204
205 if ( function_exists( 'wpforms_conditional_logic' ) ) {
206
207 // Load core files needed to activate deactivate_plugins().
208 require_once ABSPATH . 'wp-admin/includes/plugin.php';
209 require_once ABSPATH . 'wp-includes/pluggable.php';
210
211 // Deactivate Conditional Logic addon.
212 deactivate_plugins( 'wpforms-conditional-logic/wpforms-conditional-logic.php' );
213
214 // To avoid namespace collisions, reload current page.
215 $url = esc_url_raw( remove_query_arg( 'wpforms-test' ) );
216 wp_redirect( $url );
217 exit;
218 }
219 }
220
221 /**
222 * Include files.
223 *
224 * @since 1.0.0
225 */
226 private function includes() {
227
228 $this->includes_magic();
229
230 // Global includes.
231 require_once WPFORMS_PLUGIN_DIR . 'includes/functions.php';
232 require_once WPFORMS_PLUGIN_DIR . 'includes/class-install.php';
233 require_once WPFORMS_PLUGIN_DIR . 'includes/class-form.php';
234 require_once WPFORMS_PLUGIN_DIR . 'includes/class-fields.php';
235 require_once WPFORMS_PLUGIN_DIR . 'includes/class-frontend.php';
236 // TODO: class-templates.php should be loaded in admin area only.
237 require_once WPFORMS_PLUGIN_DIR . 'includes/class-templates.php';
238 // TODO: class-providers.php should be loaded in admin area only.
239 require_once WPFORMS_PLUGIN_DIR . 'includes/class-providers.php';
240 require_once WPFORMS_PLUGIN_DIR . 'includes/class-process.php';
241 require_once WPFORMS_PLUGIN_DIR . 'includes/class-smart-tags.php';
242 require_once WPFORMS_PLUGIN_DIR . 'includes/class-logging.php';
243 require_once WPFORMS_PLUGIN_DIR . 'includes/class-widget.php';
244 require_once WPFORMS_PLUGIN_DIR . 'includes/class-preview.php';
245 require_once WPFORMS_PLUGIN_DIR . 'includes/class-conditional-logic-core.php';
246 require_once WPFORMS_PLUGIN_DIR . 'includes/emails/class-emails.php';
247 require_once WPFORMS_PLUGIN_DIR . 'includes/integrations.php';
248
249 // Admin/Dashboard only includes, also in ajax.
250 if ( is_admin() ) {
251 require_once WPFORMS_PLUGIN_DIR . 'includes/admin/admin.php';
252 require_once WPFORMS_PLUGIN_DIR . 'includes/admin/class-notices.php';
253 require_once WPFORMS_PLUGIN_DIR . 'includes/admin/class-menu.php';
254 require_once WPFORMS_PLUGIN_DIR . 'includes/admin/overview/class-overview.php';
255 require_once WPFORMS_PLUGIN_DIR . 'includes/admin/builder/class-builder.php';
256 require_once WPFORMS_PLUGIN_DIR . 'includes/admin/builder/functions.php';
257 require_once WPFORMS_PLUGIN_DIR . 'includes/admin/class-settings.php';
258 require_once WPFORMS_PLUGIN_DIR . 'includes/admin/class-welcome.php';
259 require_once WPFORMS_PLUGIN_DIR . 'includes/admin/class-tools.php';
260 require_once WPFORMS_PLUGIN_DIR . 'includes/admin/class-editor.php';
261 require_once WPFORMS_PLUGIN_DIR . 'includes/admin/class-review.php';
262 require_once WPFORMS_PLUGIN_DIR . 'includes/admin/class-importers.php';
263 require_once WPFORMS_PLUGIN_DIR . 'includes/admin/class-about.php';
264 require_once WPFORMS_PLUGIN_DIR . 'includes/admin/ajax-actions.php';
265 require_once WPFORMS_PLUGIN_DIR . 'includes/admin/class-am-notification.php';
266 require_once WPFORMS_PLUGIN_DIR . 'includes/admin/class-am-deactivation-survey.php';
267 require_once WPFORMS_PLUGIN_DIR . 'includes/admin/class-am-dashboard-widget-extend-feed.php';
268 }
269 }
270
271 /**
272 * Including the new files with PHP 5.3 style.
273 *
274 * @since 1.4.7
275 */
276 private function includes_magic() {
277
278 // Autoloader is put into its own file to save space here.
279 require_once WPFORMS_PLUGIN_DIR . 'autoloader.php';
280
281 /*
282 * Load admin components.
283 */
284 add_action( 'wpforms_loaded', array( '\WPForms\Admin\Loader', 'get_instance' ) );
285
286 /*
287 * Properly init the providers loader, that will handle all the related logic and further loading.
288 */
289 add_action( 'wpforms_loaded', array( '\WPForms\Providers\Loader', 'get_instance' ) );
290
291 /*
292 * Properly init the integrations loader, that will handle all the related logic and further loading.
293 */
294 add_action( 'wpforms_loaded', array( '\WPForms\Integrations\Loader', 'get_instance' ) );
295 }
296
297 /**
298 * Setup objects.
299 *
300 * @since 1.0.0
301 */
302 public function objects() {
303
304 // Global objects.
305 $this->form = new \WPForms_Form_Handler();
306 $this->frontend = new \WPForms_Frontend();
307 $this->process = new \WPForms_Process();
308 $this->smart_tags = new \WPForms_Smart_Tags();
309 $this->logs = new \WPForms_Logging();
310 $this->preview = new \WPForms_Preview();
311
312 if ( is_admin() ) {
313 if ( ! wpforms_setting( 'hide-announcements', false ) ) {
314 new \AM_Notification( WPFORMS_PLUGIN_SLUG, $this->version );
315 }
316
317 if ( $this->pro || ( ! $this->pro && ! file_exists( WP_PLUGIN_DIR . '/wpforms/wpforms.php' ) ) ) {
318 new \AM_Deactivation_Survey( 'WPForms', basename( dirname( __DIR__ ) ) );
319 }
320 }
321
322 // Hook now that all of the WPForms stuff is loaded.
323 do_action( 'wpforms_loaded' );
324 }
325 }
326 }
327
328 namespace {
329
330 /**
331 * The function which returns the one WPForms instance.
332 *
333 * @since 1.0.0
334 *
335 * @return WPForms\WPForms
336 */
337 function wpforms() {
338 return WPForms\WPForms::instance();
339 }
340 }
341