Plugin Directory

Changeset 2984218


Ignore:
Timestamp:
10/26/2023 07:42:22 AM (2 years ago)
Author:
api2cartdev
Message:

Updated to 2.2.0

Location:
api2cart-bridge-connector/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • api2cart-bridge-connector/trunk/bridge2cart/bridge.php

    r2978736 r2984218  
    11<?php
    2 /*-----------------------------------------------------------------------------+
    3 | API2Cart                                                                     |
    4 | Copyright (c) 2017 API2Cart.com <manager@api2cart.com>                       |
    5 | All rights reserved                                                          |
    6 +------------------------------------------------------------------------------+
    7 | PLEASE READ  THE FULL TEXT OF SOFTWARE LICENSE AGREEMENT IN THE "license.txt"|
    8 | FILE PROVIDED WITH THIS DISTRIBUTION.                                        |
    9 |                                                                              |
    10 | THIS  AGREEMENT  EXPRESSES  THE  TERMS  AND CONDITIONS ON WHICH YOU MAY USE  |
    11 | THIS SOFTWARE   PROGRAM   AND  ASSOCIATED  DOCUMENTATION   THAT  API2CART    |
    12 | (hereinafter  referred to as "THE AUTHOR") IS FURNISHING  OR MAKING          |
    13 | AVAILABLE TO YOU WITH  THIS  AGREEMENT  (COLLECTIVELY,  THE  "SOFTWARE").    |
    14 | PLEASE   REVIEW   THE  TERMS  AND   CONDITIONS  OF  THIS  LICENSE AGREEMENT  |
    15 | CAREFULLY   BEFORE   INSTALLING   OR  USING  THE  SOFTWARE.  BY INSTALLING,  |
    16 | COPYING   OR   OTHERWISE   USING   THE   SOFTWARE,  YOU  AND  YOUR  COMPANY  |
    17 | (COLLECTIVELY,  "YOU")  ARE  ACCEPTING  AND AGREEING  TO  THE TERMS OF THIS  |
    18 | LICENSE   AGREEMENT.   IF  YOU    ARE  NOT  WILLING   TO  BE  BOUND BY THIS  |
    19 | AGREEMENT, DO  NOT INSTALL OR USE THE SOFTWARE.  VARIOUS   COPYRIGHTS   AND  |
    20 | OTHER   INTELLECTUAL   PROPERTY   RIGHTS    PROTECT   THE   SOFTWARE.  THIS  |
    21 | AGREEMENT IS A LICENSE AGREEMENT THAT GIVES  YOU  LIMITED  RIGHTS   TO  USE  |
    22 | THE  SOFTWARE   AND  NOT  AN  AGREEMENT  FOR SALE OR FOR  TRANSFER OF TITLE. |
    23 | THE AUTHOR RETAINS ALL RIGHTS NOT EXPRESSLY GRANTED BY THIS AGREEMENT.       |
    24 |                                                                              |
    25 | The Developer of the Code is API2Cart,                                       |
    26 | Copyright (C) 2006 - 2020 All Rights Reserved.                               |
    27 +------------------------------------------------------------------------------+
    28 |                                                                              |
    29 |                            ATTENTION!                                        |
    30 +------------------------------------------------------------------------------+
    31 | By our Terms of Use you agreed not to change, modify, add, or remove portions|
    32 | of Bridge Script source code as it is owned by API2Cart company.             |
    33 | You agreed not to use, reproduce, modify, adapt, publish, translate          |
    34 | the Bridge Script source code into any form, medium, or technology           |
    35 | now known or later developed throughout the universe.                        |
    36 |                                                                              |
    37 | Full text of our TOS located at                                              |
    38 |                       https://www.api2cart.com/terms-of-service              |
    39 +-----------------------------------------------------------------------------*/
    402
    413interface A2C_Platform_Actions {
     
    13092
    13193    /**
     94     * Category Add
     95     *
    13296     * @param array $data Data
    13397     *
     
    137101
    138102    /**
     103     * Category Update
     104     *
    139105     * @param array $data Data
    140106     *
     
    144110
    145111    /**
     112     * Category Update
     113     *
    146114     * @param array $data Data
    147115     *
     
    664632     * OrderUpdate
    665633     *
     634     * @param array $a2cData Data
     635     *
    666636     * @inheritDoc
    667637     */
     
    671641
    672642    /**
     643     * Category Add
     644     *
    673645     * @param array $data Data
    674646     *
     
    680652
    681653    /**
     654     * Category Update
     655     *
    682656     * @param array $data Data
    683657     *
     
    689663
    690664    /**
     665     * Category Delete
     666     *
    691667     * @param array $data Data
    692668     *
     
    13551331                            $entity->delete_meta_data( '_wc_shipment_tracking_items' );
    13561332                        } else {
    1357                             $entity->update_meta_data( '_wc_shipment_tracking_items',  $data );
     1333                            $entity->update_meta_data( '_wc_shipment_tracking_items', $data );
    13581334                        }
    13591335
     
    18241800
    18251801    /**
     1802     * Category Add
     1803     *
    18261804     * @param array $a2cData Data
    18271805     *
    18281806     * @return array
    18291807     */
    1830     public function categoryAdd(array $a2cData)
    1831     {
     1808    public function categoryAdd(array $a2cData) {
    18321809        $response = array(
    18331810            'error_code' => self::ERROR_CODE_SUCCESS,
     
    18661843            unset($postParams['a2c_sign']);
    18671844            $postParams['a2c_sign'] = hash_hmac('sha256', http_build_query($postParams), A2CBC_TOKEN);
    1868             $url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     1845            $url = ( isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ? 'https' : 'http' ) . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    18691846
    18701847            // Add Post Params for WPML
     
    18791856                    'headers'     => [
    18801857                        'Accept-Language:*',
    1881                         'User-Agent:' . $_SERVER['HTTP_USER_AGENT'],
     1858                        'User-Agent:' . sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ),
    18821859                    ],
    18831860                    'body'        => $postParams,
     
    19001877
    19011878    /**
     1879     * Category Update
     1880     *
    19021881     * @param array $a2cData Data
    19031882     *
    19041883     * @return array
    19051884     */
    1906     public function categoryUpdate(array $a2cData)
    1907     {
     1885    public function categoryUpdate(array $a2cData) {
    19081886        $response = array(
    19091887            'error_code' => self::ERROR_CODE_SUCCESS,
     
    19451923
    19461924    /**
     1925     * Category Delete
     1926     *
    19471927     * @param array $a2cData Data
    19481928     *
    19491929     * @return array
    19501930     */
    1951     public function categoryDelete(array $a2cData)
    1952     {
     1931    public function categoryDelete(array $a2cData) {
    19531932        $response = array(
    19541933            'error_code' => self::ERROR_CODE_SUCCESS,
  • api2cart-bridge-connector/trunk/connectorMain.php

    r2978736 r2984218  
    55Author: API2Cart
    66Author URI: https://api2cart.com/
    7 Version: 2.1.0
     7Version: 2.2.0
    88*/
     9
     10/*
     11Api2Cart Bridge Connector is free software: you can redistribute it and/or modify
     12it under the terms of the GNU General Public License as published by
     13the Free Software Foundation, either version 2 of the License, or
     14any later version.
     15
     16Api2Cart Bridge Connector is distributed in the hope that it will be useful,
     17but WITHOUT ANY WARRANTY; without even the implied warranty of
     18MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
     19GNU General Public License for more details.
     20
     21You should have received a copy of the GNU General Public License
     22along with Api2Cart Bridge Connector. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
     23*/
     24
    925defined( 'ABSPATH' ) || die( 'Cannot access pages directly.' );
    1026define( 'A2CBC_BRIDGE_IS_CUSTOM_OPTION_NAME', 'A2C_woocommerce_bridge_connector_is_custom' );
     
    158174    wp_enqueue_style( 'connector-css', plugins_url( 'css/style.css', __FILE__ ) , [], $theme_version );
    159175    wp_enqueue_script( 'connector-js', plugins_url( 'js/scripts.js', __FILE__ ), [ 'jquery' ], $theme_version );
     176    wp_enqueue_script( 'connector-js', plugins_url( 'js/scripts.js', __FILE__ ), [], $theme_version );
     177    wp_localize_script( 'connector-js', 'A2CAjax', array( 'ajaxurl' => admin_url( 'admin-ajax.php' )));
    160178
    161179    $showButton = 'install';
  • api2cart-bridge-connector/trunk/css/style.css

    r2722470 r2984218  
    2323}
    2424
    25 .bridge .container{
     25.bridge--container{
    2626    background: #fff;
    2727    border: 1px solid #e1e1e1;
     
    3232
    3333.bridge .store-key{
    34     display: none;
     34    visibility: hidden;
    3535}
    3636
     
    4949}
    5050
    51 .connectormessage {
    52     display: none;
    53     opacity: 0.9;
     51.bridge--connectormessage {
    5452    position: absolute;
    5553    background: #2876c4;
     
    6260    font-size: 14px;
    6361}
    64 .connectormessage.bridge_error { background: #F05657; }
    65 
    66 .clearfix:after {
     62.bridge--connectormessage.bridge_error { background: #F05657; }
     63
     64.bridge--clearfix:after {
    6765    content: "";
    6866    visibility: hidden;
  • api2cart-bridge-connector/trunk/js/scripts.js

    r2927081 r2984218  
    1 jQuery(document).ready(function($) {
    21
    3   var SELF_PATH = 'admin-ajax.php';
     2document.addEventListener('DOMContentLoaded', function() {
    43
    5   var messages = $('#messages');
     4  var messages = document.getElementById('messages');
    65
    7   var installationsText = $('#connector-installed-txt');
    8   var contentBlockManage = $('#content-block-manage');
     6  var installationsText = document.getElementById('connector-installed-txt');
     7  var contentBlockManage = document.getElementById('content-block-manage');
    98
    10   var showButton = $("#showButton");
    11   var bridgeStoreKey = $('#bridgeStoreKey');
    12   var storeKey = $('#storeKey');
    13   var storeBlock = $('.store-key');
    14   var classMessage = $('.connectormessage');
    15   var progress = $('.progress');
    16   var additionalInfo = $("#additionalInfo");
    17   var bridgeUrl = $("#additionalInfo #bridgeUrlVal");
     9  var showButton = document.getElementById('showButton');
     10  var bridgeStoreKey = document.getElementById('bridgeStoreKey');
     11  var storeKey = document.getElementById('storeKey');
     12  var storeBlock = document.querySelectorAll('.store-key')[0];
     13  var classMessage = document.querySelectorAll('.bridge--connectormessage')[0];
     14  var progress = document.querySelectorAll('.progress')[0];
     15  var additionalInfo = document.getElementById('additionalInfo');
     16  var bridgeUrl = document.getElementById('bridgeUrlVal');
    1817
    1918  var timeDelay = 500;
    2019
    21   var bridgeConnectionInstall   = $("#bridgeConnectionInstall");
    22   var bridgeConnectionUninstall = $("#bridgeConnectionUninstall");
     20  var bridgeConnectionInstall = document.getElementById('bridgeConnectionInstall');
     21  var bridgeConnectionUninstall = document.getElementById('bridgeConnectionUninstall');
    2322
    24   var updateBridgeStoreKey = $('#updateBridgeStoreKey');
     23  var updateBridgeStoreKey = document.getElementById('updateBridgeStoreKey');
     24  classMessage.style.opacity = '0';
     25  classMessage.style.visibility = 'hidden';
    2526
    26   if (showButton.val() == 'install') {
    27     installationsText.show();
    28     contentBlockManage.hide();
    29     storeBlock.fadeOut();
    30     updateBridgeStoreKey.hide();
    31     bridgeConnectionUninstall.hide();
    32     bridgeConnectionInstall.show();
     27  if (showButton.value == 'install') {
     28    installationsText.style.visibility = 'visible';
     29    contentBlockManage.style.height = '0';
     30    contentBlockManage.style.visibility = 'hidden';
     31    installationsText.style.height = 'auto';
     32    installationsText.style.margin = 'inherit';
     33    storeBlock.style.visibility = 'hidden';
     34    updateBridgeStoreKey.style.visibility = 'hidden';
     35    bridgeConnectionUninstall.style.display = 'none';
     36    bridgeConnectionInstall.style.display = 'inline-block';
    3337  } else {
    34     installationsText.hide();
    35     contentBlockManage.show();
    36     storeBlock.fadeIn();
    37     updateBridgeStoreKey.show();
    38     bridgeConnectionInstall.hide();
    39     bridgeConnectionUninstall.show();
     38    installationsText.style.visibility = 'hidden';
     39    contentBlockManage.style.height = 'auto';
     40    contentBlockManage.style.visibility = 'visible';
     41    installationsText.style.height = '0';
     42    installationsText.style.margin = '0';
     43    storeBlock.style.visibility = 'visible';
     44    updateBridgeStoreKey.style.visibility = 'visible';
     45    bridgeConnectionInstall.style.display = 'none';
     46    bridgeConnectionUninstall.style.display = 'inline-block';
    4047  }
    4148
    4249  function statusMessage(message, status) {
    43     var timeout = 3000;
     50    var timeout = 2500;
    4451
    4552    if (status == 'success') {
    46       classMessage.removeClass('bridge_error');
     53      classMessage.classList.remove('bridge_error');
    4754    } else {
    48       classMessage.addClass('bridge_error');
    49       timeout = 5000;
     55      classMessage.classList.add('bridge_error');
     56      timeout = timeout;
    5057    }
    51     classMessage.html('<span>' + message + '</span>');
    52     classMessage.fadeIn("slow");
    53     classMessage.fadeOut(5000);
     58    classMessage.innerHTML = '<span>' + message + '</span>';
     59    classMessage.style.display = 'block';
     60
     61
     62    fadeIn(classMessage, timeout, function () {
     63      fadeOut(classMessage, 500);
     64    });
     65
    5466    var messageClear = setTimeout(function(){
    55       classMessage.html('');
     67      classMessage.innerHTML = '';
    5668    }, timeout);
    5769    clearTimeout(messageClear);
    5870  }
    5971
    60   $('.btn-setup').click(function() {
    61     var self = $(this);
    62     $(this).attr("disabled", true);
    63     progress.slideDown("fast");
    64     var install = 'install';
    65     if (showButton.val() == 'uninstall') {
    66       install = 'remove';
    67     }
     72  var setupButtons = document.querySelectorAll('.btn-setup');
     73  setupButtons.forEach(function(button) {
     74    button.addEventListener('click', function() {
     75      var self = this;
     76      self.disabled = true;
     77      progress.style.display = 'block';
     78      var install = 'install';
     79      if (showButton.value == 'uninstall') {
     80        install = 'remove';
     81      }
    6882
    69     $.ajax({
    70       cache: false,
    71       url: SELF_PATH,
    72       dataType: 'json',
    73       type: 'POST',
    74       data:{
    75         action: 'A2CBCbridge_action',
    76         connector_action: install + 'Bridge'
    77       },
    78       success: function(data) {
    79         self.attr("disabled", false);
    80         progress.slideUp("fast");
     83      var xhr = new XMLHttpRequest();
     84      xhr.open('POST', A2CAjax.ajaxurl, true);
     85      xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
     86      xhr.onload = function() {
     87        if (xhr.status === 200) {
     88          self.disabled = false;
     89          progress.style.display = 'none';
     90          var data = JSON.parse(xhr.responseText);
    8191
    82         if (install == 'install') {
    83           if (data.status.success != true) {
    84             statusMessage('Can not install Connector' + '\r\n' + data.status.message,'error');
    85             return;
     92          if (install == 'install') {
     93            if (data.status.success !== true) {
     94              statusMessage('Can not install Connector' + '\r\n' + data.status.message, 'error');
     95              return;
     96            }
     97
     98            updateStoreKey(data.data.storeKey);
     99            bridgeUrl.innerHTML = data.data.bridgeUrl;
     100            fadeOut(installationsText, timeDelay);
     101            installationsText.style.height = '0';
     102            installationsText.style.margin = '0';
     103            contentBlockManage.style.height = 'auto';
     104            fadeIn(contentBlockManage, timeDelay);
     105            fadeIn(storeBlock, 1000);
     106            fadeIn(updateBridgeStoreKey, 1000);
     107            showButton.value = 'uninstall';
     108            bridgeConnectionInstall.style.display = 'none';
     109            bridgeConnectionUninstall.style.display = 'inline-block';
     110
     111            if (data.status.custom === true) {
     112              additionalInfo.style.display = 'block';
     113            } else {
     114              additionalInfo.style.display = 'none';
     115            }
     116
     117            statusMessage('Connector Installed Successfully', 'success');
     118          } else {
     119            if (data.status.success !== true) {
     120              statusMessage(data.status.message, 'error');
     121              return;
     122            }
     123
     124            fadeOut(contentBlockManage, timeDelay);
     125            contentBlockManage.style.height = '0';
     126            installationsText.style.height = 'auto';
     127            installationsText.style.margin = 'inherit';
     128            fadeIn(installationsText, timeDelay);
     129            fadeOut(storeBlock, 'fast');
     130            fadeOut(updateBridgeStoreKey, 'fast');
     131            showButton.value = 'install';
     132            bridgeConnectionUninstall.style.display = 'none';
     133            bridgeConnectionInstall.style.display = 'inline-block';
     134            additionalInfo.style.display = 'none';
     135            statusMessage('Connector Uninstalled Successfully', 'success');
    86136          }
     137        } else {
     138          statusMessage('Can\'t install Connector', 'error');
     139        }
     140      };
    87141
    88           updateStoreKey(data.data.storeKey);
    89           bridgeUrl.html(data.data.bridgeUrl);
    90           installationsText.fadeOut(timeDelay);
    91           contentBlockManage.delay(timeDelay).fadeIn(timeDelay);
    92           storeBlock.fadeIn("slow");
    93           updateBridgeStoreKey.fadeIn("slow");
    94           showButton.val('uninstall');
    95           bridgeConnectionInstall.hide();
    96           bridgeConnectionUninstall.show();
    97 
    98           if (data.status.custom == true) {
    99             additionalInfo.show();
    100           } else {
    101             additionalInfo.hide();
    102           }
    103 
    104           statusMessage('Connector Installed Successfully','success');
    105         } else {
    106           if (data.status.success != true) {
    107             statusMessage(data.status.message,'error');
    108             return;
    109           }
    110 
    111           contentBlockManage.fadeOut(timeDelay);
    112           installationsText.delay(timeDelay).fadeIn(timeDelay);
    113           storeBlock.fadeOut("fast");
    114           updateBridgeStoreKey.fadeOut("fast");
    115           showButton.val('install');
    116           bridgeConnectionUninstall.hide();
    117           bridgeConnectionInstall.show();
    118           additionalInfo.hide();
    119           statusMessage('Connector Uninstalled Successfully','success');
    120         }
    121       }
     142      xhr.send('action=A2CBCbridge_action&connector_action=' + install + 'Bridge');
    122143    });
    123144  });
    124145
    125   updateBridgeStoreKey.click(function() {
    126     $.ajax({
    127       dataType: 'json',
    128       cache: false,
    129       url: SELF_PATH,
    130       type: 'POST',
    131       data:{
    132         action: 'A2CBCbridge_action',
    133         connector_action: 'updateToken'
    134       },
    135       success: function(data) {
    136         if (data.status.success != true) {
    137           statusMessage(data.status.message,'error');
     146  updateBridgeStoreKey.addEventListener('click', function() {
     147    var xhr = new XMLHttpRequest();
     148    xhr.open('POST', A2CAjax.ajaxurl, true);
     149    xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
     150    xhr.onload = function() {
     151      if (xhr.status === 200) {
     152        var data = JSON.parse(xhr.responseText);
     153        if (data.status.success !== true) {
     154          statusMessage(data.status.message, 'error');
    138155          return;
    139156        }
    140157        updateStoreKey(data.data.storeKey);
    141         statusMessage('Connector Updated Successfully!','success');
     158        statusMessage('Connector Updated Successfully!', 'success');
     159      } else {
     160        statusMessage('Can\'t install Connector', 'error');
    142161      }
    143     });
     162    };
     163
     164    xhr.send('action=A2CBCbridge_action&connector_action=updateToken');
    144165  });
    145166
    146   function updateStoreKey(store_key){
    147     storeKey.html(store_key);
     167  function updateStoreKey(store_key) {
     168    storeKey.innerHTML = store_key;
     169  }
     170
     171  function fadeIn(element, duration, callback) {
     172    element.style.transition = 'opacity ' + duration + 'ms';
     173    element.style.opacity = '1';
     174    element.style.visibility = 'visible';
     175
     176    element.addEventListener('transitionend', function() {
     177      element.style.transition = '';
     178
     179      if (typeof callback === 'function') {
     180        callback();
     181      }
     182    }, { once: true });
     183  }
     184
     185  function fadeOut(element, duration) {
     186    element.style.transition = 'opacity ' + duration + 'ms';
     187    element.style.opacity = '0';
     188
     189    element.addEventListener('transitionend', function() {
     190      element.style.visibility = 'hidden';
     191    }, { once: true });
    148192  }
    149193
  • api2cart-bridge-connector/trunk/readme.txt

    r2978736 r2984218  
    6969= 2.0.4 =* Fix plugin settings link.
    7070= 2.1.0 =* Updated bridge to 145 version. Added category action in the bridge
     71= 2.2.0 =* Fix UI
  • api2cart-bridge-connector/trunk/settings.phtml

    r2902279 r2984218  
    11<div class="bridge">
    2   <div class="connectormessage"></div>
     2  <div class="bridge--connectormessage"></div>
    33
    44
    5   <div class="container">
     5  <div class="bridge--container">
    66
    77    <div class="text-center">
     
    4444      </table>
    4545    </div>
    46     <div class="clearfix"></div>
     46    <div class="bridge--clearfix"></div>
    4747  </div>
    4848
  • api2cart-bridge-connector/trunk/worker.php

    r2941862 r2984218  
    122122        preg_match( "/define\('(\w+)',\s*'([^']+)'\);/", file_get_contents( $this->bridgePath . $this->configFilePath ), $matches );
    123123
    124         if ( $matches[2] != $storeKey ) {
     124        if ( isset( $matches[2] ) && $matches[2] != $storeKey ) {
    125125            $this->updateToken( $storeKey );
    126126        }
     
    197197        $url = $this->bridgeUrl . '?' . $query;
    198198
     199        if ( wp_http_supports( array( 'ssl' ) ) ) {
     200            $url = set_url_scheme( $url, 'https' );
     201        }
     202
    199203        if ( $isHttp ) {
    200             $url = str_replace( 'https://', 'http://', $url );
     204            $url = set_url_scheme( $url, 'http' );
    201205        }
    202206
     
    206210                'timeout'     => 30,
    207211                'redirection' => 5,
    208                 'httpversion' => '1.0',
    209                 'sslverify'   => false,
    210212                'blocking'    => true,
    211213                'headers'     => $headers,
Note: See TracChangeset for help on using the changeset viewer.