base && ( 'popup' === $screen->post_type || 'popup_theme' === $screen->post_type ) ) { return; } // Generate appropriate upsell message. $message = self::generate_upgrade_message(); if ( empty( $message ) ) { return; } wp_enqueue_style( 'pum-admin-general' ); ?>
> */ private static function detect_integrations() { $detection_map = [ // Pro+ integrations (from Pro to Pro+). 'pro_plus' => [ 'ecommerce' => [ 'WooCommerce' => class_exists( 'WooCommerce' ), 'Easy Digital Downloads' => class_exists( 'Easy_Digital_Downloads' ), ], 'lms' => [ 'LifterLMS' => class_exists( 'LifterLMS' ), ], ], // Pro integrations (from Free to Pro). 'pro' => [ 'crm' => [ 'FluentCRM' => defined( 'FLUENTCRM' ), ], ], ]; $integrations = [ 'pro_plus' => [ 'ecommerce' => [], 'lms' => [], ], 'pro' => [ 'crm' => [], ], ]; foreach ( $detection_map as $tier => $categories ) { foreach ( $categories as $category => $plugins ) { foreach ( $plugins as $label => $is_detected ) { if ( $is_detected ) { $integrations[ $tier ][ $category ][] = $label; } } } } // Remove empty categories. foreach ( $integrations as $tier => $categories ) { $integrations[ $tier ] = array_filter( $categories ); } return array_filter( $integrations ); } /** * Generate appropriate upgrade message based on current license and plugin status. * * @return string Upgrade message or empty string if no message should be shown. */ private static function generate_upgrade_message() { $license_service = \PopupMaker\plugin( 'license' ); $license_tier = $license_service->get_license_tier(); $license_status = $license_service->get_license_status(); $pro_is_active = \PopupMaker\plugin()->is_pro_active(); $active_extensions = pum_enabled_extensions(); $has_active_add_ons = ! empty( $active_extensions ); /** * 1. Pro Plus users with valid license see nothing. * 2. Pro users with valid license get targeted integration messaging. * 3. Pro users with invalid license get general upgrade messaging. * 4. Free users or users with invalid license get general upgrade messaging. * 5. Extension users get no message for now. * 6. Extension users without valid license get no message for now. */ // 1. Pro Plus users with valid license see nothing. if ( 'valid' === $license_status && 'pro_plus' === $license_tier ) { return ''; } // 2. Pro users with valid license get targeted integration messaging. if ( 'valid' === $license_status && 'pro' === $license_tier ) { return self::get_pro_integration_message(); } // 3. Pro users with invalid license get general upgrade messaging. if ( $pro_is_active && 'valid' !== $license_status ) { return self::get_free_upgrade_message(); } // 4. Free users get general upgrade messaging. if ( ! $pro_is_active && ! $has_active_add_ons ) { return self::get_free_upgrade_message(); } // 5 & 6. Extension users get no message for now (regardless of license status). if ( $has_active_add_ons ) { return ''; } // Fallback (should not reach here). return ''; } /** * Generate targeted upgrade messages based on detected integrations. * * @param string $user_tier Current user tier ('free', 'pro', 'pro_plus'). * @return string Targeted upgrade message or empty string. */ private static function get_integration_messages( $user_tier ) { $upgrade_link = admin_url( 'edit.php?post_type=popup&page=pum-settings#go-pro' ); $integrations = self::detect_integrations(); $messages = []; // For Pro users, show Pro+ integration opportunities. if ( in_array( $user_tier, [ 'free', 'pro' ], true ) && ! empty( $integrations['pro_plus'] ) ) { foreach ( $integrations['pro_plus'] as $category => $platforms ) { if ( ! empty( $platforms ) ) { $platform_list = self::format_integration_list( $platforms ); switch ( $category ) { case 'ecommerce': $messages[] = sprintf( /* translators: 1: Detected ecommerce platforms, 2: Opening link tag, 3: Closing link tag. */ esc_html__( 'Automate %1$s campaigns with %2$sPopup Maker Pro+ Ecommerce%3$s - unlock cart actions, revenue attribution, and precision targeting.', 'popup-maker' ), $platform_list, '', '' ); break; case 'lms': $messages[] = sprintf( /* translators: 1: Detected LMS platforms, 2: Opening link tag, 3: Closing link tag. */ esc_html__( 'Deliver targeted funnels for %1$s with %2$sPopup Maker Pro+ LMS%3$s - track enrollments, issue rewards, and automate course journeys.', 'popup-maker' ), $platform_list, '', '' ); break; } } } } // For Free users, show Pro integration opportunities. if ( 'free' === $user_tier && ! empty( $integrations['pro'] ) ) { foreach ( $integrations['pro'] as $category => $platforms ) { if ( ! empty( $platforms ) ) { $platform_list = self::format_integration_list( $platforms ); switch ( $category ) { case 'crm': $messages[] = sprintf( /* translators: 1: Detected CRM platforms, 2: Opening link tag, 3: Closing link tag. */ esc_html__( 'Unlock %1$s integration with %2$sPopup Maker Pro%3$s - connect popups to your CRM workflows and automate lead capture.', 'popup-maker' ), $platform_list, '', '' ); break; } } } } // Randomly select one message if available. if ( ! empty( $messages ) ) { $random_index = array_rand( $messages ); return $messages[ $random_index ]; } return ''; } /** * Get upgrade message for Pro users based on detected integrations. * * @return string Targeted upgrade message. */ private static function get_pro_integration_message() { $integration_message = self::get_integration_messages( 'pro' ); if ( ! empty( $integration_message ) ) { return $integration_message; } // Generic Pro+ upgrade message fallback. $upgrade_link = admin_url( 'edit.php?post_type=popup&page=pum-settings#go-pro' ); return sprintf( /* translators: %s - Wraps ending in link to pro settings page. */ esc_html__( 'Level up with %1$sPopup Maker Pro+%2$s - unlock ecommerce automation, revenue attribution, and enhanced targeting.', 'popup-maker' ), '', '' ); } /** * Get upgrade message for free users. * * @return string General upgrade message. */ private static function get_free_upgrade_message() { // Try to get an integration-specific message first. $integration_message = self::get_integration_messages( 'free' ); if ( ! empty( $integration_message ) ) { return $integration_message; } // Generic upgrade message fallback. $upgrade_link = admin_url( 'edit.php?post_type=popup&page=pum-settings#go-pro' ); return sprintf( /* translators: %s - Wraps ending in link to pro settings page. */ esc_html__( 'Unlock advanced features with %1$sPopup Maker Pro & Pro+%2$s - Enhanced targeting, revenue tracking, live analytics, and more.', 'popup-maker' ), '', '' ); } /** * Convert detected platform names into a readable list. * * @param string[] $items List of platform names. * @return string */ private static function format_integration_list( array $items ) { $items = array_values( array_filter( $items ) ); if ( empty( $items ) ) { return ''; } if ( function_exists( 'wp_sprintf_l' ) ) { return wp_sprintf_l( '%l', $items ); } $count = count( $items ); if ( 1 === $count ) { return $items[0]; } $last = array_pop( $items ); return sprintf( /* translators: 1: List of platforms, 2: Last platform. */ esc_html__( '%1$s and %2$s', 'popup-maker' ), implode( esc_html__( ', ', 'popup-maker' ), $items ), $last ); } /** * Adds messages throughout Popup Settings UI * * @param array $tabs The tabs/fields for popup settings. * @return array */ public static function popup_promotional_fields( $tabs = [] ) { if ( ! pum_extension_enabled( 'forced-interaction' ) && ! pum_extension_enabled( 'pro' ) ) { /* translators: %s url to product page. */ $message = sprintf( __( 'Want to disable the close button? Check out Popup Maker Pro!', 'popup-maker' ), 'https://wppopupmaker.com/pricing/?utm_source=plugin-theme-editor&utm_medium=text-link&utm_campaign=upsell&utm_content=close-button-settings' ); // TODO Rewrite this for PM Pro instead of extension. $promotion = [ 'type' => 'html', 'content' => '