one-click-accessibility/modules/settings/notices/quota-100.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_100 extends Notice_Base {
public string $type = 'error-elementor';
public bool $is_dismissible = true;
public bool $per_user = false;
public $capability = 'manage_options';
public string $id = 'quota-banner-100';
public function content(): string {
return sprintf( '<h3>%s</h3><p>%s</p><p><a class="button button-primary" style="background-color: #93003F; border-color: #93003F;" href="%s">%s</a></p>',
__( 'Oh no! Ally has reached the monthly widget load limit.', 'pojo-accessibility' ),
__( 'Upgrade now to increase your plans monthly widget loads limit and ensure all accessibility features stay fully available for every visitor.', 'pojo-accessibility' ),
SettingsModule::get_upgrade_link( 'acc-100-quota' ),
__( 'Upgrade Now', 'pojo-accessibility' ),
);
}
public function maybe_add_quota_100_notice() : void {
$plan_data = Settings::get( Settings::PLAN_DATA );
if ( ! $plan_data ) {
$this->conditions = false;
}
$plan_usage = (int) SettingsModule::get_plan_usage();
if ( 100 === $plan_usage ) {
$this->conditions = true;
} elseif ( $plan_usage < 100 ) {
$this->undismiss();
$this->conditions = false;
} else {
$this->conditions = false;
}
}
public function __construct() {
add_action( 'current_screen', [ $this, 'maybe_add_quota_100_notice' ] );
parent::__construct();
}
}