admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('easy_invoice_promotion_nonce') ]); // Add plain text CSS for plugin row action wp_add_inline_style('easy-invoice-promotion', ' .plugin-action-links a[href*="easy-invoice#pricing"] { color: #ff9500 !important; font-weight: 600 !important; text-decoration: none !important; font-size: 12px !important; transition: all 0.3s ease !important; } .plugin-action-links a[href*="easy-invoice#pricing"]:hover { color: #e67e00 !important; text-decoration: underline !important; } '); } /** * Check if Easy Invoice Pro is active */ public static function isProActive() { if (!function_exists('is_plugin_active')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } return is_plugin_active('easy-invoice-pro/easy-invoice-pro.php'); } /** * Get the count of invoices created by the user */ public static function getInvoiceCount() { $args = [ 'post_type' => 'easy_invoice', 'post_status' => ['publish', 'draft', 'pending'], 'posts_per_page' => -1, 'fields' => 'ids' ]; $query = new \WP_Query($args); return $query->found_posts; } /** * Check if promotion should be shown */ public static function shouldShowPromotion() { // Don't show if Pro is active if (self::isProActive()) { return false; } // Don't show if permanently hidden if (get_option(self::PERMANENTLY_HIDDEN_OPTION)) { return false; } // Check if user has created enough invoices $invoice_count = self::getInvoiceCount(); if ($invoice_count < self::MIN_INVOICES) { return false; } // Check if banner was dismissed $dismissed = get_option(self::DISMISSED_OPTION); if ($dismissed) { // Check if enough time has passed to show again $last_shown = get_option(self::LAST_SHOWN_OPTION); if ($last_shown) { $days_since_shown = (current_time('timestamp') - strtotime($last_shown)) / DAY_IN_SECONDS; if ($days_since_shown < self::RESHOW_AFTER_DAYS) { return false; } } } return true; } /** * Display the promotion banner if conditions are met */ public static function maybeShowPromotionBanner() { if (!self::shouldShowPromotion()) { return; } // Update last shown timestamp update_option(self::LAST_SHOWN_OPTION, current_time('mysql')); $invoice_count = self::getInvoiceCount(); ?>
You've created invoice(s)! Get 20% OFF on Easy Invoice Pro. Unlock recurring invoices, advanced reporting, multiple payment gateways, and priority support.
🎉 Special Offer: Save 20% on your Pro upgrade with advanced features and priority support!
Unlock powerful features including recurring invoices, advanced reporting, multiple payment gateways, and priority support.
🎉 Special Offer: Save 20% on your Pro upgrade with advanced features and priority support!