Plugin Directory

Changeset 2710949


Ignore:
Timestamp:
04/18/2022 08:36:40 AM (4 years ago)
Author:
webcodist
Message:

Update to version 1.1.0

Location:
e-commerce-data-interchange
Files:
4 added
32 edited
1 copied

Legend:

Unmodified
Added
Removed
  • e-commerce-data-interchange/tags/1.1.0/e-commerce-data-interchange.php

    r2703415 r2710949  
    11<?php declare( strict_types=1 );
    22/**
    3  * Plugin Name:       E-Commerce Data Interchange
    4  * Plugin URI:        https://edi.byteperfect.dev/
    5  * Description:       The plugin provides data interchange between the WooCommerce plugin and 1C.
    6  * Version:           1.0.0
    7  * Author:            Aleksandr Levashov <me@webcodist.com>
    8  * Author URI:        https://webcodist.com/
    9  * Requires at least: 5.7
    10  * Requires PHP:      7.4
    11  * License:           GPLv3
    12  * License URI:       https://www.gnu.org/licenses/gpl-3.0.html
    13  * Text Domain:       edi
    14  * Domain Path:       /languages/
     3 * Plugin Name:          E-Commerce Data Interchange
     4 * Plugin URI:           https://edi.byteperfect.dev/
     5 * Description:          The plugin provides data interchange between the WooCommerce plugin and 1C.
     6 * Version:              1.0.0
     7 * Author:               Aleksandr Levashov <me@webcodist.com>
     8 * Author URI:           https://webcodist.com/
     9 * Requires at least:    5.7
     10 * Requires PHP:         7.4
     11 * WC requires at least: 3.6.0
     12 * WC tested up to:      6.4.1
     13 * License:              GPLv3
     14 * License URI:          https://www.gnu.org/licenses/gpl-3.0.html
     15 * Text Domain:          edi
     16 * Domain Path:          /languages/
    1517 *
    1618 * @package BytePerfect\EDI
  • e-commerce-data-interchange/tags/1.1.0/languages/edi-ru_RU.po

    r2703415 r2710949  
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/e-commerce-data-"
    77"interchange\n"
    8 "POT-Creation-Date: 2022-03-25T16:58:10+03:00\n"
    9 "PO-Revision-Date: 2022-03-25 16:59+0300\n"
     8"POT-Creation-Date: 2022-04-17T12:25:11+03:00\n"
     9"PO-Revision-Date: 2022-04-17 12:26+0300\n"
    1010"Last-Translator: Aleksandr Levashov <me@webcodist.com>\n"
    1111"Language-Team: Aleksandr Levashov <me@webcodist.com>\n"
     
    6464
    6565#. translators: %s: file name.
    66 #: src/CatalogInterchange.php:73
     66#: src/CatalogInterchange.php:71
     67msgid "Unexpected file name: %s."
     68msgstr "Неожиданное имя файла: %s."
     69
     70#. translators: %s: file name.
     71#: src/CatalogInterchange.php:79
    6772msgid "%s was processed successfully."
    6873msgstr "%s успешно обработан."
     
    132137msgstr "Ошибка распаковки файла: %s"
    133138
    134 #: src/EDI.php:85
     139#: src/EDI.php:90
    135140msgid "Settings"
    136141msgstr "Настройки"
    137142
    138143#. translators: %s: WooCommerce URL.
    139 #: src/EDI.php:113
     144#: src/EDI.php:118
    140145msgid "The %s plugin is required for electronic data interchange."
    141146msgstr "Плагин %s необходим для электронного обмена данными."
    142147
    143148#. translators: %s: access type.
    144 #: src/EDI.php:179
     149#: src/EDI.php:184
    145150msgid "File system %s is not implemented."
    146151msgstr "Файловая система %s не реализована."
     
    167172
    168173#. translators: %d: parent id.
    169 #: src/Parsers/CategoriesParser.php:149
     174#: src/Parsers/CategoriesParser.php:153
    170175msgid "Product category parent is invalid: %d"
    171176msgstr "Родительская категория товара недействительна: %d"
    172177
    173178#. translators: %s: error message.
    174 #: src/Parsers/CategoriesParser.php:165
     179#: src/Parsers/CategoriesParser.php:169
    175180msgid "Error create product category: %s"
    176181msgstr "Ошибка при создании категории товара: %s"
    177182
    178183#. translators: %s: category data.
    179 #: src/Parsers/CategoriesParser.php:194
     184#: src/Parsers/CategoriesParser.php:198
    180185msgid "Cannot update product category: %s"
    181186msgstr "Невозможно обновить категорию товара: %s"
     
    198203msgstr "Ошибка загрузки изображения: %s"
    199204
    200 #: src/Request.php:179
     205#: src/Request.php:178
    201206msgid "Unexpected XML entry."
    202207msgstr "Неожиданная запись XML."
    203208
    204209#. translators: %s: property name.
    205 #: src/Request.php:211
     210#: src/Request.php:210
    206211msgid "Undefined property: %s"
    207212msgstr "Неопределенное свойство: %s"
    208213
    209 #: src/Request.php:255
     214#: src/Request.php:254
    210215msgid "Synchronization was interrupted on the site side."
    211216msgstr "Синхронизация была прервана на стороне сайта."
    212217
    213 #: src/Request.php:301
     218#: src/Request.php:305
    214219msgid "Products synchronization"
    215220msgstr "Синхронизация товаров"
    216221
    217 #: src/Request.php:303
     222#: src/Request.php:307
    218223msgid "Orders synchronization"
    219224msgstr "Синхронизация заказов"
    220225
    221 #: src/Request.php:310
     226#: src/Request.php:314
    222227msgid "Initialization"
    223228msgstr "Инициализация"
    224229
    225 #: src/Request.php:312
     230#: src/Request.php:316
    226231msgid "Getting the import file"
    227232msgstr "Получение файла импорта"
    228233
    229 #: src/Request.php:314
     234#: src/Request.php:318
    230235msgid "Import"
    231236msgstr "Импорт"
    232237
    233 #: src/Request.php:316
     238#: src/Request.php:320
    234239msgid "Export orders"
    235240msgstr "Экспорт заказов"
    236241
    237 #: src/Request.php:321
     242#: src/Request.php:325
    238243msgid "Interrupting the import process..."
    239244msgstr "Прерывание процесса импорта..."
    240245
    241 #: src/Settings.php:44
     246#: src/Settings.php:50
    242247msgid "EDI"
    243248msgstr "EDI"
    244249
    245 #: src/Settings.php:53
     250#: src/Settings.php:59
    246251msgid "General settings"
    247252msgstr "Общие настройки"
    248253
    249 #: src/Settings.php:58
     254#: src/Settings.php:64
    250255msgid "Site URL used for 1C interchange:"
    251256msgstr "URL сайта для обмена с 1С:"
    252257
    253 #: src/Settings.php:65
     258#: src/Settings.php:71
    254259msgid "Username"
    255260msgstr "Имя пользователя"
    256261
    257 #: src/Settings.php:68
     262#: src/Settings.php:74
    258263msgid "Username used for 1C interchange."
    259264msgstr "Имя пользователя для обмена с 1С."
    260265
    261 #: src/Settings.php:73
     266#: src/Settings.php:79
    262267msgid "Password"
    263268msgstr "Пароль"
    264269
    265 #: src/Settings.php:76
     270#: src/Settings.php:82
    266271msgid "Password used for 1C interchange."
    267272msgstr "Пароль для обмена с 1С."
    268273
    269 #: src/Settings.php:81
     274#: src/Settings.php:87
    270275msgid "Import categories"
    271276msgstr "Импортировать категории"
    272277
    273 #: src/Settings.php:88
     278#: src/Settings.php:94
    274279msgid "Import products"
    275280msgstr "Импортировать товары"
    276281
    277 #: src/Settings.php:95
     282#: src/Settings.php:101
    278283msgid "Import attributes"
    279284msgstr "Импортировать атрибуты"
    280285
    281 #: src/Settings.php:102
     286#: src/Settings.php:108
    282287msgid "Import images"
    283288msgstr "Импортировать изображения"
    284289
    285 #: src/Settings.php:171
     290#: src/Settings.php:116
     291msgid "Advanced settings"
     292msgstr "Продвинутые настройки"
     293
     294#: src/Settings.php:119
     295msgid ""
     296"🛑 Please do not change these settings unless you are sure what you are doing!"
     297msgstr ""
     298"🛑 Пожалуйста, не меняйте эти настройки, если вы не уверены в том, что "
     299"делаете!"
     300
     301#: src/Settings.php:127
     302msgid "Import chunk size (in bytes)"
     303msgstr "Размер импортируемого фрагмента (в байтах)"
     304
     305#: src/Settings.php:128
     306msgid "The maximum allowed file size to transfer per request."
     307msgstr "Максимально допустимый размер файла для передачи по запросу."
     308
     309#: src/Settings.php:141
     310msgid "Enable detailed logging"
     311msgstr "Включить подробное логирование"
     312
     313#: src/Settings.php:212
    286314msgid "Interrupt"
    287315msgstr "Прервать"
    288316
    289317#. translators: %s: attribute map value.
    290 #: src/Utils.php:260 src/Utils.php:283
     318#: src/Utils.php:275 src/Utils.php:298
    291319msgid "Attribute map is: %s."
    292320msgstr "Сопоставление атрибутов: %s."
    293321
    294 #: src/Utils.php:290
     322#: src/Utils.php:305
    295323msgid "Error update attribute map."
    296324msgstr "Ошибка обновления сопоставления атрибутов."
  • e-commerce-data-interchange/tags/1.1.0/languages/edi.pot

    r2703415 r2710949  
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2022-03-25T16:58:10+03:00\n"
     12"POT-Creation-Date: 2022-04-17T12:25:11+03:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.6.0\n"
     
    5959
    6060#. translators: %s: file name.
    61 #: src/CatalogInterchange.php:73
     61#: src/CatalogInterchange.php:71
     62msgid "Unexpected file name: %s."
     63msgstr ""
     64
     65#. translators: %s: file name.
     66#: src/CatalogInterchange.php:79
    6267msgid "%s was processed successfully."
    6368msgstr ""
     
    127132msgstr ""
    128133
    129 #: src/EDI.php:85
     134#: src/EDI.php:90
    130135msgid "Settings"
    131136msgstr ""
    132137
    133138#. translators: %s: WooCommerce URL.
    134 #: src/EDI.php:113
     139#: src/EDI.php:118
    135140msgid "The %s plugin is required for electronic data interchange."
    136141msgstr ""
    137142
    138143#. translators: %s: access type.
    139 #: src/EDI.php:179
     144#: src/EDI.php:184
    140145msgid "File system %s is not implemented."
    141146msgstr ""
     
    162167
    163168#. translators: %d: parent id.
    164 #: src/Parsers/CategoriesParser.php:149
     169#: src/Parsers/CategoriesParser.php:153
    165170msgid "Product category parent is invalid: %d"
    166171msgstr ""
    167172
    168173#. translators: %s: error message.
    169 #: src/Parsers/CategoriesParser.php:165
     174#: src/Parsers/CategoriesParser.php:169
    170175msgid "Error create product category: %s"
    171176msgstr ""
    172177
    173178#. translators: %s: category data.
    174 #: src/Parsers/CategoriesParser.php:194
     179#: src/Parsers/CategoriesParser.php:198
    175180msgid "Cannot update product category: %s"
    176181msgstr ""
     
    194199msgstr ""
    195200
    196 #: src/Request.php:179
     201#: src/Request.php:178
    197202msgid "Unexpected XML entry."
    198203msgstr ""
    199204
    200205#. translators: %s: property name.
    201 #: src/Request.php:211
     206#: src/Request.php:210
    202207msgid "Undefined property: %s"
    203208msgstr ""
    204209
    205 #: src/Request.php:255
     210#: src/Request.php:254
    206211msgid "Synchronization was interrupted on the site side."
    207212msgstr ""
    208213
    209 #: src/Request.php:301
     214#: src/Request.php:305
    210215msgid "Products synchronization"
    211216msgstr ""
    212217
    213 #: src/Request.php:303
     218#: src/Request.php:307
    214219msgid "Orders synchronization"
    215220msgstr ""
    216221
    217 #: src/Request.php:310
     222#: src/Request.php:314
    218223msgid "Initialization"
    219224msgstr ""
    220225
    221 #: src/Request.php:312
     226#: src/Request.php:316
    222227msgid "Getting the import file"
    223228msgstr ""
    224229
    225 #: src/Request.php:314
     230#: src/Request.php:318
    226231msgid "Import"
    227232msgstr ""
    228233
    229 #: src/Request.php:316
     234#: src/Request.php:320
    230235msgid "Export orders"
    231236msgstr ""
    232237
    233 #: src/Request.php:321
     238#: src/Request.php:325
    234239msgid "Interrupting the import process..."
    235240msgstr ""
    236241
    237 #: src/Settings.php:44
     242#: src/Settings.php:50
    238243msgid "EDI"
    239244msgstr ""
    240245
    241 #: src/Settings.php:53
     246#: src/Settings.php:59
    242247msgid "General settings"
    243248msgstr ""
    244249
    245 #: src/Settings.php:58
     250#: src/Settings.php:64
    246251msgid "Site URL used for 1C interchange:"
    247252msgstr ""
    248253
    249 #: src/Settings.php:65
     254#: src/Settings.php:71
    250255msgid "Username"
    251256msgstr ""
    252257
    253 #: src/Settings.php:68
     258#: src/Settings.php:74
    254259msgid "Username used for 1C interchange."
    255260msgstr ""
    256261
    257 #: src/Settings.php:73
     262#: src/Settings.php:79
    258263msgid "Password"
    259264msgstr ""
    260265
    261 #: src/Settings.php:76
     266#: src/Settings.php:82
    262267msgid "Password used for 1C interchange."
    263268msgstr ""
    264269
    265 #: src/Settings.php:81
     270#: src/Settings.php:87
    266271msgid "Import categories"
    267272msgstr ""
    268273
    269 #: src/Settings.php:88
     274#: src/Settings.php:94
    270275msgid "Import products"
    271276msgstr ""
    272277
    273 #: src/Settings.php:95
     278#: src/Settings.php:101
    274279msgid "Import attributes"
    275280msgstr ""
    276281
    277 #: src/Settings.php:102
     282#: src/Settings.php:108
    278283msgid "Import images"
    279284msgstr ""
    280285
    281 #: src/Settings.php:171
     286#: src/Settings.php:116
     287msgid "Advanced settings"
     288msgstr ""
     289
     290#: src/Settings.php:119
     291msgid "🛑 Please do not change these settings unless you are sure what you are doing!"
     292msgstr ""
     293
     294#: src/Settings.php:127
     295msgid "Import chunk size (in bytes)"
     296msgstr ""
     297
     298#: src/Settings.php:128
     299msgid "The maximum allowed file size to transfer per request."
     300msgstr ""
     301
     302#: src/Settings.php:141
     303msgid "Enable detailed logging"
     304msgstr ""
     305
     306#: src/Settings.php:212
    282307msgid "Interrupt"
    283308msgstr ""
    284309
    285310#. translators: %s: attribute map value.
    286 #: src/Utils.php:260
    287 #: src/Utils.php:283
     311#: src/Utils.php:275
     312#: src/Utils.php:298
    288313msgid "Attribute map is: %s."
    289314msgstr ""
    290315
    291 #: src/Utils.php:290
     316#: src/Utils.php:305
    292317msgid "Error update attribute map."
    293318msgstr ""
  • e-commerce-data-interchange/tags/1.1.0/readme.txt

    r2703415 r2710949  
    1 === EDI ===
     1=== EDI - Обмен данными между WooCommerce и 1С ===
    22Contributors: webcodist
    33Tags: 1c, 1с, commerceml, integration, e-commerce, ecommerce, commerce, shop, cart, woothemes, woocommerce
    44Donate link: https://boosty.to/byteperfect
    55Requires at least: 5.7
    6 Tested up to: 5.9.2
     6Tested up to: 5.9.3
    77Requires PHP: 7.4
    8 Stable tag: 1.0.0
     8Stable tag: 1.1.0
    99License: GPLv3
    1010License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    1717**Особенностью плагина является отсутствие специальных требований к хостингу. Это позволяет плагину стабильно работать даже на дешевых shared-хостингах. Плагин готов к работе сразу после установки!**
    1818
    19 =Плагин EDI - Обмен данными между WooCommerce и 1С позволяет:=
     19= Плагин EDI - Обмен данными между WooCommerce и 1С позволяет: =
    2020✅ Осуществлять выгрузку товаров:
    2121- список товаров и вариантов*,
     
    5757
    5858== Changelog ==
     59
     60= 1.1.0 =
     61*Дата релиза - 18 апреля 2022*
     62
     63* Поддержка WordPress v5.9.3
     64* Поддержка WooCommerce v6.4.1
     65* Исправлена синхронизация ранее синхронизированных категории.
     66* Добавлена опция включения подробного логирования.
     67* Добавлены команды WP-CLI.
     68* Доработано определение имени XML-файла импорта.
     69* Реализована возможность указать максимально допустимый размер файла импорта.
     70* Различные улучшения.
     71
     72
    5973= 1.0.0 =
     74*Дата релиза - 1 апреля 2022*
     75
    6076Публичный релиз плагина.
    6177
  • e-commerce-data-interchange/tags/1.1.0/src/CatalogInterchange.php

    r2703415 r2710949  
    6262        EDI::log()->debug( sprintf( __( 'Processing %s ...', 'edi' ), $this->request->filename ) );
    6363
    64         if ( 'import.xml' === $this->request->filename ) {
     64        if ( 0 === strpos( $this->request->filename, 'import' ) ) {
    6565            $parser_class_name = '\BytePerfect\EDI\Parsers\ImportXMLParser';
     66        } elseif ( 0 === strpos( $this->request->filename, 'offers' ) ) {
     67            $parser_class_name = '\BytePerfect\EDI\Parsers\OffersXMLParser';
    6668        } else {
    67             $parser_class_name = '\BytePerfect\EDI\Parsers\OffersXMLParser';
     69            throw new Exception(
     70            /* translators: %s: file name. */
     71                sprintf( __( 'Unexpected file name: %s.', 'edi' ), $this->request->filename )
     72            );
    6873        }
     74
    6975        $parser = new $parser_class_name( $this->request );
    7076        if ( $parser->parse() ) {
  • e-commerce-data-interchange/tags/1.1.0/src/EDI.php

    r2703415 r2710949  
    88namespace BytePerfect\EDI;
    99
     10use BytePerfect\EDI\CLI\EDI_CLI;
    1011use Exception;
    1112use WC_Logger;
     
    3940
    4041        new Settings();
     42
     43        if ( defined( 'WP_CLI' ) && WP_CLI ) {
     44            new EDI_CLI();
     45        }
    4146
    4247        register_activation_hook(
  • e-commerce-data-interchange/tags/1.1.0/src/Parsers/CategoriesParser.php

    r2703415 r2710949  
    8383        );
    8484
    85         if ( is_null( $category_id ) ) {
     85        if (
     86            is_null( $category_id )
     87            ||
     88            ! get_term_by( 'id', $category_id, 'product_cat' )
     89        ) {
    8690            $category_id = $this->create_category( $name, $parent_id );
    8791
  • e-commerce-data-interchange/tags/1.1.0/src/Parsers/XMLParser.php

    r2703415 r2710949  
    123123            ! $this->eof
    124124            &&
    125             ( defined( 'WP_CLI' ) || ( ! $this->time_exceeded() && ! $this->memory_exceeded() ) )
     125            ( ( defined( 'WP_CLI' ) && WP_CLI ) || ( ! $this->time_exceeded() && ! $this->memory_exceeded() ) )
    126126        );
    127127
  • e-commerce-data-interchange/tags/1.1.0/src/Request.php

    r2703415 r2710949  
    2727    const EDI_ENDPOINT = '/edi/1c';
    2828
     29    const XML_IMPORT_FILENAME_MASK = '/^(?:import|offers).*\.xml$/';
     30
    2931    const ZIP_IMPORT_FILENAME_MASK = '/^v8_.+\.zip$/';
    3032
     
    152154            ! empty( $this->filename )
    153155            &&
    154             ! in_array( $this->filename, array( 'import.xml', 'offers.xml' ), true )
     156            ! preg_match( self::XML_IMPORT_FILENAME_MASK, $this->filename )
    155157            &&
    156158            ! preg_match( self::ZIP_IMPORT_FILENAME_MASK, $this->filename )
     
    262264     */
    263265    protected function authorize(): void {
     266        // Bypass authorization if WP_CLI request.
     267        if ( defined( 'WP_CLI' ) && WP_CLI ) {
     268            return;
     269        }
     270
    264271        $username    = Settings::get_username();
    265272        $password    = Settings::get_password();
  • e-commerce-data-interchange/tags/1.1.0/src/Response.php

    r2703415 r2710949  
    5252        }
    5353
    54         if ( 'failure' === $this->type || ( defined( 'EDI_DEBUG' ) && EDI_DEBUG ) ) {
     54        if ( 'failure' === $this->type || Settings::get_detailed_logging() ) {
    5555            EDI::log()->notice( '🔙' . $message );
    5656        }
  • e-commerce-data-interchange/tags/1.1.0/src/Settings.php

    r2703415 r2710949  
    2020 * @method static get_password(): string
    2121 * @method static get_export_from_timestamp()
     22 * @method static get_import_chunk_size(): int
     23 * @method static get_import_categories()
     24 * @method static get_import_products()
     25 * @method static get_import_attributes()
     26 * @method static get_import_images()
     27 * @method static get_detailed_logging()
    2228 *
    2329 * @package BytePerfect\EDI
     
    2935    public function __construct() {
    3036        add_action( 'cmb2_admin_init', array( $this, 'register_options_metabox' ) );
    31         add_action( 'admin_bar_menu', array( $this, 'admin_bar_render' ) );
    32         add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_script' ), PHP_INT_MAX );
     37
     38        if ( is_admin() ) {
     39            add_action( 'admin_bar_menu', array( $this, 'admin_bar_render' ) );
     40            add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_script' ), PHP_INT_MAX );
     41        }
    3342    }
    3443
     
    107116
    108117        do_action( 'edi_register_options_metabox', $cmb_options );
     118
     119        $cmb_options->add_field(
     120            array(
     121                'name' => __( 'Advanced settings', 'edi' ),
     122                'id'   => 'expert_settings',
     123                'type' => 'title',
     124                'desc' => __(
     125                    '🛑 Please do not change these settings unless you are sure what you are doing!',
     126                    'edi'
     127                ),
     128            )
     129        );
     130        $cmb_options->add_field(
     131            array(
     132                'name'            => __( 'Import chunk size (in bytes)', 'edi' ),
     133                'desc'            => __( 'The maximum allowed file size to transfer per request.', 'edi' ),
     134                'id'              => 'import_chunk_size',
     135                'type'            => 'text_small',
     136                'attributes'      => array(
     137                    'type' => 'number',
     138                    'min'  => '0',
     139                ),
     140                'default'         => 1000000,
     141                'sanitization_cb' => array( $this, 'sanitize_import_chunk_size' ),
     142            )
     143        );
     144        $cmb_options->add_field(
     145            array(
     146                'name' => __( 'Enable detailed logging', 'edi' ),
     147                'id'   => 'detailed_logging',
     148                'type' => 'checkbox',
     149            )
     150        );
    109151    }
    110152
     
    135177                    'import_attributes' => '',
    136178                    'import_images'     => '',
     179                    'import_chunk_size' => 1000000,
     180                    'detailed_logging'  => '',
    137181                )
    138182            ),
     
    202246        );
    203247    }
     248
     249    /**
     250     * Sanitize import chunk size value.
     251     *
     252     * @param string $value Import chunk size.
     253     *
     254     * @return int
     255     */
     256    public function sanitize_import_chunk_size( string $value ): int {
     257        return absint( $value );
     258    }
    204259}
  • e-commerce-data-interchange/tags/1.1.0/src/Utils.php

    r2703415 r2710949  
    2525     */
    2626    public static function get_file_limit(): int {
     27        // Получаю все значения.
    2728        $file_limits = array(
     29            Settings::get_import_chunk_size(),
    2830            self::filesize_to_bytes( (string) ini_get( 'post_max_size' ) ),
    2931            self::filesize_to_bytes( (string) ini_get( 'upload_max_filesize' ) ),
     
    3133        );
    3234
    33         return (int) min( $file_limits );
     35        // Убираю все "пустые" значения.
     36        $file_limits = array_filter( $file_limits );
     37
     38        // Нахожу минимальное значение, иначе использую значение по-умолчанию 64 килобайта.
     39        $file_limit = empty( $file_limits ) ? 64000 : min( $file_limits );
     40        // Определяю 90% от найденного значения.
     41        $file_limit = $file_limit * 0.9;
     42
     43        return (int) $file_limit;
    3444    }
    3545
     
    5363                return (int) $filesize * 1000;
    5464            default:
    55                 return (int) $filesize;
     65                $filesize = (int) $filesize;
     66                if ( $filesize < 0 ) {
     67                    $filesize = 0;
     68                }
     69
     70                return $filesize;
    5671        }
    5772    }
  • e-commerce-data-interchange/tags/1.1.0/vendor/autoload.php

    r2703415 r2710949  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInit2ea6fe8ada44306e7b1a1f2958fc19d4::getLoader();
     7return ComposerAutoloaderInit107406ad375ef1ce4b81c91b6324180f::getLoader();
  • e-commerce-data-interchange/tags/1.1.0/vendor/composer/autoload_real.php

    r2703415 r2710949  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit2ea6fe8ada44306e7b1a1f2958fc19d4
     5class ComposerAutoloaderInit107406ad375ef1ce4b81c91b6324180f
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInit2ea6fe8ada44306e7b1a1f2958fc19d4', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInit107406ad375ef1ce4b81c91b6324180f', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
    29         spl_autoload_unregister(array('ComposerAutoloaderInit2ea6fe8ada44306e7b1a1f2958fc19d4', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInit107406ad375ef1ce4b81c91b6324180f', 'loadClassLoader'));
    3030
    3131        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    3333            require __DIR__ . '/autoload_static.php';
    3434
    35             call_user_func(\Composer\Autoload\ComposerStaticInit2ea6fe8ada44306e7b1a1f2958fc19d4::getInitializer($loader));
     35            call_user_func(\Composer\Autoload\ComposerStaticInit107406ad375ef1ce4b81c91b6324180f::getInitializer($loader));
    3636        } else {
    3737            $map = require __DIR__ . '/autoload_namespaces.php';
     
    5454
    5555        if ($useStaticLoader) {
    56             $includeFiles = Composer\Autoload\ComposerStaticInit2ea6fe8ada44306e7b1a1f2958fc19d4::$files;
     56            $includeFiles = Composer\Autoload\ComposerStaticInit107406ad375ef1ce4b81c91b6324180f::$files;
    5757        } else {
    5858            $includeFiles = require __DIR__ . '/autoload_files.php';
    5959        }
    6060        foreach ($includeFiles as $fileIdentifier => $file) {
    61             composerRequire2ea6fe8ada44306e7b1a1f2958fc19d4($fileIdentifier, $file);
     61            composerRequire107406ad375ef1ce4b81c91b6324180f($fileIdentifier, $file);
    6262        }
    6363
     
    7171 * @return void
    7272 */
    73 function composerRequire2ea6fe8ada44306e7b1a1f2958fc19d4($fileIdentifier, $file)
     73function composerRequire107406ad375ef1ce4b81c91b6324180f($fileIdentifier, $file)
    7474{
    7575    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • e-commerce-data-interchange/tags/1.1.0/vendor/composer/autoload_static.php

    r2703415 r2710949  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit2ea6fe8ada44306e7b1a1f2958fc19d4
     7class ComposerStaticInit107406ad375ef1ce4b81c91b6324180f
    88{
    99    public static $files = array (
     
    3232    {
    3333        return \Closure::bind(function () use ($loader) {
    34             $loader->prefixLengthsPsr4 = ComposerStaticInit2ea6fe8ada44306e7b1a1f2958fc19d4::$prefixLengthsPsr4;
    35             $loader->prefixDirsPsr4 = ComposerStaticInit2ea6fe8ada44306e7b1a1f2958fc19d4::$prefixDirsPsr4;
    36             $loader->classMap = ComposerStaticInit2ea6fe8ada44306e7b1a1f2958fc19d4::$classMap;
     34            $loader->prefixLengthsPsr4 = ComposerStaticInit107406ad375ef1ce4b81c91b6324180f::$prefixLengthsPsr4;
     35            $loader->prefixDirsPsr4 = ComposerStaticInit107406ad375ef1ce4b81c91b6324180f::$prefixDirsPsr4;
     36            $loader->classMap = ComposerStaticInit107406ad375ef1ce4b81c91b6324180f::$classMap;
    3737
    3838        }, null, ClassLoader::class);
  • e-commerce-data-interchange/trunk/e-commerce-data-interchange.php

    r2703415 r2710949  
    11<?php declare( strict_types=1 );
    22/**
    3  * Plugin Name:       E-Commerce Data Interchange
    4  * Plugin URI:        https://edi.byteperfect.dev/
    5  * Description:       The plugin provides data interchange between the WooCommerce plugin and 1C.
    6  * Version:           1.0.0
    7  * Author:            Aleksandr Levashov <me@webcodist.com>
    8  * Author URI:        https://webcodist.com/
    9  * Requires at least: 5.7
    10  * Requires PHP:      7.4
    11  * License:           GPLv3
    12  * License URI:       https://www.gnu.org/licenses/gpl-3.0.html
    13  * Text Domain:       edi
    14  * Domain Path:       /languages/
     3 * Plugin Name:          E-Commerce Data Interchange
     4 * Plugin URI:           https://edi.byteperfect.dev/
     5 * Description:          The plugin provides data interchange between the WooCommerce plugin and 1C.
     6 * Version:              1.0.0
     7 * Author:               Aleksandr Levashov <me@webcodist.com>
     8 * Author URI:           https://webcodist.com/
     9 * Requires at least:    5.7
     10 * Requires PHP:         7.4
     11 * WC requires at least: 3.6.0
     12 * WC tested up to:      6.4.1
     13 * License:              GPLv3
     14 * License URI:          https://www.gnu.org/licenses/gpl-3.0.html
     15 * Text Domain:          edi
     16 * Domain Path:          /languages/
    1517 *
    1618 * @package BytePerfect\EDI
  • e-commerce-data-interchange/trunk/languages/edi-ru_RU.po

    r2703415 r2710949  
    66"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/e-commerce-data-"
    77"interchange\n"
    8 "POT-Creation-Date: 2022-03-25T16:58:10+03:00\n"
    9 "PO-Revision-Date: 2022-03-25 16:59+0300\n"
     8"POT-Creation-Date: 2022-04-17T12:25:11+03:00\n"
     9"PO-Revision-Date: 2022-04-17 12:26+0300\n"
    1010"Last-Translator: Aleksandr Levashov <me@webcodist.com>\n"
    1111"Language-Team: Aleksandr Levashov <me@webcodist.com>\n"
     
    6464
    6565#. translators: %s: file name.
    66 #: src/CatalogInterchange.php:73
     66#: src/CatalogInterchange.php:71
     67msgid "Unexpected file name: %s."
     68msgstr "Неожиданное имя файла: %s."
     69
     70#. translators: %s: file name.
     71#: src/CatalogInterchange.php:79
    6772msgid "%s was processed successfully."
    6873msgstr "%s успешно обработан."
     
    132137msgstr "Ошибка распаковки файла: %s"
    133138
    134 #: src/EDI.php:85
     139#: src/EDI.php:90
    135140msgid "Settings"
    136141msgstr "Настройки"
    137142
    138143#. translators: %s: WooCommerce URL.
    139 #: src/EDI.php:113
     144#: src/EDI.php:118
    140145msgid "The %s plugin is required for electronic data interchange."
    141146msgstr "Плагин %s необходим для электронного обмена данными."
    142147
    143148#. translators: %s: access type.
    144 #: src/EDI.php:179
     149#: src/EDI.php:184
    145150msgid "File system %s is not implemented."
    146151msgstr "Файловая система %s не реализована."
     
    167172
    168173#. translators: %d: parent id.
    169 #: src/Parsers/CategoriesParser.php:149
     174#: src/Parsers/CategoriesParser.php:153
    170175msgid "Product category parent is invalid: %d"
    171176msgstr "Родительская категория товара недействительна: %d"
    172177
    173178#. translators: %s: error message.
    174 #: src/Parsers/CategoriesParser.php:165
     179#: src/Parsers/CategoriesParser.php:169
    175180msgid "Error create product category: %s"
    176181msgstr "Ошибка при создании категории товара: %s"
    177182
    178183#. translators: %s: category data.
    179 #: src/Parsers/CategoriesParser.php:194
     184#: src/Parsers/CategoriesParser.php:198
    180185msgid "Cannot update product category: %s"
    181186msgstr "Невозможно обновить категорию товара: %s"
     
    198203msgstr "Ошибка загрузки изображения: %s"
    199204
    200 #: src/Request.php:179
     205#: src/Request.php:178
    201206msgid "Unexpected XML entry."
    202207msgstr "Неожиданная запись XML."
    203208
    204209#. translators: %s: property name.
    205 #: src/Request.php:211
     210#: src/Request.php:210
    206211msgid "Undefined property: %s"
    207212msgstr "Неопределенное свойство: %s"
    208213
    209 #: src/Request.php:255
     214#: src/Request.php:254
    210215msgid "Synchronization was interrupted on the site side."
    211216msgstr "Синхронизация была прервана на стороне сайта."
    212217
    213 #: src/Request.php:301
     218#: src/Request.php:305
    214219msgid "Products synchronization"
    215220msgstr "Синхронизация товаров"
    216221
    217 #: src/Request.php:303
     222#: src/Request.php:307
    218223msgid "Orders synchronization"
    219224msgstr "Синхронизация заказов"
    220225
    221 #: src/Request.php:310
     226#: src/Request.php:314
    222227msgid "Initialization"
    223228msgstr "Инициализация"
    224229
    225 #: src/Request.php:312
     230#: src/Request.php:316
    226231msgid "Getting the import file"
    227232msgstr "Получение файла импорта"
    228233
    229 #: src/Request.php:314
     234#: src/Request.php:318
    230235msgid "Import"
    231236msgstr "Импорт"
    232237
    233 #: src/Request.php:316
     238#: src/Request.php:320
    234239msgid "Export orders"
    235240msgstr "Экспорт заказов"
    236241
    237 #: src/Request.php:321
     242#: src/Request.php:325
    238243msgid "Interrupting the import process..."
    239244msgstr "Прерывание процесса импорта..."
    240245
    241 #: src/Settings.php:44
     246#: src/Settings.php:50
    242247msgid "EDI"
    243248msgstr "EDI"
    244249
    245 #: src/Settings.php:53
     250#: src/Settings.php:59
    246251msgid "General settings"
    247252msgstr "Общие настройки"
    248253
    249 #: src/Settings.php:58
     254#: src/Settings.php:64
    250255msgid "Site URL used for 1C interchange:"
    251256msgstr "URL сайта для обмена с 1С:"
    252257
    253 #: src/Settings.php:65
     258#: src/Settings.php:71
    254259msgid "Username"
    255260msgstr "Имя пользователя"
    256261
    257 #: src/Settings.php:68
     262#: src/Settings.php:74
    258263msgid "Username used for 1C interchange."
    259264msgstr "Имя пользователя для обмена с 1С."
    260265
    261 #: src/Settings.php:73
     266#: src/Settings.php:79
    262267msgid "Password"
    263268msgstr "Пароль"
    264269
    265 #: src/Settings.php:76
     270#: src/Settings.php:82
    266271msgid "Password used for 1C interchange."
    267272msgstr "Пароль для обмена с 1С."
    268273
    269 #: src/Settings.php:81
     274#: src/Settings.php:87
    270275msgid "Import categories"
    271276msgstr "Импортировать категории"
    272277
    273 #: src/Settings.php:88
     278#: src/Settings.php:94
    274279msgid "Import products"
    275280msgstr "Импортировать товары"
    276281
    277 #: src/Settings.php:95
     282#: src/Settings.php:101
    278283msgid "Import attributes"
    279284msgstr "Импортировать атрибуты"
    280285
    281 #: src/Settings.php:102
     286#: src/Settings.php:108
    282287msgid "Import images"
    283288msgstr "Импортировать изображения"
    284289
    285 #: src/Settings.php:171
     290#: src/Settings.php:116
     291msgid "Advanced settings"
     292msgstr "Продвинутые настройки"
     293
     294#: src/Settings.php:119
     295msgid ""
     296"🛑 Please do not change these settings unless you are sure what you are doing!"
     297msgstr ""
     298"🛑 Пожалуйста, не меняйте эти настройки, если вы не уверены в том, что "
     299"делаете!"
     300
     301#: src/Settings.php:127
     302msgid "Import chunk size (in bytes)"
     303msgstr "Размер импортируемого фрагмента (в байтах)"
     304
     305#: src/Settings.php:128
     306msgid "The maximum allowed file size to transfer per request."
     307msgstr "Максимально допустимый размер файла для передачи по запросу."
     308
     309#: src/Settings.php:141
     310msgid "Enable detailed logging"
     311msgstr "Включить подробное логирование"
     312
     313#: src/Settings.php:212
    286314msgid "Interrupt"
    287315msgstr "Прервать"
    288316
    289317#. translators: %s: attribute map value.
    290 #: src/Utils.php:260 src/Utils.php:283
     318#: src/Utils.php:275 src/Utils.php:298
    291319msgid "Attribute map is: %s."
    292320msgstr "Сопоставление атрибутов: %s."
    293321
    294 #: src/Utils.php:290
     322#: src/Utils.php:305
    295323msgid "Error update attribute map."
    296324msgstr "Ошибка обновления сопоставления атрибутов."
  • e-commerce-data-interchange/trunk/languages/edi.pot

    r2703415 r2710949  
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "POT-Creation-Date: 2022-03-25T16:58:10+03:00\n"
     12"POT-Creation-Date: 2022-04-17T12:25:11+03:00\n"
    1313"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
    1414"X-Generator: WP-CLI 2.6.0\n"
     
    5959
    6060#. translators: %s: file name.
    61 #: src/CatalogInterchange.php:73
     61#: src/CatalogInterchange.php:71
     62msgid "Unexpected file name: %s."
     63msgstr ""
     64
     65#. translators: %s: file name.
     66#: src/CatalogInterchange.php:79
    6267msgid "%s was processed successfully."
    6368msgstr ""
     
    127132msgstr ""
    128133
    129 #: src/EDI.php:85
     134#: src/EDI.php:90
    130135msgid "Settings"
    131136msgstr ""
    132137
    133138#. translators: %s: WooCommerce URL.
    134 #: src/EDI.php:113
     139#: src/EDI.php:118
    135140msgid "The %s plugin is required for electronic data interchange."
    136141msgstr ""
    137142
    138143#. translators: %s: access type.
    139 #: src/EDI.php:179
     144#: src/EDI.php:184
    140145msgid "File system %s is not implemented."
    141146msgstr ""
     
    162167
    163168#. translators: %d: parent id.
    164 #: src/Parsers/CategoriesParser.php:149
     169#: src/Parsers/CategoriesParser.php:153
    165170msgid "Product category parent is invalid: %d"
    166171msgstr ""
    167172
    168173#. translators: %s: error message.
    169 #: src/Parsers/CategoriesParser.php:165
     174#: src/Parsers/CategoriesParser.php:169
    170175msgid "Error create product category: %s"
    171176msgstr ""
    172177
    173178#. translators: %s: category data.
    174 #: src/Parsers/CategoriesParser.php:194
     179#: src/Parsers/CategoriesParser.php:198
    175180msgid "Cannot update product category: %s"
    176181msgstr ""
     
    194199msgstr ""
    195200
    196 #: src/Request.php:179
     201#: src/Request.php:178
    197202msgid "Unexpected XML entry."
    198203msgstr ""
    199204
    200205#. translators: %s: property name.
    201 #: src/Request.php:211
     206#: src/Request.php:210
    202207msgid "Undefined property: %s"
    203208msgstr ""
    204209
    205 #: src/Request.php:255
     210#: src/Request.php:254
    206211msgid "Synchronization was interrupted on the site side."
    207212msgstr ""
    208213
    209 #: src/Request.php:301
     214#: src/Request.php:305
    210215msgid "Products synchronization"
    211216msgstr ""
    212217
    213 #: src/Request.php:303
     218#: src/Request.php:307
    214219msgid "Orders synchronization"
    215220msgstr ""
    216221
    217 #: src/Request.php:310
     222#: src/Request.php:314
    218223msgid "Initialization"
    219224msgstr ""
    220225
    221 #: src/Request.php:312
     226#: src/Request.php:316
    222227msgid "Getting the import file"
    223228msgstr ""
    224229
    225 #: src/Request.php:314
     230#: src/Request.php:318
    226231msgid "Import"
    227232msgstr ""
    228233
    229 #: src/Request.php:316
     234#: src/Request.php:320
    230235msgid "Export orders"
    231236msgstr ""
    232237
    233 #: src/Request.php:321
     238#: src/Request.php:325
    234239msgid "Interrupting the import process..."
    235240msgstr ""
    236241
    237 #: src/Settings.php:44
     242#: src/Settings.php:50
    238243msgid "EDI"
    239244msgstr ""
    240245
    241 #: src/Settings.php:53
     246#: src/Settings.php:59
    242247msgid "General settings"
    243248msgstr ""
    244249
    245 #: src/Settings.php:58
     250#: src/Settings.php:64
    246251msgid "Site URL used for 1C interchange:"
    247252msgstr ""
    248253
    249 #: src/Settings.php:65
     254#: src/Settings.php:71
    250255msgid "Username"
    251256msgstr ""
    252257
    253 #: src/Settings.php:68
     258#: src/Settings.php:74
    254259msgid "Username used for 1C interchange."
    255260msgstr ""
    256261
    257 #: src/Settings.php:73
     262#: src/Settings.php:79
    258263msgid "Password"
    259264msgstr ""
    260265
    261 #: src/Settings.php:76
     266#: src/Settings.php:82
    262267msgid "Password used for 1C interchange."
    263268msgstr ""
    264269
    265 #: src/Settings.php:81
     270#: src/Settings.php:87
    266271msgid "Import categories"
    267272msgstr ""
    268273
    269 #: src/Settings.php:88
     274#: src/Settings.php:94
    270275msgid "Import products"
    271276msgstr ""
    272277
    273 #: src/Settings.php:95
     278#: src/Settings.php:101
    274279msgid "Import attributes"
    275280msgstr ""
    276281
    277 #: src/Settings.php:102
     282#: src/Settings.php:108
    278283msgid "Import images"
    279284msgstr ""
    280285
    281 #: src/Settings.php:171
     286#: src/Settings.php:116
     287msgid "Advanced settings"
     288msgstr ""
     289
     290#: src/Settings.php:119
     291msgid "🛑 Please do not change these settings unless you are sure what you are doing!"
     292msgstr ""
     293
     294#: src/Settings.php:127
     295msgid "Import chunk size (in bytes)"
     296msgstr ""
     297
     298#: src/Settings.php:128
     299msgid "The maximum allowed file size to transfer per request."
     300msgstr ""
     301
     302#: src/Settings.php:141
     303msgid "Enable detailed logging"
     304msgstr ""
     305
     306#: src/Settings.php:212
    282307msgid "Interrupt"
    283308msgstr ""
    284309
    285310#. translators: %s: attribute map value.
    286 #: src/Utils.php:260
    287 #: src/Utils.php:283
     311#: src/Utils.php:275
     312#: src/Utils.php:298
    288313msgid "Attribute map is: %s."
    289314msgstr ""
    290315
    291 #: src/Utils.php:290
     316#: src/Utils.php:305
    292317msgid "Error update attribute map."
    293318msgstr ""
  • e-commerce-data-interchange/trunk/readme.txt

    r2703415 r2710949  
    1 === EDI ===
     1=== EDI - Обмен данными между WooCommerce и 1С ===
    22Contributors: webcodist
    33Tags: 1c, 1с, commerceml, integration, e-commerce, ecommerce, commerce, shop, cart, woothemes, woocommerce
    44Donate link: https://boosty.to/byteperfect
    55Requires at least: 5.7
    6 Tested up to: 5.9.2
     6Tested up to: 5.9.3
    77Requires PHP: 7.4
    8 Stable tag: 1.0.0
     8Stable tag: 1.1.0
    99License: GPLv3
    1010License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    1717**Особенностью плагина является отсутствие специальных требований к хостингу. Это позволяет плагину стабильно работать даже на дешевых shared-хостингах. Плагин готов к работе сразу после установки!**
    1818
    19 =Плагин EDI - Обмен данными между WooCommerce и 1С позволяет:=
     19= Плагин EDI - Обмен данными между WooCommerce и 1С позволяет: =
    2020✅ Осуществлять выгрузку товаров:
    2121- список товаров и вариантов*,
     
    5757
    5858== Changelog ==
     59
     60= 1.1.0 =
     61*Дата релиза - 18 апреля 2022*
     62
     63* Поддержка WordPress v5.9.3
     64* Поддержка WooCommerce v6.4.1
     65* Исправлена синхронизация ранее синхронизированных категории.
     66* Добавлена опция включения подробного логирования.
     67* Добавлены команды WP-CLI.
     68* Доработано определение имени XML-файла импорта.
     69* Реализована возможность указать максимально допустимый размер файла импорта.
     70* Различные улучшения.
     71
     72
    5973= 1.0.0 =
     74*Дата релиза - 1 апреля 2022*
     75
    6076Публичный релиз плагина.
    6177
  • e-commerce-data-interchange/trunk/src/CatalogInterchange.php

    r2703415 r2710949  
    6262        EDI::log()->debug( sprintf( __( 'Processing %s ...', 'edi' ), $this->request->filename ) );
    6363
    64         if ( 'import.xml' === $this->request->filename ) {
     64        if ( 0 === strpos( $this->request->filename, 'import' ) ) {
    6565            $parser_class_name = '\BytePerfect\EDI\Parsers\ImportXMLParser';
     66        } elseif ( 0 === strpos( $this->request->filename, 'offers' ) ) {
     67            $parser_class_name = '\BytePerfect\EDI\Parsers\OffersXMLParser';
    6668        } else {
    67             $parser_class_name = '\BytePerfect\EDI\Parsers\OffersXMLParser';
     69            throw new Exception(
     70            /* translators: %s: file name. */
     71                sprintf( __( 'Unexpected file name: %s.', 'edi' ), $this->request->filename )
     72            );
    6873        }
     74
    6975        $parser = new $parser_class_name( $this->request );
    7076        if ( $parser->parse() ) {
  • e-commerce-data-interchange/trunk/src/EDI.php

    r2703415 r2710949  
    88namespace BytePerfect\EDI;
    99
     10use BytePerfect\EDI\CLI\EDI_CLI;
    1011use Exception;
    1112use WC_Logger;
     
    3940
    4041        new Settings();
     42
     43        if ( defined( 'WP_CLI' ) && WP_CLI ) {
     44            new EDI_CLI();
     45        }
    4146
    4247        register_activation_hook(
  • e-commerce-data-interchange/trunk/src/Parsers/CategoriesParser.php

    r2703415 r2710949  
    8383        );
    8484
    85         if ( is_null( $category_id ) ) {
     85        if (
     86            is_null( $category_id )
     87            ||
     88            ! get_term_by( 'id', $category_id, 'product_cat' )
     89        ) {
    8690            $category_id = $this->create_category( $name, $parent_id );
    8791
  • e-commerce-data-interchange/trunk/src/Parsers/XMLParser.php

    r2703415 r2710949  
    123123            ! $this->eof
    124124            &&
    125             ( defined( 'WP_CLI' ) || ( ! $this->time_exceeded() && ! $this->memory_exceeded() ) )
     125            ( ( defined( 'WP_CLI' ) && WP_CLI ) || ( ! $this->time_exceeded() && ! $this->memory_exceeded() ) )
    126126        );
    127127
  • e-commerce-data-interchange/trunk/src/Request.php

    r2703415 r2710949  
    2727    const EDI_ENDPOINT = '/edi/1c';
    2828
     29    const XML_IMPORT_FILENAME_MASK = '/^(?:import|offers).*\.xml$/';
     30
    2931    const ZIP_IMPORT_FILENAME_MASK = '/^v8_.+\.zip$/';
    3032
     
    152154            ! empty( $this->filename )
    153155            &&
    154             ! in_array( $this->filename, array( 'import.xml', 'offers.xml' ), true )
     156            ! preg_match( self::XML_IMPORT_FILENAME_MASK, $this->filename )
    155157            &&
    156158            ! preg_match( self::ZIP_IMPORT_FILENAME_MASK, $this->filename )
     
    262264     */
    263265    protected function authorize(): void {
     266        // Bypass authorization if WP_CLI request.
     267        if ( defined( 'WP_CLI' ) && WP_CLI ) {
     268            return;
     269        }
     270
    264271        $username    = Settings::get_username();
    265272        $password    = Settings::get_password();
  • e-commerce-data-interchange/trunk/src/Response.php

    r2703415 r2710949  
    5252        }
    5353
    54         if ( 'failure' === $this->type || ( defined( 'EDI_DEBUG' ) && EDI_DEBUG ) ) {
     54        if ( 'failure' === $this->type || Settings::get_detailed_logging() ) {
    5555            EDI::log()->notice( '🔙' . $message );
    5656        }
  • e-commerce-data-interchange/trunk/src/Settings.php

    r2703415 r2710949  
    2020 * @method static get_password(): string
    2121 * @method static get_export_from_timestamp()
     22 * @method static get_import_chunk_size(): int
     23 * @method static get_import_categories()
     24 * @method static get_import_products()
     25 * @method static get_import_attributes()
     26 * @method static get_import_images()
     27 * @method static get_detailed_logging()
    2228 *
    2329 * @package BytePerfect\EDI
     
    2935    public function __construct() {
    3036        add_action( 'cmb2_admin_init', array( $this, 'register_options_metabox' ) );
    31         add_action( 'admin_bar_menu', array( $this, 'admin_bar_render' ) );
    32         add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_script' ), PHP_INT_MAX );
     37
     38        if ( is_admin() ) {
     39            add_action( 'admin_bar_menu', array( $this, 'admin_bar_render' ) );
     40            add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_script' ), PHP_INT_MAX );
     41        }
    3342    }
    3443
     
    107116
    108117        do_action( 'edi_register_options_metabox', $cmb_options );
     118
     119        $cmb_options->add_field(
     120            array(
     121                'name' => __( 'Advanced settings', 'edi' ),
     122                'id'   => 'expert_settings',
     123                'type' => 'title',
     124                'desc' => __(
     125                    '🛑 Please do not change these settings unless you are sure what you are doing!',
     126                    'edi'
     127                ),
     128            )
     129        );
     130        $cmb_options->add_field(
     131            array(
     132                'name'            => __( 'Import chunk size (in bytes)', 'edi' ),
     133                'desc'            => __( 'The maximum allowed file size to transfer per request.', 'edi' ),
     134                'id'              => 'import_chunk_size',
     135                'type'            => 'text_small',
     136                'attributes'      => array(
     137                    'type' => 'number',
     138                    'min'  => '0',
     139                ),
     140                'default'         => 1000000,
     141                'sanitization_cb' => array( $this, 'sanitize_import_chunk_size' ),
     142            )
     143        );
     144        $cmb_options->add_field(
     145            array(
     146                'name' => __( 'Enable detailed logging', 'edi' ),
     147                'id'   => 'detailed_logging',
     148                'type' => 'checkbox',
     149            )
     150        );
    109151    }
    110152
     
    135177                    'import_attributes' => '',
    136178                    'import_images'     => '',
     179                    'import_chunk_size' => 1000000,
     180                    'detailed_logging'  => '',
    137181                )
    138182            ),
     
    202246        );
    203247    }
     248
     249    /**
     250     * Sanitize import chunk size value.
     251     *
     252     * @param string $value Import chunk size.
     253     *
     254     * @return int
     255     */
     256    public function sanitize_import_chunk_size( string $value ): int {
     257        return absint( $value );
     258    }
    204259}
  • e-commerce-data-interchange/trunk/src/Utils.php

    r2703415 r2710949  
    2525     */
    2626    public static function get_file_limit(): int {
     27        // Получаю все значения.
    2728        $file_limits = array(
     29            Settings::get_import_chunk_size(),
    2830            self::filesize_to_bytes( (string) ini_get( 'post_max_size' ) ),
    2931            self::filesize_to_bytes( (string) ini_get( 'upload_max_filesize' ) ),
     
    3133        );
    3234
    33         return (int) min( $file_limits );
     35        // Убираю все "пустые" значения.
     36        $file_limits = array_filter( $file_limits );
     37
     38        // Нахожу минимальное значение, иначе использую значение по-умолчанию 64 килобайта.
     39        $file_limit = empty( $file_limits ) ? 64000 : min( $file_limits );
     40        // Определяю 90% от найденного значения.
     41        $file_limit = $file_limit * 0.9;
     42
     43        return (int) $file_limit;
    3444    }
    3545
     
    5363                return (int) $filesize * 1000;
    5464            default:
    55                 return (int) $filesize;
     65                $filesize = (int) $filesize;
     66                if ( $filesize < 0 ) {
     67                    $filesize = 0;
     68                }
     69
     70                return $filesize;
    5671        }
    5772    }
  • e-commerce-data-interchange/trunk/vendor/autoload.php

    r2703415 r2710949  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInit2ea6fe8ada44306e7b1a1f2958fc19d4::getLoader();
     7return ComposerAutoloaderInit107406ad375ef1ce4b81c91b6324180f::getLoader();
  • e-commerce-data-interchange/trunk/vendor/composer/autoload_real.php

    r2703415 r2710949  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit2ea6fe8ada44306e7b1a1f2958fc19d4
     5class ComposerAutoloaderInit107406ad375ef1ce4b81c91b6324180f
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInit2ea6fe8ada44306e7b1a1f2958fc19d4', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInit107406ad375ef1ce4b81c91b6324180f', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
    29         spl_autoload_unregister(array('ComposerAutoloaderInit2ea6fe8ada44306e7b1a1f2958fc19d4', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInit107406ad375ef1ce4b81c91b6324180f', 'loadClassLoader'));
    3030
    3131        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    3333            require __DIR__ . '/autoload_static.php';
    3434
    35             call_user_func(\Composer\Autoload\ComposerStaticInit2ea6fe8ada44306e7b1a1f2958fc19d4::getInitializer($loader));
     35            call_user_func(\Composer\Autoload\ComposerStaticInit107406ad375ef1ce4b81c91b6324180f::getInitializer($loader));
    3636        } else {
    3737            $map = require __DIR__ . '/autoload_namespaces.php';
     
    5454
    5555        if ($useStaticLoader) {
    56             $includeFiles = Composer\Autoload\ComposerStaticInit2ea6fe8ada44306e7b1a1f2958fc19d4::$files;
     56            $includeFiles = Composer\Autoload\ComposerStaticInit107406ad375ef1ce4b81c91b6324180f::$files;
    5757        } else {
    5858            $includeFiles = require __DIR__ . '/autoload_files.php';
    5959        }
    6060        foreach ($includeFiles as $fileIdentifier => $file) {
    61             composerRequire2ea6fe8ada44306e7b1a1f2958fc19d4($fileIdentifier, $file);
     61            composerRequire107406ad375ef1ce4b81c91b6324180f($fileIdentifier, $file);
    6262        }
    6363
     
    7171 * @return void
    7272 */
    73 function composerRequire2ea6fe8ada44306e7b1a1f2958fc19d4($fileIdentifier, $file)
     73function composerRequire107406ad375ef1ce4b81c91b6324180f($fileIdentifier, $file)
    7474{
    7575    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • e-commerce-data-interchange/trunk/vendor/composer/autoload_static.php

    r2703415 r2710949  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit2ea6fe8ada44306e7b1a1f2958fc19d4
     7class ComposerStaticInit107406ad375ef1ce4b81c91b6324180f
    88{
    99    public static $files = array (
     
    3232    {
    3333        return \Closure::bind(function () use ($loader) {
    34             $loader->prefixLengthsPsr4 = ComposerStaticInit2ea6fe8ada44306e7b1a1f2958fc19d4::$prefixLengthsPsr4;
    35             $loader->prefixDirsPsr4 = ComposerStaticInit2ea6fe8ada44306e7b1a1f2958fc19d4::$prefixDirsPsr4;
    36             $loader->classMap = ComposerStaticInit2ea6fe8ada44306e7b1a1f2958fc19d4::$classMap;
     34            $loader->prefixLengthsPsr4 = ComposerStaticInit107406ad375ef1ce4b81c91b6324180f::$prefixLengthsPsr4;
     35            $loader->prefixDirsPsr4 = ComposerStaticInit107406ad375ef1ce4b81c91b6324180f::$prefixDirsPsr4;
     36            $loader->classMap = ComposerStaticInit107406ad375ef1ce4b81c91b6324180f::$classMap;
    3737
    3838        }, null, ClassLoader::class);
Note: See TracChangeset for help on using the changeset viewer.