Plugin Directory

Changeset 3284584


Ignore:
Timestamp:
04/30/2025 06:16:44 AM (10 months ago)
Author:
anshumanja
Message:

limited access mode

Location:
accessibe/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • accessibe/trunk/accessibe.php

    r3237954 r3284584  
    44  * Plugin URI: https://accessibe.com/
    55  * Description: accessiBe is the #1 fully automated web accessibility solution. Protect your website from lawsuits and increase your potential audience.
    6   * Version: 2.6
     6  * Version: 2.7
    77  * Author: accessiBe
    88  * Author URI: https://accessibe.com/
     
    1818require 'vendor/autoload.php';
    1919use Mixpanel\Mixpanel;
     20
     21define('ACCESSIBE_WP_UNIVERSAL_URL', 'https://universal.accessibe.com');
    2022
    2123define('ACCESSIBE_WP_PLUGIN_DIR', plugin_dir_path(__FILE__));
  • accessibe/trunk/accessibe_inc/js/accessibe.js

    r3231917 r3284584  
    4242        action: "accessibe_license_trial",
    4343       })
     44    );
     45  },
     46  sendAddVerificationPageRequest: async (data) => {
     47    return JSON.parse(
     48      await jQuery.post(ajaxurl, {
     49        _ajax_nonce: accessibe_vars.run_tool_nonce,
     50        data: JSON.stringify(data),
     51        action: "accessibe_add_verification_page",
     52      })
    4453    );
    4554  },
     
    106115  setMerchant: (data) => {
    107116    AcsbStore.merchantData = data;
    108     console.log("setting merchant data", data);
     117    Logger.log("setting merchant data", data);
    109118    //sendMerchantDetails();
    110119  },
    111120  sendDataToIframe: (eventName, data, additionalData={}) => {
    112121    document.getElementById(ACSB_UNI_IFRAME_ID).contentWindow.postMessage({ eventName, data, additionalData }, '*');
    113     console.log(eventName, data);
    114   }
     122    Logger.log(eventName, data);
     123  },
     124  sendDomainVerificationRequest: (type, path, domain) => {
     125    API.sendDataToIframe('domain-verification-request', { type, path, domain });
     126  },
    115127}
    116128jQuery(document).ready(async ($) => {
    117129  AcsbStore.jQueryReady = true;
    118   console.log("accessibe.js loaded");
     130  Logger.log("accessibe.js loaded");
    119131  await API.syncMerchantDetails();
     132  API.sendRedirectUrl(window.location.href);
    120133});
    121134
     
    123136    let response;
    124137    if (event.data.eventName){
    125       console.log(event.data.eventName, event.data);
     138      Logger.log(event.data.eventName, event.data);
    126139    }
    127140    switch (event.data.eventName) {
     
    143156        break;
    144157      case 'license-trial': {
    145         const data = await API.sendLicenseData({...event.data.data, newLicense: event.data.newLicense});
    146         console.log('license-trial response ::', data);
     158        const data = await API.sendLicenseData({
     159          licenseId: event.data.data.licenseId,
     160          accountId: event.data.data.accountId,
     161          domain: event.data.data.domain,
     162          widgetConfig: event.data.data.widgetConfig,
     163          siteId: event.data.data.siteId,
     164          isNewLicenseTrial: event.data.data.isNewLicenseTrial,
     165        });
     166        Logger.log('license-trial response ::', data);
    147167        await API.syncMerchantDetails();
    148168        break;
     
    161181        await API.modifyConfig(event.data.data.widgetConfig);
    162182        break;
     183      case 'redirect-to-url':
     184        const { add_redirect_url_with_key: redirectUrlKey, url: targetUrl } = event.data.data;
     185        const urlToRedirect = new URL(targetUrl);
     186        if (redirectUrlKey) {
     187          urlToRedirect.searchParams.set(redirectUrlKey, window.location.href);
     188        }
     189        window.location.href = urlToRedirect.href;
     190        break;
     191      case 'remove-query-param':
     192        const paramToremove = event.data.data.param;
     193        const url = new URL(window.location.href);
     194        url.searchParams.delete(paramToremove);
     195        window.history.replaceState({}, document.title, url);
     196        break;
     197      case 'create-domain-ownership-request':
     198        const res = await API.sendAddVerificationPageRequest(event.data.data);
     199        API.sendDomainVerificationRequest(res.type, res.path, res.domain);
     200        Logger.log("verify-ownership response", res);
     201        break;
     202      default:
     203        break;
    163204  }});
     205
     206const isDebugMode = localStorage.getItem('debug') === 'true';
     207
     208const Logger = {
     209  log(message, ...optionalParams) {
     210    if (isDebugMode) {
     211      console.log(`.[INFO] ${message}`, ...optionalParams);
     212    }
     213  },
     214
     215  error(message, ...optionalParams) {
     216    if (isDebugMode) {
     217      console.error(`.[ERROR] ${message}`, ...optionalParams);
     218    }
     219  },
     220
     221  debug(message, ...optionalParams) {
     222    if (isDebugMode) {
     223      console.debug(`.[DEBUG] ${message}`, ...optionalParams);
     224    }
     225  },
     226};
  • accessibe/trunk/class.accessibeforwp.php

    r3237954 r3284584  
    5656
    5757    public static $icon_mapping_to_widget = [
    58             "LegacyDisplay" => "display",
    59             "LegacyDisplay2" => "display2",
    60             "LegacyDisplay3" => "display3",
    61             "LegacyHelp" => "help",
    62             "LegacyPeople" => "people",
    63             "LegacyPeople2" => "people2",
    64             "LegacySettings" => "settings",
    65             "LegacySettings2" => "settings2",
    66             "LegacyWheels" => "wheels",
    67             "LegacyWheels2" => "wheels2",
     58      "LegacyDisplay" => "display",
     59      "LegacyDisplay2" => "display2",
     60      "LegacyDisplay3" => "display3",
     61      "LegacyHelp" => "help",
     62      "LegacyPeople" => "people",
     63      "LegacyPeople2" => "people2",
     64      "LegacySettings" => "settings",
     65      "LegacySettings2" => "settings2",
     66      "LegacyWheels" => "wheels",
     67      "LegacyWheels2" => "wheels2",
    6868    ];
    6969
    7070    public static function accessibe_init() {
    71         if (!self::$accessibe_initiated) {
    72             self::accessibe_init_hooks();
    73         }
     71      if (!self::$accessibe_initiated) {
     72        self::accessibe_init_hooks();
     73        self::accessibe_get_plugin_version();
     74      }
    7475    } // accessibe_init
    7576
     
    127128        /* update admin footer text */
    128129        add_filter('admin_footer_text', array('AccessibeWp', 'accessibe_admin_footer_text'));
    129 
     130        /* add verification file */
     131        add_action('wp_ajax_accessibe_add_verification_page', array('AccessibeWp', 'accessibe_add_verification_page_ajax'));
    130132    } // accessibe_init_hooks
    131133
     
    144146   */
    145147    public static function accessibe_get_plugin_version() {
    146         $accessibe_plugin_data = get_file_data(ACCESSIBE_WP_FILE, array('version' => 'Version'), 'plugin');
    147         self::$accessibe_version = $accessibe_plugin_data['version'];
    148         return $accessibe_plugin_data['version'];
     148      if (isset(self::$accessibe_version)) {
     149        return self::$accessibe_version;
     150      }
     151      $accessibe_plugin_data = get_file_data(ACCESSIBE_WP_FILE, array('version' => 'Version'), 'plugin');
     152      self::$accessibe_version = $accessibe_plugin_data['version'];
     153      return $accessibe_plugin_data['version'];
    149154    } // accessibe_get_plugin_version
    150155
     
    210215                }
    211216            }
    212             $icon_value = $accessibe_options['triggerIcon'];
    213             $accessibe_options['triggerIcon'] = self::$icon_mapping_to_widget[$icon_value];
     217            $icon_value = isset($accessibe_options['triggerIcon']) ? $accessibe_options['triggerIcon'] : '';
     218            $accessibe_options['triggerIcon'] = isset(self::$icon_mapping_to_widget[$icon_value]) ? self::$icon_mapping_to_widget[$icon_value] : 'people';
    214219        }
    215220
     
    263268    } // accessibe_dismiss_pointer_ajax
    264269
     270    /**
     271     * Add ownership verification file
     272     */
     273    public static function accessibe_add_verification_page_ajax() {
     274        $file_name = 'accessibe_verification.txt';
     275        $verificationData = json_decode(stripslashes($_POST['data']));
     276        $file_path = ABSPATH . $file_name; // Path to the public file
     277        $token = $verificationData->token;
     278        $result = array(
     279            'type' => esc_html('FILE_URL'),
     280            'path' => '',
     281            'domain' => self::get_current_domain(),
     282        );
     283    if (file_put_contents($file_path, $token)) {
     284            $result['path'] = site_url($file_name) . '?v=' . time();
     285    } else {
     286            $result['failed-1'] = $file_path;
     287            // Get uploads directory path and URL
     288            $upload_dir = wp_upload_dir();
     289            $dir_path = trailingslashit($upload_dir['basedir']) . 'accessibe';
     290            $file_path = $dir_path . '/' . $file_name;
     291   
     292            // Ensure directory exists
     293            if (!file_exists($dir_path)) {
     294                wp_mkdir_p($dir_path);
     295            }
     296   
     297            if (file_put_contents($file_path, $token)) {
     298                $result['path'] = trailingslashit($upload_dir['baseurl']) . 'accessibe' . '/' . $file_name . '?v=' . time();
     299            } else {
     300                $result['failed-2'] = $file_path;
     301            }
     302        }
     303        echo json_encode($result);
     304        wp_die();
     305    } // accessibe_add_verification_page_ajax
    265306
    266307    public static function accessibe_merchant_detail_ajax() {
     
    278319            'fullName' => $display_name,
    279320            'storeId' => self::sanitizeDomain(wp_parse_url(site_url())['host']),
     321            'wapperApp' => array(
     322              'name' => 'WordPress',
     323              'version' => self::accessibe_get_plugin_version() . ''
     324            ),
    280325            'mixpanelProps' => array (
    281326                'wordpressStoreName' => self::sanitizeDomain(wp_parse_url(site_url())['host']),
     
    305350    } // accessibe_merchant_detail_ajax
    306351
     352    public static function get_current_domain() {
     353        $current_domain = wp_parse_url(site_url())['host'];
     354        return self::sanitizeDomain($current_domain);
     355    }
     356   
    307357    public static function accessibe_domain_list_ajax() {
    308358        $existing_domains = json_decode(stripslashes($_POST['existingDomains']));
    309359
    310         $current_domain = self::sanitizeDomain(wp_parse_url(site_url())['host']);
     360        $current_domain = self::get_current_domain();
    311361        // $current_domain = '9cc3-2405-201-5c0f-d070-14fd-b303-b02-1999.ngrok-free.app';
    312362
     
    691741        ?>
    692742        <div class="wrap">
    693             <iframe id='accessibe-universal-iframe' src='https://universal.accessibe.com'></iframe>
     743        <iframe id='accessibe-universal-iframe' src='<?php echo esc_url_raw(ACCESSIBE_WP_UNIVERSAL_URL . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '')); ?>'></iframe>
    694744        </div>
    695745        <!-- /.wrap -->
  • accessibe/trunk/mixpanel.php

    r3219469 r3284584  
    88    public function __construct()
    99    {
    10         $this->config = $this->getConfig();
    11         $this->mixpanel = Mixpanel::getInstance('d2a99cd5439edf8f95db8ad1fe2efdca', $this->config); // Assuming a Mixpanel PHP SDK is available
     10      $this->config = $this->getConfig();
     11      $this->mixpanel = Mixpanel::getInstance('d2a99cd5439edf8f95db8ad1fe2efdca', $this->config); // Assuming a Mixpanel PHP SDK is available
    1212    }
    1313
    1414    private function getConfig() {
    15         $config = [
    16             'host' => 'dashboard.accessibe.com',
    17             'events_endpoint' => '/mixpanel/proxy/track',
    18             'people_endpoint' => '/mixpanel/proxy/engage',
    19             'use_ssl' => true,
    20             'error_callback' => function($err) {
    21                 if ($err) {
    22                     error_log("Mixpanel Error: " . print_r($err, true));
    23                 } else {
    24                     error_log("Mixpanel Success: No error returned");
    25                 }
     15      $config = [
     16        'host' => 'dashboard.accessibe.com',
     17        'events_endpoint' => '/mixpanel/proxy/track',
     18        'people_endpoint' => '/mixpanel/proxy/engage',
     19        'use_ssl' => true,
     20        'error_callback' => function($err) {
     21            if ($err) {
     22              error_log("Mixpanel Error: " . print_r($err, true));
     23            } else {
     24              error_log("Mixpanel Success: No error returned");
    2625            }
    27         ];
     26        }
     27      ];
    2828
    2929   
    30         return $config;
     30      return $config;
    3131    }
    3232
    3333    private function addDefaultProps($properties)
    3434    {
    35         $properties['accessiBeProduct'] = 'Universal Plugin';
    36         $properties['eventType'] = 'server-side';
    37         $properties['pluginSource'] = 'WordPress';
    38         $properties['isReact'] = false;
     35      $properties['accessiBeProduct'] = 'Universal Plugin';
     36      $properties['eventType'] = 'server-side';
     37      $properties['pluginSource'] = 'WordPress';
     38      $properties['isReact'] = false;
    3939
    40         return $properties;
     40      return $properties;
    4141    }
    4242
    4343    public function trackEvent($eventName, $properties = [])
    4444    {
    45         if (!$this->mixpanel) {
    46             return false;
    47         }
     45      if (!$this->mixpanel) {
     46        return false;
     47      }
    4848
    49         if (isset($properties['userId'])) {
    50             $properties['$user_id'] = $properties['userId'];
    51             $properties['distinct_id'] = $properties['userId'];
    52             unset($properties['userId']);
    53         } else if (!isset($properties['distinct_id']) && !isset($properties['$user_id'])) {
    54             $properties['distinct_id'] = $properties['primaryDomain'] ?? null;
    55         }
    56    
    57         if (strpos($eventName, '$') === false) {
    58             // Add default props only if the event is not system-defined (e.g., $identify)
    59             $properties = $this->addDefaultProps($properties);
    60         }
     49      if (isset($properties['userId'])) {
     50        $properties['$user_id'] = $properties['userId'];
     51        $properties['distinct_id'] = $properties['userId'];
     52        unset($properties['userId']);
     53      } else if (!isset($properties['distinct_id']) && !isset($properties['$user_id'])) {
     54        $properties['distinct_id'] = $properties['primaryDomain'] ?? null;
     55      }
     56 
     57      if (strpos($eventName, '$') === false) {
     58        // Add default props only if the event is not system-defined (e.g., $identify)
     59        $properties = $this->addDefaultProps($properties);
     60      }
    6161
    62         try {
    63             $this->mixpanel->track($eventName, $properties);
    64         } catch (Exception $e) {
    65             error_log("Mixpanel tracking error: " . $e->getMessage());
    66         }
     62      try {
     63        $this->mixpanel->track($eventName, $properties);
     64      } catch (Exception $e) {
     65        error_log("Mixpanel tracking error: " . $e->getMessage());
     66      }
    6767    }
    6868
    6969    public function isInitialized()
    7070    {
    71         return $this->mixpanel !== null;
     71      return $this->mixpanel !== null;
    7272    }
    7373
     
    7575    {
    7676        if (!$this->mixpanel) {
    77             return false;
     77          return false;
    7878        }
    7979
  • accessibe/trunk/readme.txt

    r3237954 r3284584  
    33Tags: accessibility, web accessibility, wordpress accessibility, ada, wcag, accessible, a11y
    44Requires at least: 4.7
    5 Tested up to: 6.7
    6 Stable tag: 2.6
     5Tested up to: 6.8
     6Stable tag: 2.7
    77Requires PHP: 7.0
    88License: GPLv2 or later
     
    6868
    6969== Changelog ==
     70= v2.7 =
     71* 2025-04-28
     72* Limited Access Mode
     73
    7074= v2.6 =
    7175* 2025-02-07
Note: See TracChangeset for help on using the changeset viewer.