one-click-accessibility/modules/settings/notices/quota-80.php
Nirbhay Singh be5cfc839d
[APP-1243] Admin upgrade notices (#241)
* add: admin quota notices

* add: fix function name and phpcs issues

* fix: formatting issues
2025-03-24 16:00:10 +05:30

55 lines
1.6 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace EA11y\Modules\Settings\Notices;
use EA11y\Classes\Utils\Notice_Base;
use EA11y\Modules\Settings\Classes\Settings;
use EA11y\Modules\Settings\Module as SettingsModule;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Class Sticky_Deprecated_Nag
*/
class Quota_80 extends Notice_Base {
public string $type = 'warning';
public bool $is_dismissible = true;
public bool $per_user = false;
public $capability = 'manage_options';
public string $id = 'quota-banner-80';
public function content(): string {
return sprintf( '<h3>%s</h3><p>%s</p><p><a class="button button-primary" href="%s">%s</a></p>',
__( 'You\'ve reached 80% of your monthly widget loads in Ally!', 'pojo-accessibility' ),
__( 'Upgrade now to increase your plans monthly widget loads limit and ensure all accessibility features remain fully available for every visitor.', 'pojo-accessibility' ),
SettingsModule::get_upgrade_link( 'acc-80-quota' ),
__( 'Upgrade Now', 'pojo-accessibility' ),
);
}
public function maybe_add_quota_80_notice() : void {
$plan_data = Settings::get( Settings::PLAN_DATA );
if ( ! $plan_data ) {
$this->conditions = false;
}
$plan_usage = (int) SettingsModule::get_plan_usage();
if ( $plan_usage > 80 && $plan_usage < 100 ) {
$this->conditions = true;
} elseif ( $plan_usage < 80 ) {
$this->undismiss();
$this->conditions = false;
} else {
$this->conditions = false;
}
}
public function __construct() {
add_action( 'current_screen', [ $this, 'maybe_add_quota_80_notice' ] );
parent::__construct();
}
}