Skip to content

Commit

Permalink
WebP Pro Upgrade Notice (#1033)
Browse files Browse the repository at this point in the history
* Add a notice to the WebP widget indicating that upgrading to Pro offers additional limits
* Fix limit gauges so they yellow/red show properly
* Fixed Pro hourly limit widget showing the wrong limit
  • Loading branch information
jacobd91 authored Jan 16, 2025
1 parent 8d30a0b commit e1556ec
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
18 changes: 9 additions & 9 deletions Extension_ImageService_Widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,18 @@ jQuery( document ).ready(
var chart_data = google.visualization.arrayToDataTable( data[key]['data'], true );
var yellow_from, yellow_to, red_from;

if ( data[key]['limit'] > 100 && data[key]['limit'] <= 1000 ) {
yellow_from = data[key]['limit'] - 200;
yellow_to = data[key]['limit'] - 100;
red_from = data[key]['limit'] - 100;
} else if ( data[key]['limit'] > 1000 ) {
yellow_from = data[key]['limit'] - 2000;
if ( data[key]['limit'] > 10 && data[key]['limit'] <= 100 ) {
yellow_from = data[key]['limit'] - 40;
yellow_to = data[key]['limit'] - 10;
red_from = data[key]['limit'] - 10;
} else if ( data[key]['limit'] > 100 ) {
yellow_from = data[key]['limit'] - 4000;
yellow_to = data[key]['limit'] - 1000;
red_from = data[key]['limit'] - 1000;
} else {
yellow_from = data[key]['limit'] - 20;
yellow_to = data[key]['limit'] - 10;
red_from = data[key]['limit'] - 10;
yellow_from = data[key]['limit'] - 4;
yellow_to = data[key]['limit'] - 1;
red_from = data[key]['limit'] - 1;
}

var chart_options = {
Expand Down
7 changes: 6 additions & 1 deletion Extension_ImageService_Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ public static function admin_init_w3tc_dashboard() {

// Validate hourly data. If no data then set usage to 0 and appropriate limits.
$usage['usage_hourly'] = 'Unknown' !== $usage['usage_hourly'] ? $usage['usage_hourly'] : 0;
$usage['limit_hourly'] = 'Unknown' !== $usage['limit_hourly'] ? $usage['limit_hourly'] : ( $is_pro ? 10000 : 100 );

if ( $is_pro ) {
$usage['limit_hourly'] = 'Unknown' !== $usage['limit_hourly_licensed'] ? $usage['limit_hourly_licensed'] : 10000;
} else {
$usage['limit_hourly'] = 'Unknown' !== $usage['limit_hourly'] ? $usage['limit_hourly'] : 100;
}

// Validate monthly data. If no data then set usage to 0 and appropriate limits.
// Remove if pro as we don't show a gauge for pro usage.
Expand Down
6 changes: 6 additions & 0 deletions Extension_ImageService_Widget_View.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
<div id="counts_chart"></div>
<h3 class="w3tc-webp-widget-stats-title"><?php esc_html_e( 'API Use Limits', 'w3-total-cache' ); ?></h3>
<div id="api_charts"></div>
<?php if ( ! Util_Environment::is_w3tc_pro( $config ) ) : ?>
<div class="notice notice-info" style="margin: 0;">
<p><?php esc_html_e( 'Need higher API limits? Upgrade to Pro for significantly higher hourly limits and no monthly cap!', 'w3-total-cache' ); ?></p>
<p><input type="button" class="button-primary button-buy-plugin" data-src="account_widget" value="<?php esc_attr_e( 'Learn more about Pro', 'w3-total-cache' ); ?>" /></p>
</div>
<?php endif ?>
</div>
<?php
} else {
Expand Down

0 comments on commit e1556ec

Please sign in to comment.