PluginProbe
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell / 3.12.6
WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell v3.12.6
3.13.3 3.13.2 3.13.1 3.13.0 3.12.13 3.12.12 3.12.11 3.12.10 3.12.9 3.12.8 3.12.7 3.12.6 3.12.5 3.12.4 3.12.3 3.12.1 3.12.2 3.12.0 3.11.1 3.11.0 3.10.9 3.10.8 3.10.7 3.10.6 2.8.16 All 261 releases
wpfunnels / admin / modules / automations / class-wpfnl-automations.php

class-wpfnl-automations.php in WPFunnels – Funnel Builder for WooCommerce with Checkout & One Click Upsell 3.12.6, at admin/modules/automations/class-wpfnl-automations.php

166 lines 7.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Automations module
4 *
5 * @package
6 */
7
8 namespace WPFunnels\Modules\Admin\Automations;
9
10 use WPFunnels\Admin\Module\Wpfnl_Admin_Module;
11 use WPFunnels\Traits\SingletonTrait;
12
13 class Module extends Wpfnl_Admin_Module
14 {
15 use SingletonTrait;
16
17 public function __construct()
18 {
19 // Enqueue automation-canvas scripts
20 add_action('admin_enqueue_scripts', [$this, 'enqueue_automation_scripts']);
21
22 // Initialize REST API
23 require_once WPFNL_DIR . '/admin/modules/automations/class-wpfnl-automation-rest-api.php';
24 }
25
26 /**
27 * Enqueue automation canvas scripts
28 *
29 * @param string $hook Current admin page hook
30 * @since 3.9.5
31 */
32 public function enqueue_automation_scripts($hook)
33 {
34 // Only load on automation page
35 if ('wpfunnels_page_wpfnl_automations' !== $hook) {
36 return;
37 }
38
39 // Enqueue wp-tinymce for WYSIWYG editor support
40 wp_tinymce_inline_scripts();
41 wp_enqueue_editor();
42
43 // Load automation-canvas script
44 $automation_asset_file = WPFNL_DIR . '/admin/assets/dist/js/automation-canvas.min.asset.php';
45 $automation_dependencies = ['wp-element', 'wp-i18n', 'wp-api-fetch', 'wp-data'];
46 $automation_version = WPFNL_VERSION;
47
48 if (file_exists($automation_asset_file)) {
49 $automation_asset = require $automation_asset_file;
50 $automation_dependencies = isset($automation_asset['dependencies']) ? $automation_asset['dependencies'] : $automation_dependencies;
51 $automation_version = isset($automation_asset['version']) ? $automation_asset['version'] : $automation_version;
52 }
53
54 wp_enqueue_script(
55 'wpfnl-automation-canvas',
56 WPFNL_URL . 'admin/assets/dist/js/automation-canvas.min.js',
57 $automation_dependencies,
58 $automation_version,
59 true
60 );
61
62 // Enqueue automation-canvas styles
63 $automation_css_dir = WPFNL_DIR . '/admin/assets/dist/styles/';
64 if (is_dir($automation_css_dir)) {
65 $css_files = glob($automation_css_dir . 'automation-canvas.*.css');
66 if (!empty($css_files)) {
67 $css_file = basename($css_files[0]);
68 wp_enqueue_style(
69 'wpfnl-automation-canvas-styles',
70 WPFNL_URL . 'admin/assets/dist/styles/' . $css_file,
71 [],
72 $automation_version
73 );
74 }
75 }
76
77 // Localize script with data
78 wp_localize_script(
79 'wpfnl-automation-canvas',
80 'wpfnlAutomationVars',
81 [
82 'ajaxUrl' => admin_url('admin-ajax.php'),
83 'nonce' => wp_create_nonce('wpfnl_automation_nonce'),
84 'restUrl' => rest_url(),
85 'restNonce' => wp_create_nonce('wp_rest'),
86 ]
87 );
88
89 // Provide MRM_Vars global that automation-canvas components depend on.
90 $current_user = wp_get_current_user();
91 $email_settings = get_option( '_mrm_email_settings', array() );
92 $is_pro_active = defined( 'MAIL_MINT_PRO_VERSION' );
93 $is_pro_lic_active = $is_pro_active && class_exists( 'MRM\\Common\\MrmCommon' ) && \MRM\Common\MrmCommon::is_mailmint_pro_license_active();
94 $mint_trans = class_exists( 'Mint\\MRM\\Utilities\\Helper\\TranslationString\\TransStrings' )
95 ? \Mint\MRM\Utilities\Helper\TranslationString\TransStrings::getStrings()
96 : array();
97 $lists = class_exists( 'Mint\\MRM\\DataBase\\Models\\ContactGroupModel' )
98 ? \Mint\MRM\DataBase\Models\ContactGroupModel::get_all_to_custom_select( 'lists' )
99 : array();
100 $tags = class_exists( 'Mint\\MRM\\DataBase\\Models\\ContactGroupModel' )
101 ? \Mint\MRM\DataBase\Models\ContactGroupModel::get_all_to_custom_select( 'tags' )
102 : array();
103
104 wp_localize_script(
105 'wpfnl-automation-canvas',
106 'MRM_Vars',
107 array(
108 'ajaxurl' => admin_url( 'admin-ajax.php' ),
109 'api_base_url' => get_rest_url(),
110 'nonce' => wp_create_nonce( 'wp_rest' ),
111 'current_userID' => get_current_user_id(),
112 'admin_url' => get_admin_url(),
113 'date_format' => get_option( 'date_format', 'F j, Y' ),
114 'time_format' => get_option( 'time_format', 'H:i' ),
115 'gmt_offset' => get_option( 'gmt_offset' ),
116 'local_time' => date_i18n( 'Y-m-d H:i:s' ),
117 'current_user_email' => $current_user->user_email,
118 'email_settings' => $email_settings,
119 'lists' => $lists,
120 'tags' => $tags,
121 'is_wc_active' => class_exists( 'WooCommerce' ),
122 'is_edd_active' => defined( 'EDD_VERSION' ),
123 'is_mailmint_pro_active' => $is_pro_active,
124 'is_mailmint_pro_license_active' => $is_pro_lic_active,
125 'is_tutor_active' => defined( 'TUTOR_VERSION' ),
126 'is_gform_active' => class_exists( 'GFCommon' ),
127 'is_jetform_active' => class_exists( 'Jet_Form_Builder\\Plugin' ),
128 'is_fluentform_active' => defined( 'FLUENTFORM' ),
129 'is_learndash_active' => defined( 'LEARNDASH_VERSION' ),
130 'is_memberpress_active' => defined( 'MEPR_VERSION' ),
131 'is_contact_form_active' => defined( 'WPCF7_VERSION' ),
132 'is_lifterlms_active' => defined( 'LLMS_VERSION' ),
133 'is_fluent_booking_active' => defined( 'FLUENT_BOOKING_VERSION' ),
134 'is_wp_form_active' => class_exists( 'WPForms' ),
135 'is_bricks_active' => defined( 'BRICKS_VERSION' ),
136 'is_wcs_active' => class_exists( 'WC_Subscriptions' ),
137 'is_wcm_active' => class_exists( 'WC_Memberships' ),
138 'is_wcw_active' => class_exists( 'TInvWishlist' ),
139 'mint_trans' => $mint_trans,
140 'mint_page' => 'automation',
141 'open_ai_key' => array(),
142 'twilio_settings' => array(),
143 'post_types' => array(),
144 'contact_general_fields' => array(),
145 'contact_custom_fields' => array(),
146 )
147 );
148 }
149
150 public function get_view()
151 {
152 require_once WPFNL_DIR . '/admin/modules/automations/views/view.php';
153 }
154
155 public function get_name()
156 {
157 return __('automations','wpfnl');
158 }
159
160 public function init_ajax()
161 {
162
163 }
164 }
165
166