@@ -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