From 0dc3f4b01d7312de969d234a9a409ba8ab28b4c3 Mon Sep 17 00:00:00 2001 From: Timo Date: Wed, 27 Dec 2017 15:42:13 +0100 Subject: [PATCH] versioning --- includes/wcwuunder-create.php | 30 +++++++++++++++++++++--------- woocommerce-wuunder.php | 4 ++-- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/includes/wcwuunder-create.php b/includes/wcwuunder-create.php index f7aaf0d..0b45898 100644 --- a/includes/wcwuunder-create.php +++ b/includes/wcwuunder-create.php @@ -6,7 +6,7 @@ class WC_Wuunder_Create { public $order_id; - private $version_obj = array("product" => "Woocommerce extension", "version" => array("build" => "2.1.2", "plugin" => "2.0")); + private $version_obj = array("product" => "Woocommerce extension", "version" => array("build" => "2.2.0", "plugin" => "2.0")); public function __construct() { @@ -77,9 +77,7 @@ private function buildWuunderData($orderId) if ($dimensions === null) { $dimensions = explode(' x ', $item['dimensions']); } -// if ($description === null) { - $description .= "- " . $item['name'] . "\r\n"; -// } + $description .= "- " . $item['quantity'] . "x " . $item['name'] . "\r\n"; } if ($totalWeight === 0) { @@ -327,23 +325,37 @@ public function get_customer_address($orderid, $phone) } - public function get_base64_image($picture) + public function get_base64_image($imagepath) { - - $imagepath = $picture; try { - if (filesize($imagepath) <= 2097152) { //smaller or equal to 2MB + $fileSize = (substr($imagepath, 0, 4) === "http") ? $this->remote_filesize($imagepath) : filesize($imagepath); + if ($fileSize <= 2097152) { //smaller or equal to 2MB $imagedata = file_get_contents($imagepath); $image = base64_encode($imagedata); } else { $image = ""; } return $image; - }catch(Exception $e) { + } catch (Exception $e) { return ""; } } + private function remote_filesize($url) + { + static $regex = '/^Content-Length: *+\K\d++$/im'; + if (!$fp = @fopen($url, 'rb')) { + return false; + } + if ( + isset($http_response_header) && + preg_match($regex, implode("\n", $http_response_header), $matches) + ) { + return (int)$matches[0]; + } + return strlen(stream_get_contents($fp)); + } + public function add_listing_actions($order) { diff --git a/woocommerce-wuunder.php b/woocommerce-wuunder.php index 6ec0ba2..12c9ba3 100644 --- a/woocommerce-wuunder.php +++ b/woocommerce-wuunder.php @@ -3,7 +3,7 @@ * Plugin Name: WooCommerce Wuunder * Plugin URI: http://wearewuunder.com * Description: Wuunder shipping plugin - * Version: 2.1.2 + * Version: 2.2.0 * Author: Wuunder * Author URI: http://wearewuunder.com */ @@ -49,7 +49,7 @@ class Woocommerce_Wuunder public static $plugin_path; public static $plugin_basename; - const VERSION = '2.1.2'; + const VERSION = '2.2.0'; public function __construct() {