Plugin Directory

Changeset 3464861


Ignore:
Timestamp:
02/19/2026 08:51:49 AM (2 days ago)
Author:
berlinlion
Message:

Release 1.0.52

Location:
a11ybridge/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • a11ybridge/trunk/a11ybridge-plugin.php

    r3462162 r3464861  
    44 * Plugin URI:        https://a11ybridge.de
    55 * Description:       Accessibility toolbar for WordPress: font size, contrast, focus mode, color-blind filters, keyboard navigation, text-to-speech, and optional AI text simplification.
    6  * Version:           1.0.50
     6 * Version:           1.0.52
    77 * Requires at least: 6.0
    88 * Tested up to:      6.9
     
    5252// 1) Plugin release version (already defined by you from plugin header)
    5353if (!defined('A11YBRIDGE_VERSION')) {
    54     define('A11YBRIDGE_VERSION', '1.0.50'); // fallback, should never be used
     54    define('A11YBRIDGE_VERSION', '1.0.52'); // fallback, should never be used
    5555}
    5656
     
    962962            if (!$available || !$client_visible) { continue; }
    963963
    964             // Only show features explicitly enabled in admin basics settings
    965             if (empty($general_settings[$key])) { continue; }
     964            // Decide enabled state:
     965            // - If the admin saved an explicit value, respect it (0/1)
     966            // - Otherwise, use the feature's default from settings-fields.php
     967            if (array_key_exists($key, $general_settings)) {
     968                $is_enabled = ((int) $general_settings[$key] === 1);
     969            } else {
     970                $is_enabled = !empty($data['enabled']);
     971            }
     972
     973            if (!$is_enabled) { continue; }
    966974
    967975            $rendered_any = true;
  • a11ybridge/trunk/admin/settings-basics.php

    r3461470 r3464861  
    2828    $settings_basic   = require plugin_dir_path(__FILE__) . '../includes/settings-fields.php';
    2929
    30     // Nur die Grundfunktionen anzeigen
     30    // Basics tab: include only features that are available in this build.
    3131    $basic_features = array_filter($settings_basic, function($feature) {
    32         return !in_array($feature['title'], [
    33             'KI-Bildbeschreibung',
    34             'Text-Vereinfachung',
    35             'Sprachbefehle',
    36             'Barrierefreiheits-Scanner',
    37             'Barrierefreiheits-Badge'
    38         ]);
     32        if (!is_array($feature)) {
     33            return false;
     34        }
     35        $available = !empty($feature['available']);
     36        $client_visible = array_key_exists('client_visible', $feature) ? (bool) $feature['client_visible'] : true;
     37        return $available && $client_visible;
    3938    });
    40     ?>
     39?>
    4140
    4241    <form method="post" action="options.php">
     
    5958
    6059                <div class="a11y-field-group <?php echo esc_attr($lock['class']); ?>">
     60                    <?php
     61                        // Default: use the feature's declared default unless the admin explicitly saved 0/1.
     62                        $feature_enabled_val = array_key_exists($key, $general_settings)
     63                            ? (int) $general_settings[$key]
     64                            : ( !empty($data['enabled']) ? 1 : 0 );
     65                    ?>
     66                    <input type="hidden"
     67                        name="a11ybridge_plugin_general_settings[<?php echo esc_attr($key); ?>]"
     68                        value="0" />
    6169                    <input type="checkbox"
    6270                        id="<?php echo esc_attr($key); ?>"
    6371                        name="a11ybridge_plugin_general_settings[<?php echo esc_attr($key); ?>]"
    6472                        value="1"
    65                         <?php checked(isset($general_settings[$key]) ? (bool)$general_settings[$key] : false, true); ?>
     73                        <?php checked($feature_enabled_val, 1); ?>
    6674                        <?php echo wp_kses_data($lock['attrs']); ?> />
    6775
     
    194202            <div class="a11y-field-group <?php echo esc_attr($lock['class']); ?>">
    195203
     204            <?php
     205                    $toolbar_auto_hide_val = array_key_exists('toolbar_auto_hide', $general_settings)
     206                        ? (int) $general_settings['toolbar_auto_hide']
     207                        : 0;
     208                ?>
     209
     210                <input type="hidden"
     211                    name="a11ybridge_plugin_general_settings[toolbar_auto_hide]"
     212                    value="0" />
     213
    196214                <input type="checkbox"
    197215                    id="toolbar_auto_hide"
    198216                    name="a11ybridge_plugin_general_settings[toolbar_auto_hide]"
    199217                    value="1"
    200                     <?php checked(isset($general_settings['toolbar_auto_hide']) ? (bool)$general_settings['toolbar_auto_hide'] : false, true); ?> />
     218                    <?php checked($toolbar_auto_hide_val, 1); ?> />
    201219
    202220                <label for="toolbar_auto_hide">
     
    223241            <?php $lock = a11ybridge_ui_lock_attrs('basics_mobile_friendly'); ?>
    224242            <div class="a11y-field-group <?php echo esc_attr($lock['class']); ?>">
     243                <?php
     244                    $mobile_optimized_val = array_key_exists('mobile_optimized', $general_settings)
     245                        ? (int) $general_settings['mobile_optimized']
     246                        : 0;
     247                ?>
     248
     249                <input type="hidden"
     250                    name="a11ybridge_plugin_general_settings[mobile_optimized]"
     251                    value="0" />
    225252
    226253                <input type="checkbox"
     
    228255                    name="a11ybridge_plugin_general_settings[mobile_optimized]"
    229256                    value="1"
    230                     <?php checked(isset($general_settings['mobile_optimized']) ? (bool)$general_settings['mobile_optimized'] : false, true); ?> />
     257                    <?php checked($mobile_optimized_val, 1); ?> />
    231258
    232259                <label for="mobile_optimized">
     
    247274            <?php $lock = a11ybridge_ui_lock_attrs('basics_touch_friendly'); ?>
    248275            <div class="a11y-field-group <?php echo esc_attr($lock['class']); ?>">
     276
     277            <?php
     278                    $touch_friendly_val = array_key_exists('touch_friendly', $general_settings)
     279                        ? (int) $general_settings['touch_friendly']
     280                        : 0;
     281                ?>
     282
     283                <input type="hidden"
     284                    name="a11ybridge_plugin_general_settings[touch_friendly]"
     285                    value="0" />
    249286
    250287                <input type="checkbox"
     
    252289                    name="a11ybridge_plugin_general_settings[touch_friendly]"
    253290                    value="1"
    254                     <?php checked(isset($general_settings['touch_friendly']) ? (bool)$general_settings['touch_friendly'] : false, true); ?> />
     291                    <?php checked($touch_friendly_val, 1); ?> />
    255292
    256293                <label for="touch_friendly">
  • a11ybridge/trunk/admin/settings-pro.php

    r3462162 r3464861  
    153153            <h2><?php esc_html_e('Cloud connection (optional)', 'a11ybridge'); ?></h2>
    154154            <p class="description">
    155               <?php esc_html_e('A11yBridge can optionally connect to A11yBridge cloud services for AI features and quota/licensing. For WP.org compliance, no external requests are made until you enable cloud services (or activate a license).', 'a11ybridge'); ?>
     155              <?php esc_html_e('A11yBridge can optionally connect to A11yBridge cloud services for AI features and quota/licensing. For WP.org compliance, no external requests are made until you enable cloud services and opt-in.', 'a11ybridge'); ?>
    156156            </p>
    157157
  • a11ybridge/trunk/frontend/assets/js/text-simplification.js

    r3462162 r3464861  
    2222   
    2323    async init() {
    24       // Hard gate: do not expose UI or make requests unless admin enabled cloud + feature.
     24      // Gate: the admin must enable the feature.
     25      // Cloud opt-in may be disabled; in that case we keep the UI available, but we show
     26      // a helpful notice (instead of a generic error) when a visitor tries to use it.
    2527        const cfg = window.a11ybridgePlugin || {};
    26         if (!cfg.cloudEnabled || !cfg.adminTextSimplificationEnabled) {
    27             globalThis.A11yBridgeLogger.debug('🛑 Text Simplification disabled (cloud or admin feature toggle off).');
     28        if (!cfg.adminTextSimplificationEnabled) {
     29            globalThis.A11yBridgeLogger.debug('🛑 Text Simplification disabled (admin feature toggle off).');
    2830            return;
     31        }
     32        if (!cfg.cloudEnabled) {
     33            globalThis.A11yBridgeLogger.debug('⚠️ Text Simplification: Cloud opt-in is disabled. Requests will be blocked.');
    2934        }
    3035
     
    599604    async getAiProxyToken() {
    600605        const tokenUrl = window.a11ybridgePlugin?.aiTokenUrl || null;
    601         if (!tokenUrl) return '';
     606        if (!tokenUrl) {
     607            return { token: '', ok: false, status: 0, error: 'missing_token_url', message: '' };
     608        }
    602609
    603610        try {
     
    610617                cache: 'no-store',
    611618            });
    612             if (!r.ok) return '';
    613619            const data = await r.json().catch(() => null);
    614             return (data && data.token) ? String(data.token) : '';
     620
     621            if (r.ok && data && data.token) {
     622                return { token: String(data.token), ok: true, status: r.status, error: '', message: '' };
     623            }
     624
     625            const error = (data && (data.error || data.code)) ? String(data.error || data.code) : `http_${r.status}`;
     626            const message = (data && data.message) ? String(data.message) : '';
     627            return { token: '', ok: false, status: r.status, error, message };
    615628        } catch (e) {
    616             return '';
     629            return { token: '', ok: false, status: 0, error: 'network_error', message: '' };
    617630        }
    618631    }
     
    660673                '';
    661674           
    662             const cfg = window.A11YBRIDGE_CONFIG || {};
    663 
    664             const aiToken = await this.getAiProxyToken();
    665             if (!aiToken) {
    666                 throw new Error('AI token unavailable');
    667             }
     675            const pluginCfg = window.a11ybridgePlugin || {};
     676
     677            if (!pluginCfg.cloudEnabled) {
     678                this.updateNotification(
     679                    notif,
     680                    '⚠️ Cloud opt-in is disabled. Text simplification requires the admin to enable Cloud services in A11yBridge settings.',
     681                    'warning',
     682                    6500
     683                );
     684                return;
     685            }
     686
     687            if (!pluginCfg.adminTextSimplificationEnabled) {
     688                this.updateNotification(
     689                    notif,
     690                    '⚠️ Text simplification is disabled by the site administrator.',
     691                    'warning',
     692                    5500
     693                );
     694                return;
     695            }
     696
     697            const tok = await this.getAiProxyToken();
     698            if (!tok || !tok.token) {
     699                let msg = '❌ Could not start text simplification.';
     700                const err = (tok && tok.error) ? String(tok.error) : '';
     701
     702                if (err === 'cloud_or_feature_disabled' || err === 'a11ybridge_cloud_disabled') {
     703                    msg = '⚠️ Cloud opt-in is disabled. Text simplification requires the admin to enable Cloud services in A11yBridge settings.';
     704                } else if (err === 'rate_limited') {
     705                    msg = '⚠️ Too many requests. Please try again in a moment.';
     706                } else if (err) {
     707                    msg = `❌ Could not fetch AI token (${err}).`;
     708                } else {
     709                    msg = '❌ AI token unavailable.';
     710                }
     711
     712                this.updateNotification(notif, msg, 'error', 6500);
     713                return;
     714            }
     715
     716            const aiToken = tok.token;
    668717
    669718            const response = await fetch(this.apiUrl, {
     
    690739              const bodyText = await response.text().catch(() => '');
    691740              globalThis.A11yBridgeLogger.error('❌ Simplify error response:', response.status, bodyText);
    692               throw new Error(`HTTP ${response.status}: ${bodyText}`);
     741              let parsed = null;
     742              try { parsed = bodyText ? JSON.parse(bodyText) : null; } catch {}
     743             
     744              const code = parsed && (parsed.code || parsed.error) ? String(parsed.code || parsed.error) : '';
     745              const message = parsed && parsed.message ? String(parsed.message) : '';
     746             
     747              // Friendly, explicit messages for the common admin-gating cases
     748              if (response.status === 403 && (code === 'a11ybridge_cloud_disabled' || code === 'cloud_or_feature_disabled')) {
     749                this.updateNotification(
     750                  notif,
     751                  '⚠️ Cloud opt-in is disabled. Text simplification requires the admin to enable Cloud services in A11yBridge settings.',
     752                  'warning',
     753                  6500
     754                );
     755                return;
     756              }
     757              if (response.status === 403 && code === 'a11ybridge_feature_disabled') {
     758                this.updateNotification(
     759                  notif,
     760                  '⚠️ Text simplification is disabled by the site administrator.',
     761                  'warning',
     762                  5500
     763                );
     764                return;
     765              }
     766              if (response.status === 429 || code === 'rate_limited') {
     767                this.updateNotification(
     768                  notif,
     769                  '⚠️ Too many requests. Please try again in a moment.',
     770                  'warning',
     771                  4500
     772                );
     773                return;
     774              }
     775
     776              const userMsg = message ? `❌ ${message}` : '❌ Error during simplification';
     777              this.updateNotification(notif, userMsg, 'error', 6500);
     778              return;
    693779            }
    694780
  • a11ybridge/trunk/includes/settings-fields.php

    r3461470 r3464861  
    115115        'script'         => '',
    116116        'icon'           => '⌨️',
    117         'enabled'        => false,
     117        'enabled'        => true,
    118118        'available'      => true,
    119119        'client_visible' => true,
     
    160160        'script'         => '',
    161161        'icon'           => '🎯',
    162         'enabled'        => false,
     162        'enabled'        => true,
    163163        'available'      => true,
    164164        'client_visible' => true,
     
    173173        'script'         => '',
    174174        'icon'           => '👁️',
    175         'enabled'        => false,
     175        'enabled'        => true,
    176176        'available'      => true,
    177177        'client_visible' => true,
     
    186186        'script'         => '',
    187187        'icon'           => '🔈',
    188         'enabled'        => false,
     188        'enabled'        => true,
    189189        'available'      => true,
    190190        'client_visible' => true,
  • a11ybridge/trunk/readme.txt

    r3462162 r3464861  
    22Contributors: berlinlion
    33Donate link: https://a11ybridge.de/
    4 Tags: accessibility, wcag, contrast, text-to-speech, keyboard, a11y, screen reader, web-accessibility
     4Tags: accessibility, a11y, wcag, keyboard, text-to-speech
    55Requires at least: 6.0
    66Tested up to: 6.9.1
    77Requires PHP: 7.4
    8 Stable tag: 1.0.50
     8Stable tag: 1.0.52
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    144144== Changelog ==
    145145
    146 = 1.0.50 =
     146= 1.0.52 =
    147147* WP.org compliance fixes: removed trialware indicators, removed legacy frontend templates with direct script/style tags.
    148148* Fixed undefined function error in a11ybridge-plugin.php (legacy footer hook removed).
     
    155155== Upgrade Notice ==
    156156
    157 = 1.0.50 =
     157= 1.0.52 =
    158158Recommended update for WP.org submission compliance and stability fixes.
    159159
Note: See TracChangeset for help on using the changeset viewer.