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(); ?>
⚡ Limited Time

🚀 Upgrade to Easy Invoice Pro - Save 20%!

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!

⚡ Save 20% - Upgrade to Pro Maybe later
= 2) { update_option(self::PERMANENTLY_HIDDEN_OPTION, true); } wp_send_json_success(); } /** * Add "Upgrade to Pro" action in plugin row */ public static function addPluginRowAction($links) { // Don't show if Pro is active if (self::isProActive()) { return $links; } $upgrade_link = sprintf( '%s', esc_url(self::PRO_PRICING_URL), __('Upgrade to Pro', 'easy-invoice') ); // Add to the beginning of the links array array_unshift($links, $upgrade_link); return $links; } /** * Add "Upgrade to Pro" menu item to main admin menu */ public static function addUpgradeToProMenu() { // Only show if Pro is not active if (self::isProActive()) { return; } global $submenu; // Add the submenu item directly to the submenu array $submenu['easy-invoice'][] = array( __('Upgrade to Pro', 'easy-invoice'), 'manage_options', self::PRO_PRICING_URL, __('Upgrade to Pro', 'easy-invoice'), 999 ); // Add inline style to the submenu add_action('admin_head', function() { ?>

🚀 Upgrade to Easy Invoice Pro

Get 20% OFF Your Pro Upgrade!

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!

⚡ Save 20% - Upgrade to Pro Now

Why Upgrade to Pro?