PluginProbe
Post Grid Gutenberg Blocks – PostX / 4.1.9
Post Grid Gutenberg Blocks – PostX v4.1.9
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 4.1.9, at classes/Notice.php

516 lines 19.2 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 = 'v416';
22 private $valid_notices = array();
23
24 public function __construct() {
25 add_filter( 'ultp_dashboard_notice', array( $this, 'dashboard_notice_callback' ) );
26 add_action( 'admin_notices', array( $this, 'ultp_installation_notice_callback' ) );
27 add_action( 'admin_init', array( $this, 'set_dismiss_notice_callback' ) );
28 }
29
30 public function notice_data() {
31 $valid_notices = array();
32 $default_notice = apply_filters( 'ultp_dashboard_notice', array() );
33 if ( is_array( $default_notice ) && count( $default_notice ) > 0 ) {
34 foreach ( $default_notice as $key => $notice ) {
35 $current_time = gmdate( 'U' );
36 if ( $current_time > strtotime( $notice['start'] ) && $current_time < strtotime( $notice['end'] ) && $notice['visibility'] ) {
37 $valid_notices[] = $notice;
38 }
39 }
40 }
41 return $valid_notices;
42 }
43
44
45 /**
46 * Dashboard Notice Data
47 *
48 * @since v.3.1.8
49 * @param NULL
50 * @return NULL
51 */
52 public function dashboard_notice_callback() {
53 return array(
54 array(
55 'key' => 'ultp_summer_sale_24',
56 'start' => '25-06-2024',
57 'end' => '20-07-2024',
58 // 'type' => 'banner',
59 // 'content' => ULTP_URL.'assets/img/dashboard_banner/black_friday_free.jpg',
60 'type' => 'content',
61 'force' => true,
62 'url' => ultimate_post()->get_premium_link('', 'dashboard_db_banner'),
63 'visibility' => !ultimate_post()->is_lc_active(),
64 'priority' => 50,
65 'repeat_interval' => '',
66 )
67 );
68 }
69
70 /**
71 * Promotional Dismiss Notice Option Data
72 *
73 * @since v.2.0.1
74 * @param NULL
75 * @return NULL
76 */
77 public function set_dismiss_notice_callback() {
78 $valid_notices = $this->notice_data();
79
80 if( !( isset($_GET['ultp_dashboard_nonce']) && wp_verify_nonce(sanitize_key(wp_unslash($_GET['ultp_dashboard_nonce'])), 'ultp-dashboardnonce') )) {
81 return;
82 }
83 if ( count( $valid_notices ) > 0 ) {
84 foreach ( $valid_notices as $notice ) {
85 $notice_key = isset( $notice['key'] ) ? $notice['key'] : $this->notice_version;
86 if ( isset( $_GET['disable_postx_notice_' .$notice_key ] ) ) { // @codingStandardsIgnoreLine
87 if ( sanitize_key( $_GET['disable_postx_notice_' . $notice_key] ) == 'yes' ) { // @codingStandardsIgnoreLine
88 if ( isset( $notice['repeat_interval'] ) && '' != $notice['repeat_interval'] ) {
89 $interval = (int) $notice['repeat_interval'];
90 ultimate_post()->set_transient_without_cache( 'ultp_get_pro_notice_' . $notice_key, 'off', $interval ); // 30 (2592000) days notice
91 } else {
92 ultimate_post()->set_transient_without_cache( 'ultp_get_pro_notice_' . $notice_key, 'off' ); // 30 (2592000) days notice
93 }
94 }
95 }
96 }
97 }
98 }
99
100 /**
101 * Dismiss Notice HTML Data
102 *
103 * @since v.1.0.0
104 * @param NULL
105 * @return STRING
106 */
107 public function ultp_installation_notice_callback() {
108 $valid_notices = $this->notice_data();
109 $ultp_dashboard_nonce = wp_create_nonce('ultp-dashboardnonce');
110 if ( count( $valid_notices ) > 0 ) {
111 $this->ultp_notice_css();
112 foreach ( $valid_notices as $notice ) {
113 $notice_key = isset( $notice['key'] ) ? $notice['key'] : $this->notice_version;
114 if ( ultimate_post()->get_transient_without_cache('ultp_get_pro_notice_' . $notice_key) != 'off' ) {
115 if ( ( $notice['force'] || get_transient('wpxpo_installation_date') != 'yes' ) ) {
116 if ( ! isset( $_GET['disable_postx_notice_' . $notice_key] ) ) { // @codingStandardsIgnoreLine
117 switch ( $notice['type'] ) {
118 case 'banner': ?>
119 <div class="wc-install ultp-free-notice">
120 <div class="wc-install-body ultp-image-banner">
121 <a class="wc-dismiss-notice" href="<?php echo esc_url( add_query_arg( array( 'disable_postx_notice_' . $notice_key => 'yes', 'ultp_dashboard_nonce' => $ultp_dashboard_nonce ) ) ); ?>">Dismiss</a>
122 <a class="ultp-btn-image" target="_blank" href="<?php echo esc_url($notice['url']); ?>">
123 <img loading="lazy" src="<?php echo esc_url($notice['content']); ?>" alt="Discount Banner"/>
124 </a>
125 </div>
126 </div>
127 <?php
128 break;
129 case 'content':
130 $icon = ULTP_URL . 'assets/img/logo-sm.svg';
131 $url = 'https://www.wpxpo.com/postx/pricing/?utm_source=db-postx-global&utm_medium=summer-sale&utm_campaign=postx-dashboard';
132 ?>
133 <div class="ultp-notice-wrapper notice data_collection_notice">
134 <?php
135 if ( isset( $icon ) ) {
136 ?>
137 <div class="ultp-notice-icon"> <img src="<?php echo esc_url( $icon ); ?>"/> </div>
138 <?php
139 }
140 ?>
141
142 <div class="ultp-notice-content-wrapper">
143 <div class="">Sizzling Summer Sale is<strong> LIVE!</strong> Beat the heat with upto <strong>50% DISCOUNT</strong> on PostX Pro</div>
144 <div class="ultp-notice-buttons">
145 <a class="ultp-notice-btn button button-primary" href="<?php echo esc_url( $url ); ?>" target="_blank"> Upgrade to Pro </a>
146 <a href=<?php echo esc_url( add_query_arg( array( 'disable_postx_notice_' . $notice_key => 'yes', 'ultp_dashboard_nonce' => $ultp_dashboard_nonce ) ) ); ?> class="ultp-notice-dont-save-money" > I don’t want to save money </a>
147 </div>
148 </div>
149 <a href=<?php echo esc_url( add_query_arg( array( 'disable_postx_notice_' . $notice_key => 'yes', 'ultp_dashboard_nonce' => $ultp_dashboard_nonce ) ) ); ?> class="ultp-notice-close"><span class="ultp-notice-close-icon dashicons dashicons-dismiss"> </span></a>
150 </div>
151 <?php
152 break;
153 }
154 }
155 }
156 }
157 }
158 }
159
160 }
161
162 /**
163 * Admin Notice CSS File
164 *
165 * @since v.1.0.0
166 * @param NULL
167 * @return STRING
168 */
169 public function ultp_notice_css() {
170 ?>
171 <style type="text/css">
172 .ultp-notice-wrapper {
173 border: 1px solid #c3c4c7;
174 border-left: 3px solid #037fff;
175 margin-bottom: 15px;
176 display: flex;
177 align-items: center;
178 background: #F7F9FF;
179 width: 100%;
180 padding: 10px 0px;
181 position: relative;
182 }
183 .ultp-notice-icon {
184 margin-left: 15px;
185 }
186 .ultp-notice-icon img {
187 max-width: 42px;
188 width: 100%;
189 }
190 .ultp-notice-content-wrapper {
191 display: flex;
192 flex-direction: column;
193 gap: 8px;
194 font-size: 14px;
195 line-height: 20px;
196 margin-left: 15px;
197 }
198 .ultp-notice-buttons {
199 display: flex;
200 align-items: center;
201 gap: 15px;
202 }
203 .ultp-notice-dont-save-money {
204 font-size: 12px;
205 }
206 .ultp-notice-close {
207 position: absolute;
208 right: 2px;
209 top: 5px;
210 text-decoration: unset;
211 color: #b6b6b6;
212 font-family: dashicons;
213 font-size: 16px;
214 font-style: normal;
215 font-weight: 400;
216 line-height: 20px;
217 }
218 .ultp-notice-close-icon {
219 font-size: 14px;
220 }
221 .ultp-free-notice.wc-install {
222 display: flex;
223 align-items: center;
224 background: #fff;
225 margin-top: 40px;
226 width: calc(100% - 50px);
227 border: 1px solid #ccd0d4;
228 padding: 4px;
229 border-radius: 4px;
230 border-left: 3px solid #007fe1;
231 line-height: 0;
232 }
233 .ultp-free-notice.wc-install img {
234 margin-right: 0;
235 max-width: 100%;
236 }
237 .ultp-free-notice .wc-install-body {
238 -ms-flex: 1;
239 flex: 1;
240 position: relative;
241 padding: 10px;
242 }
243 .ultp-free-notice .wc-install-body.ultp-image-banner{
244 padding: 0px;
245 }
246 .ultp-free-notice .wc-install-body h3 {
247 margin-top: 0;
248 font-size: 24px;
249 margin-bottom: 15px;
250 }
251 .ultp-install-btn {
252 margin-top: 15px;
253 display: inline-block;
254 }
255 .ultp-free-notice .wc-install .dashicons{
256 display: none;
257 animation: dashicons-spin 1s infinite;
258 animation-timing-function: linear;
259 }
260 .ultp-free-notice.wc-install.loading .dashicons {
261 display: inline-block;
262 margin-top: 12px;
263 margin-right: 5px;
264 }
265 .ultp-free-notice .wc-install-body h3 {
266 font-size: 20px;
267 margin-bottom: 5px;
268 }
269 .ultp-free-notice .wc-install-body > div {
270 max-width: 100%;
271 margin-bottom: 10px;
272 }
273 .ultp-free-notice .button-hero {
274 padding: 8px 14px !important;
275 min-height: inherit !important;
276 line-height: 1 !important;
277 box-shadow: none;
278 border: none;
279 transition: 400ms;
280 }
281 .ultp-free-notice .ultp-btn-notice-pro {
282 background: #2271b1;
283 color: #fff;
284 }
285 .ultp-free-notice .ultp-btn-notice-pro:hover,
286 .ultp-free-notice .ultp-btn-notice-pro:focus {
287 background: #185a8f;
288 }
289 .ultp-free-notice .button-hero:hover,
290 .ultp-free-notice .button-hero:focus {
291 border: none;
292 box-shadow: none;
293 }
294 @keyframes dashicons-spin {
295 0% {
296 transform: rotate( 0deg );
297 }
298 100% {
299 transform: rotate( 360deg );
300 }
301 }
302 .ultp-free-notice .wc-dismiss-notice {
303 color: #fff;
304 background-color: #000000;
305 padding-top: 0px;
306 position: absolute;
307 right: 0;
308 top: 0px;
309 padding: 10px 10px 14px;
310 border-radius: 0 0 0 4px;
311 display: inline-block;
312 transition: 400ms;
313 }
314 .ultp-free-notice .wc-dismiss-notice:hover {
315 color:red;
316 }
317 .ultp-free-notice .wc-dismiss-notice .dashicons{
318 display: inline-block;
319 text-decoration: none;
320 animation: none;
321 font-size: 16px;
322 }
323 /* ===== Eid Banner Css ===== */
324 .ultp-free-notice .wc-install-body {
325 background: linear-gradient(90deg,rgb(0,110,188) 0%,rgb(2,17,196) 100%);
326 }
327 .ultp-free-notice p{
328 color: #fff;
329 margin: 5px 0px;
330 font-size: 16px;
331 font-weight: 300;
332 letter-spacing: 1px;
333 }
334 .ultp-free-notice p.ultp-enjoy-offer {
335 display: inline;
336 font-weight: bold;
337
338 }
339 .ultp-free-notice .ultp-get-now {
340 font-size: 14px;
341 color: #fff;
342 background: #14a8ff;
343 padding: 8px 12px;
344 border-radius: 4px;
345 text-decoration: none;
346 margin-left: 10px;
347 position: relative;
348 top: -4px;
349 transition: 400ms;
350 }
351 .ultp-free-notice .ultp-get-now:hover{
352 background: #068fe0;
353 }
354 .ultp-free-notice .ultp-dismiss {
355 color: #fff;
356 background-color: #000964;
357 padding-top: 0px;
358 position: absolute;
359 right: 0;
360 top: 0px;
361 padding: 10px 8px 12px;
362 border-radius: 0 0 0 4px;
363 display: inline-block;
364 transition: 400ms;
365 }
366 .ultp-free-notice .ultp-dismiss:hover {
367 color: #d2d2d2;
368 }
369 /*----- ULTP Into Notice ------*/
370 .notice.notice-success.ultp-notice {
371 border-left-color: #4D4DFF;
372 padding: 0;
373 }
374 .ultp-notice-container {
375 display: flex;
376 }
377 .ultp-notice-container a{
378 text-decoration: none;
379 }
380 .ultp-notice-container a:visited{
381 color: white;
382 }
383 .ultp-notice-container img {
384 height: 100px;
385 width: 100px;
386 }
387 .ultp-notice-image {
388 padding-top: 15px;
389 padding-left: 12px;
390 padding-right: 12px;
391 background-color: #f4f4ff;
392 }
393 .ultp-notice-image img{
394 max-width: 100%;
395 }
396 .ultp-notice-content {
397 width: 100%;
398 padding: 16px;
399 display: flex;
400 flex-direction: column;
401 gap: 8px;
402 }
403 .ultp-notice-ultp-button {
404 max-width: fit-content;
405 padding: 8px 15px;
406 font-size: 16px;
407 color: white;
408 background-color: #4D4DFF;
409 border: none;
410 border-radius: 2px;
411 cursor: pointer;
412 margin-top: 6px;
413 text-decoration: none;
414 }
415 .ultp-notice-heading {
416 font-size: 18px;
417 font-weight: 500;
418 color: #1b2023;
419 }
420 .ultp-notice-content-header {
421 display: flex;
422 justify-content: space-between;
423 align-items: center;
424 }
425 .ultp-notice-close .dashicons-no-alt {
426 font-size: 25px;
427 height: 26px;
428 width: 25px;
429 cursor: pointer;
430 color: #585858;
431 }
432 .ultp-notice-close .dashicons-no-alt:hover {
433 color: red;
434 }
435 .ultp-notice-content-body {
436 font-size: 14px;
437 color: #343b40;
438 }
439 .ultp-notice-wholesalex-button:hover {
440 background-color: #6C6CFF;
441 color: white;
442 }
443 span.ultp-bold {
444 font-weight: bold;
445 }
446 a.ultp-pro-dismiss:focus {
447 outline: none;
448 box-shadow: unset;
449 }
450 .ultp-free-notice .loading, .ultp-notice .loading {
451 width: 16px;
452 height: 16px;
453 border: 3px solid #FFF;
454 border-bottom-color: transparent;
455 border-radius: 50%;
456 display: inline-block;
457 box-sizing: border-box;
458 animation: rotation 1s linear infinite;
459 margin-left: 10px;
460 }
461 a.ultp-notice-ultp-button:hover {
462 color: #fff !important;
463 }
464 @keyframes rotation {
465 0% {
466 transform: rotate(0deg);
467 }
468 100% {
469 transform: rotate(360deg);
470 }
471 }
472 </style>
473 <?php
474 }
475
476 public function set_notice($key='',$value='',$expiration='') {
477 if($key) {
478 $option_name = 'ultp_notice';
479 $notice_data = ultimate_post()->get_option_without_cache($option_name,array());
480 if(!isset($notice_data) || !is_array($notice_data)) {
481 $notice_data = array();
482 }
483
484 $notice_data[$key] = $value;
485
486 if($expiration) {
487 $expire_notice_key = 'timeout_'.$key;
488 $notice_data[$expire_notice_key] = time() + $expiration;
489 }
490 update_option( $option_name, $notice_data );
491 }
492 }
493
494 public function get_notice($key='') {
495 if($key) {
496 $option_name = 'ultp_notice';
497 $notice_data = ultimate_post()->get_option_without_cache($option_name,array());
498 if(!isset($notice_data) || !is_array($notice_data)) {
499 return false;
500 }
501
502 if(isset($notice_data[$key])) {
503 $expire_notice_key = 'timeout_'.$key;
504 if(isset($notice_data[$expire_notice_key]) && $notice_data[$expire_notice_key]< time() ) {
505 unset($notice_data[$key]);
506 unset($notice_data[$expire_notice_key]);
507 update_option( $option_name, $notice_data);
508 return false;
509 }
510 return $notice_data[$key];
511 }
512 }
513 return false;
514 }
515
516 }