PluginProbe
EmailKit – Email Customizer for WooCommerce & WP / 1.6.9
EmailKit – Email Customizer for WooCommerce & WP v1.6.9
1.6.9 1.6.8 1.6.7 trunk 1.0.0 1.2.0 1.4.0 1.4.5 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6
emailkit / includes / Admin / MetaField / StyleLoad.php

StyleLoad.php in EmailKit – Email Customizer for WooCommerce & WP 1.6.9, at includes/Admin/MetaField/StyleLoad.php

174 lines 5.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace EmailKit\Admin\MetaField;
4
5 defined('ABSPATH') || exit;
6
7 use WC_Shipping_Zones;
8
9 class StyleLoad
10 {
11 const EMAILKIT_ICON_BASE_URL = EMAILKIT_URL . "assets/Images/";
12 private $emailKit;
13
14 public function __construct()
15 {
16 add_action('init', function () {
17 add_action('wp_enqueue_scripts', [$this, 'addEnqueue']);
18 });
19 }
20
21
22 public function addEnqueue()
23 {
24 $this->builder_data();
25
26 ?>
27
28 <script id="__NEXT_DATA__" type="application/json">
29 {
30 "props": {
31 "pageProps": {}
32 },
33 "page": "/",
34 "query": {},
35 "buildId": "BNHEjAAqfCFPc8hjndtt6",
36 "assetPrefix": ".",
37 "nextExport": true,
38 "autoExport": true,
39 "isFallback": false
40 }
41 </script>
42 <?php
43
44
45
46 // $response = wp_remote_get(EMAILKIT_URL . 'build/build-manifest.json');
47
48 // if (!is_wp_error($response) && wp_remote_retrieve_response_code($response) === 200) {
49 // $json_data = wp_remote_retrieve_body($response);
50 // $json_data = json_decode($json_data, true);
51
52 // if('' ==$json_data || !is_array($json_data)) {
53 // return;
54 // }
55 // if ($json_data && is_array($json_data)) {
56
57 // $scripts = $json_data["js"];
58 // $styles = $json_data["css"];
59
60 // foreach ($scripts as $index => $script) {
61 // wp_enqueue_script("emailkit-js" . $index, EMAILKIT_URL . $script, ['wp-plugins', 'wp-edit-post', 'wp-i18n', 'wp-element', 'wp-dom', 'wp-data'], EMAILKIT_VERSION, true);
62 // }
63 // foreach ($styles as $index => $style) {
64 // wp_enqueue_style("emailkit-css" . $index, EMAILKIT_URL . $style, [], EMAILKIT_VERSION);
65 // }
66 // }
67 // }
68
69 wp_enqueue_media();
70 wp_enqueue_style('media');
71 wp_enqueue_script("emailkit-js", EMAILKIT_URL . 'dist/app.js', ['wp-plugins', 'wp-edit-post', 'wp-i18n', 'wp-element', 'wp-dom', 'wp-data'], EMAILKIT_VERSION, true);
72 wp_enqueue_style("emailkit-css", EMAILKIT_URL . 'dist/app.css', [], EMAILKIT_VERSION);
73 if (is_admin()) {
74 wp_enqueue_style('emailkit-admin-style', EMAILKIT_URL . 'assets/dist/admin/styles/email-builder-navbar.css', [], EMAILKIT_VERSION);
75 }
76
77 wp_set_script_translations('emailkit-js', 'emailkit', EMAILKIT_DIR . 'languages');
78 }
79
80 public function builder_data()
81 {
82 //add_filter('show_admin_bar', '__return_false');
83
84 // Remove all WordPress actions
85 //remove_all_actions('wp_head');
86 remove_all_actions('wp_print_styles');
87 /* remove_all_actions('wp_print_head_scripts');
88 remove_all_actions('wp_footer');
89
90 // Handle `wp_enqueue_scripts`
91 remove_all_actions('wp_enqueue_scripts');
92 remove_all_actions('after_wp_tiny_mce');
93
94 // Handle `wp_head`
95 add_action('wp_head', 'wp_enqueue_scripts', 1);
96 add_action('wp_head', 'wp_print_styles', 8);
97 add_action('wp_head', 'wp_print_head_scripts', 9);
98 add_action('wp_head', 'wp_site_icon');
99
100
101 // Handle `wp_footer`
102 add_action('wp_footer', 'wp_print_footer_scripts', 20);
103 add_action('wp_footer', 'wp_auth_check_html', 30); */
104
105 // Entry theme style conflict with emailkit
106 if ( isset($_GET['action']) && $_GET['action'] == 'emailkit-builder' && get_template() == 'entry' ) {
107 add_action( 'wp_print_styles', function() {
108 wp_dequeue_style('bootstrap');
109 wp_dequeue_style('swg-css');
110 }, 100);
111 }
112
113 // Hello Elementor theme style conflict with emailkit
114 if ( get_template() == 'hello-elementor' ) {
115 wp_dequeue_style('hello-elementor');
116
117 }
118
119 // Flatsome theme style conflict with emailkit
120 else if(isset($_GET['action']) && $_GET['action'] == 'emailkit-builder' && get_template() == 'flatsome' ) {
121
122 add_action( 'wp_print_styles', function() {
123 wp_dequeue_style('flatsome-main');
124
125 });
126
127 ?>
128 <style>
129 .mobile-sidebar,
130 .no-scrollbar,
131 .mfp-hide {
132 display: none !important;
133 }
134 </style>
135 <?php
136 }
137
138 $copy_paste_enabled = \EmailKit\Promotional\Util::get_settings('emailkit_enable_copy_paste', 'no');
139 $_nonce = wp_create_nonce('wp_rest');
140 $post_id = isset($_GET['post']) ? sanitize_text_field(wp_unslash($_GET['post'])) : ''; //phpcs:ignore WordPress.Security.NonceVerification -- Nonce can't be added in CPT edit page URL
141 $is_emailkit_pro_active = is_plugin_active('emailkit-pro/emailkit-pro.php');
142 $is_shipping_zone_available = class_exists('WC_Shipping_Zones') ? !empty(WC_Shipping_Zones::get_zones()) : false;
143 $config = [
144 'version' => EMAILKIT_VERSION,
145 'restNonce' => esc_attr($_nonce),
146 'siteUrl' => esc_url(get_site_url()),
147 'assetsUrl' => esc_url(EMAILKIT_URL . 'assets/'),
148 'baseApi' => esc_url(get_rest_url(null, 'emailkit/v1/')),
149 'baseUrl' => esc_url(EMAILKIT_URL),
150 'adminUrl' => esc_url(admin_url()),
151 'adminEmail' => get_option('admin_email'),
152 'post_id' => $post_id,
153 'template_status' => get_post_meta($post_id,'emailkit_template_status',true),
154 'template_type' => get_post_meta($post_id,'emailkit_template_type',true),
155 'email_type' => get_post_meta($post_id,'emailkit_email_type',true),
156 'is_emailkit_pro_active' => ($is_emailkit_pro_active ? true : false),
157 'isWoocommreceActivate' => is_plugin_active('woocommerce/woocommerce.php') ? 'active' : 'inactive',
158 'isShippingZoneAvailable' => $is_shipping_zone_available ? 'active' : 'inactive',
159 'iconBaseUrl' => self::EMAILKIT_ICON_BASE_URL,
160 'copyPasteEnabled' => ($is_emailkit_pro_active && $copy_paste_enabled == 'yes') ? true : false,
161 ];
162
163
164
165 ?>
166 <script>
167 localStorage.removeItem('editorState');
168 window.emailKit = window.emailKit ?? {};
169 window.emailKit.config = <?php echo wp_json_encode($config); ?>;
170 </script>
171 <?php
172 }
173 }
174