| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
/** |
| 7 |
* Funnel Builder-integral framework bootstrap (subcore/). |
| 8 |
* |
| 9 |
* These classes are NOT part of the shared, arbitrated WooFunnels core -- Funnel |
| 10 |
* Builder owns them -- but they still boot through the core kernel like any other |
| 11 |
* framework class. This whole folder lives at the FB plugin root (subcore/), OUTSIDE |
| 12 |
* the woofunnels/ submodule: nothing plugin-specific remains in the shared core, and |
| 13 |
* no other FunnelKit plugin references it. Funnel Builder's own bootstrap |
| 14 |
* (funnel-builder.php) requires this file; here we register these classes into the |
| 15 |
* kernel's load lists via the generic bwf_kernel_* filters, and the actual class |
| 16 |
* loading happens here, off those filters, rather than from the shared core. Every path |
| 17 |
* below is __DIR__-relative, so the folder can sit anywhere FB ships it. |
| 18 |
* |
| 19 |
* Two kinds of class live here: |
| 20 |
* |
| 21 |
* 1. On-demand classes that used to sit in the shared kernel classmap and are FB-owned, |
| 22 |
* never referenced by CRM or Cart (BWF_Admin_Breadcrumbs, BWF_Admin_General_Settings, |
| 23 |
* BWF_Data_Tags, BWF_Facebook_Sdk_Factory, BWF_Facebook_Sdk). They resolve through the |
| 24 |
* subcore autoloader below -- registered at file-load, so it wins for these names |
| 25 |
* whenever Funnel Builder is active, regardless of which core copy won arbitration. |
| 26 |
* |
| 27 |
* 2. Eager / static-init classes (BWF_Ecomm_Tracking_Common, WooFunnels_Deactivate) that |
| 28 |
* the core kernel boots via the bwf_kernel_* filters. Those callbacks only fire when |
| 29 |
* FB's own dismantled core is the copy that loaded; an un-dismantled full core carries |
| 30 |
* those classes itself, so subcore/ is neither loaded nor needed there. |
| 31 |
*/ |
| 32 |
|
| 33 |
/** |
| 34 |
* Autoloader for the FB-owned on-demand framework classes moved out of the shared |
| 35 |
* kernel classmap. Paths are subcore-local (no dependency on WooFunnel_Loader::$ultimate_path), |
| 36 |
* so they resolve the same no matter which core set that seam. |
| 37 |
*/ |
| 38 |
spl_autoload_register( |
| 39 |
static function ( $class ) { |
| 40 |
$map = array( |
| 41 |
'bwf_admin_breadcrumbs' => 'class-bwf-admin-breadcrumbs.php', |
| 42 |
'bwf_admin_general_settings' => 'class-bwf-admin-general-settings.php', |
| 43 |
'bwf_data_tags' => 'class-bwf-data-tags.php', |
| 44 |
'bwf_facebook_sdk_factory' => 'class-bwf-facebook-sdk-factory.php', |
| 45 |
'bwf_facebook_sdk' => 'class-bwf-facebook-sdk.php', |
| 46 |
); |
| 47 |
$key = strtolower( $class ); |
| 48 |
if ( ! isset( $map[ $key ] ) ) { |
| 49 |
return; |
| 50 |
} |
| 51 |
$file = __DIR__ . '/' . $map[ $key ]; |
| 52 |
if ( file_exists( $file ) ) { |
| 53 |
require_once $file; |
| 54 |
} |
| 55 |
} |
| 56 |
); |
| 57 |
|
| 58 |
/** |
| 59 |
* wf_get_cookie / wf_get_url_parameter shortcodes (BWF_Data_Tags). Moved here from the |
| 60 |
* shared kernel's wire_lazy_classes(): the data-tag feature is FB's, so its wiring and |
| 61 |
* its class travel together. Handlers resolve BWF_Data_Tags lazily (via the autoloader |
| 62 |
* above) only when a tag actually renders. |
| 63 |
*/ |
| 64 |
foreach ( array( 'get_cookie', 'get_url_parameter' ) as $wf_data_tag_code ) { |
| 65 |
add_shortcode( |
| 66 |
'wf_' . $wf_data_tag_code, |
| 67 |
static function ( $attr = array() ) use ( $wf_data_tag_code ) { |
| 68 |
/** Same escaping as the real handler: these are cookie / query values. */ |
| 69 |
return esc_html( (string) BWF_Data_Tags::get_instance()->{$wf_data_tag_code}( $attr ) ); |
| 70 |
} |
| 71 |
); |
| 72 |
} |
| 73 |
|
| 74 |
/** |
| 75 |
* Conversion / ecomm tracking. Kept behind class_exists( 'WFFN_Core' ) -- it is |
| 76 |
* inert without Funnel Builder -- matching the pre-dismantle eager-load gate. |
| 77 |
*/ |
| 78 |
add_filter( |
| 79 |
'bwf_kernel_eager_classes', |
| 80 |
static function ( $classes ) { |
| 81 |
if ( class_exists( 'WFFN_Core' ) && ! in_array( 'BWF_Ecomm_Tracking_Common', $classes, true ) ) { |
| 82 |
require_once __DIR__ . '/class-bwf-ecomm-tracking-common.php'; |
| 83 |
if ( class_exists( 'BWF_Ecomm_Tracking_Common' ) ) { |
| 84 |
$classes[] = 'BWF_Ecomm_Tracking_Common'; |
| 85 |
} |
| 86 |
} |
| 87 |
|
| 88 |
return $classes; |
| 89 |
} |
| 90 |
); |
| 91 |
|
| 92 |
/** |
| 93 |
* FB-owned deactivation survey. Admin-only (its hooks are admin_footer / admin_init / |
| 94 |
* wp_ajax), and skipped if some other loaded core already supplies the class -- so a |
| 95 |
* mixed site never shows two survey modals. |
| 96 |
*/ |
| 97 |
add_filter( |
| 98 |
'bwf_kernel_static_init_classes', |
| 99 |
static function ( $classes ) { |
| 100 |
if ( is_admin() && ! class_exists( 'WooFunnels_Deactivate' ) ) { |
| 101 |
require_once __DIR__ . '/class-woofunnels-deactivate.php'; |
| 102 |
if ( class_exists( 'WooFunnels_Deactivate' ) ) { |
| 103 |
$classes[] = 'WooFunnels_Deactivate'; |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
return $classes; |
| 108 |
} |
| 109 |
); |
| 110 |
|