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