per
0) : ?>-day free trial
Get started10, 'headers' => ['Accept' => 'application/json'], ]); if (is_wp_error($response) || wp_remote_retrieve_response_code($response) !== 200) { return []; } $payload = json_decode((string) wp_remote_retrieve_body($response), true); $plans = is_array($payload) && isset($payload['data']['plans']) && is_array($payload['data']['plans']) ? $payload['data']['plans'] : []; $catalog = []; foreach ($plans as $plan) { if (! is_array($plan)) { continue; } $id = absint($plan['id'] ?? 0); $name = sanitize_text_field((string) ($plan['name'] ?? '')); $price = isset($plan['price']) && is_numeric($plan['price']) ? (float) $plan['price'] : -1; if ($id <= 0 || $name === '' || $price < 0) { continue; } $catalog[] = [ 'id' => $id, 'name' => $name, 'description' => wp_kses_post((string) ($plan['description'] ?? '')), 'price' => $price, 'currency' => strtoupper(sanitize_text_field((string) ($plan['currency'] ?? 'USD'))), 'frequency' => sanitize_text_field((string) ($plan['frequency'] ?? 'monthly')), 'featured' => ! empty($plan['featured']), 'trial_days' => max(0, absint($plan['trial_days'] ?? 0)), ]; } if ($catalog !== []) { set_transient($cache_key, $catalog, MINUTE_IN_SECONDS); } return $catalog; } function aismart_live_pricing_money($price, $currency) { $amount = number_format_i18n((float) $price, 2); return strtoupper((string) $currency) === 'USD' ? '$' . $amount : $amount . ' ' . esc_html($currency); } function aismart_live_pricing_shortcode() { $plans = aismart_live_pricing_catalog(); if ($plans === []) { return '
per
0) : ?>-day free trial
Get started