BlackFriday.php
8 months ago
EidSpecial.php
8 months ago
LoadResourceType.php
8 months ago
Review.php
8 months ago
SummerSale.php
8 months ago
SummerSale.php
90 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Notice Controller class. |
| 4 | * |
| 5 | * @package RT_TPG |
| 6 | */ |
| 7 | |
| 8 | namespace RT\ThePostGrid\Controllers\Admin\Notice; |
| 9 | |
| 10 | // Do not allow directly accessing this file. |
| 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | exit( 'This script cannot be accessed directly.' ); |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * Notice Controller class. |
| 17 | */ |
| 18 | class SummerSale { |
| 19 | |
| 20 | /** |
| 21 | * Class Constructor |
| 22 | */ |
| 23 | public function __construct() { |
| 24 | add_action( 'admin_notices', [ __CLASS__, 'summer_special_deal_admin_notice' ] ); |
| 25 | add_action( 'wp_ajax_dismiss_summer_notice', [ __CLASS__, 'dismiss_summer_notice' ] ); |
| 26 | } |
| 27 | |
| 28 | public static function summer_special_deal_admin_notice() { |
| 29 | // Set expiration date (April 7) |
| 30 | $expiration_date = strtotime( 'May 31, 2025' ); |
| 31 | |
| 32 | // Check if the current date is past the expiration date |
| 33 | if ( time() > $expiration_date ) { |
| 34 | return; |
| 35 | } |
| 36 | |
| 37 | // Check if notice is dismissed |
| 38 | if ( get_user_meta( get_current_user_id(), 'dismissed_summer_notice', true ) ) { |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | |
| 43 | $plugin_name = 'The Post Grid'; |
| 44 | $download_link = 'https://www.radiustheme.com/downloads/the-post-grid-pro-for-wordpress/'; |
| 45 | |
| 46 | ?> |
| 47 | |
| 48 | |
| 49 | <div class="notice notice-info is-dismissible summer-notice" data-rttpg-dismissable="rttpg_dismiss_bf_notice" |
| 50 | style="display:grid !important;grid-template-columns: 100px auto;padding-top: 25px; padding-bottom: 22px;"> |
| 51 | <img alt="<?php echo esc_attr( $plugin_name ); ?>" |
| 52 | src="<?php echo esc_url( rtTPG()->get_assets_uri( 'images/post-grid-gif.gif' ) ); ?>" |
| 53 | width="74px" height="74px" style="grid-row: 1 / 4; align-self: center;justify-self: center"/> |
| 54 | <h3 style="margin:0;display: inline-flex;align-items: center;gap: 4px;"> |
| 55 | <?php echo sprintf( ' %s – ☀️ Summer Sale', esc_html( $plugin_name ) ); ?> |
| 56 | <img alt="Deal" style="width: 60px;position: static" src="<?php echo esc_url( rtTPG()->get_assets_uri( 'images/deal.gif' ) ); ?>"> |
| 57 | </h3> |
| 58 | <p style="margin-top: 0; font-size: 14px;"> |
| 59 | <strong>Hot Summer Deals:</strong> |
| 60 | Beat the heat with cool discounts on |
| 61 | <b><a href="<?php echo esc_url( $download_link ); ?>" style="text-decoration: none;color: inherit">The Post Grid</a></b>. Save |
| 62 | <b style="display:inline-block;color: white;background:red;padding: 0 8px;border-radius:3px; transform: skewX(-10deg);">UP TO 40%</b> |
| 63 | for a limited time! ☀️🔥🌴 |
| 64 | </p> |
| 65 | <p style="margin:0;"> |
| 66 | <a class="button button-primary" href="<?php echo esc_url( $download_link ); ?>" |
| 67 | style="background: #4e13ff;" |
| 68 | target="_blank">Buy Now</a> |
| 69 | </p> |
| 70 | </div> |
| 71 | |
| 72 | |
| 73 | <script> |
| 74 | jQuery(document).on('click', '.summer-notice .notice-dismiss', function () { |
| 75 | jQuery.post(ajaxurl, { |
| 76 | action: 'dismiss_summer_notice', |
| 77 | security: '<?php echo wp_create_nonce( "dismiss_summer_notice" ); ?>', |
| 78 | }) |
| 79 | }) |
| 80 | </script> |
| 81 | <?php |
| 82 | } |
| 83 | |
| 84 | public static function dismiss_summer_notice() { |
| 85 | check_ajax_referer( 'dismiss_summer_notice', 'security' ); |
| 86 | update_user_meta( get_current_user_id(), 'dismissed_summer_notice', true ); |
| 87 | wp_die(); |
| 88 | } |
| 89 | |
| 90 | } |