| 1 |
<?php |
| 2 |
|
| 3 |
namespace Disco\Notice; |
| 4 |
|
| 5 |
use Disco\App\Disco; |
| 6 |
|
| 7 |
class PromotionalNotice { |
| 8 |
public function __construct() { |
| 9 |
// add_action( 'admin_notices', [ $this, 'display_promotional_notice' ] ); |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Display the promotional notice. |
| 14 |
* |
| 15 |
* @return void |
| 16 |
*/ |
| 17 |
public function display_promotional_notice() { |
| 18 |
|
| 19 |
if( Disco::is_pro() ) { |
| 20 |
return; |
| 21 |
} |
| 22 |
|
| 23 |
global $pagenow; |
| 24 |
|
| 25 |
$allowed_pages = [ |
| 26 |
'index.php', // Dashboard |
| 27 |
]; |
| 28 |
|
| 29 |
$plugin_page_slug = 'disco-create-discount'; |
| 30 |
|
| 31 |
// If NOT dashboard AND NOT your plugin page → return |
| 32 |
if ( |
| 33 |
! in_array( $pagenow, $allowed_pages, true ) && |
| 34 |
( ! isset( $_GET['page'] ) || $_GET['page'] !== $plugin_page_slug ) |
| 35 |
) { |
| 36 |
return; |
| 37 |
} |
| 38 |
|
| 39 |
// Stop if user is not logged in |
| 40 |
if ( ! is_user_logged_in() ) { |
| 41 |
return; |
| 42 |
} |
| 43 |
|
| 44 |
|
| 45 |
$current_time = time(); |
| 46 |
|
| 47 |
$promo_start = strtotime('2025-12-01 00:00:00'); |
| 48 |
$promo_end = strtotime('2026-01-05 11:59:00'); |
| 49 |
|
| 50 |
// If not in promotion window, don't show |
| 51 |
if ( $current_time < $promo_start || $current_time > $promo_end ) { |
| 52 |
return; |
| 53 |
} |
| 54 |
|
| 55 |
$user_id = get_current_user_id(); |
| 56 |
$dismiss = get_user_meta( $user_id, 'disco_promotional_holiday_banner_2025', true ); |
| 57 |
|
| 58 |
if ( $dismiss === 'never' ) { |
| 59 |
return; // User dismissed permanently |
| 60 |
} |
| 61 |
|
| 62 |
?> |
| 63 |
<div class="disco-promotional-notice-wrapper"> |
| 64 |
<div class="notice notice-success is-dismissible disco-promotional-notice"> |
| 65 |
<a href="https://discoplugin.com/pricing/?utm_source=Floating-Holiday&utm_medium=free-to-pro&utm_campaign=H-Holiday&utm_id=1" target="_blank"> |
| 66 |
<img src="<?php echo esc_url( plugins_url( 'assets/img/promotional/holiday_promotional_banner_2025.png', DISCO_PLUGIN_ABSOLUTE ) ); ?>" alt="Promotional Banner" style="max-width: 100%; height: auto;"> |
| 67 |
</a> |
| 68 |
</div> |
| 69 |
</div> |
| 70 |
<?php |
| 71 |
} |
| 72 |
} |
| 73 |
|