| @@ -659,9 +659,18 @@ | ||
| 659 | 659 | // If user is logged in then return the customer by user id. |
| 660 | 660 | // This `get_current_user_id` function is WP function and |
| 661 | 661 | // it returns user id if user is logged in. |
| 662 | 662 | if (get_current_user_id()) { //if user is logged in |
| 663 | - return Customer::where('user_id', get_current_user_id())->first(); | |
| 663 | + // Ordered for the same reason getCurrentPerson() and | |
| 664 | + // Customer::getCustomerFromData() are: the user_id column carries a | |
| 665 | + // plain index, not a unique one, so one account can have more than | |
| 666 | + // one customer record. Without an order the record that wins is | |
| 667 | + // whatever the storage engine returns first, and this helper could | |
| 668 | + // disagree with the other two about which record a request belongs | |
| 669 | + // to. | |
| 670 | + return Customer::where('user_id', get_current_user_id()) | |
| 671 | + ->orderBy('id', 'ASC') | |
| 672 | + ->first(); | |
| 664 | 673 | } |
| 665 | 674 | } |
| 666 | 675 | |
| 667 | 676 | public static function getCurrentPerson() |
| @@ -1628,26 +1637,43 @@ | ||
| 1628 | 1637 | } |
| 1629 | 1638 | |
| 1630 | 1639 | /** |
| 1631 | 1640 | * Build a fluentsupport.com upgrade/pricing link tagged with UTM params |
| 1632 | - * per the standard "Upgrade to Pro" link spec (utm_source is always | |
| 1633 | - * "fluent-support"; utm_medium reflects free vs pro install). | |
| 1641 | + * per the standard "Upgrade to Pro" link spec: | |
| 1642 | + * utm_source = fluent-support (fixed vocabulary, never the wp.org slug) | |
| 1643 | + * utm_medium = free_plugin | pro_plugin (acquisition vs cross-sell) | |
| 1644 | + * utm_campaign= upgrade_pro (override via $args['campaign']) | |
| 1645 | + * utm_content = the exact placement, e.g. feature_lock_dropbox, upgrade_page | |
| 1646 | + * utm_term = plugin version that generated the link | |
| 1647 | + * | |
| 1648 | + * This is the single source of truth for upgrade URLs. The admin SPA does | |
| 1649 | + * not rebuild these client-side; it re-points utm_content on the URL this | |
| 1650 | + * method localizes into appVars (see the $upgradeUrl mixin in start.js). | |
| 1651 | + * | |
| 1652 | + * @param string $content The utm_content placement. | |
| 1653 | + * @param array $args Optional: 'campaign', 'base_url', plus any utm_* override. | |
| 1654 | + * @return string | |
| 1634 | 1655 | */ |
| 1635 | - public static function getUpgradeUrl($content, $args = []) | |
| 1656 | + public static function getUpgradeUrl($content = 'upgrade_page', $args = []) | |
| 1636 | 1657 | { |
| 1637 | 1658 | $args = wp_parse_args($args, [ |
| 1638 | 1659 | 'campaign' => 'upgrade_pro', |
| 1639 | - 'base_url' => 'https://fluentsupport.com/pricing' | |
| 1660 | + 'base_url' => apply_filters('fluent_support/pro_upgrade_base_url', 'https://fluentsupport.com/pricing'), | |
| 1640 | 1661 | ]); |
| 1641 | 1662 | |
| 1642 | 1663 | $params = [ |
| 1643 | 1664 | 'utm_source' => 'fluent-support', |
| 1644 | - 'utm_medium' => defined('FLUENTSUPPORTPRO') ? 'pro_plugin' : 'free_plugin', | |
| 1665 | + // Same constant Menu.php uses for appVars.has_pro — keep the two in sync. | |
| 1666 | + 'utm_medium' => defined('FLUENTSUPPORTPRO_PLUGIN_VERSION') ? 'pro_plugin' : 'free_plugin', | |
| 1645 | 1667 | 'utm_campaign' => $args['campaign'], |
| 1646 | 1668 | 'utm_content' => $content, |
| 1647 | 1669 | 'utm_term' => FLUENT_SUPPORT_VERSION, |
| 1648 | - 'utm_id' => '' | |
| 1649 | 1670 | ]; |
| 1671 | + | |
| 1672 | + // Drop any blank params (e.g. a missing version) so they never hit the URL. | |
| 1673 | + $params = array_filter($params, function ($value) { | |
| 1674 | + return $value !== '' && $value !== null; | |
| 1675 | + }); | |
| 1650 | 1676 | |
| 1651 | 1677 | return add_query_arg($params, $args['base_url']); |
| 1652 | 1678 | } |
| 1653 | 1679 | |