publish ) ? (int) $forums->publish : 0; } /** * Get personalized message based on user's usage * * @return array Message data with headline and subheadline */ function frmx_get_personalized_message() { $forums_count = frmx_get_forums_count(); $install_days = frmx_get_install_days(); // Personalized messaging based on usage if ( $forums_count >= 10 ) { return array( 'headline' => sprintf( /* translators: %d: number of forums */ esc_html__( 'You\'ve created %d forums! Ready to supercharge your community?', 'forumax' ), $forums_count ), 'subheadline' => esc_html__( 'Unlock advanced features like Private Forums, User Badges & Role-based Access', 'forumax' ), 'cta' => esc_html__( 'Upgrade & Save 45%', 'forumax' ), ); } elseif ( $install_days >= 30 ) { return array( 'headline' => esc_html__( 'You\'ve been with us for a month! Here\'s a special thank you.', 'forumax' ), 'subheadline' => esc_html__( 'Get 45% off Forumax Pro as our way of saying thanks!', 'forumax' ), 'cta' => esc_html__( 'Claim Your Reward', 'forumax' ), ); } else { return array( 'headline' => esc_html__( 'Unlock the Full Power of Forumax', 'forumax' ), 'subheadline' => esc_html__( 'Join 3,000+ happy customers who upgraded to Pro', 'forumax' ), 'cta' => esc_html__( 'Get 45% Off Now', 'forumax' ), ); } } /** * Get the number of days since plugin installation * * @return int Number of days */ function frmx_get_install_days() { $installed_time = get_option( 'bbpc_installed' ); if ( ! $installed_time ) { return 0; } return (int) floor( ( time() - $installed_time ) / DAY_IN_SECONDS ); } /** * Check if the notice should be shown based on snooze * * @return bool Whether to show the notice */ function frmx_should_show_offer_notice() { $user_id = get_current_user_id(); $snooze_until = get_user_meta( $user_id, 'bbpc_offer_snooze_until', true ); if ( $snooze_until && time() < (int) $snooze_until ) { return false; } return true; } /** * Display the upgrade offer notice */ function forumax_offer_notice() { $is_dev_mode = defined( 'DEVELOPER_MODE' ) && DEVELOPER_MODE; if ( is_user_logged_in() && ! $is_dev_mode ) { $user_id = get_current_user_id(); $dismissed = get_user_meta( $user_id, 'bbpc_offer_dismissed', true ); if ( '1' === $dismissed ) { return; } if ( ! frmx_should_show_offer_notice() ) { return; } } $message = frmx_get_personalized_message(); $coupon_code = 'DASH45'; $pricing_url = 'https://forumax.spider-themes.net/pricing/'; // Pro features to highlight $pro_features = array( array( 'icon' => 'dashicons-chart-bar', 'title' => esc_html__( 'Advanced Analytics', 'forumax' ), 'desc' => esc_html__( 'Track forum activity, user engagement & content performance in real-time', 'forumax' ), ), array( 'icon' => 'dashicons-lock', 'title' => esc_html__( 'Access Control', 'forumax' ), 'desc' => esc_html__( 'Restrict forum access by user roles & membership levels', 'forumax' ), ), array( 'icon' => 'dashicons-groups', 'title' => esc_html__( 'Private Forums', 'forumax' ), 'desc' => esc_html__( 'Create exclusive private forums for specific user groups & teams', 'forumax' ), ), array( 'icon' => 'dashicons-awards', 'title' => esc_html__( 'User Badges', 'forumax' ), 'desc' => esc_html__( 'Reward active members with custom badges & reputation points', 'forumax' ), ), ); ?>
🎉

45%

'User not logged in.' ) ); } $user_id = get_current_user_id(); $action = isset( $_POST['notice_action'] ) ? sanitize_text_field( wp_unslash( $_POST['notice_action'] ) ) : ''; if ( 'dismiss' === $action ) { update_user_meta( $user_id, 'bbpc_offer_dismissed', '1' ); wp_send_json_success( array( 'message' => 'Notice dismissed permanently.' ) ); } elseif ( 'snooze' === $action ) { // Snooze for 3 days $snooze_until = time() + ( 3 * DAY_IN_SECONDS ); update_user_meta( $user_id, 'bbpc_offer_snooze_until', $snooze_until ); wp_send_json_success( array( 'message' => 'Notice snoozed for 3 days.' ) ); } else { wp_send_json_error( array( 'message' => 'Invalid action.' ) ); } wp_die(); } // Keep backward compatibility - remove old action if it exists remove_action( 'wp_ajax_bbpc_dismiss_offer_notice', 'forumax_dismiss_offer_notice' );