| 1 | <?php |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | namespace Automattic\Jetpack\PremiumAnalytics; |
| 9 | |
| 10 | use Automattic\Jetpack\Current_Plan; |
| 11 | use Automattic\Jetpack\PremiumAnalytics\REST\Api_Proxy_Controller; |
| 12 | use Automattic\Jetpack\Stats\Options as Stats_Options; |
| 13 | use Automattic\Jetpack\Status; |
| 14 | use Automattic\Jetpack\Status\Host; |
| 15 | |
| 16 | |
| 17 | if ( ! function_exists( __NAMESPACE__ . '\\ensure_widget_registry_ready' ) ) { |
| 18 | require_once __DIR__ . '/widget-modules.php'; |
| 19 | } |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | |
| 25 | |
| 26 | const STATS_PLAN_TIER_FILTER = 'jetpack_premium_analytics_stats_plan_tier'; |
| 27 | |
| 28 | const STATS_TIER_COMMERCIAL = 'commercial'; |
| 29 | const STATS_TIER_LEGACY_FREE = 'legacy-free'; |
| 30 | const STATS_TIER_PAID = 'paid'; |
| 31 | const STATS_TIER_LEGACY_BASIC = 'legacy-basic'; |
| 32 | const STATS_TIER_FREE = 'free'; |
| 33 | const STATS_TIER_JETPACK_FREE = 'jetpack-free'; |
| 34 | const STATS_TIER_UNKNOWN = 'unknown'; |
| 35 | |
| 36 | const STATS_TIERS = array( STATS_TIER_COMMERCIAL, STATS_TIER_LEGACY_FREE, STATS_TIER_PAID, STATS_TIER_LEGACY_BASIC, STATS_TIER_FREE, STATS_TIER_JETPACK_FREE, STATS_TIER_UNKNOWN ); |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | const JETPACK_STATS_COMMERCIAL_PRODUCTS = array( 'jetpack_stats_monthly', 'jetpack_stats_yearly', 'jetpack_stats_bi_yearly' ); |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | const JETPACK_STATS_COMMERCIAL_PLAN_PREFIXES = array( 'jetpack_business', 'jetpack_complete', 'jetpack_growth' ); |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | function get_stats_plan_tier() { |
| 56 | $host = new Host(); |
| 57 | |
| 58 | if ( $host->is_wpcom_platform() ) { |
| 59 | $tier = get_wpcom_stats_plan_tier( $host->is_woa_site() ); |
| 60 | } elseif ( $host->is_vip_site() ) { |
| 61 | $tier = STATS_TIER_COMMERCIAL; |
| 62 | } else { |
| 63 | $tier = get_jetpack_stats_plan_tier(); |
| 64 | } |
| 65 | |
| 66 | |
| 67 | |
| 68 | |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | $filtered = apply_filters( STATS_PLAN_TIER_FILTER, $tier ); |
| 75 | |
| 76 | |
| 77 | if ( ! in_array( $filtered, STATS_TIERS, true ) ) { |
| 78 | |
| 79 | _doing_it_wrong( __FUNCTION__, esc_html( sprintf( __( 'The %s filter must return one of the STATS_TIER_* values.', 'jetpack-premium-analytics-pkg' ), STATS_PLAN_TIER_FILTER ) ), 'jetpack-premium-analytics-$$next-version$$' ); |
| 80 | return $tier; |
| 81 | } |
| 82 | |
| 83 | return $filtered; |
| 84 | } |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | function get_wpcom_stats_plan_tier( $is_atomic ) { |
| 95 | if ( ! function_exists( 'wpcom_site_has_feature' ) ) { |
| 96 | return STATS_TIER_UNKNOWN; |
| 97 | } |
| 98 | |
| 99 | |
| 100 | if ( $is_atomic && function_exists( 'wpcom_get_site_purchases' ) && ! \wpcom_get_site_purchases() ) { |
| 101 | return STATS_TIER_UNKNOWN; |
| 102 | } |
| 103 | |
| 104 | |
| 105 | $tiers = array( |
| 106 | 'stats-commercial' => STATS_TIER_COMMERCIAL, |
| 107 | 'stats-free' => STATS_TIER_LEGACY_FREE, |
| 108 | 'stats-paid' => STATS_TIER_PAID, |
| 109 | 'stats-basic' => STATS_TIER_LEGACY_BASIC, |
| 110 | ); |
| 111 | foreach ( $tiers as $feature => $tier ) { |
| 112 | if ( \wpcom_site_has_feature( $feature ) ) { |
| 113 | return $tier; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | return STATS_TIER_FREE; |
| 118 | } |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | function get_jetpack_stats_plan_tier() { |
| 128 | if ( ! has_cached_jetpack_plan() ) { |
| 129 | return STATS_TIER_UNKNOWN; |
| 130 | } |
| 131 | |
| 132 | return has_jetpack_stats_commercial_purchase() ? STATS_TIER_COMMERCIAL : STATS_TIER_JETPACK_FREE; |
| 133 | } |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | function has_cached_jetpack_plan() { |
| 143 | $plan = get_option( Current_Plan::PLAN_OPTION ); |
| 144 | |
| 145 | return is_array( $plan ) && is_array( $plan['features']['active'] ?? null ) && $plan['features']['active']; |
| 146 | } |
| 147 | |
| 148 | |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | |
| 154 | |
| 155 | function has_jetpack_stats_commercial_purchase() { |
| 156 | $plan = get_option( Current_Plan::PLAN_OPTION ); |
| 157 | $products = get_option( Current_Plan::SITE_PRODUCTS_OPTION, array() ); |
| 158 | $products = is_array( $products ) ? $products : array(); |
| 159 | |
| 160 | $slugs = array_column( $products, 'product_slug' ); |
| 161 | if ( isset( $plan['product_slug'] ) ) { |
| 162 | $slugs[] = $plan['product_slug']; |
| 163 | } |
| 164 | |
| 165 | foreach ( $slugs as $slug ) { |
| 166 | if ( in_array( $slug, JETPACK_STATS_COMMERCIAL_PRODUCTS, true ) ) { |
| 167 | return true; |
| 168 | } |
| 169 | foreach ( JETPACK_STATS_COMMERCIAL_PLAN_PREFIXES as $prefix ) { |
| 170 | if ( 0 === strpos( $slug, $prefix ) ) { |
| 171 | return true; |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | return in_array( 'stats-commercial', $plan['features']['active'] ?? array(), true ); |
| 177 | } |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | function has_jetpack_stats_product() { |
| 187 | $plan = get_option( Current_Plan::PLAN_OPTION ); |
| 188 | $products = get_option( Current_Plan::SITE_PRODUCTS_OPTION, array() ); |
| 189 | $products = is_array( $products ) ? $products : array(); |
| 190 | |
| 191 | $slugs = array_column( $products, 'product_slug' ); |
| 192 | if ( isset( $plan['product_slug'] ) ) { |
| 193 | $slugs[] = $plan['product_slug']; |
| 194 | } |
| 195 | |
| 196 | foreach ( $slugs as $slug ) { |
| 197 | if ( is_string( $slug ) && 0 === strpos( $slug, 'jetpack_stats' ) ) { |
| 198 | return true; |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | return false; |
| 203 | } |
| 204 | |
| 205 | |
| 206 | |
| 207 | |
| 208 | |
| 209 | const STATS_UPGRADE_BANNER_TIERS = array( STATS_TIER_JETPACK_FREE, STATS_TIER_LEGACY_FREE, STATS_TIER_LEGACY_BASIC ); |
| 210 | |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | function offers_free_site_upgrade( $tier ) { |
| 220 | |
| 221 | if ( ! in_array( $tier, STATS_UPGRADE_BANNER_TIERS, true ) || ( new Host() )->is_wpcom_simple() ) { |
| 222 | return false; |
| 223 | } |
| 224 | |
| 225 | $first_visit = get_dashboard_first_visit(); |
| 226 | |
| 227 | return null !== $first_visit && time() - $first_visit >= 30 * DAY_IN_SECONDS; |
| 228 | } |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | const STATS_COMMERCIAL_FEATURES = array( 'authors', 'search-terms', 'videos', 'utm', 'devices', 'regions-cities' ); |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | const STATS_ADVANCED_FEATURES = array( 'utm', 'devices', 'regions-cities' ); |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | function get_locked_stats_features( $tier ) { |
| 249 | switch ( $tier ) { |
| 250 | case STATS_TIER_LEGACY_FREE: |
| 251 | case STATS_TIER_JETPACK_FREE: |
| 252 | return STATS_ADVANCED_FEATURES; |
| 253 | case STATS_TIER_PAID: |
| 254 | return STATS_COMMERCIAL_FEATURES; |
| 255 | case STATS_TIER_LEGACY_BASIC: |
| 256 | return array_merge( STATS_COMMERCIAL_FEATURES, array( 'referrers', 'clicks', 'csv', 'intervals', 'long-date-presets' ) ); |
| 257 | case STATS_TIER_FREE: |
| 258 | return array_merge( |
| 259 | STATS_COMMERCIAL_FEATURES, |
| 260 | array( 'top-posts', 'referrers', 'countries', 'clicks', 'file-downloads', 'insights', 'tags', 'csv', 'intervals', 'long-date-presets', 'recent-7-days' ) |
| 261 | ); |
| 262 | default: |
| 263 | return array(); |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | |
| 268 | |
| 269 | |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | |
| 275 | function get_stats_feature_copy( $feature ) { |
| 276 | $traffic_support = 'https://jetpack.com/support/jetpack-stats/traffic-dashboard/'; |
| 277 | |
| 278 | switch ( $feature ) { |
| 279 | case 'top-posts': |
| 280 | return array( |
| 281 | 'description' => __( 'Discover your <link>post and pages</link> traffic in detail and learn what content resonates the most.', 'jetpack-premium-analytics-pkg' ), |
| 282 | 'support_url' => $traffic_support . '#analyzing-popular-posts-pages-and-archives', |
| 283 | ); |
| 284 | case 'referrers': |
| 285 | return array( |
| 286 | 'description' => __( 'Find out where your <link>visitors come from</link> to optimize your content strategy.', 'jetpack-premium-analytics-pkg' ), |
| 287 | 'support_url' => $traffic_support . '#referrers', |
| 288 | ); |
| 289 | case 'countries': |
| 290 | return array( |
| 291 | 'description' => __( 'Discover where your <link>visitors are located</link> and identify where your traffic is coming from.', 'jetpack-premium-analytics-pkg' ), |
| 292 | 'support_url' => $traffic_support . '#views-by-locations', |
| 293 | ); |
| 294 | case 'regions-cities': |
| 295 | return array( |
| 296 | 'description' => __( 'Access to <link>region and city stats</link> for more accurate analysis.', 'jetpack-premium-analytics-pkg' ), |
| 297 | 'support_url' => $traffic_support . '#regions-and-cities', |
| 298 | ); |
| 299 | case 'clicks': |
| 300 | return array( |
| 301 | 'description' => __( 'Learn what <link>external links</link> your visitors click on your site to reveal their areas of interest.', 'jetpack-premium-analytics-pkg' ), |
| 302 | 'support_url' => $traffic_support . '#clicks', |
| 303 | ); |
| 304 | case 'file-downloads': |
| 305 | return array( |
| 306 | 'description' => __( 'Discover the most <link>downloaded files</link> by your visitors.', 'jetpack-premium-analytics-pkg' ), |
| 307 | 'support_url' => 'https://wordpress.com/support/stats/analyze-content-performance/#track-file-downloads', |
| 308 | ); |
| 309 | case 'authors': |
| 310 | return array( |
| 311 | 'description' => __( 'Identify your audience’s <link>favorite writers</link> and perspectives.', 'jetpack-premium-analytics-pkg' ), |
| 312 | 'support_url' => $traffic_support . '#authors', |
| 313 | ); |
| 314 | case 'search-terms': |
| 315 | return array( |
| 316 | 'description' => __( 'Discover the <link>terms and phrases</link> your visitors use to find your site.', 'jetpack-premium-analytics-pkg' ), |
| 317 | 'support_url' => $traffic_support . '#search-terms', |
| 318 | ); |
| 319 | case 'videos': |
| 320 | return array( |
| 321 | 'description' => __( 'Discover your <link>most popular videos</link> and find out how they performed.', 'jetpack-premium-analytics-pkg' ), |
| 322 | 'support_url' => 'https://jetpack.com/support/jetpack-videopress/add-video-block-editor/video-stats/', |
| 323 | ); |
| 324 | case 'utm': |
| 325 | return array( |
| 326 | 'description' => __( 'Generate UTM parameters and track your <link>campaign performance data</link>.', 'jetpack-premium-analytics-pkg' ), |
| 327 | 'support_url' => $traffic_support . '#harnessing-utm-stats-for-precision-tracking', |
| 328 | ); |
| 329 | case 'devices': |
| 330 | return array( |
| 331 | 'description' => __( 'See which <link>devices, browsers and OS</link> your visitors are using.', 'jetpack-premium-analytics-pkg' ), |
| 332 | 'support_url' => $traffic_support . '#devices-stats', |
| 333 | ); |
| 334 | case 'tags': |
| 335 | return array( |
| 336 | 'description' => __( 'Track the most viewed <link>tags & categories</link>.', 'jetpack-premium-analytics-pkg' ), |
| 337 | 'support_url' => 'https://wordpress.com/support/stats/learn-insights-about-your-website/#all-time-insights', |
| 338 | ); |
| 339 | default: |
| 340 | return array( |
| 341 | 'description' => __( 'Upgrade your plan to unlock Jetpack Stats.', 'jetpack-premium-analytics-pkg' ), |
| 342 | 'support_url' => '', |
| 343 | ); |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | |
| 348 | |
| 349 | |
| 350 | const WPCOM_SUPPORT_LOCALES = array( 'ar', 'de', 'es', 'fr', 'he', 'id', 'it', 'ja', 'ko', 'nl', 'pt-br', 'ru', 'sv', 'tr', 'zh-cn', 'zh-tw' ); |
| 351 | |
| 352 | |
| 353 | |
| 354 | |
| 355 | |
| 356 | |
| 357 | |
| 358 | |
| 359 | |
| 360 | |
| 361 | |
| 362 | function localize_stats_support_url( $url ) { |
| 363 | $prefix = 'https://wordpress.com/support/'; |
| 364 | if ( ! str_starts_with( $url, $prefix ) ) { |
| 365 | return $url; |
| 366 | } |
| 367 | |
| 368 | $locale = strtolower( str_replace( '_', '-', get_user_locale() ) ); |
| 369 | if ( ! in_array( $locale, WPCOM_SUPPORT_LOCALES, true ) ) { |
| 370 | $locale = strtok( $locale, '-' ); |
| 371 | } |
| 372 | if ( ! in_array( $locale, WPCOM_SUPPORT_LOCALES, true ) ) { |
| 373 | return $url; |
| 374 | } |
| 375 | |
| 376 | return 'https://wordpress.com/' . $locale . '/support/' . substr( $url, strlen( $prefix ) ); |
| 377 | } |
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | |
| 383 | |
| 384 | |
| 385 | |
| 386 | |
| 387 | |
| 388 | |
| 389 | function get_stats_upgrade_url( $feature, $tier, $from = 'jetpack-premium-analytics' ) { |
| 390 | $return_path = 'admin.php?page=' . Analytics::MENU_PAGE_SLUG; |
| 391 | |
| 392 | if ( STATS_TIER_JETPACK_FREE === $tier ) { |
| 393 | |
| 394 | $stats_page = function_exists( 'menu_page_url' ) ? menu_page_url( 'stats', false ) : ''; |
| 395 | if ( ! $stats_page || ! Stats_Options::get_option( 'enable_odyssey_stats' ) ) { |
| 396 | return ''; |
| 397 | } |
| 398 | |
| 399 | $query = http_build_query( |
| 400 | array( |
| 401 | 'from' => $from, |
| 402 | 'productType' => 'commercial', |
| 403 | 'redirect_uri' => $return_path, |
| 404 | ), |
| 405 | '', |
| 406 | '&', |
| 407 | PHP_QUERY_RFC3986 |
| 408 | ); |
| 409 | |
| 410 | return $stats_page . '#!/stats/purchase/' . (int) \Jetpack_Options::get_option( 'id' ) . '?' . $query; |
| 411 | } |
| 412 | |
| 413 | $plan = in_array( $feature, STATS_COMMERCIAL_FEATURES, true ) ? 'premium' : 'personal'; |
| 414 | $site_slug = ( new Status() )->get_site_suffix(); |
| 415 | |
| 416 | return 'https://wordpress.com/checkout/' . rawurlencode( $site_slug ) . '/' . $plan . '?redirect_to=' . rawurlencode( admin_url( $return_path ) ); |
| 417 | } |
| 418 | |
| 419 | |
| 420 | |
| 421 | |
| 422 | |
| 423 | |
| 424 | |
| 425 | |
| 426 | function get_stats_plan_gates() { |
| 427 | $tier = get_stats_plan_tier(); |
| 428 | $features = get_locked_stats_features( $tier ); |
| 429 | |
| 430 | $locked_features = array(); |
| 431 | foreach ( $features as $feature ) { |
| 432 | $copy = get_stats_feature_copy( $feature ); |
| 433 | $copy['support_url'] = localize_stats_support_url( $copy['support_url'] ); |
| 434 | $locked_features[ $feature ] = $copy + array( 'upgrade_url' => get_stats_upgrade_url( $feature, $tier ) ); |
| 435 | } |
| 436 | |
| 437 | $locked_widget_types = array(); |
| 438 | if ( $locked_features ) { |
| 439 | ensure_widget_registry_ready(); |
| 440 | |
| 441 | foreach ( get_available_widget_types() as $name => $widget_type ) { |
| 442 | if ( isset( $widget_type->plan_feature ) && isset( $locked_features[ $widget_type->plan_feature ] ) ) { |
| 443 | $locked_widget_types[ $name ] = $widget_type->plan_feature; |
| 444 | } |
| 445 | } |
| 446 | } |
| 447 | |
| 448 | return array( |
| 449 | 'tier' => $tier, |
| 450 | 'locked_features' => $locked_features, |
| 451 | 'locked_widget_types' => $locked_widget_types, |
| 452 | ); |
| 453 | } |
| 454 | |
| 455 | |
| 456 | |
| 457 | |
| 458 | |
| 459 | |
| 460 | |
| 461 | |
| 462 | function configure_stats_plan_gates() { |
| 463 | add_filter( 'jetpack_admin_js_script_data', __NAMESPACE__ . '\\inject_stats_plan_gates_script_data', 20 ); |
| 464 | add_action( 'admin_init', __NAMESPACE__ . '\\maybe_refresh_jetpack_plan' ); |
| 465 | add_action( 'admin_init', __NAMESPACE__ . '\\maybe_invalidate_stats_caches' ); |
| 466 | } |
| 467 | |
| 468 | |
| 469 | |
| 470 | |
| 471 | |
| 472 | |
| 473 | |
| 474 | |
| 475 | |
| 476 | function inject_stats_plan_gates_script_data( array $data ): array { |
| 477 | |
| 478 | if ( ! Analytics::is_dashboard_request() ) { |
| 479 | return $data; |
| 480 | } |
| 481 | |
| 482 | if ( ! isset( $data['premium_analytics'] ) || ! is_array( $data['premium_analytics'] ) ) { |
| 483 | $data['premium_analytics'] = array(); |
| 484 | } |
| 485 | |
| 486 | $gates = get_stats_plan_gates(); |
| 487 | |
| 488 | |
| 489 | $data['premium_analytics']['plan_gates'] = array( |
| 490 | 'tier' => $gates['tier'], |
| 491 | 'locked_features' => (object) $gates['locked_features'], |
| 492 | 'locked_widget_types' => (object) $gates['locked_widget_types'], |
| 493 | 'has_stats_product' => has_jetpack_stats_product(), |
| 494 | |
| 495 | 'free_site_upgrade' => offers_free_site_upgrade( $gates['tier'] ) |
| 496 | ? array( 'upgrade_url' => get_stats_upgrade_url( 'utm', $gates['tier'], 'jetpack-premium-analytics-free-site-upgrade-notice' ) ) |
| 497 | : null, |
| 498 | ); |
| 499 | |
| 500 | return $data; |
| 501 | } |
| 502 | |
| 503 | |
| 504 | |
| 505 | |
| 506 | const EMPTY_PLAN_REFRESH_TRANSIENT = 'jetpack_premium_analytics_empty_plan_refresh'; |
| 507 | |
| 508 | |
| 509 | |
| 510 | |
| 511 | const PURCHASE_PLAN_REFRESH_TRANSIENT = 'jetpack_premium_analytics_purchase_plan_refresh'; |
| 512 | |
| 513 | |
| 514 | |
| 515 | |
| 516 | const PURCHASE_CACHE_INVALIDATION_TRANSIENT = 'jetpack_premium_analytics_purchase_cache_invalidation'; |
| 517 | |
| 518 | |
| 519 | |
| 520 | |
| 521 | |
| 522 | |
| 523 | |
| 524 | |
| 525 | function maybe_invalidate_stats_caches() { |
| 526 | |
| 527 | if ( ! Analytics::is_dashboard_request() || '' === get_stats_purchase_success_type() || ( new Host() )->is_wpcom_simple() ) { |
| 528 | return; |
| 529 | } |
| 530 | |
| 531 | |
| 532 | if ( get_transient( PURCHASE_CACHE_INVALIDATION_TRANSIENT ) ) { |
| 533 | return; |
| 534 | } |
| 535 | set_transient( PURCHASE_CACHE_INVALIDATION_TRANSIENT, 1, MINUTE_IN_SECONDS ); |
| 536 | |
| 537 | Api_Proxy_Controller::invalidate_cache(); |
| 538 | delete_transient( Notices::NOTICES_CACHE_KEY ); |
| 539 | } |
| 540 | |
| 541 | |
| 542 | |
| 543 | |
| 544 | |
| 545 | |
| 546 | |
| 547 | |
| 548 | |
| 549 | |
| 550 | function maybe_refresh_jetpack_plan() { |
| 551 | if ( ! Analytics::is_dashboard_request() || ( new Host() )->is_wpcom_platform() ) { |
| 552 | return; |
| 553 | } |
| 554 | |
| 555 | if ( '' !== get_stats_purchase_success_type() ) { |
| 556 | $transient = PURCHASE_PLAN_REFRESH_TRANSIENT; |
| 557 | $ttl = MINUTE_IN_SECONDS; |
| 558 | } elseif ( ! has_cached_jetpack_plan() ) { |
| 559 | $transient = EMPTY_PLAN_REFRESH_TRANSIENT; |
| 560 | $ttl = 15 * MINUTE_IN_SECONDS; |
| 561 | } else { |
| 562 | return; |
| 563 | } |
| 564 | |
| 565 | if ( get_transient( $transient ) ) { |
| 566 | return; |
| 567 | } |
| 568 | set_transient( $transient, 1, $ttl ); |
| 569 | |
| 570 | Current_Plan::refresh_from_wpcom( array( 'timeout' => 5 ) ); |
| 571 | } |