PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.0.5.4
Adminify – White Label, Admin Menu Editor, Login Customizer v4.0.5.4
4.3.2 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 All 165 releases
← All changes | Inc/Classes/Pro_Upgrade.php +472 -126 4.2.64.0.5.4 View file →
@@ -1,97 +1,461 @@
1 1 <?php
2 2
3 -namespace PXLBSAdminify\Inc\Classes;
3 +namespace WPAdminify\Inc\Classes;
4 4
5 -use PXLBSAdminify\Inc\Classes\Helper;
6 -use PXLBSAdminify\Inc\Classes\Notifications\Base\Date;
5 +use WPAdminify\Inc\Classes\Helper;
6 +use WPAdminify\Inc\Classes\Notifications\Base\Date;
7 +
8 +
7 9 // No, Direct access Sir !!!
8 -if ( !defined( 'ABSPATH' ) ) {
9 - exit;
10 +if (!defined('ABSPATH')) {
11 + exit;
10 12 }
13 +
11 14 /**
12 15 * Upgrade to Pro Class
13 16 *
14 17 * Jewel Theme <support@jeweltheme.com>
15 18 */
16 -class Pro_Upgrade {
17 - use Date;
18 - public $slug;
19 +class Pro_Upgrade
20 +{
19 21
20 - protected $data = array();
22 + use Date;
21 23
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 - }
24 + public $slug;
30 25
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 - }
26 + protected $data = array();
40 27
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 - }
28 + protected $modes = array(
29 + 'development' => array(
30 + 'sheet_id' => '1VLpfKspHHNM6JIFOQtohqDRyHR85J3KR5RLF4jqlz0Q',
31 + 'tab_id' => 0,
32 + ),
33 + 'production' => array(
34 + 'sheet_id' => '1VLpfKspHHNM6JIFOQtohqDRyHR85J3KR5RLF4jqlz0Q',
35 + 'tab_id' => 0,
36 + ),
37 + );
49 38
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 - }
39 + /**
40 + * Construct method
41 + */
42 + public function __construct()
43 + {
44 + $this->slug = Helper::jltwp_adminify_slug_cleanup();
63 45
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 - ?>
46 + $this->maybe_sync_remote_data();
47 + $this->register_sync_hook();
48 + $this->set_data();
82 49
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;">
50 + add_action('admin_footer', array($this, 'display_popup'));
86 51
52 + add_action('wp_dashboard_setup', array($this, 'dashboard_widget'));
53 + add_action('wp_network_dashboard_setup', array($this, 'dashboard_widget'));
54 + }
55 +
56 + /**
57 + * Register Dashboard widget
58 + *
59 + * @return void
60 + * @author Jewel Theme <support@jeweltheme.com>
61 + */
62 + public function dashboard_widget()
63 + {
64 + wp_add_dashboard_widget(
65 + 'jltwp_adminify_dashboard_widget', // Widget slug.
66 + esc_html__('WP Adminify News & Updates', 'adminify'), // Title.
67 + array($this, 'dashboard_widget_render') // Display function.
68 + );
69 +
70 + // Globalize the metaboxes array, this holds all the widgets for wp-admin.
71 + global $wp_meta_boxes;
72 +
73 + // Get the regular dashboard widgets array
74 + // (which already has our new widget but appended at the end).
75 +
76 + if (is_network_admin()) {
77 + $default_dashboard = $wp_meta_boxes['dashboard-network']['normal']['core'];
78 + } else {
79 + $default_dashboard = $wp_meta_boxes['dashboard']['normal']['core'];
80 + }
81 +
82 + // Backup and delete our new dashboard widget from the end of the array.
83 + $example_widget_backup = array('jltwp_adminify_dashboard_widget' => $default_dashboard['jltwp_adminify_dashboard_widget']);
84 + unset($default_dashboard['jltwp_adminify_dashboard_widget']);
85 +
86 + // Merge the two arrays together so our widget is at the beginning.
87 + $sorted_dashboard = array_merge($example_widget_backup, $default_dashboard);
88 +
89 + // Save the sorted array back into the original metaboxes .
90 + if (is_network_admin()) {
91 + $wp_meta_boxes['dashboard-network']['normal']['core'] = $sorted_dashboard;
92 + } else {
93 + $wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard;
94 + }
95 + }
96 +
97 + /**
98 + * Render dashboard widget
99 + *
100 + * @author Jewel Theme <support@jeweltheme.com>
101 + */
102 + public function dashboard_widget_render()
103 + {
104 + include_once ABSPATH . WPINC . '/feed.php';
105 +
106 + $feed_url = 'https://jeweltheme.com/feed.xml';
107 +
108 + // Get a SimplePie feed object from the specified feed source .
109 + $rss = fetch_feed($feed_url);
110 + $maxitems = 0;
111 +
112 + if (!is_wp_error($rss)) { // Checks that the object is created correctly .
113 + // Figure out how many total items there are, and choose a limit .
114 + $maxitems = $rss->get_item_quantity(5);
115 +
116 + // Build an array of all the items, starting with element 0 (first element).
117 + $rss_items = $rss->get_items(0, $maxitems);
118 +
119 + // Get RSS title .
120 + $rss_title = '<a href="' . $rss->get_permalink() . '" target="_blank">' . strtoupper($rss->get_title()) . '</a>';
121 + }
122 +
123 + // Display the container .
124 + echo '<div class="wp-adminify-rss-widget">';
125 +
126 + if (wp_validate_boolean($this->get_content('is_campaign'))) { ?>
127 +
128 + <div class="wp-adminify-dashboard-promo" style="--wp-adminify-popup-color: <?php echo esc_attr($this->get_content('btn_color')); ?>;">
129 + <a target="_blank" href="<?php echo esc_url($this->get_content('button_url')); ?>">
130 + <img src="<?php echo esc_url($this->get_content('image_url')); ?>" alt="WP Adminify Promo Image" style="width: 100%; height: auto;">
131 + </a>
132 +
133 + <a class="wp-adminify-popup-button" target="_blank" href="<?php echo esc_url($this->get_content('button_url')); ?>">
134 + <?php
135 + if (jltwp_adminify()->can_use_premium_code()) {
136 + echo esc_html__('Upgrade Now', 'adminify');
137 + } else {
138 + echo esc_html($this->get_content('button_text'));
139 + } ?>
140 + </a>
141 + </div>
142 +
143 + <?php
144 + }
145 +
146 + // Starts items listing within <ul> tag
147 + // Check items .
148 + if (!empty($maxitems)) {
149 + echo '<ul>';
150 + // Loop through each feed item and display each item as a hyperlink.
151 + foreach ($rss_items as $item) {
152 + // Uncomment line below to display non human date
153 + // $item_date = $item->get_date( get_option('date_format').' @ '.get_option('time_format') ); .
154 +
155 + // Get human date (comment if you want to use non human date) .
156 + // $item_date = human_time_diff( $item->get_date( 'U' ), current_time( 'timestamp' ) ) . ' ' . __( 'ago', 'adminify' );
157 +
158 + // Start displaying item content within a <li> tag .
159 + echo '<li>';
160 + // create item link .
161 + echo '<a href="' . esc_url($item->get_permalink()) . '" title="' . esc_attr($item->get_title()) . '" target="_blank">';
162 + // Get item title .
163 + echo esc_html($item->get_title());
164 + echo '</a>';
165 + // Display date .
166 + // echo ' <span class="rss-date">' . esc_html( $item_date ) . '</span><br />';
167 + // Get item content .
168 + $content = $item->get_content();
169 + // Shorten content .
170 + $content = wp_html_excerpt($content, 120) . ' ';
171 + // Display content .
172 + echo esc_html($content);
173 + // End <li> tag .
174 + echo '</li>';
175 + }
176 + echo '</ul>';
177 + // End <ul> tag .
178 + }
179 + ?>
180 +
181 + <div class="wp-adminify-dashboard_footer">
182 + <ul>
183 + <li class="wp-adminify-overview__blog">
184 + <a href="https://wpadminify.com/blog" target="_blank">
185 + Blog
186 + <span class="screen-reader-text">
187 + <?php echo esc_html__('(opens in a new window)', 'adminify'); ?>
188 + </span>
189 + <span aria-hidden="true" class="dashicons dashicons-external"></span>
190 + </a>
191 + </li>
192 + <li class="wp-adminify-overview__help">
193 + <a href="https://wpadminify.com/docs" target="_blank">
194 + Help
195 + <span class="screen-reader-text">
196 + <?php echo esc_html__('(opens in a new window)', 'adminify'); ?>
197 + </span>
198 + <span aria-hidden="true" class="dashicons dashicons-external"></span>
199 + </a>
200 + </li>
201 + <li class="wp-adminify-overview__upgrade">
202 + <a href="https://wpadminify.com/pricing" target="_blank">
203 + Upgrade
204 + <span class="screen-reader-text">
205 + <?php echo esc_html__('(opens in a new window)', 'adminify'); ?>
206 + </span>
207 + <span aria-hidden="true" class="dashicons dashicons-external"></span>
208 + </a>
209 + </li>
210 +
211 + </ul>
212 + </div>
213 + <style>
214 + /* News Dashboard Widget */
215 + .wp-adminify-rss-widget .hndle.ui-sortable-handle img {
216 + margin: -5px 10px -5px 0;
217 + }
218 +
219 + .wp-adminify-rss-widget .wp-adminify-dashboard_footer {
220 + margin: 0 -12px -12px;
221 + padding: 0 12px;
222 + border-top: 1px solid #eee;
223 + }
224 +
225 + .wp-adminify-rss-widget .wp-adminify-dashboard_footer ul {
226 + display: flex;
227 + list-style: none;
228 + }
229 +
230 + .wp-adminify-rss-widget .wp-adminify-dashboard_footer ul li:first-child {
231 + padding-left: 0;
232 + border: none;
233 + }
234 +
235 + .wp-adminify-rss-widget .wp-adminify-dashboard_footer li {
236 + padding: 0 10px;
237 + margin: 0;
238 + border-left: 1px solid #ddd;
239 + }
240 +
241 + .wp-adminify-rss-widget .wp-adminify-overview__go-pro a {
242 + color: #FCB92C;
243 + font-weight: 500;
244 + }
245 + </style>
246 +
247 + <?php
248 + echo '</div>';
249 + }
250 +
251 +
252 + /**
253 + * Set merged data
254 + *
255 + * @return void
256 + * @author Jewel Theme <support@jeweltheme.com>
257 + */
258 + public function set_data()
259 + {
260 + $this->data = Helper::get_merged_data(self::get_data());
261 + }
262 +
263 + /**
264 + * Get Sheet data
265 + *
266 + * @author Jewel Theme <support@jeweltheme.com>
267 + */
268 + public static function get_data()
269 + {
270 + return get_option('jltwp_adminify_sheet_promo_data');
271 + }
272 +
273 + /**
274 + * Get Contents
275 + *
276 + * @param [type] $key .
277 + *
278 + * @author Jewel Theme <support@jeweltheme.com>
279 + */
280 + public function get_content($key)
281 + {
282 + return $this->data[$key];
283 + }
284 +
285 + /**
286 + * Get Option has data
287 + *
288 + * @author Jewel Theme <support@jeweltheme.com>
289 + */
290 + public function get_data_hash()
291 + {
292 + return get_option('jltwp_adminify_sheet_promo_data_hash');
293 + }
294 +
295 + /**
296 + * Sync to remote data
297 + *
298 + * @author Jewel Theme <support@jeweltheme.com>
299 + */
300 + public function maybe_sync_remote_data()
301 + {
302 + $data = self::get_data();
303 +
304 + if (empty($data)) {
305 + $this->sheet_data_remote_sync();
306 + }
307 + }
308 +
309 + /**
310 + * Register Sync hook
311 + *
312 + * @return void
313 + * @author Jewel Theme <support@jeweltheme.com>
314 + */
315 + public function register_sync_hook()
316 + {
317 + $hook_action = 'jltwp_adminify_sheet_promo_data_remote_sync';
318 + add_action($hook_action, array($this, 'sheet_data_remote_sync'));
319 +
320 + if (!wp_next_scheduled($hook_action)) {
321 + wp_schedule_event(time(), 'daily', $hook_action);
322 + }
323 +
324 + register_deactivation_hook(WP_ADMINIFY_FILE, array($this, 'clear_register_sync_hook'));
325 + }
326 +
327 + /**
328 + * Clear register sync hook
329 + *
330 + * @return void
331 + * @author Jewel Theme <support@jeweltheme.com>
332 + */
333 + public function clear_register_sync_hook()
334 + {
335 + wp_clear_scheduled_hook('jltwp_adminify_sheet_promo_data_remote_sync');
336 + }
337 +
338 + /**
339 + * Data sync with remote
340 + *
341 + * @return void
342 + * @author Jewel Theme <support@jeweltheme.com>
343 + */
344 + public function sheet_data_remote_sync()
345 + {
346 + $data = self::get_data();
347 + $force = false;
348 +
349 + if (empty($data)) {
350 + $force = true;
351 + }
352 +
353 + $sheet_hash_data = $this->get_data_hash();
354 + $remote_data = $this->get_sheet_promo_remote_data();
355 + $sheet_data_hash = base64_encode(json_encode($remote_data));
356 +
357 + if ($force || $sheet_hash_data !== $sheet_data_hash) {
358 + update_option('jltwp_adminify_sheet_promo_data', $remote_data);
359 + update_option('jltwp_adminify_sheet_promo_data_hash', $sheet_data_hash);
360 + do_action('jltwp_adminify_sheet_promo_data_reset');
361 + }
362 + }
363 +
364 + /**
365 + * Get Environment mode
366 + *
367 + * @author Jewel Theme <support@jeweltheme.com>
368 + */
369 + public function get_mode()
370 + {
371 + return defined('WP_DEBUG') && WP_DEBUG ? 'development' : 'production';
372 + }
373 +
374 + /**
375 + * Get Sheet URL
376 + *
377 + * @author Jewel Theme <support@jeweltheme.com>
378 + */
379 + public function get_sheet_url()
380 + {
381 + $sheet_id = $this->modes[$this->get_mode()]['sheet_id'];
382 + $tab_id = $this->modes[$this->get_mode()]['tab_id'];
383 +
384 + return "https://docs.google.com/spreadsheets/export?format=csv&id={$sheet_id}&gid={$tab_id}";
385 + }
386 +
387 + /**
388 + * Promotional remote data
389 + *
390 + * @author Jewel Theme <support@jeweltheme.com>
391 + */
392 + public function get_sheet_promo_remote_data()
393 + {
394 + $transient_key = $this->slug . '_sheet_promo_data';
395 +
396 + $data = get_transient($transient_key);
397 + if ($data !== false) return $data;
398 +
399 + $url = $this->get_sheet_url();
400 +
401 + $response = wp_remote_get($url);
402 +
403 + if (is_wp_error($response)) {
404 + return false;
405 + }
406 +
407 + $response = wp_remote_retrieve_body($response);
408 +
409 + if (!$response) {
410 + return false;
411 + }
412 +
413 + $data = array_map('str_getcsv', explode("\n", $response));
414 +
415 + $header = array_shift($data);
416 +
417 + $data = array_map(function (array $row) use ($header) {
418 + return array_combine($header, $row);
419 + }, $data);
420 +
421 + // filter plugin is not empty .
422 + $data = array_filter($data, function ($row) {
423 + return !empty($row['name']);
424 + });
425 +
426 + $plugin_slug = Helper::jltwp_adminify_slug_cleanup();
427 + $data = wp_list_filter($data, array('product_slug' => $plugin_slug));
428 +
429 + if (!empty($data)) {
430 + $data = array_values($data)[0];
431 + }
432 +
433 + set_transient($transient_key, $data, HOUR_IN_SECONDS);
434 +
435 + return $data;
436 + }
437 +
438 + /**
439 + * Display popup contents
440 + *
441 + * @author Jewel Theme <support@jeweltheme.com>
442 + */
443 + public function display_popup()
444 + {
445 + if( jltwp_adminify()->can_use_premium_code() ){
446 + if( $this->get_content('show_for_premium') === 'FALSE' ){
447 + return '';
448 + }
449 + }
450 + $image_url = $this->get_content('image_url');
451 + ?>
452 +
453 + <div class="wp-adminify-popup wp-adminify-upgrade-popup" id="wp-adminify-popup" data-plugin="<?php echo esc_attr($this->slug); ?>" tabindex="1" style="display: none;">
454 +
87 455 <div class="wp-adminify-popup-overlay"></div>
88 456
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 - ?>;">
457 + <div class="wp-adminify-popup-modal" style="background-image: url('<?php echo esc_url($image_url); ?>'); --wp-adminify-popup-color: <?php echo esc_attr($this->get_content('btn_color')); ?>;">
94 458
95 459 <!-- close -->
96 460 <div class="wp-adminify-popup-modal-close popup-dismiss">×</div>
97 461
@@ -99,69 +463,50 @@
99 463 <div class="wp-adminify-popup-modal-footer">
100 464 <!-- countdown -->
101 465 <div class="wp-adminify-popup-countdown" style="display: none;">
102 466
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 - ?>
467 + <?php if (!empty($this->get_content('notice'))) { ?>
468 + <span data-counter="notice" style="color:#F4B740; font-size:14px; padding-bottom:20px; font-style:italic;"><?php echo esc_html__('Notice:', 'adminify'); ?> <?php echo $this->get_content('notice'); ?></span>
469 + <?php } ?>
114 470
115 - <span class="wp-adminify-popup-countdown-text"><?php
116 - echo esc_html__( 'Deal Ends In', 'adminify' );
117 - ?></span>
471 + <span class="wp-adminify-popup-countdown-text"><?php echo esc_html__('Deal Ends In', 'adminify'); ?></span>
118 472 <div class="wp-adminify-popup-countdown-time">
119 473 <div>
120 474 <span data-counter="days">00</span>
121 - <span><?php
122 - echo esc_html__( 'Days', 'adminify' );
123 - ?></span>
475 + <span><?php echo esc_html__('Days', 'adminify'); ?></span>
124 476 </div>
125 477 <span>:</span>
126 478 <div>
127 479 <span data-counter="hours">00</span>
128 - <span><?php
129 - echo esc_html__( 'Hours', 'adminify' );
130 - ?></span>
480 + <span><?php echo esc_html__('Hours', 'adminify'); ?></span>
131 481 </div>
132 482 <span>:</span>
133 483 <div>
134 484 <span data-counter="minutes">00</span>
135 - <span><?php
136 - echo esc_html__( 'Minutes', 'adminify' );
137 - ?></span>
485 + <span><?php echo esc_html__('Minutes', 'adminify'); ?></span>
138 486 </div>
139 487 <span>:</span>
140 488 <div>
141 489 <span data-counter="seconds">00</span>
142 - <span><?php
143 - echo esc_html__( 'Seconds', 'adminify' );
144 - ?></span>
490 + <span><?php echo esc_html__('Seconds', 'adminify'); ?></span>
145 491 </div>
146 492 </div>
147 493 </div>
148 494
149 495 <!-- 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>
496 + <a class="wp-adminify-popup-button" target="_blank" href="<?php echo esc_url($this->get_content('button_url')); ?>"><?php
497 + if (jltwp_adminify()->can_use_premium_code()) {
498 + echo esc_html__('Upgrade Now', 'adminify');
499 + } else {
500 + echo esc_html($this->get_content('button_text'));
501 + } ?></a>
502 + </div>
155 503 </div>
156 - </div>
157 504 </div>
158 505
159 506 <script>
160 507 var $container = jQuery('#wp-adminify-popup'),
161 - plugin_data = <?php
162 - echo wp_json_encode( $this->data );
163 - ?>,
508 + plugin_data = <?php echo json_encode($this->get_sheet_promo_remote_data(), true); ?>,
164 509 events = {}; //Events
165 510
166 511 // Update Counter
167 512 function updateCounter(seconds) {
@@ -242,27 +587,28 @@
242 587
243 588 }, 1000);
244 589 }
245 590
246 - initCounter('<?php
247 - echo esc_attr( $this->counter_date() );
248 - ?>');
591 + initCounter('<?php echo esc_attr($this->counter_date()); ?>');
249 592 </script>
250 593
251 - <?php
252 - }
594 +<?php
595 + }
253 596
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 - }
597 + /**
598 + * Counter Date
599 + *
600 + * @author Jewel Theme <support@jeweltheme.com>
601 + */
602 + public function counter_date()
603 + {
604 + $endDate = $this->get_content('end_date');
267 605
606 + $is_active = $this->date_is_current_or_next($endDate);
607 +
608 + if ($is_active) {
609 + return $endDate;
610 + }
611 +
612 + return $this->date_increment($this->current_time(), 3);
613 + }
268 614 }