PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 4.7.2
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v4.7.2
4.9.1 4.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.1 3.0.0 3.1.0 3.1.1 4.0.0 4.0.1 4.1.0 4.1.1 4.2.0 4.2.1 4.3.0 4.3.1 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.6.8 4.6.9 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.8.9 trunk 0.1.2-beta 0.1.3-beta 0.1.4-beta 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.5.0 1.5.1 1.6.0 1.6.1 1.7.0 1.8.0 1.8.1 1.9.0
shopengine / utils / emailkit / emailkit.php
shopengine / utils / emailkit Last commit date
assets 1 year ago emailkit.php 1 year ago
emailkit.php
223 lines
1 <?php
2
3 namespace Wpmet\Libs;
4
5 defined('ABSPATH') || exit;
6
7 if( !class_exists('\Wpmet\Libs\Emailkit') ) {
8
9 class Emailkit{
10
11 private $is_already_installed = '';
12
13 /**
14 * Constructor for initializing the class.
15 *
16 * @access public
17 * @return void
18 */
19 public function __construct() {
20
21 do_action('edit_with_emailkit_loaded');
22
23 if( empty( $_GET[ 'page' ] ) || 'wc-settings' !== $_GET[ 'page' ] || empty( $_GET[ 'tab' ] ) || 'email' !== $_GET[ 'tab' ] ) {
24 return;
25 }
26
27 if( !function_exists('get_plugins') ) {
28 include_once ABSPATH . 'wp-admin/includes/plugin.php';
29 }
30
31 $installed_plugins = get_plugins();
32 $this->is_already_installed = isset($installed_plugins['emailkit/EmailKit.php']) ? 1 : 0;
33
34 $message = '<div class="edit-with-emailkit-wrapper"><div class="edit-with-emailkit-banner-left"><div class="edit-with-emailkit-banner-main"><div class="edit-with-emailkit-banner-logo"><img src="'.plugin_dir_url( __FILE__ ).'/assets/logo.svg" /></div><div class="edit-with-emailkit-banner-middle"><div class="edit-with-emailkit-banner-title">Edit your woocommerce emails with EmailKit builder for free.</div><p>Get 22+ WooCommerce elements, 14+ templates, Shortcode support, and more for absolutely free with EmailKit - The Best WordPress Email Customizer.✨</p></div></div></div><div class="edit-with-emailkit-banner-right"><div class="emailkit-install-activate-btn">Get EmailKit</div></div></div>';
35
36 $dismissed_coutner = get_option('shopengine-edit_with_emailkit_banner_dismissed_'.get_current_user_id(), 0);
37 $notice_showing_delay_time = (3600 * 24 * 15);
38
39 if($dismissed_coutner == 1){
40 $notice_showing_delay_time = (3600 * 24 * 30);
41 }elseif($dismissed_coutner == 2){
42 $notice_showing_delay_time = (3600 * 24 * 180);
43 }elseif($dismissed_coutner >= 3){
44 $notice_showing_delay_time = (3600 * 24 * 99999);
45 }
46
47 \Oxaim\Libs\Notice::instance('shopengine', 'edit_with_emailkit_banner')
48 ->set_dismiss('user', $notice_showing_delay_time)
49 ->set_message($message)
50 ->call();
51
52 add_action('admin_head', [$this, 'emailkit_admin_head']);
53 }
54
55 public function emailkit_admin_head() {
56 ?>
57 <style>
58 .notice-shopengine-edit_with_emailkit_banner{
59 background-image: url("<?php echo esc_url(plugin_dir_url( __FILE__ ).'/assets/notification.svg') ?>") !important;
60 color: #fff;
61 background-size: cover !important;
62 background-repeat: no-repeat !important;
63 background-position: center center !important;
64 border: none !important;
65 }
66 .notice-shopengine-edit_with_emailkit_banner .edit-with-emailkit-banner-main{
67 display: flex;
68 gap: 15px;
69 }
70 .notice-shopengine-edit_with_emailkit_banner button::before{
71 color: #ffffff;
72 }
73
74 .notice-shopengine-edit_with_emailkit_banner .notice-container-full-width{
75 padding: 0;
76 margin: 0 !important;
77 }
78 .notice-shopengine-edit_with_emailkit_banner .notice-container-full-width .edit-with-emailkit-wrapper{
79 display: flex;
80 justify-content: space-between;
81 align-items: center;
82 }
83 .notice-shopengine-edit_with_emailkit_banner .notice-container-full-width .edit-with-emailkit-wrapper .edit-with-emailkit-banner-right{
84 margin-right: 60px;
85 }
86
87 .notice-shopengine-edit_with_emailkit_banner .notice-container-full-width .edit-with-emailkit-wrapper .edit-with-emailkit-banner-left .edit-with-emailkit-banner-main .edit-with-emailkit-banner-logo{
88 padding: 24px 8px 0px 8px;
89 border-left: 6px solid #13d5ff;
90 background: #FFFFFF1A;
91 }
92 .notice-shopengine-edit_with_emailkit_banner .notice-container-full-width .edit-with-emailkit-wrapper .edit-with-emailkit-banner-left .edit-with-emailkit-banner-middle{
93 padding: 20px 4px;
94 }
95 .notice-shopengine-edit_with_emailkit_banner .notice-container-full-width .edit-with-emailkit-wrapper .edit-with-emailkit-banner-right .emailkit-install-activate-btn{
96 font-size: 14px;
97 font-weight: 500;
98 color: #070C14;
99 padding: 15px 22px;
100 background: #EBFF00;
101 cursor: pointer;
102 border-radius: 4px;
103 }
104 .edit-with-emailkit-banner-title{
105 font-size: 24px;
106 font-weight: 600;
107 margin-bottom: 8px;
108 }
109 </style>
110 <script type="text/javascript">
111
112 jQuery( document ).ready( function( $ ) {
113
114 const emailKitInstallBtn = document.querySelector('.emailkit-install-activate-btn');
115
116 if( !emailKitInstallBtn ) {
117 return;
118 }
119
120 const isAlreadyInstalled = "<?php echo esc_attr($this->is_already_installed) ?>";
121 let installationUrl = "<?php echo esc_url($this->installation_url('emailkit/EmailKit.php')) ?>";
122 let activationUrl = "<?php echo esc_url($this->activation_url('emailkit/EmailKit.php')) ?>";
123 installationUrl = installationUrl?.replace(/&#038;/g, '&');
124 activationUrl = activationUrl?.replace(/&#038;/g, '&');
125
126 function emailkit_install_active_plugin(ajaxurl, success_callback, beforeText) {
127 try {
128 $.ajax({
129 type: "GET",
130 url: ajaxurl,
131 beforeSend: () => {
132 emailKitInstallBtn.innerHTML = beforeText;
133 },
134 success: (response) => {
135 if (success_callback) {
136 success_callback();
137 }else{
138 location.reload();
139 }
140 },
141 error: function (error) {
142 console.error(error);
143 }
144 });
145 } catch (error) {
146 console.error("An error occurred:", error);
147 }
148 }
149
150 emailKitInstallBtn.addEventListener('click', function(e) {
151
152 e.preventDefault();
153
154 if(isAlreadyInstalled === '0'){
155 emailkit_install_active_plugin.call(this, installationUrl, () => {
156 emailkit_install_active_plugin.call(this, activationUrl, null, 'Activating...');
157 }, 'Installing...');
158 } else if (isAlreadyInstalled === '1') {
159 emailkit_install_active_plugin.call(this, activationUrl, null, 'Activating...');
160 }
161 });
162 });
163 </script>
164 <?php
165 }
166
167 /**
168 * Get plugin installation url
169 *
170 * @access public
171 * @param string
172 * @return string
173 */
174 public function installation_url( $pluginName ) {
175 $action = 'install-plugin';
176 $pluginSlug = $this->get_plugin_slug( $pluginName );
177
178 return wp_nonce_url(
179 add_query_arg(
180 array(
181 'action' => $action,
182 'plugin' => $pluginSlug
183 ),
184 admin_url( 'update.php' )
185 ),
186 $action . '_' . $pluginSlug
187 );
188 }
189
190 /**
191 * Get plugin slug
192 *
193 * @access public
194 * @param string
195 * @return string
196 */
197 public function get_plugin_slug( $name ) {
198 $split = explode( '/', $name );
199
200 return isset( $split[0] ) ? $split[0] : null;
201 }
202
203 /**
204 * Get plugin activation url
205 *
206 * @access public
207 * @param string
208 * @return string
209 */
210 public function activation_url( $pluginName ) {
211
212 return wp_nonce_url( add_query_arg(
213 array(
214 'action' => 'activate',
215 'plugin' => $pluginName,
216 'plugin_status' => 'all',
217 'paged' => '1&s',
218 ),
219 admin_url( 'plugins.php' )
220 ), 'activate-plugin_' . $pluginName );
221 }
222 }
223 }