PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.2.25
Adminify – White Label, Admin Menu Editor, Login Customizer v4.2.25
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
adminify / Inc / Classes / Pro_Upgrade.php

Pro_Upgrade.php in Adminify – White Label, Admin Menu Editor, Login Customizer 4.2.25, at Inc/Classes/Pro_Upgrade.php

269 lines 6.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PXLBSAdminify\Inc\Classes;
4
5 use PXLBSAdminify\Inc\Classes\Helper;
6 use PXLBSAdminify\Inc\Classes\Notifications\Base\Date;
7 // No, Direct access Sir !!!
8 if ( !defined( 'ABSPATH' ) ) {
9 exit;
10 }
11 /**
12 * Upgrade to Pro Class
13 *
14 * Jewel Theme <support@jeweltheme.com>
15 */
16 class Pro_Upgrade {
17 use Date;
18 public $slug;
19
20 protected $data = array();
21
22 /**
23 * Construct method
24 */
25 public function __construct() {
26 $this->slug = Helper::slug_cleanup();
27 $this->set_data();
28 add_action( 'admin_footer', array($this, 'display_popup') );
29 }
30
31 /**
32 * Set merged data
33 *
34 * @return void
35 * @author Jewel Theme <support@jeweltheme.com>
36 */
37 public function set_data() {
38 $this->data = Helper::get_merged_data( self::get_data() );
39 }
40
41 /**
42 * Get Sheet data
43 *
44 * @author Jewel Theme <support@jeweltheme.com>
45 */
46 public static function get_data() {
47 return get_option( 'pxlbsadminify_sheet_promo_data' );
48 }
49
50 /**
51 * Get Contents
52 *
53 * @param [type] $key .
54 *
55 * @author Jewel Theme <support@jeweltheme.com>
56 */
57 public function get_content( $key ) {
58 if ( empty( $this->data ) ) {
59 return;
60 }
61 return $this->data[$key];
62 }
63
64 /**
65 * Display popup contents
66 *
67 * @author Jewel Theme <support@jeweltheme.com>
68 */
69 public function display_popup() {
70 if ( empty( $this->get_content( 'is_live' ) ) ) {
71 $image_url = PXLBSADMINIFY_ASSETS_IMAGE . 'promo-image.png';
72 $notice = 'Use "SPECIAL40" to Get Flat 40% OFF';
73 $btn_url = 'https://wpadminify.com/pricing/';
74 $btn_text = 'GET THE DEAL';
75 } else {
76 $image_url = $this->get_content( 'image_url' );
77 $notice = $this->get_content( 'notice' );
78 $btn_url = $this->get_content( 'button_url' );
79 $btn_text = $this->get_content( 'button_text' );
80 }
81 ?>
82
83 <div class="wp-adminify-popup wp-adminify-upgrade-popup" id="wp-adminify-popup" data-plugin="<?php
84 echo esc_attr( $this->slug );
85 ?>" tabindex="1" style="display: none;">
86
87 <div class="wp-adminify-popup-overlay"></div>
88
89 <div class="wp-adminify-popup-modal" style="background-image: url('<?php
90 echo esc_url( $image_url );
91 ?>'); --wp-adminify-popup-color: <?php
92 echo esc_attr( $this->get_content( 'btn_color' ) );
93 ?>;">
94
95 <!-- close -->
96 <div class="wp-adminify-popup-modal-close popup-dismiss">×</div>
97
98 <!-- content section -->
99 <div class="wp-adminify-popup-modal-footer">
100 <!-- countdown -->
101 <div class="wp-adminify-popup-countdown" style="display: none;">
102
103 <?php
104 if ( !empty( $notice ) ) {
105 ?>
106 <span data-counter="notice" style="color:#F4B740; font-size:14px; padding-bottom:20px; font-style:italic;"><?php
107 echo esc_html__( 'Notice:', 'adminify' );
108 ?> <?php
109 echo wp_kses_post( $notice );
110 ?></span>
111 <?php
112 }
113 ?>
114
115 <span class="wp-adminify-popup-countdown-text"><?php
116 echo esc_html__( 'Deal Ends In', 'adminify' );
117 ?></span>
118 <div class="wp-adminify-popup-countdown-time">
119 <div>
120 <span data-counter="days">00</span>
121 <span><?php
122 echo esc_html__( 'Days', 'adminify' );
123 ?></span>
124 </div>
125 <span>:</span>
126 <div>
127 <span data-counter="hours">00</span>
128 <span><?php
129 echo esc_html__( 'Hours', 'adminify' );
130 ?></span>
131 </div>
132 <span>:</span>
133 <div>
134 <span data-counter="minutes">00</span>
135 <span><?php
136 echo esc_html__( 'Minutes', 'adminify' );
137 ?></span>
138 </div>
139 <span>:</span>
140 <div>
141 <span data-counter="seconds">00</span>
142 <span><?php
143 echo esc_html__( 'Seconds', 'adminify' );
144 ?></span>
145 </div>
146 </div>
147 </div>
148
149 <!-- button -->
150 <a class="wp-adminify-popup-button" style="color: #fff!important;" target="_blank" href="<?php
151 echo esc_url( $btn_url );
152 ?>"><?php
153 echo esc_html( $btn_text );
154 ?></a>
155 </div>
156 </div>
157 </div>
158
159 <script>
160 var $container = jQuery('#wp-adminify-popup'),
161 plugin_data = <?php
162 echo wp_json_encode( $this->data );
163 ?>,
164 events = {}; //Events
165
166 // Update Counter
167 function updateCounter(seconds) {
168 const $counter = $container.find(".wp-adminify-popup-countdown-time");
169 const $days = $counter.find("[data-counter='days']");
170 const $hours = $counter.find("[data-counter='hours']");
171 const $minutes = $counter.find("[data-counter='minutes']");
172 const $seconds = $counter.find("[data-counter='seconds']");
173 const days = Math.floor(seconds / (3600 * 24));
174 seconds -= days * 3600 * 24;
175 const hrs = Math.floor(seconds / 3600);
176 seconds -= hrs * 3600;
177 const mnts = Math.floor(seconds / 60);
178 seconds -= mnts * 60;
179
180 $days.text(days);
181 $hours.text(hrs);
182 $minutes.text(mnts);
183 $seconds.text(seconds);
184 }
185
186 // Trigger Event
187 function trigger(event, args = []) {
188 if (typeof(events[event]) !== 'undefined') {
189 events[event].forEach(callback => {
190 callback.apply(this, args);
191 });
192 }
193 }
194
195 // initCounter
196 function initCounter(last_date) {
197 $container.find(".wp-adminify-popup-countdown-time").show();
198
199 const countdown = () => {
200
201 // system time
202 const now = new Date().getTime();
203
204 // set end time to 11:59:59 PM
205 const endDate = new Date(last_date);
206 endDate.setHours(23);
207 endDate.setMinutes(59);
208 endDate.setSeconds(59);
209
210 const seconds = Math.floor((endDate.getTime() - now) / 1000);
211
212 if (seconds < 0) {
213 return false;
214 }
215
216 updateCounter(seconds);
217
218 return true;
219 }
220
221 let result = countdown();
222
223
224 if (result) {
225 trigger("countdownStart", [plugin_data]);
226 $container.find(".wp-adminify-popup-countdown").show(0);
227 } else {
228 trigger("countdownFinish", [plugin_data]);
229 $container.find(".wp-adminify-popup-countdown").hide(0);
230 }
231
232 // update counter every 1 second
233 const counter = setInterval(() => {
234
235 const result = countdown();
236
237 if (!result) {
238 clearInterval(counter);
239 trigger("counter_end", [plugin_data]);
240 $container.find(".wp-adminify-popup-countdown").hide(0);
241 }
242
243 }, 1000);
244 }
245
246 initCounter('<?php
247 echo esc_attr( $this->counter_date() );
248 ?>');
249 </script>
250
251 <?php
252 }
253
254 /**
255 * Counter Date
256 *
257 * @author Jewel Theme <support@jeweltheme.com>
258 */
259 public function counter_date() {
260 $endDate = $this->get_content( 'end_date' );
261 $is_active = $this->date_is_current_or_next( $endDate );
262 if ( $is_active ) {
263 return $endDate;
264 }
265 return $this->date_increment( $this->current_time(), 3 );
266 }
267
268 }
269