| Server IP : 52.25.153.185 / Your IP : 216.73.217.117 Web Server : Apache System : Linux ip-172-26-6-158 5.10.0-45-cloud-amd64 #1 SMP Debian 5.10.259-1 (2026-07-02) x86_64 User : daemon ( 1) PHP Version : 8.1.10 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /bitnami/wordpress/wp-content/plugins/allaccessible/inc/ |
Upload File : |
<?php
/**
* Widget Loader for AllAccessible
*
* Handles frontend widget injection:
* - Free users: Load default widget
* - Premium users: Load customized widget from API
*
* @package AllAccessible
* @since 2.0.0
*/
if (!defined('ABSPATH')) {
die('You are not allowed to call this page directly.');
}
class AllAccessible_WidgetLoader {
private static $instance = null;
public static function get_instance() {
if (self::$instance === null) {
self::$instance = new self();
}
return self::$instance;
}
private function __construct() {
add_action('wp_head', array($this, 'load_widget'));
}
/**
* Load accessibility widget on frontend
*/
public function load_widget() {
// Don't load in admin, on 404s/feeds/previews, or inside page-builder
// editors (Oxygen, Divi, Elementor, ...). See AllAccessible_ContextGuard.
// Falls back to the legacy is_admin() check if the guard file is missing
// (partial update) so the widget keeps loading rather than vanishing.
$skip = class_exists('AllAccessible_ContextGuard')
? AllAccessible_ContextGuard::should_skip_widget()
: is_admin();
if ($skip) {
return;
}
$account_id = get_option('aacb_accountID');
// Free users: Load free widget from CDN
if (empty($account_id)) {
$account_id = 'wp_vFtGhKjLm'; // Free for tracking purposes
$widget_src = 'https://api.allaccessible.org/widget/wp_vFtGhKjLm.js';
} else {
// Premium users: Load custom widget from CDN
$widget_src = 'https://api.allaccessible.org/widget/' . $account_id . '.js';
}
// Check for preview mode
$is_preview = isset($_GET['aacb_preview']) && $_GET['aacb_preview'];
?>
<script
data-accessible-account-id="<?php echo esc_attr($account_id); ?>"
data-site-url="<?php echo esc_url(get_bloginfo('wpurl')); ?>"
id="allAccessibleWidget"
src="<?php echo esc_url($widget_src); ?>"
defer>
</script>
<?php if ($is_preview): ?>
<script>
window.addEventListener('load', function() {
var aacbButton = document.getElementById('accessibility-trigger-button');
if (aacbButton) {
aacbButton.click();
}
});
</script>
<?php endif;
}
}
// Initialize widget loader
add_action('plugins_loaded', function() {
AllAccessible_WidgetLoader::get_instance();
});