occasion = $occasion_slug;
$this->start_datetime = $start_datetime;
$this->end_datetime = $end_datetime;
$current_datetime = current_time('Y-m-d H:i:s');
if( $current_datetime >= $this->start_datetime && $current_datetime <= $this->end_datetime ) {
// Hook into the admin_notices action to display the banner
add_action('admin_notices', array($this, 'display_banner'));
// Add styles
add_action('admin_head', array($this, 'add_styles'));
add_action('wp_ajax_wpvr_sale_notification_notice', array($this, 'wpvr_sale_notification_notice'));
}
}
/**
* Displays the special occasion banner if the current date and time are within the specified range.
*/
public function display_banner()
{
$screen = get_current_screen();
$promotional_notice_pages = ['dashboard', 'plugins', 'edit-wpvr_item', 'toplevel_page_wpvr', 'wp-vr_page_wpvr-setup-wizard', 'wpvr_item', 'wp-vr_page_wpvr-addons','wp-vr_page_wpvr-setting'];
if (!in_array($screen->id, $promotional_notice_pages)) {
return;
}
if ( $screen->base === 'plugins' || $screen->base === 'dashboard' ) {
if ( defined( 'WPVR_SPECIAL_OCCASION_BANNER_SHOWN_GLOBAL' ) ) {
return;
}
define( 'WPVR_SPECIAL_OCCASION_BANNER_SHOWN_GLOBAL', true );
}
// Check if banner was dismissed within last 5 days
$dismissed_option = 'wpvr_' . $this->occasion . '_dismissed';
$dismissed_time = get_option($dismissed_option, 0);
if ($dismissed_time && (time() - $dismissed_time) < 432000) {
return; // Don't show if dismissed within last 5 days
}
$base_url = 'https://rextheme.com/wpvr/wpvr-pricing/';
$utm_params = array(
'utm_source' => 'website',
'utm_medium' => 'plugin-ban-wpvr',
'utm_campaign' => 'eidoffer2026',
);
$btn_link = add_query_arg( $utm_params, $base_url );
$img_url = WPVR_PLUGIN_DIR_URL . 'admin/icon/banner-images/ramadan-kareem.webp';
$img_path = WPVR_PLUGIN_DIR_PATH . 'admin/icon/banner-images/ramadan-kareem.webp';
$img_size = getimagesize($img_path);
$img_width = $img_size[0];
$img_height = $img_size[1];
?>
false,
'data' => 'Permission denied.'
);
wp_send_json($response);
}
$nonce = isset($_POST['nonce']) ? sanitize_text_field(wp_unslash($_POST['nonce'])) : '';
if (!$nonce || !wp_verify_nonce($nonce, 'wpvr')) {
wp_die( esc_html__( 'Permission check failed', 'wpvr' ) );
}
// Store current timestamp for 24-hour dismissal
$dismissed_option = 'wpvr_' . $this->occasion . '_dismissed';
update_option($dismissed_option, time());
echo wp_json_encode(['success' => true]);
wp_die();
}
}