Skip to content

Commit 75bc1a0

Browse files
committed
wip
1 parent d115baf commit 75bc1a0

File tree

3 files changed

+140
-5
lines changed

3 files changed

+140
-5
lines changed

assets/css/admin.css

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,42 @@
3232
.udb-notice-metabox.is-info {
3333
border-left-width: 4px;
3434
border-left-color: #72aee6;
35-
}
35+
}
36+
37+
/**
38+
* BFCM Notice.
39+
*/
40+
.udb-bfcm-notice {
41+
padding: 25px 20px;
42+
}
43+
44+
.udb-bfcm-notice .notice-body {
45+
display: flex;
46+
}
47+
48+
.udb-bfcm-notice .notice-icon {
49+
padding-right: 25px;
50+
}
51+
52+
.udb-bfcm-notice .notice-icon img {
53+
max-width: 55px;
54+
}
55+
56+
.udb-bfcm-notice .notice-content {
57+
width: 100%;
58+
}
59+
60+
.udb-bfcm-notice .notice-content h2 {
61+
margin-top: 0;
62+
margin-bottom: 10px;
63+
font-weight: 700;
64+
}
65+
66+
.udb-bfcm-notice .notice-content > p {
67+
margin-top: 0;
68+
margin-bottom: 10px;
69+
}
70+
71+
.udb-bfcm-notice .notice-content > p:last-child {
72+
margin-bottom: 0;
73+
}

assets/js/notice-dismissal.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
function init() {
55
$(document).on(
66
"click",
7-
".udb-notice.is-permanent-dismissible .notice-dismiss",
7+
".udb-review-notice.is-permanent-dismissible .notice-dismiss",
8+
ajax.saveDismissal
9+
);
10+
$(document).on(
11+
"click",
12+
".udb-bfcm-notice.is-permanent-dismissible .notice-dismiss",
813
ajax.saveDismissal
914
);
1015
}

class-setup.php

Lines changed: 95 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ public function setup() {
9090
add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ), 20 );
9191
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ), 20 );
9292
add_action( 'admin_notices', array( self::get_instance(), 'review_notice' ) );
93+
add_action( 'admin_notices', array( self::get_instance(), 'bfcm_notice' ) );
9394
add_action( 'wp_ajax_udb_dismiss_review_notice', array( $this, 'dismiss_review_notice' ) );
95+
add_action( 'wp_ajax_udb_dismiss_bfcm_notice', array( $this, 'dismiss_bfcm_notice' ) );
9496

9597
register_deactivation_hook( ULTIMATE_DASHBOARD_PLUGIN_FILE, array( $this, 'deactivation' ), 20 );
9698

@@ -331,7 +333,7 @@ public function review_notice() {
331333
$notice .= '<br/>';
332334
$notice .= "<a href=\"$review_url\" style=\"margin-top: 15px;\" target='_blank' class=\"button-primary\">$btn_text</a>";
333335

334-
echo '<div class="notice udb-notice review-notice notice-success is-dismissible is-permanent-dismissible" data-ajax-action="udb_dismiss_review_notice">';
336+
echo '<div class="notice udb-notice udb-review-notice notice-success is-dismissible is-permanent-dismissible" data-ajax-action="udb_dismiss_review_notice">';
335337
echo '<p>' . $notice . '</p>';
336338
echo '</div>';
337339

@@ -345,11 +347,101 @@ public function dismiss_review_notice() {
345347
$dismiss = isset( $_POST['dismiss'] ) ? absint( $_POST['dismiss'] ) : 0;
346348

347349
if ( empty( $dismiss ) ) {
348-
wp_send_json_error( __( 'Invalid Request', 'ultimate-dashboard' ) );
350+
wp_send_json_error( 'Invalid Request' );
349351
}
350352

351353
update_option( 'review_notice_dismissed', 1 );
352-
wp_send_json_success( __( 'Review notice has been dismissed', 'ultimate-dashboard' ) );
354+
wp_send_json_success( 'Review notice has been dismissed.' );
355+
356+
}
357+
358+
/**
359+
* Show BFCM notice.
360+
*/
361+
public function bfcm_notice( $module ) {
362+
363+
// Stop if PRO version is active.
364+
if ( udb_is_pro_active() ) {
365+
// return;
366+
}
367+
368+
// Stop here if current user is not an admin.
369+
if ( ! current_user_can( 'administrator' ) ) {
370+
return;
371+
}
372+
373+
global $pagenow;
374+
375+
// Stop if we are not on the dashboard page.
376+
if ( $pagenow !== 'index.php' &&
377+
! $module->screen()->is_new_widget() &&
378+
! $module->screen()->is_edit_widget() &&
379+
! $module->screen()->is_widget_list() ) {
380+
return;
381+
}
382+
383+
$start = strtotime( 'november 22nd, 2021' );
384+
$end = strtotime( 'november 30th, 2021' );
385+
$now = time();
386+
387+
$now = strtotime( 'november 22nd, 2021' ); // Remove before pushing.
388+
389+
// Stop here if we are not in the sales period.
390+
if ( $now < $start || $now > $end ) {
391+
return;
392+
}
393+
394+
// Stop here if notice has been dismissed.
395+
if ( ! empty( get_option( 'udb_bfcm_notice_dismissed', 0 ) ) ) {
396+
return;
397+
}
398+
399+
400+
$bfcm_url = 'https://wp-pagebuilderframework.com/pricing/?utm_source=repository&utm_medium=bfcm_banner&utm_campaign=wpbf';
401+
?>
402+
403+
<div class="notice udb-notice udb-bfcm-notice notice-info is-dismissible is-permanent-dismissible" data-ajax-action="udb_dismiss_bfcm_notice">
404+
<div class="notice-body">
405+
<div class="notice-icon">
406+
<img src="<?php echo esc_url( ULTIMATE_DASHBOARD_PLUGIN_URL ); ?>/assets/img/logo.png" alt="Ultimate Dashboard Logo">
407+
</div>
408+
<div class="notice-content">
409+
<h2>
410+
<?php _e( 'Up to 30% Off Ultimate Dashboard PRO - Black Friday Sale*', 'ultimate-dashboard' ); ?>
411+
</h2>
412+
<p>
413+
<?php _e( 'Save big & upgrade to the <strong>Ultimate Dashboard PRO</strong>, today!', 'ultimate-dashboard' ); ?>
414+
</p>
415+
<p>
416+
<?php _e( 'Hurry up! The deal will expire soon!', 'ultimate-dashboard' ); ?><br>
417+
<em><?php _e( 'All prices are reduced. No coupon code required.', 'ultimate-dashboard' ); ?></em>
418+
</p>
419+
<p>
420+
<a href="<?php echo esc_url( $bfcm_url ); ?>" class="button button-primary">
421+
<?php _e( 'Get the Deal', 'ultimate-dashboard' ); ?>
422+
</a>
423+
<small><?php _e( '*Only Administrators will see this message!', 'ultimate-dashboard' ); ?></small>
424+
</p>
425+
</div>
426+
</div>
427+
</div>
428+
429+
<?php
430+
}
431+
432+
/**
433+
* Dismiss BFCM notice.
434+
*/
435+
public function dismiss_bfcm_notice() {
436+
437+
$dismiss = isset( $_POST['dismiss'] ) ? absint( $_POST['dismiss'] ) : 0;
438+
439+
if ( empty( $dismiss ) ) {
440+
wp_send_json_error( 'Invalid Request' );
441+
}
442+
443+
update_option( 'udb_bfcm_notice_dismissed', 1 );
444+
wp_send_json_success( 'Review notice has been dismissed.' );
353445

354446
}
355447

0 commit comments

Comments
 (0)