PluginProbe
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits / 3.1.9
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits v3.1.9
3.2.2 3.2.3 3.2.1 3.2.0 3.1.9 3.1.8 3.1.7 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.9 trunk 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.3 1.1.4 1.1.5 All 174 releases
master-addons / inc / classes / notifications / upgrade-notice.php

upgrade-notice.php in Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits 3.1.9, at inc/classes/notifications/upgrade-notice.php

123 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace MasterAddons\Inc\Classes\Notifications;
4
5 if (!defined('ABSPATH')) {
6 exit; // Exit if accessed directly
7 }
8
9 use MasterAddons\Inc\Classes\Notifications\Model\Popup;
10 use MasterAddons\Inc\Classes\Pro_Upgrade;
11 use MasterAddons\Inc\Classes\Helper;
12
13 if (!class_exists('Upgrade_Notice')) {
14 /**
15 * Upgrade notice class
16 *
17 * Jewel Theme <[email protected]>
18 */
19 class Upgrade_Notice extends Popup
20 {
21
22
23 protected $data = array();
24
25 /**
26 * Constructor method
27 */
28 public function __construct()
29 {
30 $this->init_data();
31
32 // On sheet data update, remove the popup data, to auto rebuid the data.
33 add_action(
34 'jltma_sheet_promo_data_reset',
35 function () {
36 $this->delete();
37 }
38 );
39
40 if (!empty($this->data)) {
41 parent::__construct();
42 }
43 }
44
45 /**
46 * Get Contents
47 *
48 * @param [type] $key .
49 *
50 * @author Jewel Theme <[email protected]>
51 */
52 public function get_content($key)
53 {
54 return $this->data[$key];
55 }
56
57 /**
58 * Set Intervals
59 *
60 * @author Jewel Theme <[email protected]>
61 */
62 public function intervals()
63 {
64 $end_date = $this->get_content('end_date');
65 $end_offset = $this->date_diff($end_date);
66
67 if ($end_offset < 0) {
68 return array();
69 } // Already Expired .
70
71 if (0 === $end_offset) {
72 return array(0);
73 } // Only Today is Left .
74
75 $intervals = array();
76
77 $start_date = $this->get_content('start_date');
78 $start_offset = $this->date_diff($start_date);
79
80 // Start Done .
81 $start = $start_offset <= 0 ? 0 : abs($start_offset);
82 $intervals[] = $start;
83
84 // End Calculated .
85 $end = $end_offset - $start;
86
87 // Middle Done .
88 if ($end > 3) {
89 $middle = round($end / 2);
90 $end = $end - $middle;
91 $intervals[] = $middle;
92 }
93
94 // End Done .
95 if ($end > 0) {
96 $intervals[] = $end;
97 }
98
99 return $intervals;
100 }
101
102 /**
103 * Init Data
104 *
105 * @author Jewel Theme <[email protected]>
106 */
107 public function init_data()
108 {
109 $sheet_data = Pro_Upgrade::get_data();
110
111 if (empty($sheet_data)) {
112 return;
113 }
114
115 $today = $this->current_time();
116
117 $this->data = Helper::get_merged_data($sheet_data, $today, $this->date_increment($today, 10));
118
119 $this->is_active = wp_validate_boolean($this->data['is_live'] ?? false);
120 }
121 }
122 }
123