$shopid, 'primaryid' => $accessibility_primaryid); $content = $this->api->call('/NewGetShopData', $data, 'get'); $has_content = !empty($content); if (!is_array($content)) { $content = []; } if (!isset($content['data']) || !is_array($content['data'])) { $content['data'] = []; } $shop_text_defaults = [ 'keybaord_nav_switch' => 0, 'cursor_switch' => 0, 'desaturate_switch' => 0, 'contrast_switch' => 0, 'bigger_text_switch' => 0, 'highlight_link_switch' => 0, 'readable_fonts_switch' => 0, 'reading_mask_switch' => 0, 'highlight_titles_switch' => 0, 'text_magnifier_switch' => 0, 'image_alt_tooltip_switch' => 0, 'stop_animation_switch' => 0, 'word_spacing_switch' => 0, 'disable_branding_switch' => 0, 'language_variable_switch' => 0, 'virtual_keyboard_switch' => 0, 'statement_on_off_switch' => 0, 'statement_edit' => '', 'statement_link' => '', 'filter_content_switch' => 0, 'alignment_switch' => 0, 'adjust_background_colors_switch' => 0, 'useful_links_switch' => 0, 'voicecommands_switch' => 0, 'image_hide_switch' => 0, 'mute_sounds_switch' => 0, 'highlight_hover_switch' => 0, 'talk_and_type_switch' => 0, 'hover_text' => 0, 'disable_widget_sound_switch' => 0, 'text_speech_switch' => 0, 'content_scaling_switch' => 0, 'highlight_focus_switch' => 0, 'color_blind_switch' => 0, 'disable_report_problem' => 0, 'hide_search_bar' => 0, 'hide_statement' => 0, 'letter_spacing_switch' => 0, 'line_height_switch' => 0, 'adjust_text_colors_switch' => 0, 'adjust_title_colors_switch' => 0, 'gif_hide_switch' => 0, 'read_mode_switch' => 0, 'bigblack_cursor_switch' => 0, 'profile_settings_switch' => 0, ]; $content['data']['shop_text'] = wp_parse_args( (is_array($content['data']['shop_text'] ?? null) ? $content['data']['shop_text'] : []), $shop_text_defaults ); $content['data']['default_lang'] = is_array($content['data']['default_lang'] ?? null) ? $content['data']['default_lang'] : []; $content['data'] = wp_parse_args($content['data'], [ 'id' => '', 'plan' => '', 'plan_display_name' => '', 'access_by_admin' => '', 'is_installation_popup_shown' => 1, 'is_plan_select_popup_shown' => 1, ]); $primary_id = $content['data']['id']; if ($primary_id) { update_option('accessibility_primaryid', $primary_id); } $current_plan = $content['data']['plan']; // If API hasn't synced plan yet, fall back to the locally stored plan so UI doesn't stay locked. if (empty($current_plan)) { $current_plan = (string) get_option('accessibility_plan', ''); $content['data']['plan'] = $current_plan; } if ($current_plan) { update_option('accessibility_plan', $current_plan); } $member_plan = (string) $content['data']['plan_display_name']; $access_by_admin = (string) $content['data']['access_by_admin']; ?> $shopid, 'keybaord_nav_switch' => $keybaord_nav_switch, 'cursor_switch' => $cursor_switch, 'desaturate_switch' => $desaturate_switch, 'contrast_switch' => $contrast_switch, 'bigger_text_switch' => $bigger_text_switch, 'highlight_link_switch' => $highlight_link_switch, 'readable_fonts_switch' => $readable_fonts_switch, 'reading_mask_switch' => $reading_mask_switch, 'highlight_titles_switch' => $highlight_titles_switch, 'text_magnifier_switch' => $text_magnifier_switch, 'image_alt_tooltip_switch' => $image_alt_tooltip_switch, 'stop_animation_switch' => $stop_animation_switch, 'word_spacing_switch' => $word_spacing_switch, 'letter_spacing_switch' => $letter_spacing_switch, 'line_height_switch' => $line_height_switch, 'alignment_switch' => $alignment_switch, 'image_hide_switch' => $image_hide_switch, 'text_speech_switch' => $text_speech_switch, //'smart_contrast_switch' => $smart_contrast_switch, 'mute_sounds_switch' => $mute_sounds_switch, 'content_scaling_switch' => $content_scaling_switch, 'gif_hide_switch' => $gif_hide_switch, 'read_mode_switch' => $read_mode_switch, 'useful_links_switch' => $useful_links_switch, 'highlight_hover_switch' => $highlight_hover_switch, 'highlight_focus_switch' => $highlight_focus_switch, 'bigblack_cursor_switch' => $bigblack_cursor_switch, 'profile_settings_switch' => $profile_settings_switch, 'voicecommands_switch' => $voicecommands_switch, 'talk_and_type_switch' => $talk_and_type_switch, 'disable_widget_sound_switch' => $disable_widget_sound_switch, 'hover_text' => $hover_text, 'color_blind_switch' => $color_blind_switch, 'disable_report_problem_switch' => $disable_report_problem_switch, 'hide_statement' => $hide_statement, 'hide_search_bar' => $hide_search_bar, 'disable_branding_switch' => $disable_branding_switch, 'language_variable_switch' => $language_variable_switch, 'virtual_keyboard_switch' => $virtual_keyboard_switch, 'statement_on_off_switch' => $statement_on_off_switch, 'statement_edit' => $statement_edit, 'statement_link' => $statement_link, 'adjust_background_colors_switch' => $adjust_background_colors_switch, 'adjust_text_colors_switch' => $adjust_text_colors_switch, 'adjust_title_colors_switch' => $adjust_title_colors_switch, 'filter_content_switch' => $filter_content_switch ); $returnsenddata = $this->api->call('/updateShopData', $send_data, 'post'); if ($returnsenddata['status'] == 200) { echo '
× Success!
'; // Clear transient cache to reflect changes immediately delete_transient('accessibility_widget_data_' . $shopid); $data = array('shopid' => $returnsenddata['data']['shopid'],); $content = $this->api->call('/NewGetShopData', $data, 'get'); } else { echo '
× Error! '; echo esc_html($returnsenddata['messages']); echo '
'; } } } } ?> You have admin access

"; } if (!empty($current_plan) && strpos(strtolower($member_plan), 'develop') !== false) { echo "

You have member access

"; } if (empty($current_plan)) { echo "

"; _e('Unlock full functionality by upgrading to a paid plan', 'accessibility-assistant'); echo "

"; } ?>

%s %s
", esc_html($plan_message), esc_url($plan_page_url), esc_html($upgrade_text)); } ?>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

/>

]+>/', $text)) { $parts = preg_split('/(<[^>]+>)/', $text, -1, PREG_SPLIT_DELIM_CAPTURE); $translated = ''; foreach ($parts as $part) { if (preg_match('/<[^>]+>/', $part)) { // Keep HTML tag as is $translated .= $part; } else { // Translate text content $translated .= translateTextToLanguage($part, $target); } } return $translated; } // Build API request for plain text $api_url = add_query_arg([ 'client' => 'gtx', 'sl' => 'auto', 'tl' => $target, 'dt' => 't', 'q' => rawurlencode($text), // safer encoding ], 'https://translate.googleapis.com/translate_a/single'); $response = wp_remote_get($api_url, ['timeout' => 50]); if (is_wp_error($response)) { error_log('Translation API request failed: ' . $response->get_error_message()); return $text; } $body = wp_remote_retrieve_body($response); $json = json_decode($body, true); if (!is_array($json) || !isset($json[0])) { return $text; } $translated = ''; foreach ($json[0] as $segment) { if (is_array($segment) && isset($segment[0])) { $translated .= $segment[0]; } } // Decode \u003c -> <, etc. $translated = html_entity_decode($translated, ENT_QUOTES | ENT_HTML5, 'UTF-8'); return $translated ?: $text; } catch (Throwable $e) { error_log('Statement translation failed: ' . $e->getMessage()); return $text; } } } $link_value = $content['data']['shop_text']['statement_link'] ?? ''; $link_value = ($link_value === '0' || $link_value === 0) ? null : $link_value; $statement = $content['data']['shop_text']['statement_edit'] ?? ''; $link_enabled = !empty($content['data']['shop_text']['statement_on_off_switch']); $default_html = <<Accessibility Statement:

Accessibility Assistant App commitment to inclusivity drives us to provide an accessible online experience for all users, including those with diverse needs. We continuously strive to improve our website and services, aligning with established accessibility standards and guidelines.

Accessibility Features:

WCAG Compliance:

Our APP adheres to the Web Content Accessibility Guidelines (WCAG) 2.1, focusing on conformance levels A and AA, and we are actively working towards achieving higher levels of accessibility.

Technical Info:

Platform: Shopify, WordPress, Wix

Technologies Used: HTML, CSS, JavaScript, PHP, MYSQL

Feedback:

We value your feedback and are committed to making continuous improvements. If you encounter any issues or have specific accessibility requirements, please reach out to us at support@cartcoders.com. Your insights help us create a more inclusive online environment.

HTML; // Ensure data is safe $dataArray = $content['data'] ?? []; // Get default language safely $lang_code = $dataArray['default_lang']['language_code'] ?? null; // Transient cache key $cache_key = 'accessibility_statement_trans_' . md5($lang_code . ($shopid ?? 'any')); $cached_translations = get_transient($cache_key); if ($cached_translations && is_array($cached_translations)) { $default_statement = $cached_translations['default'] ?? html_entity_decode($default_html); $statement = $cached_translations['custom'] ?? $statement; } else { // Only translate if lang code exists if ($lang_code) { $default_html_statement = html_entity_decode($default_html); $default_statement = translateTextToLanguage($default_html_statement, $lang_code); $html_statement = $statement; $statement = translateTextToLanguage($html_statement, $lang_code); // Cache for 1 day set_transient($cache_key, [ 'default' => $default_statement, 'custom' => $statement ], DAY_IN_SECONDS); } else { // Fallback: No translation possible $default_statement = html_entity_decode($default_html); } } ?>

'statement_edit', 'textarea_rows' => 12, 'media_buttons' => false, 'teeny' => false, 'quicktags' => true ]); ?>