PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.1
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.1
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 3 weeks ago
emailkit.php
233 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 $page = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : '';
25 $tab = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : '';
26
27 if ( 'wc-settings' !== $page || 'email' !== $tab ) {
28 return;
29 }
30
31 if( !function_exists('get_plugins') ) {
32 include_once ABSPATH . 'wp-admin/includes/plugin.php';
33 }
34
35 $installed_plugins = get_plugins();
36 $this->is_already_installed = isset($installed_plugins['emailkit/EmailKit.php']) ? 1 : 0;
37 $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>';
38 $dismissed_coutner = get_option('elementskit-lite-edit_with_emailkit_banner_dismissed_'.get_current_user_id(), 0);
39 $notice_showing_delay_time = (3600 * 24 * 15);
40
41 if($dismissed_coutner == 1){
42 $notice_showing_delay_time = (3600 * 24 * 30);
43 }elseif($dismissed_coutner == 2){
44 $notice_showing_delay_time = (3600 * 24 * 180);
45 }elseif($dismissed_coutner >= 3){
46 $notice_showing_delay_time = (3600 * 24 * 1825);
47 }
48
49 \Oxaim\Libs\Notice::instance('elementskit-lite', 'edit_with_emailkit_banner')
50 ->set_dismiss('user', $notice_showing_delay_time)
51 ->set_message($message)
52 ->call();
53
54 add_action('admin_head', [$this, 'emailkit_admin_head']);
55 }
56
57 /**
58 * Added script and style for Edit with EmailKit in admin head
59 *
60 * @access public
61 * @return void
62 */
63 public function emailkit_admin_head() {
64 ?>
65 <style>
66 .notice-elementskit-lite-edit_with_emailkit_banner{
67 background-image: url("<?php echo esc_url(plugin_dir_url( __FILE__ ).'/assets/notification.svg') ?>") !important;
68 color: #fff;
69 background-size: cover !important;
70 background-repeat: no-repeat !important;
71 background-position: center center !important;
72 border: none !important;
73 }
74 .notice-elementskit-lite-edit_with_emailkit_banner .edit-with-emailkit-banner-main{
75 display: flex;
76 gap: 15px;
77 }
78 .notice-elementskit-lite-edit_with_emailkit_banner button::before{
79 color: #ffffff;
80 }
81
82 .notice-elementskit-lite-edit_with_emailkit_banner .notice-container-full-width{
83 padding: 0;
84 margin: 0 !important;
85 }
86 .notice-elementskit-lite-edit_with_emailkit_banner .notice-container-full-width .edit-with-emailkit-wrapper{
87 display: flex;
88 justify-content: space-between;
89 align-items: center;
90 }
91 .notice-elementskit-lite-edit_with_emailkit_banner .notice-container-full-width .edit-with-emailkit-wrapper .edit-with-emailkit-banner-right{
92 margin-right: 60px;
93 }
94
95 .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{
96 padding: 24px 8px 0px 8px;
97 border-left: 6px solid #13d5ff;
98 background: #FFFFFF1A;
99 }
100 .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{
101 padding: 20px 4px;
102 }
103 .notice-elementskit-lite-edit_with_emailkit_banner .notice-container-full-width .edit-with-emailkit-wrapper .edit-with-emailkit-banner-right .emailkit-install-activate-btn{
104 font-size: 14px;
105 font-weight: 500;
106 color: #070C14;
107 padding: 15px 22px;
108 background: #EBFF00;
109 cursor: pointer;
110 border-radius: 4px;
111 }
112 .edit-with-emailkit-banner-title{
113 font-size: 24px;
114 font-weight: 600;
115 margin-bottom: 8px;
116 }
117 </style>
118 <script type="text/javascript">
119
120 jQuery( document ).ready( function( $ ) {
121
122 const emailKitInstallBtn = document.querySelector('.emailkit-install-activate-btn');
123
124 if( !emailKitInstallBtn ) {
125 return;
126 }
127
128 const isAlreadyInstalled = "<?php echo esc_attr($this->is_already_installed) ?>";
129 let installationUrl = "<?php echo esc_url($this->installation_url('emailkit/EmailKit.php')) ?>";
130 let activationUrl = "<?php echo esc_url($this->activation_url('emailkit/EmailKit.php')) ?>";
131 installationUrl = installationUrl?.replace(/&#038;/g, '&');
132 activationUrl = activationUrl?.replace(/&#038;/g, '&');
133
134 function emailkit_install_active_plugin(ajaxurl, success_callback, beforeText) {
135 try {
136 $.ajax({
137 type: "GET",
138 url: ajaxurl,
139 beforeSend: () => {
140 emailKitInstallBtn.innerHTML = beforeText;
141 },
142 success: (response) => {
143 if (success_callback) {
144 success_callback();
145 }else{
146 location.reload();
147 }
148 },
149 error: function (error) {
150 console.error(error);
151 }
152 });
153 } catch (error) {
154 console.error("An error occurred:", error);
155 }
156 }
157
158 emailKitInstallBtn.addEventListener('click', function(e) {
159
160 e.preventDefault();
161
162 if(isAlreadyInstalled === '0'){
163 emailkit_install_active_plugin.call(this, installationUrl, () => {
164 emailkit_install_active_plugin.call(this, activationUrl, null, 'Activating...');
165 }, 'Installing...');
166 } else if (isAlreadyInstalled === '1') {
167 emailkit_install_active_plugin.call(this, activationUrl, null, 'Activating...');
168 }
169 });
170 });
171 </script>
172 <?php
173 }
174
175 /**
176 * Get plugin installation url
177 *
178 * @access public
179 * @param string
180 * @return string
181 */
182 public function installation_url( $pluginName ) {
183 $action = 'install-plugin';
184 $pluginSlug = $this->get_plugin_slug( $pluginName );
185
186 return wp_nonce_url(
187 add_query_arg(
188 array(
189 'action' => $action,
190 'plugin' => $pluginSlug
191 ),
192 admin_url( 'update.php' )
193 ),
194 $action . '_' . $pluginSlug
195 );
196 }
197
198 /**
199 * Get plugin slug
200 *
201 * @access public
202 * @param string
203 * @return string
204 */
205 public function get_plugin_slug( $name ) {
206 $split = explode( '/', $name );
207
208 return isset( $split[0] ) ? $split[0] : null;
209 }
210
211 /**
212 * Get plugin activation url
213 *
214 * @access public
215 * @param string
216 * @return string
217 */
218 public function activation_url( $pluginName ) {
219
220 return wp_nonce_url( add_query_arg(
221 array(
222 'action' => 'activate',
223 'plugin' => $pluginName,
224 'plugin_status' => 'all',
225 'paged' => '1&s',
226 ),
227 admin_url( 'plugins.php' )
228 ), 'activate-plugin_' . $pluginName );
229 }
230
231 }
232 }
233