PluginProbe ʕ •ᴥ•ʔ
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization / 1.18.8
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization v1.18.8
1.19.8 1.19.7 1.19.6 1.19.5 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.11.0 1.12.0 1.13.0 1.14.0 1.15.0 1.15.1 1.15.2 1.15.3 1.16.0 1.16.1 1.16.2 1.16.3 1.16.4 1.16.5 1.16.6 1.16.7 1.16.8 1.17.0 1.17.6 1.17.7 1.17.8 1.17.9 1.18.0 1.18.1 1.18.2 1.18.3 1.18.4 1.18.5 1.18.6 1.18.7 1.18.8 1.18.9 1.19.0 1.19.1 1.19.2 1.19.3 1.19.4 1.3.19 1.3.20 1.4.0 1.4.1 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.13 1.5.14 1.5.15 1.5.16 1.5.17 1.5.18 1.5.19 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.7.0 1.7.1 1.8.0 1.8.1 1.8.3 1.9.0 1.9.1 1.9.2
nitropack / classes / WordPress / Settings / Subscription.php
nitropack / classes / WordPress / Settings Last commit date
CacheWarmup.php 7 months ago Components.php 1 year ago GeneratePreview.php 7 months ago Logger.php 7 months ago OptimizationLevel.php 7 months ago Shortcodes.php 1 year ago Subscription.php 6 months ago TestMode.php 10 months ago
Subscription.php
94 lines
1 <?php
2 namespace NitroPack\WordPress\Settings;
3
4 use NitroPack\HttpClient\HttpClient;
5
6 defined( 'ABSPATH' ) || die( 'No script kiddies please!' );
7
8 /* Subscription class to handle subscription related functionalities */
9 class Subscription {
10 private static $instance = null;
11
12 /**
13 * Fetch plan details from NitroPack API
14 */
15 public function fetch_plan() {
16 $planDetailsUrl = get_nitropack_integration_url( "plan_details_json" );
17 $quickSetupHTTP = new HttpClient( $planDetailsUrl );
18 $quickSetupHTTP->timeout = 30;
19 $quickSetupHTTP->fetch();
20 $resp = $quickSetupHTTP->getStatusCode() == 200 ? json_decode( $quickSetupHTTP->getBody(), true ) : false;
21 return $resp;
22 }
23 public static function getInstance() {
24 if ( null === self::$instance ) {
25 self::$instance = new self();
26 }
27 return self::$instance;
28 }
29 /**
30 * Render subscription box in our Dashboard
31 */
32 public function render() {
33 $cdn_bandwidth_used = 'N/A';
34 $max_cdn_bandwidth = 'N/A';
35 $page_views = 'N/A';
36 $max_page_views = 'N/A';
37 $plan = $this->fetch_plan();
38 if ( $plan ) {
39 $plan_title = isset( $plan['plan_title'] ) ? $plan['plan_title'] : 'N/A';
40 $next_reset = isset( $plan['next_reset'] ) ? $plan['next_reset'] : 'N/A';
41 $next_billing = isset( $plan['next_billing'] ) ? $plan['next_billing'] : 'N/A';
42 $page_views = isset( $plan['page_views'] ) ? $plan['page_views'] : 'N/A';
43 $max_page_views = isset( $plan['max_page_views'] ) ? $plan['max_page_views'] : 'N/A';
44 $cdn_bandwidth_used = isset( $plan['cdn_bandwidth'] ) ? $plan['cdn_bandwidth'] : 'N/A';
45 $max_cdn_bandwidth = isset( $plan['max_cdn_bandwidth'] ) ? $plan['max_cdn_bandwidth'] : 'N/A';
46 }
47 ?>
48 <div class="card card-subscription">
49 <div class="card-header">
50 <h3><?php esc_html_e( 'Subscription', 'nitropack' ); ?></h3>
51 </div>
52 <div class="card-body">
53 <div class="flex flex-row items-center">
54 <div class="plan-name"><?php echo esc_html( $plan_title, 'nitropack' ); ?></div>
55 <a type="button" target="_blank" href="https://app.nitropack.io/account/billing"
56 class="btn btn-secondary ml-auto"
57 id="btn-manage-subscription"><?php esc_html_e( 'Manage subscription', 'nitropack' ); ?></a>
58 </div>
59 <div class="table-wrapper">
60 <table class="w-full">
61 <tbody>
62 <tr>
63 <td class="key"><?php esc_html_e( 'Next reset', 'nitropack' ); ?></td>
64 <td class="value" data-next-reset><?php esc_html_e( $next_reset, 'nitropack' ); ?></td>
65 </tr>
66 <tr>
67 <td class="key"><?php esc_html_e( 'Next billing', 'nitropack' ); ?></td>
68 <td class="value" data-next-billing><?php esc_html_e( $next_billing, 'nitropack' ); ?></td>
69 </tr>
70 <tr>
71 <td class="key"><?php esc_html_e( 'Page views', 'nitropack' ); ?></td>
72 <td class="value" data-page-views>
73 <?php printf( esc_html__( '%1$s out of %2$s', 'nitropack' ), $page_views, $max_page_views ); ?>
74 </td>
75 </tr>
76 <tr>
77 <td class="key"><?php esc_html_e( 'CDN bandwidth', 'nitropack' ); ?></td>
78 <td class="value" data-cdn-bandwidth>
79 <?php printf( esc_html__( '%1$s out of %2$s', 'nitropack' ), $cdn_bandwidth_used, $max_cdn_bandwidth ); ?>
80 </td>
81 </tr>
82 </tbody>
83 </table>
84 </div>
85 </div>
86 <div class="card-footer">
87 <p class="text-secondary text-smaller">
88 <?php esc_html_e( 'You will be notified by email when your website reaches the subscription resource limits.', 'nitropack' ); ?>
89 </p>
90 </div>
91 </div>
92 <?php
93 }
94 }