the lowest plan that includes it. Move a feature to another tier here. */ function azlinkpro_feature_plans() { return array( 'custom_comparison' => 'starter', 'spreadsheet' => 'starter', 'showcase' => 'starter', 'pros_cons' => 'starter', 'link_audit' => 'starter', 'click_report' => 'starter', 'click_export' => 'professional', 'ai_pros_cons' => 'professional', 'ai_review_builder' => 'agency', ); } function azlinkpro_plan_title($plan) { $titles = array('starter' => 'Starter', 'professional' => 'Professional', 'agency' => 'Agency'); return $titles[$plan] ?? ''; } /** The plans that include a feature, for messages: "Starter, Professional and Agency". */ function azlinkpro_feature_plans_label($feature) { $order = array('starter', 'professional', 'agency'); $plans = azlinkpro_feature_plans(); if (!isset($plans[$feature])) { return 'every plan'; } $names = array_map('azlinkpro_plan_title', array_slice($order, (int) array_search($plans[$feature], $order, true))); $last = array_pop($names); return $names ? implode(', ', $names) . ' and ' . $last : $last; } /** True when this site may use a feature: free ones always, paid ones on that plan, a higher one, or its trial. */ function azlinkpro_can($feature) { $plans = azlinkpro_feature_plans(); if (!isset($plans[$feature])) { return true; } if (!function_exists('azlinkpro_fs')) { return false; } $fs = azlinkpro_fs(); // is_premium() is false in the free build Freemius generates. return $fs->is_premium() && $fs->can_use_premium_code() && $fs->is_plan_or_trial($plans[$feature]); } /** Freemius's in-dashboard pricing and checkout page. */ function azlinkpro_upgrade_url() { return function_exists('azlinkpro_fs') ? azlinkpro_fs()->get_upgrade_url() : 'https://azlinkpro.com/pricing/'; } /** "Showcases are included in the Starter, Professional and Agency plans." */ function azlinkpro_upgrade_message($feature, $what) { $plans = azlinkpro_feature_plans_label($feature); return sprintf('%s %s included in the %s %s.', $what, preg_match('/s$/', $what) ? 'are' : 'is', $plans, strpos($plans, ' and ') === false ? 'plan' : 'plans'); } /** "Professional", "Starter (trial)" or "Free". */ function azlinkpro_current_plan_label() { $fs = function_exists('azlinkpro_fs') ? azlinkpro_fs() : null; if (!$fs || !$fs->is_premium() || !$fs->can_use_premium_code()) { return 'Free'; } $plan = azlinkpro_plan_title((string) $fs->get_plan_name()); if ($plan === '') { return 'Free'; } return $fs->is_trial() ? $plan . ' (trial)' : $plan; } /** Settings → Your plan. */ function azlinkpro_render_plan_summary() { $fs = function_exists('azlinkpro_fs') ? azlinkpro_fs() : null; $plan = azlinkpro_current_plan_label(); echo '
Current plan: ' . esc_html($plan) . '
'; $rows = array( 'custom_comparison' => 'Custom Comparison tables', 'spreadsheet' => 'Spreadsheet import and export', 'showcase' => 'Showcases', 'pros_cons' => 'Pros & Cons cards', 'link_audit' => 'Product Link Audit', 'click_report' => 'Link Clicks report', 'click_export' => 'Link Clicks CSV download', 'ai_pros_cons' => 'AI Pros & Cons generator', 'ai_review_builder' => 'AI Review Builder', ); echo ''; if (strpos($plan, 'Agency') !== 0) { echo 'See plans and upgrade '; } if ($account) { echo 'Account and license'; } echo '
'; } }