PluginProbe ʕ •ᴥ•ʔ
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization / 1.19.4
NitroPack – Performance, Page Speed & Cache Plugin for Core Web Vitals, CDN & Image Optimization v1.19.4
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
AutoPurge.php 4 months ago BeaverBuilder.php 4 months ago CPTOptimization.php 4 months ago CacheWarmup.php 3 months ago CartCache.php 4 months ago Components.php 3 months ago EditorClearCache.php 4 months ago GeneratePreview.php 7 months ago HTMLCompression.php 3 months ago Logger.php 4 months ago OptimizationLevel.php 3 months ago Optimizations.php 4 months ago PurgeCache.php 4 months ago Shortcodes.php 4 months ago StockRefresh.php 2 months ago Subscription.php 4 months ago SystemReport.php 3 months ago TestMode.php 4 months ago
Subscription.php
100 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 ); ?></div>
55 <?php $components = new Components();
56 echo $components->render_button( [ 'text' => 'Manage subscription', 'type' => null, 'classes' => 'btn btn-secondary ml-auto', 'href' => 'https://app.nitropack.io/account/billing', 'attributes' => [ 'id' => 'btn-manage-subscription', 'target' => '_blank' ] ] );
57 ?>
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 echo esc_html( $next_reset ); ?></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 echo esc_html( $next_billing ); ?></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
74 /* translators: %1$s: current page views, %2$s: maximum page views */
75 printf( esc_html__( '%1$s out of %2$s', 'nitropack' ), $page_views, $max_page_views );
76 ?>
77 </td>
78 </tr>
79 <tr>
80 <td class="key"><?php esc_html_e( 'CDN bandwidth', 'nitropack' ); ?></td>
81 <td class="value" data-cdn-bandwidth>
82 <?php
83 /* translators: %1$s: used CDN bandwidth, %2$s: maximum CDN bandwidth */
84 printf( esc_html__( '%1$s out of %2$s', 'nitropack' ), $cdn_bandwidth_used, $max_cdn_bandwidth );
85 ?>
86 </td>
87 </tr>
88 </tbody>
89 </table>
90 </div>
91 </div>
92 <div class="card-footer">
93 <p class="text-secondary text-smaller">
94 <?php esc_html_e( 'You will be notified by email when your website reaches the subscription resource limits.', 'nitropack' ); ?>
95 </p>
96 </div>
97 </div>
98 <?php
99 }
100 }