Changeset 3464991
- Timestamp:
- 02/19/2026 10:30:31 AM (2 days ago)
- Location:
- a11ybridge/trunk
- Files:
-
- 4 edited
-
a11ybridge-plugin.php (modified) (6 diffs)
-
admin/settings-ai.php (modified) (2 diffs)
-
frontend/assets/js/text-simplification.js (modified) (1 diff)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
a11ybridge/trunk/a11ybridge-plugin.php
r3464861 r3464991 4 4 * Plugin URI: https://a11ybridge.de 5 5 * 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.5 26 * Version: 1.0.53 7 7 * Requires at least: 6.0 8 8 * Tested up to: 6.9 … … 52 52 // 1) Plugin release version (already defined by you from plugin header) 53 53 if (!defined('A11YBRIDGE_VERSION')) { 54 define('A11YBRIDGE_VERSION', '1.0.5 2'); // fallback, should never be used54 define('A11YBRIDGE_VERSION', '1.0.53'); // fallback, should never be used 55 55 } 56 56 … … 607 607 'cloudEnabled' => (int) a11ybridge_cloud_enabled(), 608 608 'adminTextSimplificationEnabled' => (int) a11ybridge_text_simplification_admin_enabled(), 609 'adminTextSimplificationShowButton' => (int) a11ybridge_text_simplification_show_toolbar_button(), 609 610 'simplifyProxyUrl' => esc_url_raw( rest_url('a11ybridge/v1/ai/simplify') ), 610 611 'aiTokenUrl' => esc_url_raw( rest_url('a11ybridge/v1/ai/token') ), … … 991 992 $simp_enabled = !empty($simp['enable_text_simplification']); 992 993 // default: show in toolbar unless explicitly disabled 993 $simp_show_toolbar = !array_key_exists('show_toolbar_button', $simp) || !empty($simp['show_toolbar_button']); 994 995 if ($simp_enabled && $simp_show_toolbar) { 994 if ($simp_enabled) { 996 995 $rendered_any = true; 997 996 echo '<div class="a11ybridge-setting" data-setting-key="a11ybridge_plugin_enable_simple_language" data-script="" style="padding: 5px; cursor: pointer;">'; … … 1051 1050 'nonce' => wp_create_nonce('a11ybridge_settings_nonce'), 1052 1051 'isUserLoggedIn' => is_user_logged_in(), 1053 'cloudEnabled' => (int) a11ybridge_cloud_enabled(),1052 'cloudEnabled' => (int) a11ybridge_cloud_enabled(), 1054 1053 'adminTextSimplificationEnabled' => (int) a11ybridge_text_simplification_admin_enabled(), 1054 'adminTextSimplificationShowButton' => (int) a11ybridge_text_simplification_show_toolbar_button(), 1055 1055 'simplifyProxyUrl' => esc_url_raw( rest_url('a11ybridge/v1/ai/simplify') ), 1056 1056 'aiTokenUrl' => esc_url_raw( rest_url('a11ybridge/v1/ai/token') ), … … 1109 1109 1110 1110 // **Plugin-Aktivierungs- und Deaktivierungs-Hooks** 1111 /** 1112 * Seed defaults on first activation. 1113 * 1114 * Goal: New users should see the core features enabled immediately, 1115 * while anything that requires explicit consent (cloud) stays OFF. 1116 * 1117 * We only fill missing options. We never overwrite existing admin choices. 1118 */ 1119 function a11ybridge_seed_default_settings_on_activation(): void { 1120 // ---- Basics / local features ---- 1121 $general = get_option( 'a11ybridge_plugin_general_settings', null ); 1122 $general_is_empty = ( $general === null || $general === false || ! is_array( $general ) || $general === [] ); 1123 1124 if ( $general_is_empty ) { 1125 $defs = []; 1126 $settings_file = A11YBRIDGE_DIR . 'includes/settings-fields.php'; 1127 if ( file_exists( $settings_file ) ) { 1128 $fields = require $settings_file; 1129 if ( is_array( $fields ) ) { 1130 foreach ( $fields as $key => $data ) { 1131 if ( ! is_string( $key ) || $key === '' ) { continue; } 1132 if ( ! is_array( $data ) ) { continue; } 1133 1134 $available = ! empty( $data['available'] ); 1135 $client_visible = array_key_exists( 'client_visible', $data ) ? (bool) $data['client_visible'] : true; 1136 if ( ! $available || ! $client_visible ) { continue; } 1137 1138 $defs[ $key ] = ! empty( $data['enabled'] ) ? 1 : 0; 1139 } 1140 } 1141 } 1142 1143 // Toolbar should be visible by default. 1144 $defs['show_toolbar'] = 1; 1145 // Credit link must remain optional and OFF by default (WP.org compliance). 1146 $defs['show_credit_link'] = 0; 1147 1148 if ( ! empty( $defs ) ) { 1149 update_option( 'a11ybridge_plugin_general_settings', $defs, false ); 1150 } 1151 } 1152 1153 // ---- AI features toggles (UI visible) ---- 1154 $ai = get_option( 'a11ybridge_ai_settings', [] ); 1155 if ( ! is_array( $ai ) ) { $ai = []; } 1156 $ai_defaults = [ 1157 // Visible by default, but still blocked until Cloud opt-in is enabled. 1158 'enable_ai_image_description' => 1, 1159 ]; 1160 $ai_changed = false; 1161 foreach ( $ai_defaults as $k => $v ) { 1162 if ( ! array_key_exists( $k, $ai ) ) { 1163 $ai[ $k ] = $v; 1164 $ai_changed = true; 1165 } 1166 } 1167 if ( $ai_changed ) { 1168 update_option( 'a11ybridge_ai_settings', $ai, false ); 1169 } 1170 1171 // ---- Text simplification ---- 1172 $simpl = get_option( 'a11ybridge_simplification_settings', [] ); 1173 if ( ! is_array( $simpl ) ) { $simpl = []; } 1174 $simpl_defaults = [ 1175 // Enable the feature UI by default (but keep Cloud opt-in OFF). 1176 'enable_text_simplification' => 1, 1177 // Show the "simplify selected text" action by default. 1178 'show_toolbar_button' => 1, 1179 ]; 1180 $simpl_changed = false; 1181 foreach ( $simpl_defaults as $k => $v ) { 1182 if ( ! array_key_exists( $k, $simpl ) ) { 1183 $simpl[ $k ] = $v; 1184 $simpl_changed = true; 1185 } 1186 } 1187 if ( $simpl_changed ) { 1188 update_option( 'a11ybridge_simplification_settings', $simpl, false ); 1189 } 1190 } 1191 1192 /** 1193 * Text simplification: should we show the "Simplify selected text" button? 1194 * Default: ON (if not explicitly saved). 1195 */ 1196 function a11ybridge_text_simplification_show_toolbar_button(): bool { 1197 $simpl = get_option( 'a11ybridge_simplification_settings', [] ); 1198 if ( ! is_array( $simpl ) ) { $simpl = []; } 1199 1200 // Default true if never saved. 1201 if ( ! array_key_exists( 'show_toolbar_button', $simpl ) ) { return true; } 1202 return ! empty( $simpl['show_toolbar_button'] ); 1203 } 1111 1204 function a11ybridge_plugin_activate() { 1112 1205 // Aktionen beim Aktivieren des Plugins 1113 1206 a11ybridge_debug_log('[A11yBridge] activated'); 1114 } 1207 1208 // Ensure stable installation id exists. 1209 if ( function_exists( 'a11ybridge_get_install_id' ) ) { 1210 a11ybridge_get_install_id(); 1211 } 1212 1213 // Seed default feature toggles for first-time installs. 1214 if ( function_exists( 'a11ybridge_seed_default_settings_on_activation' ) ) { 1215 a11ybridge_seed_default_settings_on_activation(); 1216 } 1217 } 1218 1115 1219 register_activation_hook(__FILE__, 'a11ybridge_plugin_activate'); 1116 1220 -
a11ybridge/trunk/admin/settings-ai.php
r3461470 r3464991 23 23 $out = []; 24 24 $out['enable_text_simplification'] = !empty($in['enable_text_simplification']) ? 1 : 0; 25 $out['show_toolbar_button'] = !empty($in['show_toolbar_button']) ? 1 : 0; 25 // NOTE: show_toolbar_button must default to ON. 26 // If the field is missing in the POST payload, keep previous stored value (or default to 1). 27 $existing = get_option('a11ybridge_simplification_settings', []); 28 if (!is_array($existing)) { $existing = []; } 29 $existing_show = array_key_exists('show_toolbar_button', $existing) ? (int)$existing['show_toolbar_button'] : 1; 30 $out['show_toolbar_button'] = array_key_exists('show_toolbar_button', $in) 31 ? (!empty($in['show_toolbar_button']) ? 1 : 0) 32 : $existing_show; 26 33 $out['consent_required'] = !empty($in['consent_required']) ? 1 : 0; 27 34 $out['consent_ttl_hours'] = isset($in['consent_ttl_hours']) ? max(0, intval($in['consent_ttl_hours'])) : 24; … … 290 297 </div> 291 298 299 <!-- Show / hide the "simplify selected text" action in the toolbar (does NOT change whether the settings are available) --> 300 <?php $lock = a11ybridge_ui_lock_attrs('ai_feature_text_simplify'); ?> 301 <div class="a11y-field-group <?php echo esc_attr($lock['class']); ?>"> 302 303 <input type="hidden" 304 name="a11ybridge_simplification_settings[show_toolbar_button]" 305 value="0" /> 306 307 <input type="checkbox" 308 id="show_toolbar_button" 309 name="a11ybridge_simplification_settings[show_toolbar_button]" 310 value="1" 311 <?php checked(!array_key_exists('show_toolbar_button', $simplification_settings) || !empty($simplification_settings['show_toolbar_button'])); ?> /> 312 313 <label for="show_toolbar_button"> 314 <?php echo esc_html__('Show "Simplify selected text" button in toolbar', 'a11ybridge'); ?> 315 </label> 316 317 <abbr title="<?php echo esc_attr__('If disabled, visitors can still open the text simplification settings, but the selection action is hidden.','a11ybridge'); ?>"> 318 <span class="a11y-tooltip">i</span> 319 </abbr> 320 321 <?php echo wp_kses_post($lock['badge']); ?> 322 <?php if ($lock['attrs']) echo '<span class="a11y-disabled-overlay"></span>'; ?> 323 </div> 292 324 <?php $lock = a11ybridge_ui_lock_attrs('ai_feature_simplification_default'); ?> 293 325 <div class="a11y-field-group <?php echo esc_attr($lock['class']); ?>"> -
a11ybridge/trunk/frontend/assets/js/text-simplification.js
r3464861 r3464991 35 35 36 36 await this.loadSavedSettings(); 37 this.setupTextSelection(); 37 // Admin can hide the selection action while keeping the settings panel available. 38 const showSelectionButton = (cfg.adminTextSimplificationShowButton !== 0); 39 if (showSelectionButton) { 40 this.setupTextSelection(); 41 this.setupKeyboardShortcuts(); 42 } else { 43 console.info('[A11yBridge] Text simplification: toolbar button hidden by admin setting'); 44 } 38 45 this.setupKeyboardShortcuts(); 46 39 47 40 48 // Listen to settings changes and reload immediately (no polling) -
a11ybridge/trunk/readme.txt
r3464861 r3464991 6 6 Tested up to: 6.9.1 7 7 Requires PHP: 7.4 8 Stable tag: 1.0.5 28 Stable tag: 1.0.53 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 144 144 == Changelog == 145 145 146 = 1.0.5 2=146 = 1.0.53 = 147 147 * WP.org compliance fixes: removed trialware indicators, removed legacy frontend templates with direct script/style tags. 148 148 * Fixed undefined function error in a11ybridge-plugin.php (legacy footer hook removed). … … 155 155 == Upgrade Notice == 156 156 157 = 1.0.5 2=157 = 1.0.53 = 158 158 Recommended update for WP.org submission compliance and stability fixes. 159 159
Note: See TracChangeset
for help on using the changeset viewer.