Changeset 2984218
- Timestamp:
- 10/26/2023 07:42:22 AM (2 years ago)
- Location:
- api2cart-bridge-connector/trunk
- Files:
-
- 7 edited
-
bridge2cart/bridge.php (modified) (14 diffs)
-
connectorMain.php (modified) (2 diffs)
-
css/style.css (modified) (4 diffs)
-
js/scripts.js (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
settings.phtml (modified) (2 diffs)
-
worker.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
api2cart-bridge-connector/trunk/bridge2cart/bridge.php
r2978736 r2984218 1 1 <?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 +-----------------------------------------------------------------------------*/40 2 41 3 interface A2C_Platform_Actions { … … 130 92 131 93 /** 94 * Category Add 95 * 132 96 * @param array $data Data 133 97 * … … 137 101 138 102 /** 103 * Category Update 104 * 139 105 * @param array $data Data 140 106 * … … 144 110 145 111 /** 112 * Category Update 113 * 146 114 * @param array $data Data 147 115 * … … 664 632 * OrderUpdate 665 633 * 634 * @param array $a2cData Data 635 * 666 636 * @inheritDoc 667 637 */ … … 671 641 672 642 /** 643 * Category Add 644 * 673 645 * @param array $data Data 674 646 * … … 680 652 681 653 /** 654 * Category Update 655 * 682 656 * @param array $data Data 683 657 * … … 689 663 690 664 /** 665 * Category Delete 666 * 691 667 * @param array $data Data 692 668 * … … 1355 1331 $entity->delete_meta_data( '_wc_shipment_tracking_items' ); 1356 1332 } else { 1357 $entity->update_meta_data( '_wc_shipment_tracking_items', $data );1333 $entity->update_meta_data( '_wc_shipment_tracking_items', $data ); 1358 1334 } 1359 1335 … … 1824 1800 1825 1801 /** 1802 * Category Add 1803 * 1826 1804 * @param array $a2cData Data 1827 1805 * 1828 1806 * @return array 1829 1807 */ 1830 public function categoryAdd(array $a2cData) 1831 { 1808 public function categoryAdd(array $a2cData) { 1832 1809 $response = array( 1833 1810 'error_code' => self::ERROR_CODE_SUCCESS, … … 1866 1843 unset($postParams['a2c_sign']); 1867 1844 $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']; 1869 1846 1870 1847 // Add Post Params for WPML … … 1879 1856 'headers' => [ 1880 1857 'Accept-Language:*', 1881 'User-Agent:' . $_SERVER['HTTP_USER_AGENT'],1858 'User-Agent:' . sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ), 1882 1859 ], 1883 1860 'body' => $postParams, … … 1900 1877 1901 1878 /** 1879 * Category Update 1880 * 1902 1881 * @param array $a2cData Data 1903 1882 * 1904 1883 * @return array 1905 1884 */ 1906 public function categoryUpdate(array $a2cData) 1907 { 1885 public function categoryUpdate(array $a2cData) { 1908 1886 $response = array( 1909 1887 'error_code' => self::ERROR_CODE_SUCCESS, … … 1945 1923 1946 1924 /** 1925 * Category Delete 1926 * 1947 1927 * @param array $a2cData Data 1948 1928 * 1949 1929 * @return array 1950 1930 */ 1951 public function categoryDelete(array $a2cData) 1952 { 1931 public function categoryDelete(array $a2cData) { 1953 1932 $response = array( 1954 1933 'error_code' => self::ERROR_CODE_SUCCESS, -
api2cart-bridge-connector/trunk/connectorMain.php
r2978736 r2984218 5 5 Author: API2Cart 6 6 Author URI: https://api2cart.com/ 7 Version: 2. 1.07 Version: 2.2.0 8 8 */ 9 10 /* 11 Api2Cart Bridge Connector is free software: you can redistribute it and/or modify 12 it under the terms of the GNU General Public License as published by 13 the Free Software Foundation, either version 2 of the License, or 14 any later version. 15 16 Api2Cart Bridge Connector is distributed in the hope that it will be useful, 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 GNU General Public License for more details. 20 21 You should have received a copy of the GNU General Public License 22 along with Api2Cart Bridge Connector. If not, see https://www.gnu.org/licenses/gpl-2.0.html. 23 */ 24 9 25 defined( 'ABSPATH' ) || die( 'Cannot access pages directly.' ); 10 26 define( 'A2CBC_BRIDGE_IS_CUSTOM_OPTION_NAME', 'A2C_woocommerce_bridge_connector_is_custom' ); … … 158 174 wp_enqueue_style( 'connector-css', plugins_url( 'css/style.css', __FILE__ ) , [], $theme_version ); 159 175 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' ))); 160 178 161 179 $showButton = 'install'; -
api2cart-bridge-connector/trunk/css/style.css
r2722470 r2984218 23 23 } 24 24 25 .bridge .container{25 .bridge--container{ 26 26 background: #fff; 27 27 border: 1px solid #e1e1e1; … … 32 32 33 33 .bridge .store-key{ 34 display: none;34 visibility: hidden; 35 35 } 36 36 … … 49 49 } 50 50 51 .connectormessage { 52 display: none; 53 opacity: 0.9; 51 .bridge--connectormessage { 54 52 position: absolute; 55 53 background: #2876c4; … … 62 60 font-size: 14px; 63 61 } 64 . connectormessage.bridge_error { background: #F05657; }65 66 . clearfix:after {62 .bridge--connectormessage.bridge_error { background: #F05657; } 63 64 .bridge--clearfix:after { 67 65 content: ""; 68 66 visibility: hidden; -
api2cart-bridge-connector/trunk/js/scripts.js
r2927081 r2984218 1 jQuery(document).ready(function($) {2 1 3 var SELF_PATH = 'admin-ajax.php'; 2 document.addEventListener('DOMContentLoaded', function() { 4 3 5 var messages = $('#messages');4 var messages = document.getElementById('messages'); 6 5 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'); 9 8 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'); 18 17 19 18 var timeDelay = 500; 20 19 21 var bridgeConnectionInstall = $("#bridgeConnectionInstall");22 var bridgeConnectionUninstall = $("#bridgeConnectionUninstall");20 var bridgeConnectionInstall = document.getElementById('bridgeConnectionInstall'); 21 var bridgeConnectionUninstall = document.getElementById('bridgeConnectionUninstall'); 23 22 24 var updateBridgeStoreKey = $('#updateBridgeStoreKey'); 23 var updateBridgeStoreKey = document.getElementById('updateBridgeStoreKey'); 24 classMessage.style.opacity = '0'; 25 classMessage.style.visibility = 'hidden'; 25 26 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'; 33 37 } 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'; 40 47 } 41 48 42 49 function statusMessage(message, status) { 43 var timeout = 3000;50 var timeout = 2500; 44 51 45 52 if (status == 'success') { 46 classMessage. removeClass('bridge_error');53 classMessage.classList.remove('bridge_error'); 47 54 } else { 48 classMessage. addClass('bridge_error');49 timeout = 5000;55 classMessage.classList.add('bridge_error'); 56 timeout = timeout; 50 57 } 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 54 66 var messageClear = setTimeout(function(){ 55 classMessage. html('');67 classMessage.innerHTML = ''; 56 68 }, timeout); 57 69 clearTimeout(messageClear); 58 70 } 59 71 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 } 68 82 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); 81 91 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'); 86 136 } 137 } else { 138 statusMessage('Can\'t install Connector', 'error'); 139 } 140 }; 87 141 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'); 122 143 }); 123 144 }); 124 145 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'); 138 155 return; 139 156 } 140 157 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'); 142 161 } 143 }); 162 }; 163 164 xhr.send('action=A2CBCbridge_action&connector_action=updateToken'); 144 165 }); 145 166 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 }); 148 192 } 149 193 -
api2cart-bridge-connector/trunk/readme.txt
r2978736 r2984218 69 69 = 2.0.4 =* Fix plugin settings link. 70 70 = 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 1 1 <div class="bridge"> 2 <div class=" connectormessage"></div>2 <div class="bridge--connectormessage"></div> 3 3 4 4 5 <div class=" container">5 <div class="bridge--container"> 6 6 7 7 <div class="text-center"> … … 44 44 </table> 45 45 </div> 46 <div class=" clearfix"></div>46 <div class="bridge--clearfix"></div> 47 47 </div> 48 48 -
api2cart-bridge-connector/trunk/worker.php
r2941862 r2984218 122 122 preg_match( "/define\('(\w+)',\s*'([^']+)'\);/", file_get_contents( $this->bridgePath . $this->configFilePath ), $matches ); 123 123 124 if ( $matches[2] != $storeKey ) {124 if ( isset( $matches[2] ) && $matches[2] != $storeKey ) { 125 125 $this->updateToken( $storeKey ); 126 126 } … … 197 197 $url = $this->bridgeUrl . '?' . $query; 198 198 199 if ( wp_http_supports( array( 'ssl' ) ) ) { 200 $url = set_url_scheme( $url, 'https' ); 201 } 202 199 203 if ( $isHttp ) { 200 $url = s tr_replace( 'https://', 'http://', $url);204 $url = set_url_scheme( $url, 'http' ); 201 205 } 202 206 … … 206 210 'timeout' => 30, 207 211 'redirection' => 5, 208 'httpversion' => '1.0',209 'sslverify' => false,210 212 'blocking' => true, 211 213 'headers' => $headers,
Note: See TracChangeset
for help on using the changeset viewer.