PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.0
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.0
4.0.2 4.0.1 4.0.0 3.10.02 3.10.01 3.9.10 3.9.9 3.9.8 3.9.7 3.9.5 3.9.6 3.9.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.1 2.3.1.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.4.0 2.5.0 2.5.1 2.5.10 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.2 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.6.0 3.6.1 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.8.1 3.8.2 3.9.0 3.9.1 3.9.2 trunk 1.2.6 1.2.7 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.0.9.1 2.0.9.2 2.0.9.3
elementskit-lite / libs / emailkit / emailkit.php
elementskit-lite / libs / emailkit Last commit date
assets 2 years ago emailkit.php 2 years ago
emailkit.php
229 lines
1 <?php
2
3 namespace Wpmet\Libs;
4
5 use WP_Query;
6
7 defined('ABSPATH') || exit;
8
9 if( !class_exists('\Wpmet\Libs\Emailkit') ) {
10 class Emailkit {
11
12 private $is_already_installed = '';
13
14 /**
15 * Constructor for initializing the class.
16 *
17 * @access public
18 * @return void
19 */
20 public function __construct() {
21
22 do_action('edit_with_emailkit_loaded');
23
24 if( empty( $_GET[ 'page' ] ) || 'wc-settings' !== $_GET[ 'page' ] || empty( $_GET[ 'tab' ] ) || 'email' !== $_GET[ 'tab' ] ) {
25 return;
26 }
27
28 if( !function_exists('get_plugins') ) {
29 include_once ABSPATH . 'wp-admin/includes/plugin.php';
30 }
31
32 $installed_plugins = get_plugins();
33 $this->is_already_installed = isset($installed_plugins['emailkit/EmailKit.php']) ? 1 : 0;
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 $dismissed_coutner = get_option('elementskit-lite-edit_with_emailkit_banner_dismissed_'.get_current_user_id(), 0);
36 $notice_showing_delay_time = (3600 * 24 * 15);
37
38 if($dismissed_coutner == 1){
39 $notice_showing_delay_time = (3600 * 24 * 30);
40 }elseif($dismissed_coutner == 2){
41 $notice_showing_delay_time = (3600 * 24 * 180);
42 }elseif($dismissed_coutner >= 3){
43 $notice_showing_delay_time = (3600 * 24 * 1825);
44 }
45
46 \Oxaim\Libs\Notice::instance('elementskit-lite', 'edit_with_emailkit_banner')
47 ->set_dismiss('user', $notice_showing_delay_time)
48 ->set_message($message)
49 ->call();
50
51 add_action('admin_head', [$this, 'emailkit_admin_head']);
52 }
53
54 /**
55 * Added script and style for Edit with EmailKit in admin head
56 *
57 * @access public
58 * @return void
59 */
60 public function emailkit_admin_head() {
61 ?>
62 <style>
63 .notice-elementskit-lite-edit_with_emailkit_banner{
64 background-image: url("<?php echo esc_url(plugin_dir_url( __FILE__ ).'/assets/notification.svg') ?>") !important;
65 color: #fff;
66 background-size: cover !important;
67 background-repeat: no-repeat !important;
68 background-position: center center !important;
69 border: none !important;
70 }
71 .notice-elementskit-lite-edit_with_emailkit_banner .edit-with-emailkit-banner-main{
72 display: flex;
73 gap: 15px;
74 }
75 .notice-elementskit-lite-edit_with_emailkit_banner button::before{
76 color: #ffffff;
77 }
78
79 .notice-elementskit-lite-edit_with_emailkit_banner .notice-container-full-width{
80 padding: 0;
81 margin: 0 !important;
82 }
83 .notice-elementskit-lite-edit_with_emailkit_banner .notice-container-full-width .edit-with-emailkit-wrapper{
84 display: flex;
85 justify-content: space-between;
86 align-items: center;
87 }
88 .notice-elementskit-lite-edit_with_emailkit_banner .notice-container-full-width .edit-with-emailkit-wrapper .edit-with-emailkit-banner-right{
89 margin-right: 60px;
90 }
91
92 .notice-elementskit-lite-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{
93 padding: 24px 8px 0px 8px;
94 border-left: 6px solid #13d5ff;
95 background: #FFFFFF1A;
96 }
97 .notice-elementskit-lite-edit_with_emailkit_banner .notice-container-full-width .edit-with-emailkit-wrapper .edit-with-emailkit-banner-left .edit-with-emailkit-banner-middle{
98 padding: 20px 4px;
99 }
100 .notice-elementskit-lite-edit_with_emailkit_banner .notice-container-full-width .edit-with-emailkit-wrapper .edit-with-emailkit-banner-right .emailkit-install-activate-btn{
101 font-size: 14px;
102 font-weight: 500;
103 color: #070C14;
104 padding: 15px 22px;
105 background: #EBFF00;
106 cursor: pointer;
107 border-radius: 4px;
108 }
109 .edit-with-emailkit-banner-title{
110 font-size: 24px;
111 font-weight: 600;
112 margin-bottom: 8px;
113 }
114 </style>
115 <script type="text/javascript">
116
117 jQuery( document ).ready( function( $ ) {
118
119 const emailKitInstallBtn = document.querySelector('.emailkit-install-activate-btn');
120
121 if( !emailKitInstallBtn ) {
122 return;
123 }
124
125 const isAlreadyInstalled = "<?php echo esc_attr($this->is_already_installed) ?>";
126 let installationUrl = "<?php echo esc_url($this->installation_url('emailkit/EmailKit.php')) ?>";
127 let activationUrl = "<?php echo esc_url($this->activation_url('emailkit/EmailKit.php')) ?>";
128 installationUrl = installationUrl?.replace(/&#038;/g, '&');
129 activationUrl = activationUrl?.replace(/&#038;/g, '&');
130
131 function emailkit_install_active_plugin(ajaxurl, success_callback, beforeText) {
132 try {
133 $.ajax({
134 type: "GET",
135 url: ajaxurl,
136 beforeSend: () => {
137 emailKitInstallBtn.innerHTML = beforeText;
138 },
139 success: (response) => {
140 if (success_callback) {
141 success_callback();
142 }else{
143 location.reload();
144 }
145 },
146 error: function (error) {
147 console.error(error);
148 }
149 });
150 } catch (error) {
151 console.error("An error occurred:", error);
152 }
153 }
154
155 emailKitInstallBtn.addEventListener('click', function(e) {
156
157 e.preventDefault();
158
159 if(isAlreadyInstalled === '0'){
160 emailkit_install_active_plugin.call(this, installationUrl, () => {
161 emailkit_install_active_plugin.call(this, activationUrl, null, 'Activating...');
162 }, 'Installing...');
163 } else if (isAlreadyInstalled === '1') {
164 emailkit_install_active_plugin.call(this, activationUrl, null, 'Activating...');
165 }
166 });
167 });
168 </script>
169 <?php
170 }
171
172 /**
173 * Get plugin installation url
174 *
175 * @access public
176 * @param string
177 * @return string
178 */
179 public function installation_url( $pluginName ) {
180 $action = 'install-plugin';
181 $pluginSlug = $this->get_plugin_slug( $pluginName );
182
183 return wp_nonce_url(
184 add_query_arg(
185 array(
186 'action' => $action,
187 'plugin' => $pluginSlug
188 ),
189 admin_url( 'update.php' )
190 ),
191 $action . '_' . $pluginSlug
192 );
193 }
194
195 /**
196 * Get plugin slug
197 *
198 * @access public
199 * @param string
200 * @return string
201 */
202 public function get_plugin_slug( $name ) {
203 $split = explode( '/', $name );
204
205 return isset( $split[0] ) ? $split[0] : null;
206 }
207
208 /**
209 * Get plugin activation url
210 *
211 * @access public
212 * @param string
213 * @return string
214 */
215 public function activation_url( $pluginName ) {
216
217 return wp_nonce_url( add_query_arg(
218 array(
219 'action' => 'activate',
220 'plugin' => $pluginName,
221 'plugin_status' => 'all',
222 'paged' => '1&s',
223 ),
224 admin_url( 'plugins.php' )
225 ), 'activate-plugin_' . $pluginName );
226 }
227
228 }
229 }