Plugin Directory

Changeset 3363232


Ignore:
Timestamp:
09/17/2025 01:14:13 PM (6 months ago)
Author:
UkrSolution
Message:

3.4.12

Location:
a4-barcode-generator/trunk
Files:
10 added
9 deleted
20 edited

Legend:

Unmodified
Added
Removed
  • a4-barcode-generator/trunk/barcode_generator.php

    r3204983 r3363232  
    44Description: Create and Print barcodes on label sheets using a printer. Best tool to make inventory of your stock.
    55Text Domain: wpbcu-barcode-generator
    6 Version: 3.4.11
     6Version: 3.4.12
    77Author: UkrSolution
    88Plugin URI: https://www.ukrsolution.com/Joomla/A4-BarCode-Generator-For-Wordpress
     
    1010License: GPL2
    1111WC requires at least: 4.0.0
    12 -WC tested up to: 9.4.*
     12-WC tested up to: 10.1.*
    1313 */
    1414
     
    126126
    127127        $lastVersion = get_option("active-print-barcodes-version", "");
    128         if ($lastVersion !== "3.4.11") {
     128        if ($lastVersion !== "3.4.12") {
    129129            UkrSolution\ProductLabelsPrinting\Database::createTables();
    130             update_option("active-print-barcodes-version", "3.4.11");
     130            update_option("active-print-barcodes-version", "3.4.12");
    131131        }
    132132    });
  • a4-barcode-generator/trunk/class/BarcodeTemplates/BarcodeView.php

    r3083367 r3363232  
    4040
    4141        $barcodeGenerator = new Generator();
    42         echo esc_html($barcodeGenerator->getGeneratedBarcodeSVGFileName($this->code, $this->algorithm, $w, $h, 'black', true));
     42        echo $barcodeGenerator->getGeneratedBarcodeSVGFileName($this->code, $this->algorithm, $w, $h, 'black', true);
    4343    }
    4444}
  • a4-barcode-generator/trunk/class/Core.php

    r3204983 r3363232  
    33namespace UkrSolution\ProductLabelsPrinting;
    44
     5use UkrSolution\ProductLabelsPrinting\Makers\WoocommercePostsA4BarcodesMaker;
    56use UkrSolution\ProductLabelsPrinting\Api\PostsData;
    67use UkrSolution\ProductLabelsPrinting\BarcodeTemplates\BarcodeTemplatesController;
    78use UkrSolution\ProductLabelsPrinting\BarcodeTemplates\BarcodeView;
    8 use UkrSolution\ProductLabelsPrinting\Cart\BarcodeCart;
    99use UkrSolution\ProductLabelsPrinting\Filters\Items;
    1010use UkrSolution\ProductLabelsPrinting\Generators\BarcodeImage;
     
    1212use UkrSolution\ProductLabelsPrinting\Helpers\UserSettings;
    1313use UkrSolution\ProductLabelsPrinting\Helpers\Variables;
    14 use UkrSolution\ProductLabelsPrinting\Makers\A4BarcodesMaker;
    1514use UkrSolution\ProductLabelsPrinting\Makers\ManualA4BarcodesMaker;
    1615use UkrSolution\ProductLabelsPrinting\Makers\TestA4BarcodesMaker;
     
    2423    protected $dimensions;
    2524    protected $updater;
     25    protected $woocommerceBarcodesMakerInstance;
    2626
    2727    public function __construct()
     
    3535        add_action('init', function() {
    3636            $this->config = require Variables::$A4B_PLUGIN_BASE_PATH . 'config/config.php';
     37            $this->woocommerceBarcodesMakerInstance = new WoocommercePostsA4BarcodesMaker(array());
    3738        }, 1);
    3839
     
    379380        }
    380381
    381         wp_register_style('import_categories_button_demo', Variables::$A4B_PLUGIN_BASE_URL . 'templates/actions-assets/style.css', false, '3.4.11');
     382        wp_register_style('import_categories_button_demo', Variables::$A4B_PLUGIN_BASE_URL . 'templates/actions-assets/style.css', false, '3.4.12');
    382383        wp_enqueue_style('import_categories_button_demo');
    383384
     
    390391        global $current_user;
    391392
    392         wp_enqueue_script("barcode_loader_print", Variables::$A4B_PLUGIN_BASE_URL."assets/js/index-3.4.11-f114ea43.js", array("jquery"), null, true);
    393 wp_enqueue_script("barcode_api_print", Variables::$A4B_PLUGIN_BASE_URL."assets/js/api-3.4.11-f114ea43.js", array("jquery"), null, true);
    394 wp_enqueue_style("barcode_core_css_print", Variables::$A4B_PLUGIN_BASE_URL."public/dist/css/app_demo_3.4.11-f114ea43.css", null, null);$appJsPath = Variables::$A4B_PLUGIN_BASE_URL."public/dist/js/app_demo_3.4.11-f114ea43.js";
    395 $vendorJsPath = Variables::$A4B_PLUGIN_BASE_URL."public/dist/js/chunk-vendors_demo_3.4.11-f114ea43.js";
    396 $jszip = Variables::$A4B_PLUGIN_BASE_URL."assets/js/jszip.min-3.4.11-f114ea43.js";
     393        wp_enqueue_script("barcode_loader_print", Variables::$A4B_PLUGIN_BASE_URL."assets/js/index-3.4.12-4807abb8.js", array("jquery"), null, true);
     394wp_enqueue_script("barcode_api_print", Variables::$A4B_PLUGIN_BASE_URL."assets/js/api-3.4.12-4807abb8.js", array("jquery"), null, true);
     395wp_enqueue_style("barcode_core_css_print", Variables::$A4B_PLUGIN_BASE_URL."public/dist/css/app_demo_3.4.12-4807abb8.css", null, null);$appJsPath = Variables::$A4B_PLUGIN_BASE_URL."public/dist/js/app_demo_3.4.12-4807abb8.js";
     396$vendorJsPath = Variables::$A4B_PLUGIN_BASE_URL."public/dist/js/chunk-vendors_demo_3.4.12-4807abb8.js";
     397$jszip = Variables::$A4B_PLUGIN_BASE_URL."assets/js/jszip.min-3.4.12-4807abb8.js";
    397398
    398399
     
    458459        }
    459460
    460         $active_template->shortcodes = A4BarcodesMaker::getTemplateShortcodes($active_template->template);
     461        $active_template->shortcodes = array();
     462        $this->woocommerceBarcodesMakerInstance->extractTemplateShortcodes($active_template->template, $active_template->shortcodes);
    461463
    462464        $mainConfig = array(
     
    465467            'websiteUrl' => get_bloginfo("url"),
    466468            'adminUrl' => get_admin_url(),
    467             'pluginVersion' => '3.4.11',
     469            'pluginVersion' => '3.4.12',
    468470            'isWoocommerceActive' => is_plugin_active('woocommerce/woocommerce.php'),
    469471            'isCF7Active' => is_plugin_active('contact-form-7/wp-contact-form-7.php'),
     
    618620
    619621        $barcodes = [
    620             'isLatest' => (int) version_compare('3.4.11', $lastReleaseData['version'], '>='),
     622            'isLatest' => (int) version_compare('3.4.12', $lastReleaseData['version'], '>='),
    621623            'latest' => $lastReleaseData['version'],
    622             'version' => '3.4.11',
     624            'version' => '3.4.12',
    623625            'downloadUrl' => $lastReleaseData['url'],
    624626            'pluginUrl' => Variables::$A4B_PLUGIN_BASE_URL,
     
    668670            }
    669671
    670             $template->shortcodes = A4BarcodesMaker::getTemplateShortcodes($template->template);
     672
     673            $template->shortcodes = array();
     674            $this->woocommerceBarcodesMakerInstance->extractTemplateShortcodes($template->template, $template->shortcodes);
    671675        }
    672676
     
    703707    {
    704708        if ('BASIC' !== Variables::$A4B_PLUGIN_PLAN) {
    705             wp_enqueue_script('barcode_template_preview', Variables::$A4B_PLUGIN_BASE_URL . 'assets/js/barcode_template_preview-3.4.11-f114ea43.js', array('jquery'), null, true);
     709            wp_enqueue_script('barcode_template_preview', Variables::$A4B_PLUGIN_BASE_URL . 'assets/js/barcode_template_preview-3.4.12-4807abb8.js', array('jquery'), null, true);
    706710            wp_localize_script('barcode_templates', 'a4bBarcodeTemplates', array('pluginUrl' => Variables::$A4B_PLUGIN_BASE_URL));
    707711
  • a4-barcode-generator/trunk/class/Database.php

    r2985149 r3363232  
    178178            `params` LONGTEXT DEFAULT NULL,
    179179            `barcodeRotate` tinyint(1) DEFAULT 0,
     180            `sortAlphabetically` tinyint(1) DEFAULT 0,
    180181            `fontSize` varchar(255) DEFAULT '',
    181182            `fontAlgorithm` varchar(255) DEFAULT 'auto',
  • a4-barcode-generator/trunk/class/Generators/BarcodeImage.php

    r3083367 r3363232  
    6969    public function parseHash($hash, $fileData = array())
    7070    {
     71        if (!function_exists("imagecreate")) {
     72            echo "GD not even installed.";
     73            return;
     74        }
     75
    7176        $customTemplates = new BarcodeTemplatesController();
    7277
     
    161166            $svg = $barcodeGenerator->getGeneratedBarcodeSVGFileName($code, $algorithm, $barcodeWidth, $barcodeHeight, 'black', true);
    162167            $svg2png = SVG::fromString($svg);
    163             $png = $svg2png->toRasterImage($barcodeWidth, $barcodeHeight);
     168            $png = $svg2png->toRasterImage((int) $barcodeWidth, (int) $barcodeHeight);
    164169
    165170            Variables::initCodes($this, array(
     
    170175
    171176            if ($width && $height) {
    172                 $image = $this->createImage($width, $height);
     177                $image = $this->createImage((int) $width, (int) $height);
    173178            } else {
    174                 $image = $this->createImage($template->width, $template->height);
     179                $image = $this->createImage((int) $template->width, (int) $template->height);
    175180            }
    176181
     
    278283        }
    279284
    280         imagecopymerge($image, $barcode, $x, $y, 0, 0, $barcodeWidth, $barcodeHeight, 100);
     285        imagecopymerge($image, $barcode, (int)$x, (int)$y, 0, 0, (int)$barcodeWidth, (int)$barcodeHeight, 100);
    281286    }
    282287
     
    336341        $x = $position['x'];
    337342        $y = $position['y'] > 0 ? $this->zoomY * $position['y'] : $position['y'];
    338         imagettftext($image, $fontSize, 0, $x, $y, $textColor, $font, $text);
     343        imagettftext($image, $fontSize, 0, (int)$x, (int)$y, $textColor, $font, $text);
     344
    339345    }
    340346
  • a4-barcode-generator/trunk/class/Makers/A4BarcodesMaker.php

    r3204983 r3363232  
    467467            'product-all-parent-attributes',
    468468            'variation-all-attr',
     469            'variation-all-attr-with-names',
    469470            'product-all-attr',
    470471            'product_id_prefix',
     
    486487            'atum-order-supplier-name',
    487488            'atum-order-supplier-code',
     489            'atum-product-location',
    488490
    489491            'pbet-product-expire-date',
     
    497499
    498500            'woo-booking_item-booking-date',
     501
     502            'dokan-vendor-name'
    499503        );
    500504
     
    579583    }
    580584
    581     public static function getTemplateShortcodes($template)
    582     {
    583         $shortcodesArgs = array();
    584         $barcodesGenerator = new WoocommercePostsA4BarcodesMaker(array());
    585         $barcodesGenerator->extractTemplateShortcodes($template, $shortcodesArgs);
    586 
    587         return $shortcodesArgs;
    588     }
    589585}
  • a4-barcode-generator/trunk/class/Makers/WoocommercePostsA4BarcodesMakerFull.php

    r3204983 r3363232  
    137137        if ($this->type === "orders") {
    138138            $this->items = $this->getItemsByOrders();
     139
     140            if (!empty($this->data['existingIds'])) {
     141                $this->data['ordersIds'] = $this->data['existingIds'];
     142                $existingItems = $this->getItemsByOrders();
     143            }
    139144        } elseif ($this->type === "order-products") {
    140145            $this->items = $this->getItemsByOrderProducts();
     146
     147            if (!empty($this->data['existingIds'])) {
     148                $existingItems = uswbg_a4bGetPosts(array('post__in' => $this->data['existingIds'], 'post_type' => array('product', 'product_variation')));
     149            }
    141150        } elseif ($this->type === "products") {
    142151            $this->items = $this->getItemsByProducts();
     152
     153            if (!empty($this->data['existingIds'])) {
     154                $existingItems = uswbg_a4bGetPosts(array('post__in' => $this->data['existingIds'], 'post_type' => array('product', 'product_variation')));
     155            }
    143156        } elseif ($this->type === "atum-po-order-products") {
    144157            $this->items = $this->getItemsByAtumPoOrderProducts();
     
    148161            $getItemsMethod = $this->getItemsMethods[$forCategories][$withVariations];
    149162            $this->items = $this->$getItemsMethod();
    150         }
    151 
     163
     164            if (!empty($this->data['existingIds'])) {
     165                $existingItems = uswbg_a4bGetPosts(array('post__in' => $this->data['existingIds'], 'post_type' => array('product', 'product_variation')));
     166            }
     167        }
     168
     169        if (!empty($this->data['sortAlphabetically']) && '1' === $this->data['sortAlphabetically']) {
     170
     171            if (!empty($this->data['existingIds']) && !empty($existingItems)) {
     172                $this->items = array_merge(
     173                    $this->duplicatePostsByGivenIds(
     174                        $existingItems,
     175                        $this->data['existingIds']
     176                    ),
     177                    $this->items
     178                );
     179            }
     180
     181            $this->items = $this->sortByTitle($this->items);
     182        }
     183
     184    }
     185
     186    protected function duplicatePostsByGivenIds($posts, $ids, $field = 'ID')
     187    {
     188        $counts = array_count_values($ids);
     189
     190        $objectMap = [];
     191        foreach ($posts as $object) {
     192            $objectMap[$object->$field][] = $object;
     193        }
     194
     195        $newObjects = $posts;
     196
     197        foreach ($counts as $value => $requiredCount) {
     198            if (isset($objectMap[$value])) {
     199                $existingCount = count($objectMap[$value]);
     200                while ($existingCount < $requiredCount) {
     201                    $duplicate = $objectMap[$value][0];
     202                    $newObjects[] = $duplicate;
     203                    $existingCount++;
     204                }
     205            }
     206        }
     207
     208        return $newObjects;
    152209    }
    153210
    154211    protected function getItemsForCategoriesWithVariations()
    155212    {
    156         $productsCategories = isset($this->data['productsCategories']) ? $this->data['productsCategories'] : null;
     213        $productsCategories = isset($this->data['productsCategories']) ? $this->data['productsCategories'] : array();
    157214
    158215        $products = $this->getProductsByCategoriesFilteredByProductsStatus($productsCategories);
     
    166223    protected function getItemsForCategories()
    167224    {
    168         $productsCategories = isset($this->data['productsCategories']) ? $this->data['productsCategories'] : null;
     225        $productsCategories = isset($this->data['productsCategories']) ? $this->data['productsCategories'] : array();
    169226
    170227        return $this->getProductsByCategoriesFilteredByProductsStatus($productsCategories);
     
    183240                'fields' => 'id=>parent',
    184241            ));
     242
    185243            $parentsIdsOfVariationsByGivenProductsIds = wp_list_pluck($variationsByGivenProductsIds, 'post_parent');
    186244            $actualProductsIdsOfVariationsByGivenProductsIds = uswbg_a4bGetPosts(array(
     
    188246                'post_status' => array('publish', 'pending', 'draft', 'future', 'private', 'inherit', 'trash'),
    189247                'post__in' => empty($parentsIdsOfVariationsByGivenProductsIds) ? array(0) : array_values($parentsIdsOfVariationsByGivenProductsIds),
    190                 'posts_per_page' => -1,
    191248                'fields' => 'ids',
    192                 'suppress_filters' => true,
    193                 'lang' => 'all',
    194249            ));
    195250
     
    225280    protected function getItemsForProducts()
    226281    {
    227         $productsIds = isset($this->data['productsIds']) ? $this->data['productsIds'] : null;
     282        $productsIds = isset($this->data['productsIds']) ? $this->data['productsIds'] : array();
    228283        $importType = isset($this->data["isImportSingleVariation"]) ? $this->data["isImportSingleVariation"] : "";
    229284
    230285        if ($importType === "variation") {
    231             $products = uswbg_a4bGetPosts(array('post__in' => $productsIds, 'post_type' => 'product_variation'));
     286            $products = uswbg_a4bGetPosts(array('post__in' => !empty($productsIds) ? $productsIds : array(0), 'post_type' => 'product_variation'));
    232287        } else {
    233288            $products = $this->getProductsByIdsFilteredByProductsStatus($productsIds);
     
    239294    protected function getItemsByProducts()
    240295    {
    241         $productsIds = isset($this->data['productsIds']) ? $this->data['productsIds'] : null;
     296        $productsIds = isset($this->data['productsIds']) ? $this->data['productsIds'] : array();
    242297
    243298        $onlySelectedVariations = !empty($productsIds)
    244299            ? uswbg_a4bGetPosts(array(
    245300                'post_type'       => 'product_variation',
    246                 'post__in' => $productsIds,
     301                'post__in' => !empty($productsIds) ? $productsIds : array(0),
    247302            ))
    248303            : array();
     
    271326    protected function getProductsByIdsFilteredByProductsStatus($productsIds)
    272327    {
    273         $products = uswbg_a4bGetPosts(array('post__in' => $productsIds));
     328        $products = uswbg_a4bGetPosts(array('post__in' => !empty($productsIds) ? $productsIds : array(0)));
    274329
    275330        $productsExcludedByStatus = !empty($this->excludedProdStatusesArr)
     
    286341    {
    287342        $products = uswbg_a4bGetPosts(array(
    288             'post__in' => $productsIds,
     343            'post__in' => !empty($productsIds) ? $productsIds : array(0),
    289344            'tax_query' => array(
    290345                array(
     
    324379
    325380        $productsExcludedByStatus = !empty(UserSettings::getOption('excludedProdStatuses'))
    326             ? uswbg_a4bGetPostsByCategories($productsCategories, explode(',', UserSettings::getOption('excludedProdStatuses')))
     381            ? uswbg_a4bGetPostsByCategories($productsCategories, array('post_status' => explode(',', UserSettings::getOption('excludedProdStatuses'))))
    327382            : array();
    328383
     
    404459            ));
    405460
     461            $orderSimpleProducts = uswbg_a4bGetPosts(array(
     462                'post_type' => 'any',
     463                'post__in' => empty($itemIdToProductIdMap) ? array(0) : array_values($itemIdToProductIdMap),
     464                'orderby' => 'post__in',
     465            ));
     466
    406467            $orderProductsIndexedByPostId = array();
    407468            foreach ($orderProducts as $orderProduct) {
     469                $orderProductsIndexedByPostId[$orderProduct->ID] = $orderProduct;
     470            }
     471            foreach ($orderSimpleProducts as $orderProduct) {
    408472                $orderProductsIndexedByPostId[$orderProduct->ID] = $orderProduct;
    409473            }
     
    826890                $value = $this->getVariationAllAttribute($post, $field);
    827891                break;
     892            case 'variation-all-attr-with-names':
     893                if (!isset($field['args']) || !is_array($field['args'])) {
     894                    $field['args'] = array();
     895                }
     896                $field['args']['show-attr-name'] = 'true';
     897                $value = $this->getVariationAllAttribute($post, $field);
     898                break;
    828899            case 'product_id_prefix':
    829900                $value = $this->getProductIdWithPrefix($post, $field);
     
    857928                $value = $this->getSupplierCode($post, $field);
    858929                break;
     930            case 'atum-product-location':
     931                $value = $this->getAtumProductLocation($post, $field);
     932                break;
    859933            case 'pbet-product-expire-date':
    860934                $value = $this->getPbetProductExpireDate($post, $field);
     
    882956            case 'order-item-consequential-number':
    883957                $value = $this->getOrderItemConsequentialNumber($post, $field);
     958                break;
     959            case 'dokan-vendor-name':
     960                $value = $this->getDokanVendorName($post, $field);
    884961                break;
    885962            default:
     
    9851062
    9861063        return !empty($supplierId) ? get_post_meta($supplierId, '_code', true) : '';
     1064    }
     1065
     1066    protected function getAtumProductLocation($post, $field)
     1067    {
     1068        return $this->termsObjectsToString(get_the_terms($post, 'atum_location'));
    9871069    }
    9881070
     
    10811163    {
    10821164        $separator = isset($field['args']['separator']) ? $field['args']['separator'] : ', ';
     1165        $showLabel = isset($field['args']['show-attr-name']) && 'true' === $field['args']['show-attr-name'];
    10831166        $product = wc_get_product($post->ID);
    10841167
     
    10941177                    if (0 === strpos($metaData->key, 'pa_')) {
    10951178                        $option_term = get_term_by('slug', $attributeValue, $metaData->key);
    1096             $attributeValue = $option_term && ! is_wp_error($option_term) ? str_replace(',', '\\,', $option_term->name) : str_replace(',', '\\,', $attributeValue);
     1179                        $attributeValue = $option_term && ! is_wp_error($option_term) ? str_replace(',', '\\,', $option_term->name) : str_replace(',', '\\,', $attributeValue);
     1180                        $taxonomy = get_taxonomy($metaData->key);
     1181                        $attributeLabel = !empty($taxonomy) ? $taxonomy->labels->singular_name : $metaData->key;
     1182                    } else {
     1183                        $attributeLabel = $metaData->key;
    10971184                    }
    1098                     $allAttrsValues[] = $attributeValue;
     1185                    $allAttrsValues[] = ($showLabel ? $attributeLabel . ': ' : '') . $attributeValue;
    10991186                }
    11001187            }
     
    11101197            $parentNotVariableAttributesOptions = $this->getAttributesOptions($parentNotVariableAttributes);
    11111198
    1112             return implode($separator, array_filter($parentNotVariableAttributesOptions));
     1199            $attributesValues = array();
     1200            foreach ($parentNotVariableAttributesOptions as $attributesOption) {
     1201                $attributesValues[] = ($showLabel ? ($attributesOption['label'] . ': ') : '') . implode($separator, array_filter($attributesOption['options']));
     1202            }
     1203            return implode($separator, $attributesValues);
    11131204        } elseif ('product' === $post->post_type) {
    11141205            if ('variable' === $product->get_type()) {
     
    11181209                $parentNotVariableAttributesOptions = $this->getAttributesOptions($parentNotVariableAttributes);
    11191210
    1120                 return implode($separator, array_filter($parentNotVariableAttributesOptions));
     1211                $attributesValues = array();
     1212                foreach ($parentNotVariableAttributesOptions as $attributesOption) {
     1213                    $attributesValues[] = ($showLabel ? ($attributesOption['label'] . ': ') : '') . implode($separator, array_filter($attributesOption['options']));
     1214                }
     1215                return implode($separator, $attributesValues);
    11211216            } elseif ('simple' === $product->get_type()) {
    11221217                $simpleProductAttributes = $product->get_attributes();
    11231218                $simpleProductAttributesOptions = $this->getAttributesOptions($simpleProductAttributes);
    11241219
    1125                 return implode($separator, array_filter($simpleProductAttributesOptions));
     1220                $attributesValues = array();
     1221                foreach ($simpleProductAttributesOptions as $attributesOption) {
     1222                    $attributesValues[] = ($showLabel ? ($attributesOption['label'] . ': ') : '') . implode($separator, array_filter($attributesOption['options']));
     1223                }
     1224                return implode($separator, $attributesValues);
    11261225            } else {
    11271226                return '';
     
    11351234    {
    11361235        $separator = isset($field['args']['separator']) ? $field['args']['separator'] : ', ';
    1137         $product = wc_get_product($post->ID);
    1138 
    1139         if (empty($product)) {
    1140             return '';
    1141         }
    1142 
    1143         if (isset($post->orderItem)) {
    1144             $allAttrsValues = array();
    1145             foreach ($post->orderItem->get_all_formatted_meta_data('') as $metaData) {
    1146                 if (substr($metaData->key, 0, 1) !== '_') {
    1147                     $attributeValue = $metaData->value;
    1148                     if (0 === strpos($metaData->key, 'pa_')) {
    1149                         $option_term = get_term_by('slug', $attributeValue, $metaData->key);
    1150             $attributeValue = $option_term && ! is_wp_error($option_term) ? str_replace(',', '\\,', $option_term->name) : str_replace(',', '\\,', $attributeValue);
    1151                     }
    1152                     $allAttrsValues[] = $attributeValue;
    1153                 }
    1154             }
    1155 
    1156             return implode($separator, array_filter($allAttrsValues));
    1157         } elseif ('product_variation' === $post->post_type) {
    1158 
    1159             if (!method_exists($product, 'get_variation_attributes')) {
    1160                 return '';
    1161             }
    1162 
    1163             $attrsInfo = $product->get_variation_attributes(false);
    1164             array_walk($attrsInfo, function(&$attribute, $attribute_name) {
    1165                 if (0 === strpos($attribute_name, 'pa_')) {
    1166                     $option_term = get_term_by('slug', $attribute, $attribute_name);
    1167                     $attribute = $option_term && ! is_wp_error($option_term)
    1168                         ? str_replace(',', '\\,', $option_term->name)
    1169                         : str_replace(',', '\\,', $attribute);
    1170                 }
    1171             });
    1172 
    1173             return implode($separator, array_filter($attrsInfo));
    1174         } elseif ('product' === $post->post_type) {
    1175             if ('variable' === $product->get_type()) {
    1176                 $parentNotVariableAttributes = array_filter($product->get_attributes(), function($wcAttribute){
    1177                     return !$wcAttribute->get_variation();
    1178                 });
    1179                 $parentNotVariableAttributesOptions = $this->getAttributesOptions($parentNotVariableAttributes);
    1180 
    1181                 return implode($separator, array_filter($parentNotVariableAttributesOptions));
    1182             } elseif ('simple' === $product->get_type()) {
    1183                 $simpleProductAttributes = $product->get_attributes();
    1184                 $simpleProductAttributesOptions = $this->getAttributesOptions($simpleProductAttributes);
    1185 
    1186                 return implode($separator, array_filter($simpleProductAttributesOptions));
    1187             } else {
    1188                 return '';
    1189             }
    1190         } else {
    1191             return '';
    1192         }
    1193     }
    1194 
    1195     protected function getVariationAllAttribute($post, $field)
    1196     {
    1197         $separator = isset($field['args']['separator']) ? $field['args']['separator'] : ', ';
     1236        $showLabel = isset($field['args']['show-attr-name']) && 'true' === $field['args']['show-attr-name'];
    11981237        $product = wc_get_product($post->ID);
    11991238
     
    12101249                        $option_term = get_term_by('slug', $attributeValue, $metaData->key);
    12111250                        $attributeValue = $option_term && ! is_wp_error($option_term) ? str_replace(',', '\\,', $option_term->name) : str_replace(',', '\\,', $attributeValue);
     1251                        $taxonomy = get_taxonomy($metaData->key);
     1252                        $attributeLabel = !empty($taxonomy) ? $taxonomy->labels->singular_name : $metaData->key;
     1253                    } else {
     1254                        $attributeLabel = $metaData->key;
    12121255                    }
    1213                     $allAttrsValues[] = $attributeValue;
     1256                    $allAttrsValues[] = ($showLabel ? $attributeLabel . ': ' : '') . $attributeValue;
    12141257                }
    12151258            }
     
    12231266
    12241267            $attrsInfo = $product->get_variation_attributes(false);
    1225             array_walk($attrsInfo, function(&$attribute, $attribute_name) {
     1268
     1269            array_walk($attrsInfo, function(&$attribute, $attribute_name) use ($showLabel) {
    12261270                if (0 === strpos($attribute_name, 'pa_')) {
    12271271                    $option_term = get_term_by('slug', $attribute, $attribute_name);
     
    12291273                        ? str_replace(',', '\\,', $option_term->name)
    12301274                        : str_replace(',', '\\,', $attribute);
     1275
     1276                    $taxonomy = get_taxonomy($attribute_name);
     1277                    $attributeLabel = !empty($taxonomy) ? $taxonomy->labels->singular_name : $attribute_name;
     1278                } else {
     1279                    $attributeLabel = $attribute_name;
     1280                }
     1281
     1282                if ($showLabel && !empty($attribute)) {
     1283                    $attribute = $attributeLabel . ': ' . $attribute;
     1284                }
     1285            });
     1286
     1287            return implode($separator, array_filter($attrsInfo));
     1288        } elseif ('product' === $post->post_type) {
     1289            if ('variable' === $product->get_type()) {
     1290                $parentNotVariableAttributes = array_filter($product->get_attributes(), function($wcAttribute){
     1291                    return !$wcAttribute->get_variation();
     1292                });
     1293                $parentNotVariableAttributesOptions = $this->getAttributesOptions($parentNotVariableAttributes);
     1294
     1295                $attributesValues = array();
     1296                foreach ($parentNotVariableAttributesOptions as $attributesOption) {
     1297                    $attributesValues[] = ($showLabel ? ($attributesOption['label'] . ': ') : '') . implode($separator, array_filter($attributesOption['options']));
     1298                }
     1299                return implode($separator, $attributesValues);
     1300            } elseif ('simple' === $product->get_type()) {
     1301                $simpleProductAttributes = $product->get_attributes();
     1302                $simpleProductAttributesOptions = $this->getAttributesOptions($simpleProductAttributes);
     1303
     1304                $attributesValues = array();
     1305                foreach ($simpleProductAttributesOptions as $attributesOption) {
     1306                    $attributesValues[] = ($showLabel ? ($attributesOption['label'] . ': ') : '') . implode($separator, array_filter($attributesOption['options']));
     1307                }
     1308                return implode($separator, $attributesValues);
     1309            } else {
     1310                return '';
     1311            }
     1312        } else {
     1313            return '';
     1314        }
     1315    }
     1316
     1317    protected function getVariationAllAttribute($post, $field)
     1318    {
     1319        $separator = isset($field['args']['separator']) ? $field['args']['separator'] : ', ';
     1320        $showLabel = isset($field['args']['show-attr-name']) && 'true' === $field['args']['show-attr-name'];
     1321        $product = wc_get_product($post->ID);
     1322
     1323        if (empty($product)) {
     1324            return '';
     1325        }
     1326
     1327        if (isset($post->orderItem)) {
     1328            $allAttrsValues = array();
     1329            foreach ($post->orderItem->get_all_formatted_meta_data('') as $metaData) {
     1330                if (substr($metaData->key, 0, 1) !== '_') {
     1331                    $attributeValue = $metaData->value;
     1332                    if (0 === strpos($metaData->key, 'pa_')) {
     1333                        $option_term = get_term_by('slug', $attributeValue, $metaData->key);
     1334                        $attributeValue = $option_term && ! is_wp_error($option_term) ? str_replace(',', '\\,', $option_term->name) : str_replace(',', '\\,', $attributeValue);
     1335                        $taxonomy = get_taxonomy($metaData->key);
     1336                        $attributeLabel = !empty($taxonomy) ? $taxonomy->labels->singular_name : $metaData->key;
     1337                    } else {
     1338                        $attributeLabel = $metaData->key;
     1339                    }
     1340                    $allAttrsValues[] = ($showLabel ? $attributeLabel . ': ' : '') . $attributeValue;
     1341                }
     1342            }
     1343
     1344            return implode($separator, array_filter($allAttrsValues));
     1345        } elseif ('product_variation' === $post->post_type) {
     1346
     1347            if (!method_exists($product, 'get_variation_attributes')) {
     1348                return '';
     1349            }
     1350
     1351            $attrsInfo = $product->get_variation_attributes(false);
     1352            array_walk($attrsInfo, function(&$attribute, $attribute_name) use ($showLabel) {
     1353                if (0 === strpos($attribute_name, 'pa_')) {
     1354                    $option_term = get_term_by('slug', $attribute, $attribute_name);
     1355                    $attribute = $option_term && ! is_wp_error($option_term)
     1356                        ? str_replace(',', '\\,', $option_term->name)
     1357                        : str_replace(',', '\\,', $attribute);
     1358
     1359                    $taxonomy = get_taxonomy($attribute_name);
     1360                    $attributeLabel = !empty($taxonomy) ? $taxonomy->labels->singular_name : $attribute_name;
     1361                } else {
     1362                    $attributeLabel = $attribute_name;
     1363                }
     1364
     1365                if ($showLabel && !empty($attribute)) {
     1366                    $attribute = $attributeLabel . ': ' . $attribute;
    12311367                }
    12321368            });
     
    12431379
    12441380        foreach ($parentNotVariableAttributes as $parentNotVariableAttribute) {
    1245             $attributesOptions = array_merge(
    1246                 $attributesOptions,
    1247                 $parentNotVariableAttribute->is_taxonomy()
    1248                     ? wp_list_pluck($parentNotVariableAttribute->get_terms(), 'name')
    1249                     : $parentNotVariableAttribute->get_options()
    1250             );
     1381            if ($parentNotVariableAttribute->is_taxonomy()) {
     1382                $attributesOptions[] = array(
     1383                    'label' => $parentNotVariableAttribute->get_taxonomy_object()->attribute_label,
     1384                    'options' => wp_list_pluck($parentNotVariableAttribute->get_terms(), 'name'),
     1385                );
     1386            } else {
     1387                $attributesOptions[] = array(
     1388                    'label' => $parentNotVariableAttribute->get_name(),
     1389                    'options' => $parentNotVariableAttribute->get_options(),
     1390                );
     1391            }
    12511392        }
    12521393
     
    18842025    protected function sortByIds($targetArray, $orderArray)
    18852026    {
     2027        $targetArray = array_values($targetArray);
    18862028        $foundProductsIds = array();
    1887         foreach ($targetArray as $product) {
     2029        foreach ($targetArray as $key => $product) {
    18882030            if ('product_variation' === $product->post_type) {
    1889                 $foundProductsIds[] = $product->post_parent;
     2031                $foundProductsIds[$key] = $product->post_parent;
    18902032            } else {
    1891                 $foundProductsIds[] = $product->ID;
    1892             }
    1893         }
     2033                $foundProductsIds[$key] = $product->ID;
     2034            }
     2035        }
     2036
    18942037
    18952038        if ($orderArray) {
    1896             $orderArray = array_values(array_intersect($orderArray, $foundProductsIds));
    18972039            uksort($targetArray, function ($key1, $key2) use ($orderArray, $foundProductsIds) {
    18982040                $product1Id = $foundProductsIds[$key1];
    18992041                $product2Id = $foundProductsIds[$key2];
    19002042
    1901                 if (array_search($product1Id, $orderArray) > array_search($product2Id, $orderArray)) {
    1902                     return 1;
     2043                if (array_search($product1Id, $orderArray) === array_search($product2Id, $orderArray)) {
     2044                    return 0;
    19032045                } else {
    1904                     return 0;
    1905                 }
     2046                    return array_search($product1Id, $orderArray) > array_search($product2Id, $orderArray) ? 1 : -1;
     2047                }
     2048
    19062049            });
    19072050        }
     2051
     2052        return $targetArray;
     2053    }
     2054
     2055    protected function sortByTitle($targetArray)
     2056    {
     2057        usort($targetArray, function($item1, $item2) {
     2058            if (property_exists($item1, 'post_title') && property_exists($item2, 'post_title')) {
     2059                return strcmp($item1->post_title, $item2->post_title);
     2060            } else {
     2061                return 0;
     2062            }
     2063        });
    19082064
    19092065        return $targetArray;
     
    22082364        if ('shop_order' === $post->post_type || 'shop_order_placehold' === $post->post_type) {
    22092365            $order = $this->getOrder($post);
    2210             return !empty($order) ? wp_date($format, strtotime($order->get_date_completed())) : '';
     2366            return !empty($order) && !empty($order->get_date_completed())
     2367                ? wp_date($format, strtotime($order->get_date_completed()))
     2368                : '';
    22112369
    22122370
     
    22182376        ) {
    22192377            $order = wc_get_order($post->orderId);
    2220             return !empty($order) ? wp_date($format, strtotime($order->get_date_completed())) : '';
     2378            return !empty($order) && !empty($order->get_date_completed())
     2379                ? wp_date($format, strtotime($order->get_date_completed()))
     2380                : '';
    22212381
    22222382        } else {
     
    26812841            : '';
    26822842    }
     2843
     2844    protected function getDokanVendorName($post, $field)
     2845    {
     2846        if (!property_exists($post, 'post_author')) {
     2847            return '';
     2848        }
     2849
     2850        $dokanVendorName = get_user_meta($post->post_author, 'dokan_store_name', true);
     2851
     2852        return !empty($dokanVendorName) ? $dokanVendorName : '';
     2853    }
    26832854}
  • a4-barcode-generator/trunk/class/Models/PostsUtils.php

    r3204983 r3363232  
    7171        $value = (int)$value;
    7272        return uswbg_a4bGetPosts(array(
     73            'post_type' => array('product', 'product_variation'),
    7374            'post__in' => empty($value) ? array(0) : array($value),
    7475            'fields' => 'ids',
  • a4-barcode-generator/trunk/class/Profiles.php

    r3083367 r3363232  
    1717        foreach (array(
    1818            'name', 'templateId', 'paperId', 'sheetId', 'update',
    19             'barcodeRotate', 'fontSize', 'fontAlgorithm', 'fontLineBreak', 'barcodePosition', 'imageTextGap',
     19            'barcodeRotate', 'fontSize', 'fontAlgorithm', 'fontLineBreak', 'barcodePosition', 'imageTextGap', 'sortAlphabetically',
    2020            'barcodeHeightAuto', 'barcodeHeight', 'barcodeWidth', 'basePadding', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'showBarcode'
    2121        ) as $key) {
     
    3636            'params' => 'array',
    3737            'barcodeRotate' => 'required|numeric',
     38            'sortAlphabetically' => 'required|numeric',
    3839            'fontSize' => 'string',
    3940            'fontAlgorithm' => 'required|string',
     
    8283                        'params' => $profileParams,
    8384                        'barcodeRotate' => $data['barcodeRotate'],
     85                        'sortAlphabetically' => $data['sortAlphabetically'],
    8486                        'fontSize' => $data['fontSize'],
    8587                        'fontAlgorithm' => $data['fontAlgorithm'],
     
    178180                'params' => $profileParams,
    179181                'barcodeRotate' => $data['barcodeRotate'],
     182                'sortAlphabetically' => $data['sortAlphabetically'],
    180183                'fontSize' => $data['fontSize'],
    181184                'fontAlgorithm' => $data['fontAlgorithm'],
  • a4-barcode-generator/trunk/class/Settings.php

    r3204983 r3363232  
    258258            if (isset($data['lken'])) {
    259259                $prefix = 'ukrsolution_upgrade_print_barcodes_';
    260                 @delete_transient($prefix . '3.4.11');
     260                @delete_transient($prefix . '3.4.12');
    261261            }
    262262
  • a4-barcode-generator/trunk/class/Shortcodes.php

    r3204983 r3363232  
    3838
    3939        if (isset($attributes['class']) && is_product()) {
    40             wp_enqueue_style('product-barcode', Variables::$A4B_PLUGIN_BASE_URL . 'assets/css/style-3.4.11-f114ea43.css', array());
    41             wp_enqueue_script('product-barcode-js', Variables::$A4B_PLUGIN_BASE_URL . 'assets/js/barcodes-core-3.4.11-f114ea43.js', array('jquery'), null, true);
     40            wp_enqueue_style('product-barcode', Variables::$A4B_PLUGIN_BASE_URL . 'assets/css/style-3.4.12-4807abb8.css', array());
     41            wp_enqueue_script('product-barcode-js', Variables::$A4B_PLUGIN_BASE_URL . 'assets/js/barcodes-core-3.4.12-4807abb8.js', array('jquery'), null, true);
    4242
    4343            wp_localize_script('product-barcode-js', 'digitalBarcodeJS', array(
  • a4-barcode-generator/trunk/class/WooCommerce.php

    r3083367 r3363232  
    5656
    5757        $post = array();
    58         foreach (array('format', 'withVariations', 'isImportSingleVariation', 'isUseApi', 'lineSeparator1', 'lineSeparator2', 'lineSeparator3', 'lineSeparator4', 'page', 'profileId') as $key) {
     58        foreach (array('format', 'withVariations', 'isImportSingleVariation', 'isUseApi', 'lineSeparator1', 'lineSeparator2', 'lineSeparator3', 'lineSeparator4', 'page', 'profileId', 'sortAlphabetically') as $key) {
    5959            if (isset($_POST[$key])) {
    6060                $post[$key] = sanitize_text_field($_POST[$key]);
     
    7474            'fieldSepLine4',
    7575            'options',
     76            'existingIds',
    7677        ) as $key) {
    7778            if (isset($_POST[$key])) {
     
    8586
    8687        $validationRules = array(
    87             'productsCategories' => 'requiredItem:if_empty,productsIds|array|bail',
    88             'productsIds' => 'requiredItem:if_empty,productsCategories|array|bail',
     88            'productsCategories' => 'array',
     89            'productsIds' => 'array',
    8990            'lineBarcode' => $activeTemplate->code_match || (!empty($activeTemplate->matchingType) && !empty($activeTemplate->matching->lineBarcode)) ? 'array' : 'required|array',
    9091            'fieldLine1' => 'array',
     
    107108            'profileId' => 'numeric',
    108109            'options' => 'array',
     110            'sortAlphabetically' => 'numeric',
     111            'existingIds' => 'array',
    109112        );
    110113
     
    138141
    139142        $post = array();
    140         foreach (array('format', 'withVariations', 'isImportSingleVariation', 'isUseApi', 'lineSeparator1', 'lineSeparator2', 'lineSeparator3', 'lineSeparator4', 'page', 'profileId') as $key) {
     143        foreach (array('format', 'withVariations', 'isImportSingleVariation', 'isUseApi', 'lineSeparator1', 'lineSeparator2', 'lineSeparator3', 'lineSeparator4', 'page', 'profileId', 'sortAlphabetically') as $key) {
    141144            if (isset($_POST[$key])) {
    142145                $post[$key] = sanitize_text_field($_POST[$key]);
     
    155158            'fieldSepLine3',
    156159            'fieldSepLine4',
     160            'existingIds',
    157161        ) as $key) {
    158162            if (isset($_POST[$key])) {
     
    166170
    167171        $validationRules = array(
    168             'productsCategories' => 'requiredItem:if_empty,productsIds|array|bail',
    169             'productsIds' => 'requiredItem:if_empty,productsCategories|array|bail',
     172            'productsCategories' => 'array',
     173            'productsIds' => 'array',
    170174            'lineBarcode' => $activeTemplate->code_match ? 'array' : 'required|array',
    171175            'fieldLine1' => 'array',
     
    187191            'page' => 'string',
    188192            'profileId' => 'numeric',
     193            'sortAlphabetically' => 'numeric',
     194            'existingIds' => 'array',
    189195        );
    190196
     
    378384        global $current_user;
    379385        $post = array();
    380         foreach (array('format', 'orderQuantity', 'useStockQuantity', 'isUseApi', 'lineSeparator1', 'lineSeparator2', 'lineSeparator3', 'lineSeparator4', 'profileId', 'page') as $key) {
     386        foreach (array('format', 'orderQuantity', 'useStockQuantity', 'isUseApi', 'lineSeparator1', 'lineSeparator2', 'lineSeparator3', 'lineSeparator4', 'profileId', 'page', 'sortAlphabetically') as $key) {
    381387            if (isset($_POST[$key])) {
    382388                $post[$key] = sanitize_text_field($_POST[$key]);
     
    395401            'fieldSepLine3',
    396402            'fieldSepLine4',
     403            'existingIds',
    397404        ) as $key) {
    398405            if (isset($_POST[$key])) {
     
    409416
    410417        $validationRules = array(
    411             'ordersCategories' => 'requiredItem:if_empty,ordersIds|array|bail',
    412             'ordersIds' => 'requiredItem:if_empty,ordersCategories|array|bail',
     418            'ordersCategories' => 'array',
     419            'ordersIds' => 'array',
    413420            'lineBarcode' => $activeTemplate->code_match ? 'array' : 'required|array',
    414421            'fieldLine1' => 'array',
     
    430437            'page' => 'string',
    431438            'profileId' => 'numeric',
     439            'sortAlphabetically' => 'numeric',
     440            'existingIds' => 'array',
    432441        );
    433442
     
    500509
    501510    public function getBarcodesByOrderProducts()
     511    {
     512        Request::ajaxRequestAccess();
     513
     514        if (!current_user_can('read')) {
     515            wp_die();
     516        }
     517
     518        global $current_user;
     519
     520        $post = array();
     521        foreach (array('format', 'orderQuantity', 'useStockQuantity', 'isUseApi', 'lineSeparator1', 'lineSeparator2', 'lineSeparator3', 'lineSeparator4', 'profileId', 'page', 'sortAlphabetically') as $key) {
     522            if (isset($_POST[$key])) {
     523                $post[$key] = sanitize_text_field($_POST[$key]);
     524            }
     525        }
     526        foreach (array(
     527            'ordersCategories',
     528            'ordersIds',
     529            'lineBarcode',
     530            'fieldLine1',
     531            'fieldLine2',
     532            'fieldLine3',
     533            'fieldLine4',
     534            'fieldSepLine1',
     535            'fieldSepLine2',
     536            'fieldSepLine3',
     537            'fieldSepLine4',
     538            'itemsIds',
     539            'existingIds',
     540        ) as $key) {
     541            if (isset($_POST[$key])) {
     542                $post[$key] = USWBG_a4bRecursiveSanitizeTextField($_POST[$key]);
     543            }
     544        }
     545
     546        $customTemplatesController = new BarcodeTemplatesController();
     547        $activeTemplate = $customTemplatesController->getActiveTemplate();
     548
     549        $validationRules = array(
     550            'ordersCategories' => 'array',
     551            'ordersIds' => 'array',
     552            'lineBarcode' => $activeTemplate->code_match ? 'array' : 'required|array',
     553            'fieldLine1' => 'array',
     554            'fieldLine2' => 'array',
     555            'fieldLine3' => 'array',
     556            'fieldLine4' => 'array',
     557            'fieldSepLine1' => 'array',
     558            'fieldSepLine2' => 'array',
     559            'fieldSepLine3' => 'array',
     560            'fieldSepLine4' => 'array',
     561            'itemsIds' => 'array',
     562            'format' => 'required',
     563            'orderQuantity' => 'required',
     564            'useStockQuantity' => 'required',
     565            'lineSeparator1' => 'string',
     566            'lineSeparator2' => 'string',
     567            'lineSeparator3' => 'string',
     568            'lineSeparator4' => 'string',
     569            'page' => 'string',
     570            'profileId' => 'numeric',
     571            'sortAlphabetically' => 'numeric',
     572            'existingIds' => 'array',
     573        );
     574
     575        $data = Validator::create($post, $validationRules, true)->validate();
     576
     577        $postsBarcodesGenerator = new WoocommercePostsA4BarcodesMaker($data, 'order-products');
     578        $result = $postsBarcodesGenerator->make();
     579
     580
     581        if ($current_user && isset($data['page']) && $data['page'] === "template-editor") {
     582            if (isset($data['ordersIds']) && count($data['ordersIds'])) {
     583                \update_user_meta($current_user->ID, "usplp_product_preview", $data['ordersIds'][0]);
     584            }
     585        }
     586
     587        uswbg_a4bJsonResponse($result);
     588    }
     589
     590    public function getBarcodesByAtumPoOrderProducts()
    502591    {
    503592        Request::ajaxRequestAccess();
     
    563652        $data = Validator::create($post, $validationRules, true)->validate();
    564653
    565         $postsBarcodesGenerator = new WoocommercePostsA4BarcodesMaker($data, 'order-products');
     654        $postsBarcodesGenerator = new WoocommercePostsA4BarcodesMaker($data, 'atum-po-order-products');
    566655        $result = $postsBarcodesGenerator->make();
    567656
     
    575664        uswbg_a4bJsonResponse($result);
    576665    }
    577 
    578     public function getBarcodesByAtumPoOrderProducts()
    579     {
    580         Request::ajaxRequestAccess();
    581 
    582         if (!current_user_can('read')) {
    583             wp_die();
    584         }
    585 
    586         global $current_user;
    587 
    588         $post = array();
    589         foreach (array('format', 'orderQuantity', 'useStockQuantity', 'isUseApi', 'lineSeparator1', 'lineSeparator2', 'lineSeparator3', 'lineSeparator4', 'profileId', 'page') as $key) {
    590             if (isset($_POST[$key])) {
    591                 $post[$key] = sanitize_text_field($_POST[$key]);
    592             }
    593         }
    594         foreach (array(
    595             'ordersCategories',
    596             'ordersIds',
    597             'lineBarcode',
    598             'fieldLine1',
    599             'fieldLine2',
    600             'fieldLine3',
    601             'fieldLine4',
    602             'fieldSepLine1',
    603             'fieldSepLine2',
    604             'fieldSepLine3',
    605             'fieldSepLine4',
    606             'itemsIds',
    607         ) as $key) {
    608             if (isset($_POST[$key])) {
    609                 $post[$key] = USWBG_a4bRecursiveSanitizeTextField($_POST[$key]);
    610             }
    611         }
    612 
    613         $customTemplatesController = new BarcodeTemplatesController();
    614         $activeTemplate = $customTemplatesController->getActiveTemplate();
    615 
    616         $validationRules = array(
    617             'ordersCategories' => 'requiredItem:if_empty,ordersIds|array|bail',
    618             'ordersIds' => 'requiredItem:if_empty,ordersCategories|array|bail',
    619             'lineBarcode' => $activeTemplate->code_match ? 'array' : 'required|array',
    620             'fieldLine1' => 'array',
    621             'fieldLine2' => 'array',
    622             'fieldLine3' => 'array',
    623             'fieldLine4' => 'array',
    624             'fieldSepLine1' => 'array',
    625             'fieldSepLine2' => 'array',
    626             'fieldSepLine3' => 'array',
    627             'fieldSepLine4' => 'array',
    628             'itemsIds' => 'array',
    629             'format' => 'required',
    630             'orderQuantity' => 'required',
    631             'useStockQuantity' => 'required',
    632             'lineSeparator1' => 'string',
    633             'lineSeparator2' => 'string',
    634             'lineSeparator3' => 'string',
    635             'lineSeparator4' => 'string',
    636             'page' => 'string',
    637             'profileId' => 'numeric',
    638         );
    639 
    640         $data = Validator::create($post, $validationRules, true)->validate();
    641 
    642         $postsBarcodesGenerator = new WoocommercePostsA4BarcodesMaker($data, 'atum-po-order-products');
    643         $result = $postsBarcodesGenerator->make();
    644 
    645 
    646         if ($current_user && isset($data['page']) && $data['page'] === "template-editor") {
    647             if (isset($data['ordersIds']) && count($data['ordersIds'])) {
    648                 \update_user_meta($current_user->ID, "usplp_product_preview", $data['ordersIds'][0]);
    649             }
    650         }
    651 
    652         uswbg_a4bJsonResponse($result);
    653     }
    654666}
  • a4-barcode-generator/trunk/class/functions.php

    r2985149 r3363232  
    2525                array(
    2626                    'taxonomy' => 'product_cat',
    27                     'terms'    => $categoriesIds,
     27                    'terms'    => !empty($categoriesIds) ? $categoriesIds : array(0),
    2828                    'field'    => 'term_id',
    2929                    'operator' => 'IN',
     
    5151
    5252        $args = array_merge($defaultArgs, $args);
     53
     54        if (is_plugin_active('polylang/polylang.php')) {
     55            unset($args['lang']);
     56        }
     57
    5358        $query = new \WP_Query($args);
    5459
  • a4-barcode-generator/trunk/config/jsL10n.php

    r3204983 r3363232  
    7070    'include_variations_field_label' => __('Include variations', 'wpbcu-barcode-generator'),
    7171    'use_stock_quantity_field_label' => __('Use stock quantity', 'wpbcu-barcode-generator'),
     72    'sort_alphabetically_field_label' => __('Sort alphabetically', 'wpbcu-barcode-generator'),
    7273
    7374    'select_template' => __('Select template:', 'wpbcu-barcode-generator'),
     
    404405            __('Attributes example:', 'wpbcu-barcode-generator') => '[attr=Color], [attr=Size]',
    405406            __('Get attribute of parent:', 'wpbcu-barcode-generator') => '[attr=parent.Color]',
    406             __("All Product's Attributes:", 'wpbcu-barcode-generator') => '[product-all-attr separator=", "]',
    407             __('All Parent Attributes:', 'wpbcu-barcode-generator') => '[product-all-parent-attributes separator=", "]',
     407            __("All Product's Attributes:", 'wpbcu-barcode-generator') => '[product-all-attr separator=", " show-attr-name="true"]',
     408            __('All Parent Attributes:', 'wpbcu-barcode-generator') => '[product-all-parent-attributes separator=", " show-attr-name="true"]',
    408409            __('<i>"Color" and "Size" are actual names of attributes, please replace them to your attribute names.</i>', 'wpbcu-barcode-generator') => '',
    409410        ),
     
    411412            __('Parent product ID:', 'wpbcu-barcode-generator') => '[field=parent.ID]',
    412413            __('Parent product SKU:', 'wpbcu-barcode-generator') => '[cf=parent._sku]',
    413             __("All Variation�s Attributes:", 'wpbcu-barcode-generator') => '[variation-all-attr separator=", "]',
     414            __("All Variation�s Attributes:", 'wpbcu-barcode-generator') => '[variation-all-attr separator=", " show-attr-name="true"]',
    414415        ),
    415416        __('Date & time:', 'wpbcu-barcode-generator') => array(
     
    615616            __('Order item quantity:', 'wpbcu-barcode-generator') => '[order-product-qty]',
    616617            __("Get product's meta data:", 'wpbcu-barcode-generator') => '[atum-order-item-meta-field=Size]',
     618            __("Atum product location:", 'wpbcu-barcode-generator') => '[atum-product-location]',
    617619        ),
    618620    ),
     
    852854    'field_72' => __("Cart tax", 'wpbcu-barcode-generator'),
    853855    'field_73' => __("All Product's Attributes", 'wpbcu-barcode-generator'),
     856    'field_85' => __("All Product's Attributes (with names)", 'wpbcu-barcode-generator'),
    854857    'field_74' => __("Order item quantity", 'wpbcu-barcode-generator'),
    855858    'field_75' => __("Sale Price + Tax", 'wpbcu-barcode-generator'),
     
    862865    'field_82' => __("Order coupon", 'wpbcu-barcode-generator'),
    863866    'field_83' => __("All Parent Attributes", 'wpbcu-barcode-generator'),
     867    'field_84' => __("Dokan vendor name", 'wpbcu-barcode-generator'),
    864868
    865869    'shipping_info' => __("Shipping info", 'wpbcu-barcode-generator'),
  • a4-barcode-generator/trunk/lib/meyfa/php-svg/src/Rasterization/Renderers/RectRenderer.php

    r2870656 r3363232  
    5656        }
    5757
     58
    5859        imagefilledrectangle(
    5960            $image,
    60             $params['x1'], $params['y1'],
    61             $params['x2'], $params['y2'],
     61            (int)$params['x1'], (int)$params['y1'],
     62            (int)$params['x2'], (int)$params['y2'],
    6263            $color
    6364        );
  • a4-barcode-generator/trunk/lib/meyfa/php-svg/src/Rasterization/Renderers/Renderer.php

    r2870656 r3363232  
    4949    {
    5050        $paintOrder = $context->getComputedStyle('paint-order');
    51         $paintOrder = preg_replace('#\s{2,}#', ' ', trim($paintOrder));
     51        $paintOrder = preg_replace('#\s{2,}#', ' ', trim(is_string($paintOrder) ? $paintOrder : ''));
    5252
    5353        $defaultOrder = array('fill', 'stroke', 'markers');
  • a4-barcode-generator/trunk/lib/meyfa/php-svg/src/Rasterization/Renderers/TextRenderer.php

    r2870656 r3363232  
    2121        $font_path = dirname(__FILE__) . "/../../../../../../assets/fonts/arial.ttf";
    2222
     23
    2324        imagettftext(
    2425            $image,
    2526            $params['size'] * 0.8,
    2627            0,
    27             $params['x'],
    28             $params['y'],
     28            (int) $params['x'],
     29            (int) $params['y'],
    2930            $color,
    3031            $font_path,
  • a4-barcode-generator/trunk/lib/meyfa/php-svg/src/Rasterization/SVGRasterizer.php

    r3083367 r3363232  
    4848    private static function createImage($width, $height, $background)
    4949    {
    50         $img = imagecreatetruecolor($width, $height);
     50        $img = imagecreatetruecolor((int)$width, (int)$height);
    5151
    5252        imagealphablending($img, true);
  • a4-barcode-generator/trunk/public/dist/index.html

    r3204983 r3363232  
    1 <!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><title>Vue App</title><link href=/wp-content/plugins/barcodes/public/dist/css/app_demo_3.4.11-f114ea43.css rel=preload as=style><link href=/wp-content/plugins/barcodes/public/dist/js/app_demo_3.4.11-f114ea43.js rel=preload as=script><link href=/wp-content/plugins/barcodes/public/dist/js/chunk-vendors_demo_3.4.11-f114ea43.js rel=preload as=script><link href=/wp-content/plugins/barcodes/public/dist/css/app_demo_3.4.11-f114ea43.css rel=stylesheet></head><body><div id=app></div><script src=/wp-content/plugins/barcodes/public/dist/js/chunk-vendors_demo_3.4.11-f114ea43.js></script><script src=/wp-content/plugins/barcodes/public/dist/js/app_demo_3.4.11-f114ea43.js></script></body></html>
     1<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><title>Vue App</title><link href=/wp-content/plugins/barcodes/public/dist/css/app_demo_3.4.12-4807abb8.css rel=preload as=style><link href=/wp-content/plugins/barcodes/public/dist/js/app_demo_3.4.12-4807abb8.js rel=preload as=script><link href=/wp-content/plugins/barcodes/public/dist/js/chunk-vendors_demo_3.4.12-4807abb8.js rel=preload as=script><link href=/wp-content/plugins/barcodes/public/dist/css/app_demo_3.4.12-4807abb8.css rel=stylesheet></head><body><div id=app></div><script src=/wp-content/plugins/barcodes/public/dist/js/chunk-vendors_demo_3.4.12-4807abb8.js></script><script src=/wp-content/plugins/barcodes/public/dist/js/app_demo_3.4.12-4807abb8.js></script></body></html>
  • a4-barcode-generator/trunk/templates/printpage.php

    r3204983 r3363232  
    1010    <title>Print page</title>
    1111    <?php $allowedTags = array('link' => array('rel' => 1, 'type' => 1, 'href' => 1)); ?>
    12 <?php echo wp_kses(implode(USWBG_print_lStylePath('public/dist/css/app_demo_3.4.11-f114ea43.css')), $allowedTags); ?>
     12<?php echo wp_kses(implode(USWBG_print_lStylePath('public/dist/css/app_demo_3.4.12-4807abb8.css')), $allowedTags); ?>
    1313
    1414    <style>
     
    7878    </script>
    7979    <script src='<?php echo esc_attr(A4B_SITE_BASE_URL . '/wp-includes/js/jquery/jquery.js'); ?>'></script>
    80     <script src='<?php echo esc_attr(Variables::$A4B_PLUGIN_BASE_URL . 'assets/js/jszip.min-3.4.11-f114ea43.js'); ?>'></script>
    81 <script src='<?php echo esc_attr(Variables::$A4B_PLUGIN_BASE_URL . 'assets/js/api-3.4.11-f114ea43.js'); ?>'></script>
    82 <script src='<?php echo esc_attr(Variables::$A4B_PLUGIN_BASE_URL . 'public/dist/js/app_demo_3.4.11-f114ea43.js'); ?>'></script>
    83 <script src='<?php echo esc_attr(Variables::$A4B_PLUGIN_BASE_URL . 'public/dist/js/chunk-vendors_demo_3.4.11-f114ea43.js'); ?>'></script>
     80    <script src='<?php echo esc_attr(Variables::$A4B_PLUGIN_BASE_URL . 'assets/js/jszip.min-3.4.12-4807abb8.js'); ?>'></script>
     81<script src='<?php echo esc_attr(Variables::$A4B_PLUGIN_BASE_URL . 'assets/js/api-3.4.12-4807abb8.js'); ?>'></script>
     82<script src='<?php echo esc_attr(Variables::$A4B_PLUGIN_BASE_URL . 'public/dist/js/app_demo_3.4.12-4807abb8.js'); ?>'></script>
     83<script src='<?php echo esc_attr(Variables::$A4B_PLUGIN_BASE_URL . 'public/dist/js/chunk-vendors_demo_3.4.12-4807abb8.js'); ?>'></script>
    8484</body>
    8585
Note: See TracChangeset for help on using the changeset viewer.