PluginProbe
FunnelKit – Funnel Builder for WooCommerce Checkout / 3.15.0.8
FunnelKit – Funnel Builder for WooCommerce Checkout v3.15.0.8
3.16.0.5 3.16.0.4 3.16.0.3 3.16.0.2 3.16.0 3.16.0.1 3.15.0.9 3.15.0.8 3.0.0.1 3.0.1.1 3.0.2.1 3.1.0.1 3.1.1.1 3.1.2.1 3.10.0.1 3.10.1.1 3.10.2.1 3.11.0.0.1 3.11.0.1.1 3.11.0.2.1 3.11.1.1 3.12.0.0.1 3.12.0.1.1 3.13.0.0.1 3.13.1.0.1 All 219 releases
funnel-builder / funnel-builder.php

funnel-builder.php in FunnelKit – Funnel Builder for WooCommerce Checkout 3.15.0.8, at funnel-builder.php

503 lines 15.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: FunnelKit Funnel Builder
4 * Plugin URI: https://funnelkit.com/wordpress-funnel-builder/
5 * Description: Create high-converting sales funnels on WordPress that look professional by following a well-guided step-by-step process.
6 * Version: 3.15.0.8
7 * Author: FunnelKit
8 * Author URI: https://funnelkit.com
9 * License: GPLv3 or later
10 * License URI: http://www.gnu.org/licenses/gpl-3.0.html
11 * Text Domain: funnel-builder
12 *
13 * Requires at least: 5.4.0
14 * Tested up to: 7.0
15 * Requires PHP: 7.4
16 * WooFunnels: true
17 *
18 * Funnel Builder is free software.
19 * You can redistribute it and/or modify it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation, either version 3 of the License, or
21 * any later version.
22 *
23 * Funnel Builder is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
27 *
28 * You should have received a copy of the GNU General Public License
29 * along with Funnel Builder. If not, see <http://www.gnu.org/licenses/>.
30 */
31
32 defined( 'ABSPATH' ) || exit; // Exit if accessed directly
33
34 if ( ! class_exists( 'WFFN_Core' ) ) {
35
36 /**
37 * Class WFFN_Core
38 */
39 #[AllowDynamicProperties]
40 class WFFN_Core {
41
42 /**
43 * @var null
44 */
45 public static $_instance = null;
46
47 /**
48 * @var array
49 */
50 private static $_registered_entity = array(
51 'active' => array(),
52 'inactive' => array(),
53 );
54
55 /**
56 * @var WFFN_Admin
57 */
58 public $admin;
59
60 public $assets;
61
62 /**
63 * @var WFFN_Steps
64 */
65 public $steps;
66
67 /**
68 * @var WFFN_Substeps
69 */
70 public $substeps;
71 /**
72 * @var WFFN_Data
73 */
74 public $data;
75
76 /**
77 * @var WFFN_Logger
78 */
79 public $logger;
80
81 /**
82 * @var WFFN_Importer
83 */
84 public $import;
85
86 /**
87 * @var WFFN_Remote_Template_Importer
88 */
89 public $remote_importer;
90
91 /**
92 * @var WFFN_Page_Builder_Manager
93 */
94 public $page_builders;
95
96 /**
97 * @var WFFN_Landing_Pages
98 */
99 public $landing_pages;
100
101 /**
102 * @var WFFN_Funnel_Contacts
103 */
104 public $wffn_contacts;
105
106 /**
107 * @var WFFN_Thank_You_WC_Pages
108 */
109 public $thank_you_pages;
110
111 /** @var WFFN_Funnels_DB */
112 public $funnels_db = null;
113
114 /** @var WFFN_Template_Importer */
115 public $importer = null;
116
117 /** @var WFFN_Public */
118 public $public = null;
119
120 /** @var WFFN_WP_User_AutoLogin */
121 public $autologin = null;
122
123 /** @var WFFN_Role_Capability */
124 public $role = null;
125
126 /** @var WFFN_Admin_Notifications */
127 public $admin_notifications = null;
128
129 /**
130 * WFFN_Core constructor.
131 */
132 public function __construct() {
133
134 /**
135 * Load important variables and constants
136 */
137 $this->define_plugin_properties();
138 require_once __DIR__ . '/start.php';
139 require __DIR__ . '/includes/wffn-functions.php';
140 add_action( 'plugins_loaded', array( 'WooFunnel_Loader', 'include_core' ), - 1 );
141
142 /**
143 * Loads hooks
144 */
145 $this->load_hooks();
146 }
147
148 /**
149 * Defining constants
150 */
151 public function define_plugin_properties() {
152
153 define( 'WFFN_VERSION', '3.15.0.8' );
154 define( 'WFFN_BWF_VERSION', '1.10.12.80' );
155
156 define( 'WFFN_MIN_WC_VERSION', '3.5.0' );
157 define( 'WFFN_MIN_WP_VERSION', '5.4.0' );
158 define( 'WFFN_DB_VERSION', '4.0.0' );
159 define( 'WFFN_REVIEW_RATING_COUNT', 897 );
160 define( 'WFFN_SLUG', 'wffn' );
161 define( 'WFFN_PLUGIN_FILE', __FILE__ );
162 define( 'WFFN_PLUGIN_DIR', __DIR__ );
163 define( 'WFFN_PLUGIN_URL', untrailingslashit( plugin_dir_url( WFFN_PLUGIN_FILE ) ) );
164 define( 'WFFN_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
165 define( 'WFFN_TEMPLATE_UPLOAD_DIR', $this->get_content_dir() . '/wffn_templates/' );
166 ( defined( 'WFFN_IS_DEV' ) && true === WFFN_IS_DEV ) ? define( 'WFFN_VERSION_DEV', time() ) : define( 'WFFN_VERSION_DEV', WFFN_VERSION );
167 ( ! defined( 'WFFN_REACT_ENVIRONMENT' ) ) ? define( 'WFFN_REACT_ENVIRONMENT', 1 ) : '';
168 }
169
170 public function get_content_dir() {
171 return wp_upload_dir()['basedir'];
172 }
173
174 /**
175 * Load classes on plugins_loaded hook
176 */
177 public function load_hooks() {
178 add_action( 'plugins_loaded', array( $this, 'load_classes' ), 1 );
179 add_action( 'plugins_loaded', array( $this, 'register_classes' ), 1 );
180
181 register_activation_hook( __FILE__, array( $this, 'plugin_activation_hook' ) );
182
183 if ( ! class_exists( 'WFACP_Core' ) ) {
184
185 require __DIR__ . '/modules/checkouts/woofunnels-aero-checkout-lite.php';
186 }
187 if ( ! class_exists( 'WFOPP_Core' ) ) {
188 require __DIR__ . '/modules/optins/woofunnels-optins.php';
189 }
190 add_action( 'plugins_loaded', array( $this, 'init_oxygen' ), 10 );
191 add_action( 'wp_loaded', array( $this, 'load_divi_importer' ), 150 );
192 add_action( 'activated_plugin', array( $this, 'check_activation' ) );
193
194 // Define a constant for the plugin file, if not already defined.
195 define( 'FUNNELKIT_BRICKS_INTEGRATION_FILE', __DIR__ . '/includes/bricks-builder/' );
196 // Require the class file for Funnelkit Bricks Integration.
197 require_once __DIR__ . '/includes/bricks-builder/includes/class-bricks-integration.php';
198 }
199
200 /**
201 *
202 */
203 public function load_classes() {
204
205 try {
206 /**
207 * Loads all the admin
208 */
209 $this->load_autoloader();
210 $this->load_admin();
211 $this->load_includes();
212 $this->load_modules();
213 $this->load_steps();
214 $this->load_commons();
215 $this->load_analytics();
216 } catch ( Exception |Error $e ) {
217 // do nothing here
218 }
219 }
220
221 /**
222 * Loads the admin
223 */
224 public function load_admin() {
225 include_once __DIR__ . '/admin/class-wffn-admin.php';
226 include_once __DIR__ . '/admin/class-bwf-admin-breadcrumbs.php';
227 include_once __DIR__ . '/admin/class-bwf-admin-settings.php';
228 include_once __DIR__ . '/admin/class-wffn-page-builder-manager.php';
229 include_once __DIR__ . '/admin/class-wffn-admin-notifications.php';
230 include_once __DIR__ . '/admin/rest-api/class-wffn-rest-funnels.php';
231 include_once __DIR__ . '/admin/rest-api/class-wffn-rest-steps.php';
232 include_once __DIR__ . '/admin/rest-api/class-wffn-rest-substeps.php';
233 include_once __DIR__ . '/admin/rest-api/class-wffn-rest-funnel-settings.php';
234 include_once __DIR__ . '/admin/rest-api/class-wffn-api-update-user-preference.php';
235 include_once __DIR__ . '/admin/rest-api/class-wffn-rest-tools.php';
236 include_once __DIR__ . '/admin/rest-api/class-wffn-rest-licenses.php';
237 include_once __DIR__ . '/admin/rest-api/class-wffn-rest-funnel-canvas.php';
238 include_once __DIR__ . '/admin/rest-api/class-wffn-rest-user-preferences.php';
239 include_once __DIR__ . '/admin/rest-api/class-wffn-rest-notifications.php';
240 include_once __DIR__ . '/admin/rest-api/class-wffn-rest-get-recipes.php';
241 include_once __DIR__ . '/admin/rest-api/class-wffn-rest-setup.php';
242 include_once __DIR__ . '/admin/rest-api/class-wffn-rest-store-checkout.php';
243 include_once __DIR__ . '/admin/rest-api/class-wffn-rest-funnel-modules.php';
244 include_once __DIR__ . '/admin/rest-api-helpers/class-wffn-rest-api-helpers.php';
245 include_once __DIR__ . '/admin/rest-api/class-wffn-rest-optin-api-endpoint.php';
246 include_once __DIR__ . '/admin/rest-api/class-wffn-rest-checkout-api-endpoint.php';
247 include_once __DIR__ . '/admin/rest-api/class-wffn-rest-wizard.php';
248 include_once __DIR__ . '/admin/rest-api/class-wffn-funnel-contacts.php';
249 include_once __DIR__ . '/admin/rest-api/class-wffn-funnel-orders.php';
250 include_once __DIR__ . '/admin/rest-api/class-wffn-rest-api-dashboard-endpoint.php';
251 require_once __DIR__ . '/admin/rest-api/class-wffn-api-send-test-notification.php';
252
253 /*
254 * Order Bump Preview
255 */
256
257 include_once __DIR__ . '/admin/rest-api/class-wfob-bump-rest-api.php';
258
259 /***Global settings*/
260
261 include_once __DIR__ . '/admin/rest-api/class-wffn-rest-global-settings.php';
262
263 /**Global Header */
264 include_once __DIR__ . '/admin/includes/class-wffn-header.php';
265 }
266
267 /**
268 * Load includes folder
269 */
270 public function load_includes() {
271
272 require __DIR__ . '/includes/class-wffn-logger.php';
273 require __DIR__ . '/includes/class-wffn-session-handler.php';
274 require __DIR__ . '/includes/class-wffn-data.php';
275 require __DIR__ . '/includes/class-wffn-funnels-db.php';
276 require __DIR__ . '/includes/class-wffn-public.php';
277 require __DIR__ . '/includes/class-wffn-funnel.php';
278 require __DIR__ . '/includes/class-wffn-woofunnels-support.php';
279 require __DIR__ . '/merge-tags/class-bwf-contact-tags.php';
280 }
281
282 /**
283 * Include Modules (Landing & thankyou)
284 */
285 public function load_modules() {
286 require __DIR__ . '/includes/class-wffn-module-common.php';
287 require __DIR__ . '/modules/landing-pages/class-wffn-landing-pages.php';
288 require __DIR__ . '/modules/thankyou-pages/class-wffn-thank-you-wc-pages.php';
289 do_action( 'wffn_core_modules_loaded' );
290 }
291
292 /**
293 * Include steps and substeps
294 */
295 public function load_steps() {
296 require __DIR__ . '/includes/class-wffn-step-base.php';
297 require __DIR__ . '/includes/class-wffn-step.php';
298 require __DIR__ . '/includes/class-wffn-steps.php';
299 require __DIR__ . '/includes/class-wffn-substep.php';
300 require __DIR__ . '/includes/class-wffn-substeps.php';
301 }
302
303 /**
304 * Includes common functions.
305 */
306 public function load_commons() {
307
308 require __DIR__ . '/includes/class-wffn-common.php';
309
310 require __DIR__ . '/importer/interface-import-export.php';
311 require __DIR__ . '/importer/class-wffn-template-importer.php';
312 require __DIR__ . '/importer/class-wffn-background-importer.php';
313 require __DIR__ . '/admin/db/wffn-updater-functions.php';
314
315 include_once __DIR__ . '/admin/class-wffn-importer.php';
316
317 $response = WFFN_Common::check_builder_status( 'elementor' );
318 if ( true === $response['found'] && empty( $response['error'] ) ) {
319 require __DIR__ . '/importer/class-wffn-elementor-importer.php';
320 }
321
322 require __DIR__ . '/importer/class-wffn-wp-editor-importer.php';
323 require __DIR__ . '/compatibilities/class-wffn-plugin-compatibilities.php';
324 require __DIR__ . '/includes/class-wffn-conversion-tracking-migrator.php';
325 WFFN_Common::init();
326 }
327
328
329 public function load_divi_importer() {
330
331 try {
332 $response = WFFN_Common::check_builder_status( 'divi' );
333 if ( true === $response['found'] && empty( $response['error'] ) ) {
334 require __DIR__ . '/importer/class-wffn-divi-importer.php';
335 require __DIR__ . '/importer/class-wffn-divi5-importer.php';
336 }
337 $response = WFFN_Common::check_builder_status( 'oxy' );
338 if ( true === $response['found'] && empty( $response['error'] ) ) {
339 require __DIR__ . '/importer/class-wffn-oxygen-importer.php';
340 }
341 require __DIR__ . '/importer/class-wffn-gutenberg-importer.php';
342 } catch ( Exception $e ) {
343 // do nothing here
344 }
345 }
346
347 public function load_analytics() {
348 if ( class_exists( 'WFACP_Core' ) && wffn_is_wc_active() && ! class_exists( 'WFACP_Contacts_Analytics' ) ) {
349 require_once __DIR__ . '/contact-analytics/class-wfacp-contacts-analytics.php';
350 }
351 if ( class_exists( 'WFOPP_Core' ) && ! class_exists( 'WFFN_Optin_Contacts_Analytics' ) ) {
352 require_once __DIR__ . '/contact-analytics/class-wffn-optin-contacts-analytics.php';
353 }
354 if ( class_exists( 'WFOB_Core' ) && wffn_is_wc_active() && ! class_exists( 'WFOB_Contacts_Analytics' ) ) {
355 require_once __DIR__ . '/contact-analytics/class-wfob-contacts-analytics.php';
356 }
357 if ( class_exists( 'WFOCU_Core' ) && wffn_is_wc_active() && ! class_exists( 'WFOCU_Contacts_Analytics' ) ) {
358 require_once __DIR__ . '/contact-analytics/class-wfocu-contacts-analytics.php';
359 }
360 }
361
362 /**
363 * @return WFFN_Core|null
364 */
365 public static function get_instance() {
366 if ( null === self::$_instance ) {
367 self::$_instance = new self();
368 }
369
370 return self::$_instance;
371 }
372
373
374 /**
375 * Register classes
376 */
377 public function register_classes() {
378
379 try {
380 $load_classes = self::get_registered_class();
381 if ( is_array( $load_classes ) && count( $load_classes ) > 0 ) {
382 foreach ( $load_classes as $access_key => $class ) {
383
384 $this->$access_key = $class::get_instance();
385 }
386 do_action( 'wffn_loaded' );
387 }
388 } catch ( Exception $e ) {
389 // do nothing here
390 }
391 }
392
393 /**
394 * @return mixed
395 */
396 public static function get_registered_class() {
397 return self::$_registered_entity['active'];
398 }
399
400 public static function register( $short_name, $class ) { //phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedParameter
401
402 self::$_registered_entity['active'][ $short_name ] = $class;
403 }
404
405 /**
406 * @return WFFN_Funnels_DB
407 */
408 public function get_dB() {
409 if ( empty( $this->funnels_db ) ) {
410 $class = apply_filters( 'wffn_funnels_db_class', 'WFFN_Funnels_DB' );
411 $this->funnels_db = new $class();
412 }
413
414 return $this->funnels_db;
415 }
416
417 public function plugin_activation_hook() {
418 update_option( 'bwf_needs_rewrite', 'yes', true );
419
420 /** Save the plugin first version when the plugin was activated, if not already present */
421 $first_version = get_option( 'wffn_first_v', '' );
422 if ( empty( $first_version ) ) {
423 update_option( 'wffn_first_v', WFFN_VERSION, false );
424
425 }
426 }
427
428 public function get_plugin_url() {
429 return untrailingslashit( plugin_dir_url( WFFN_PLUGIN_FILE ) );
430 }
431
432 public function load_autoloader() {
433 spl_autoload_register( array( $this, 'autoload' ) );
434 }
435
436 public function autoload( $class_name ) {
437 if ( false !== strpos( $class_name, 'WFFN_' ) ) {
438 if ( file_exists( WFFN_PLUGIN_DIR . '/includes/' . 'class-' . $this->slugify_classname( $class_name ) . '.php' ) ) {
439 require_once WFFN_PLUGIN_DIR . '/includes/' . 'class-' . $this->slugify_classname( $class_name ) . '.php'; // phpcs:ignore WordPressVIPMinimum.Files.IncludingFile.UsingCustomConstant
440 }
441 }
442 }
443
444 public function slugify_classname( $class_name ) {
445 $classname = $this->custom_sanitize_title( $class_name );
446 $classname = str_replace( '_', '-', $classname );
447
448 return $classname;
449 }
450
451 /**
452 * Custom sanitize title method to avoid conflicts with WordPress hooks on sanitize_title
453 *
454 * @param string $title The title to sanitize
455 * @return string The sanitized title
456 */
457 private function custom_sanitize_title( $title ) {
458 $title = remove_accents( $title );
459 $title = sanitize_title_with_dashes( $title );
460
461 return $title;
462 }
463
464 public function init_oxygen() {
465 if ( class_exists( 'OxygenElement' ) ) {
466 require_once __DIR__ . '/includes/class-abstract-wffn-oxygen-fields.php';
467 }
468 }
469
470 /**
471 * Added redirection on plugin activation
472 *
473 * @param $plugin
474 */
475 public function check_activation( $plugin ) {
476 if ( $plugin === plugin_basename( WFFN_PLUGIN_FILE ) ) {
477 $pro_first_active = get_option( 'fk_fb_active_date', array() );
478 if ( empty( $pro_first_active ) || ! isset( $pro_first_active['lite'] ) ) {
479 $pro_first_active['lite'] = current_time( 'timestamp' );
480 update_option( 'fk_fb_active_date', $pro_first_active, false );
481 }
482 }
483 if ( ( defined( 'WFFN_PRO_FILE' ) && $plugin === plugin_basename( WFFN_PRO_FILE ) ) || ( defined( 'WFFN_BASIC_FILE' ) && $plugin === plugin_basename( WFFN_BASIC_FILE ) ) ) {
484 $pro_first_active = get_option( 'fk_fb_active_date', array() );
485 if ( empty( $pro_first_active ) || ! isset( $pro_first_active['pro'] ) ) {
486 $pro_first_active['pro'] = current_time( 'timestamp' );
487 update_option( 'fk_fb_active_date', $pro_first_active, false );
488 }
489 }
490 }
491 }
492 }
493 if ( ! function_exists( 'WFFN_Core' ) ) {
494 /**
495 * @return WFFN_Core|null
496 */
497 function WFFN_Core() { //@codingStandardsIgnoreLine
498 return WFFN_Core::get_instance();
499 }
500 }
501
502 $GLOBALS['WFFN_Core'] = WFFN_Core();
503