@@ -301,15 +301,27 @@ public function register_menu_page()
301301 [$ this , 'render_admin_page ' ]
302302 );
303303
304- // Add Token Dashboard submenu item
305- add_submenu_page (
306- 'options-general.php ' ,
307- __ ('Token Dashboard ' , 'jwt-auth ' ),
308- __ (' ↳ Token Details 👑 ' , 'jwt-auth ' ),
309- 'manage_options ' ,
310- 'jwt_token_dashboard ' ,
311- [$ this , 'render_token_dashboard_page ' ]
312- );
304+ if (jwt_auth_should_show_upsell ()) {
305+ add_submenu_page (
306+ 'options-general.php ' ,
307+ __ ('Token Dashboard ' , 'jwt-auth ' ),
308+ __ (' ↳ Token Details 👑 ' , 'jwt-auth ' ),
309+ 'manage_options ' ,
310+ 'jwt_token_dashboard ' ,
311+ [$ this , 'render_token_dashboard_page ' ]
312+ );
313+ }
314+ }
315+
316+ /**
317+ * Ensure install date tracking exists.
318+ *
319+ * @since 1.5.0
320+ * @return void
321+ */
322+ public function track_install_date ()
323+ {
324+ jwt_auth_track_install_date ();
313325 }
314326
315327 /**
@@ -616,12 +628,14 @@ function ($tag, $handle) {
616628 );
617629 }
618630
631+ $ upsell_metrics = jwt_auth_get_upsell_metrics ();
632+
619633 // Provide WordPress API configuration to React app
620634 if ($ is_dev_mode ) {
621635 // For dev mode, we need to add the config manually since we're not using wp_enqueue_script
622636 add_action (
623637 'admin_footer ' ,
624- function () {
638+ function () use ( $ upsell_metrics ) {
625639 $ config = [
626640 'apiUrl ' => rest_url ('jwt-auth/v1/admin/settings ' ),
627641 'nonce ' => wp_create_nonce ('wp_rest ' ),
@@ -635,6 +649,11 @@ function () {
635649 'pluginCount ' => count (get_option ('active_plugins ' , [])),
636650 'signingAlgorithm ' => 'HS256 ' ,
637651 ],
652+ 'upsell ' => [
653+ 'shouldShowUpsell ' => (bool ) $ upsell_metrics ['shouldShowUpsell ' ],
654+ 'daysActive ' => (int ) $ upsell_metrics ['daysActive ' ],
655+ 'tokensCreated ' => (int ) $ upsell_metrics ['tokensCreated ' ],
656+ ],
638657 ];
639658 echo '<script>window.jwtAuthConfig = ' .wp_json_encode ($ config ).';</script> ' ;
640659 },
@@ -649,14 +668,19 @@ function () {
649668 'nonce ' => wp_create_nonce ('wp_rest ' ),
650669 'siteUrl ' => get_bloginfo ('url ' ),
651670 'settings ' => get_option ('jwt_auth_options ' , ['share_data ' => false ]),
652- 'siteProfile ' => [
653- 'phpVersion ' => PHP_VERSION ,
654- 'wordpressVersion ' => get_bloginfo ('version ' ),
655- 'isProCompatible ' => version_compare (PHP_VERSION , '7.4 ' , '>= ' ),
656- 'isWooCommerceDetected ' => class_exists ('WooCommerce ' ),
657- 'pluginCount ' => count (get_option ('active_plugins ' , [])),
658- 'signingAlgorithm ' => 'HS256 ' ,
659- ],
671+ 'siteProfile ' => [
672+ 'phpVersion ' => PHP_VERSION ,
673+ 'wordpressVersion ' => get_bloginfo ('version ' ),
674+ 'isProCompatible ' => version_compare (PHP_VERSION , '7.4 ' , '>= ' ),
675+ 'isWooCommerceDetected ' => class_exists ('WooCommerce ' ),
676+ 'pluginCount ' => count (get_option ('active_plugins ' , [])),
677+ 'signingAlgorithm ' => 'HS256 ' ,
678+ ],
679+ 'upsell ' => [
680+ 'shouldShowUpsell ' => (bool ) $ upsell_metrics ['shouldShowUpsell ' ],
681+ 'daysActive ' => (int ) $ upsell_metrics ['daysActive ' ],
682+ 'tokensCreated ' => (int ) $ upsell_metrics ['tokensCreated ' ],
683+ ],
660684 ]
661685 );
662686 }
@@ -810,28 +834,7 @@ public function render_token_dashboard_page()
810834 */
811835 public function add_action_link (array $ links , string $ file ): array
812836 {
813-
814- if ($ file === 'jwt-authentication-for-wp-rest-api/jwt-auth.php ' ) {
815- // Fixed CTA for high-traffic plugin list (no rotation)
816- $ selected_variation = [
817- 'text ' => '<b>Add Token Dashboard</b> ' ,
818- 'utm_content ' => 'token-dashboard-primary ' ,
819- ];
820-
821- $ base_pro_url = 'https://jwtauth.pro/upgrade ' ;
822- $ utm_params = [
823- 'utm_source ' => 'plugin-list ' ,
824- 'utm_medium ' => 'action-link ' ,
825- 'utm_campaign ' => 'feature-highlight ' ,
826- 'utm_content ' => $ selected_variation ['utm_content ' ],
827- ];
828-
829- $ pro_link_url = (string ) add_query_arg ($ utm_params , $ base_pro_url );
830- $ pro_link_style = 'style="color: #00a32a; font-weight: 700; text-decoration: none;" onmouseover="this.style.color= \'#008a20 \';" onmouseout="this.style.color= \'#00a32a \';" ' ;
831-
832- $ pro_link_text = $ selected_variation ['text ' ];
833- $ links [] = '<a href=" ' .esc_url ($ pro_link_url ).'" target="_blank" ' .$ pro_link_style .' rel="noopener noreferrer"> ' .$ pro_link_text .'</a> ' ;
834- }
837+ unset($ file );
835838
836839 return $ links ;
837840 }
@@ -1085,6 +1088,7 @@ public function get_dashboard_data($request)
10851088 }
10861089
10871090 $ dismissal_data = $ dismissal_response ->get_data ();
1091+ $ upsell_metrics = jwt_auth_get_upsell_metrics ();
10881092
10891093 // Return consolidated data
10901094 return new WP_REST_Response (
@@ -1093,6 +1097,11 @@ public function get_dashboard_data($request)
10931097 'jwtStatus ' => $ status_data ,
10941098 'surveyStatus ' => $ survey_status_data ,
10951099 'surveyDismissal ' => $ dismissal_data ,
1100+ 'upsell ' => [
1101+ 'shouldShowUpsell ' => (bool ) $ upsell_metrics ['shouldShowUpsell ' ],
1102+ 'daysActive ' => (int ) $ upsell_metrics ['daysActive ' ],
1103+ 'tokensCreated ' => (int ) $ upsell_metrics ['tokensCreated ' ],
1104+ ],
10961105 ],
10971106 200
10981107 );
0 commit comments