Changeset 3440612
- Timestamp:
- 01/15/2026 09:06:35 PM (2 months ago)
- Location:
- shipo/trunk
- Files:
-
- 8 edited
-
assets/js/admin.js (modified) (1 diff)
-
assets/js/checkout.js (modified) (2 diffs)
-
assets/js/map.js (modified) (1 diff)
-
includes/class-shipo-ajax.php (modified) (1 diff)
-
includes/class-shipo-settings-fields.php (modified) (1 diff)
-
includes/class-shipo-wc-shipping.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
shipo.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shipo/trunk/assets/js/admin.js
r3395057 r3440612 47 47 var mapType = el.data('map-type'); 48 48 var mapSlug = el.data('map-slug'); 49 // var mapCoord = '46.7725790000,23.5953730000'; 50 initMap(mapType, mapSlug); 49 var mapCoord = el.data('map-coord'); 50 51 initMapAdmin(mapType, mapSlug, mapCoord); 51 52 }) 53 54 /** 55 * Generate map from Shipo 56 * @param {*} recipientType @param {*} recipientSlug @param {*} recipientCoord 57 */ 58 59 function initMapAdmin(recipientType, recipientSlug, recipientCoord) { 60 jQuery('<iframe>', { 61 id: 'mapFrame', 62 src: '', 63 }).appendTo('body').hide(); 64 65 jQuery.ajax({ 66 url: shipoAjax.ajaxurl, 67 method: 'POST', 68 dataType: 'json', 69 data: { 70 action: 'shipo_get_map', 71 recipient_slug: recipientSlug, 72 recipient_type: recipientType, 73 recipient_coord: recipientCoord, 74 shipo_nonce: shipoAjax.nonce 75 }, 76 success: function(response) { 77 if (response.success) { 78 var mapUrl = response.data.url // Assuming response.data contains the map URL 79 jQuery("#mapFrame").attr("src", mapUrl); 80 jQuery("#mapFrame").show(); 81 82 // trimiteComandaCatreIframe(); 83 } 84 } 85 }); 86 } 52 87 53 88 -
shipo/trunk/assets/js/checkout.js
r3415749 r3440612 18 18 if (cityValue.length >= 3) { 19 19 $.ajax({ 20 url: shipoAjax.ajaxurl,20 url: '/wp-json/shipo/v1/get-cities', 21 21 method: 'POST', 22 dataType: 'json', 22 23 data: { 23 action: 'shipo_get_cities',24 24 city: cityValue, 25 25 shipo_nonce: shipoAjax.nonce … … 149 149 if (streetValue.length >= 3) { 150 150 $.ajax({ 151 url: shipoAjax.ajaxurl,151 url: '/wp-json/shipo/v1/get-address', 152 152 method: 'POST', 153 dataType: 'json', 153 154 data: { 154 action: 'shipo_get_address',155 155 city: cityValue, 156 156 address: streetValue, -
shipo/trunk/assets/js/map.js
r3404077 r3440612 11 11 12 12 jQuery.ajax({ 13 url: shipoAjax.ajaxurl,13 url: '/wp-json/shipo/v1/get-map', 14 14 method: 'POST', 15 15 dataType: 'json', 16 16 data: { 17 action: 'shipo_get_map',18 17 recipient_slug: recipientSlug, 19 18 recipient_type: recipientType, -
shipo/trunk/includes/class-shipo-ajax.php
r3395057 r3440612 4 4 */ 5 5 class Shipo_Ajax { 6 7 private static $instance = 'shipo'; 8 6 9 /** 7 10 * Constructor 8 11 */ 9 12 public function __construct() { 10 add_action('wp_ajax_shipo_get_cities', array($this, 'get_cities')); 11 add_action('wp_ajax_nopriv_shipo_get_cities', array($this, 'get_cities')); 12 13 add_action('wp_ajax_shipo_get_address', array($this, 'get_address')); 14 add_action('wp_ajax_nopriv_shipo_get_address', array($this, 'get_address')); 15 16 add_action('wp_ajax_shipo_get_map', array($this, 'get_map')); 17 add_action('wp_ajax_nopriv_shipo_get_map', array($this, 'get_map')); 18 19 add_action('wp_ajax_shipo_set_coord', array($this, 'set_coord')); 20 add_action('wp_ajax_nopriv_shipo_set_coord', array($this, 'set_coord')); 13 add_action('rest_api_init', array($this, 'register_rest_routes')); 21 14 22 15 add_action('wp_ajax_shipo_generate_awb', array($this, 'generate_awb')); 23 16 17 add_action('wp_ajax_shipo_get_map', array($this, 'get_map')); 18 24 19 add_action('wp_ajax_shipo_report_awb', array($this, 'report_awb')); 25 20 26 21 add_action('wp_ajax_shipo_print_download_awb', array($this, 'print_download_awb')); 27 22 } 23 24 /** 25 * Register REST routes for the plugin 26 */ 27 public function register_rest_routes() { 28 // Define route configuration with versioning support 29 $routes = [ 30 'v1' => [ 31 '/get-cities' => [ 32 'methods' => 'POST', 33 'callback' => [$this, 'get_cities'], 34 'permission_callback' => '__return_true', 35 'args' => [ 36 'city' => [ 37 'required' => true, 38 'sanitize_callback' => 'sanitize_text_field' 39 ], 40 'shipo_nonce' => [ 41 'required' => true, 42 'sanitize_callback' => 'sanitize_text_field' 43 ] 44 ] 45 ], 46 '/get-address' => [ 47 'methods' => 'POST', 48 'callback' => [$this, 'get_address'], 49 'permission_callback' => '__return_true', 50 'args' => [ 51 'address' => [ 52 'required' => true, 53 'sanitize_callback' => 'sanitize_text_field' 54 ], 55 'city' => [ 56 'required' => true, 57 'sanitize_callback' => 'sanitize_text_field' 58 ], 59 'shipo_nonce' => [ 60 'required' => true, 61 'sanitize_callback' => 'sanitize_text_field' 62 ] 63 ] 64 ], 65 '/get-map' => [ 66 'methods' => 'POST', 67 'callback' => [$this, 'get_map'], 68 'permission_callback' => '__return_true', 69 'args' => [ 70 'recipient_slug' => [ 71 'required' => true, 72 'sanitize_callback' => 'sanitize_text_field' 73 ], 74 'recipient_type' => [ 75 'required' => true, 76 'sanitize_callback' => 'sanitize_text_field' 77 ], 78 'recipient_coord' => [ 79 'required' => true, 80 'sanitize_callback' => 'sanitize_text_field' 81 ], 82 'shipo_nonce' => [ 83 'required' => true, 84 'sanitize_callback' => 'sanitize_text_field' 85 ] 86 ] 87 ], 88 ] 89 ]; 90 91 // Register all routes, handling versions 92 foreach ($routes as $version => $version_routes) { 93 foreach ($version_routes as $route => $args) { 94 $namespace = self::$instance . '/' . $version; 95 register_rest_route($namespace, $route, $args); 96 } 97 } 98 } 28 99 29 100 /** 30 101 * Get cities 31 102 */ 32 public function get_cities() { 103 public function get_cities() { 33 104 // Checks nonce for security 34 105 if (!isset($_POST['shipo_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['shipo_nonce'])), 'shipo_nonce_action')) { -
shipo/trunk/includes/class-shipo-settings-fields.php
r3395057 r3440612 229 229 $html .= '</div>'; 230 230 } 231 232 $coord = [44.9809810000, 26.0196120000]; 231 233 232 234 $html .= '</div>'; 233 $html .= '<button class="button alt" type="button" data-map-type="locker" data-map-slug="' . esc_attr($courier_slug) . '" ' . ($courier_selected == 'disabled' ? 'disabled="disabled"' : '') . '>' . esc_html__('Select locker', 'shipo') . '</button>'; 235 $html .= '<button ' 236 . 'class="button alt" ' 237 . 'type="button" ' 238 . 'data-map-type="locker" ' 239 . 'data-map-coord="' . implode(',', $coord) . '" ' 240 . 'data-map-slug="' . esc_attr($courier_slug) . '" ' . ($courier_selected == 'disabled' ? 'disabled="disabled"' : '') . '>' . esc_html__('Select locker', 'shipo') 241 . '</button>'; 234 242 $html .= '</div>'; 235 243 } -
shipo/trunk/includes/class-shipo-wc-shipping.php
r3415749 r3440612 103 103 'data-map-type' => array(), 104 104 'data-map-slug' => array(), 105 'data-map-coord' => array(), 105 106 ), 106 107 'img' => array( -
shipo/trunk/readme.txt
r3415749 r3440612 4 4 Requires at least: 4.7 5 5 Tested up to: 6.9 6 Stable tag: 1. 47 Requires PHP: 8.06 Stable tag: 1.5 7 Requires PHP: 7.4 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 59 59 Checkout page improvements: 60 60 - Allows users to manually enter a street name in the free text field if the street is not found in the suggestions dropdown list 61 62 = 1.5 = 63 64 - Changes have been made to ensure this version can run properly on PHP 7.4+, providing compatibility and stable performance in PHP 7.4+ environments. -
shipo/trunk/shipo.php
r3415749 r3440612 3 3 * Plugin Name: Shipo 4 4 * Description: Shipo connects your webshop with top couriers instantly, no contract. Ship to address or locker, pay only when parcels are delivered. 5 * Version: 1. 45 * Version: 1.5 6 6 * Author: Shipo 7 7 * Author URI: https://shipo.ro … … 16 16 17 17 // Define plugin constants 18 define('SHIPO_PLUGIN_VERSION', '1. 4.0');18 define('SHIPO_PLUGIN_VERSION', '1.5.0'); 19 19 define('SHIPO_PLUGIN_DIR', plugin_dir_path(__FILE__)); 20 20 define('SHIPO_PLUGIN_URL', plugin_dir_url(__FILE__));
Note: See TracChangeset
for help on using the changeset viewer.