PluginProbe
Post Grid Gutenberg Blocks – PostX / 2.7.7
Post Grid Gutenberg Blocks – PostX v2.7.7
5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 5.0.17 2.1.1 2.1.2 All 237 releases
ultimate-post / classes / Notice.php

Notice.php in Post Grid Gutenberg Blocks – PostX 2.7.7, at classes/Notice.php

228 lines 7.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Notice Action.
4 *
5 * @package ULTP\Notice
6 * @since v.1.0.0
7 */
8 namespace ULTP;
9
10 defined('ABSPATH') || exit;
11
12 /**
13 * Notice class.
14 */
15 class Notice {
16 /**
17 * Setup class.
18 *
19 * @since v.1.0.0
20 */
21 private $notice_version = 'v8';
22
23 public function __construct(){
24 $default_notice = array(
25 // array(
26 // 'start' => '20-09-2022',
27 // 'end' => '29-12-2022',
28 // 'type' => 'content',
29 // 'content' => '<strong>PostX - ⚡Flash Sale⚡</strong> is LIVE! Spend <strong style="color:#1cb53e;">25% LESS</strong> on Premium Features for a <strong>⏳LIMITED Time!</strong>',
30 // 'force' => false
31 // ),
32 array(
33 'start' => '20-10-2022', // Date format "d-m-Y" [08-02-2019]
34 'end' => '02-11-2022',
35 'type' => 'banner',
36 'content' => ULTP_URL.'assets/img/banner.jpg',
37 'force' => true
38 ),
39 );
40 if (count($default_notice) > 0) {
41 foreach ($default_notice as $key => $notice) {
42 $current_time = date('U');
43 if ($current_time > strtotime($notice['start']) && $current_time < strtotime($notice['end'])) {
44 $this->type = $notice['type'];
45 $this->content = $notice['content'];
46 $this->force = $notice['force'];
47 add_action('admin_notices', array($this, 'ultp_installation_notice_callback'));
48 }
49 }
50 }
51 add_action('admin_init', array($this, 'set_dismiss_notice_callback'));
52 }
53
54 /**
55 * Promotional Dismiss Notice Option Data
56 *
57 * @since v.2.0.1
58 * @param NULL
59 * @return NULL
60 */
61 public function set_dismiss_notice_callback() {
62 if (!isset($_GET['disable_postx_notice_' . $this->notice_version])) {
63 return ;
64 }
65 if (sanitize_key($_GET['disable_postx_notice_' . $this->notice_version]) == 'yes') {
66 set_transient( 'ultp_get_pro_notice_' . $this->notice_version, 'off', 2592000 ); // 30 days notice
67 }
68 }
69
70 /**
71 * Dismiss Notice HTML Data
72 *
73 * @since v.1.0.0
74 * @param NULL
75 * @return STRING
76 */
77 public function ultp_installation_notice_callback() {
78 if (get_transient('ultp_get_pro_notice_' . $this->notice_version) != 'off') {
79 if (!ultimate_post()->is_lc_active() && ($this->force || get_transient('wpxpo_installation_date') != 'yes')) {
80 if (!isset($_GET['disable_postx_notice_' . $this->notice_version])) {
81 $this->ultp_notice_css();
82 ?>
83 <div class="wc-install ultp-pro-notice">
84 <?php
85 switch ($this->type) {
86 case 'banner': ?>
87 <div class="wc-install-body ultp-image-banner">
88 <a class="wc-dismiss-notice" href="<?php echo esc_url( add_query_arg( 'disable_postx_notice_' . $this->notice_version, 'yes' ) ); ?>">
89 Dismiss
90 </a>
91 <a class="ultp-btn-image" target="_blank" href="<?php echo esc_url(ultimate_post()->get_premium_link('', 'postx_dashboard_banner')); ?>">
92 <img loading="lazy" src="<?php echo esc_url($this->content); ?>" alt="Discount Banner"/>
93 </a>
94 </div>
95 <?php break;
96 case 'content': ?>
97 <div class="wc-install-body">
98 <div><?php echo $this->content; ?></div>
99 <a class="button button-primary button-hero ultp-btn-notice-pro" target="_blank" href="<?php echo esc_url(ultimate_post()->get_premium_link('','postx_dashboard_banner')); ?>"><span class="dashicons dashicons-image-rotate"></span><?php esc_html_e('Upgrading to Pro', 'ultimate-post'); ?></a>
100 <a class="button-secondary button-large" href="<?php echo esc_url( add_query_arg( 'disable_postx_notice_' . $this->notice_version, 'yes' ) ); ?>"><?php esc_html_e('No Thanks / Close.', 'ultimate-post'); ?></a>
101 </div>
102 <?php break;
103 }
104 ?>
105 </div>
106 <?php
107 }
108 }
109 }
110 }
111
112 /**
113 * Admin Notice CSS File
114 *
115 * @since v.1.0.0
116 * @param NULL
117 * @return STRING
118 */
119 public function ultp_notice_css() {
120 ?>
121 <style type="text/css">
122 .wc-install {
123 display: flex;
124 align-items: center;
125 background: #fff;
126 margin-top: 40px;
127 width: calc(100% - 50px);
128 border: 1px solid #ccd0d4;
129 padding: 4px;
130 border-radius: 4px;
131 border-left: 3px solid #46b450;
132 line-height: 0;
133 }
134 .wc-install img {
135 margin-right: 0;
136 max-width: 100%;
137 }
138 .wc-install-body {
139 -ms-flex: 1;
140 flex: 1;
141 position: relative;
142 padding: 10px;
143 }
144 .wc-install-body.ultp-image-banner{
145 padding: 0px;
146 }
147 .wc-install-body h3 {
148 margin-top: 0;
149 font-size: 24px;
150 margin-bottom: 15px;
151 }
152 .ultp-install-btn {
153 margin-top: 15px;
154 display: inline-block;
155 }
156 .wc-install .dashicons{
157 display: none;
158 animation: dashicons-spin 1s infinite;
159 animation-timing-function: linear;
160 }
161 .wc-install.loading .dashicons {
162 display: inline-block;
163 margin-top: 12px;
164 margin-right: 5px;
165 }
166 .ultp-pro-notice .wc-install-body h3 {
167 font-size: 20px;
168 margin-bottom: 5px;
169 }
170 .ultp-pro-notice .wc-install-body > div {
171 max-width: 100%;
172 margin-bottom: 10px;
173 }
174 .ultp-pro-notice .button-hero {
175 padding: 8px 14px !important;
176 min-height: inherit !important;
177 line-height: 1 !important;
178 box-shadow: none;
179 border: none;
180 transition: 400ms;
181 }
182 .ultp-pro-notice .ultp-btn-notice-pro {
183 background: #2271b1;
184 color: #fff;
185 }
186 .ultp-pro-notice .ultp-btn-notice-pro:hover,
187 .ultp-pro-notice .ultp-btn-notice-pro:focus {
188 background: #185a8f;
189 }
190 .ultp-pro-notice .button-hero:hover,
191 .ultp-pro-notice .button-hero:focus {
192 border: none;
193 box-shadow: none;
194 }
195 @keyframes dashicons-spin {
196 0% {
197 transform: rotate( 0deg );
198 }
199 100% {
200 transform: rotate( 360deg );
201 }
202 }
203 .wc-dismiss-notice {
204 color: #fff;
205 background-color: #000000;
206 padding-top: 0px;
207 position: absolute;
208 right: 0;
209 top: 0px;
210 padding: 10px 10px 14px;
211 border-radius: 0 0 0 4px;
212 display: inline-block;
213 transition: 400ms;
214 }
215 .wc-dismiss-notice:hover {
216 color:red;
217 }
218 .wc-dismiss-notice .dashicons{
219 display: inline-block;
220 text-decoration: none;
221 animation: none;
222 font-size: 16px;
223 }
224 </style>
225 <?php
226 }
227
228 }