Plugin Directory

Changeset 2777307


Ignore:
Timestamp:
08/29/2022 04:43:42 PM (4 years ago)
Author:
kinguin
Message:

Version 1.0.5 - Divide products to categories during import

Location:
kinguin/trunk
Files:
1 added
31 edited

Legend:

Unmodified
Added
Removed
  • kinguin/trunk/README.txt

    r2745667 r2777307  
    44Tags: digital downloads, EDD, video games, marketplace, eStore, games distributing, gaming
    55Requires at least: 5.0
    6 Tested up to: 6.0
    7 Stable tag: 1.0.4
     6Tested up to: 6.0.1
     7Stable tag: 1.0.5
    88Requires PHP: 7.0
    99License: GPLv2
     
    5353== Changelog ==
    5454
     55= 1.0.5 =
     56* Divide products to categories during import.
     57* Some small fixs and improvements.
     58
    5559= 1.0.4 =
    5660* New filtering options allow you to import only products that meet your criteria.
    5761* New sales options for flexible pricing.
    5862* Fixed problem with infinite import via webhook.
    59 
    6063
    6164= 1.0.3 =
  • kinguin/trunk/assets/css/kinguin-admin-import.css

    r2745667 r2777307  
    137137}
    138138
    139 .import-setup > pre {
    140     width:200px;
    141     margin-left:20px;
     139
     140/* ======== */
     141
     142
     143.progress-db {
     144    padding: 2px;
     145    background: #f3f3f3;
     146    border-radius: 4px;
     147    /*box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.25), 0 1px rgba(255, 255, 255, 0.08);*/
     148    height: 26px;
    142149}
    143150
    144 .import-setup > div > span {
    145     display: block;
    146     margin-left:20px;
     151@keyframes progressAnimation {
     152    0%   { width: 5%; background-color: #cccccc;}
     153    100% { width: 85%; background-color: #9bcd99; }
    147154}
    148155
    149 .import-setup > pre > span {
    150     margin-left:20px;
    151     display: inline-block;
     156.progress-bar-kinguin {
     157    height: 26px;
     158    border-radius: 4px;
     159    background-image:
     160            linear-gradient(to right,
     161            #7daa87, #9bcd99, #cccccc,
     162            #7daa87, #9bcd99, #cccccc);
     163    transition: 1s linear;
     164    transition-property: width, background-color;
    152165}
    153166
    154 #kinguin-import-setup {
    155     padding-bottom: 20px;
     167.progress-infinite .progress-bar-kinguin {
     168    width: 0%;
     169    max-width: 100%;
     170    background-image:
     171            linear-gradient(to right, #7daa87, #9bcd99, #cccccc, #cccccc);
     172    animation: colorAnimation 3s infinite;
    156173}
    157174
    158 #kinguin-import-setup > span > b {
    159     marging-bottom: 10px;
     175@keyframes colorAnimation {
     176    0% {
     177        background-image:
     178                linear-gradient(to right, #4cd964, #9bcd99, #cccccc, #cccccc);
     179    }
     180    20% {
     181        background-image:
     182                linear-gradient(to right, #cccccc, #7daa87, #9bcd99, #cccccc);
     183    }
     184    40% {
     185        background-image:
     186                linear-gradient(to right, #7daa87, #9bcd99, #cccccc, #cccccc);
     187    }
     188    60% {
     189        background-image:
     190                linear-gradient(to right, #9bcd99, #7daa87, #cccccc, #cccccc);
     191    }
     192    100% {
     193        background-image:
     194                linear-gradient(to right, #7daa87, #cccccc, #9bcd99, #cccccc);
     195    }
    160196}
    161 
    162 .kinguin-test-hidden-result {
    163     margin-top: 20px;
    164 }
    165 
    166 .kinguin-test-hidden-result > span {
    167     display: block;
    168 }
    169 
    170 .kinguin-test-filter-preset {
    171     font-size: 1.5em;
    172     margin-top: 20px;
    173     margin-bottom: 50px;
    174 }
    175 
    176 .kinguin-test-filter-preset > span {
    177     display: block;
    178 }
  • kinguin/trunk/assets/js/kinguin-products-import.js

    r2745667 r2777307  
    99        this.totalPages                   = parseInt( kinguin.total );
    1010        this.progress                     = 0;
     11        this.progressDB                   = 0;
     12        this.limit                        = 0;
    1113        this.progressCacheProductsUpdate  = false;
    1214        this.progressImportProductsUpdate = false;
    1315        this.cachedFiles                  = kinguin.cachedFiles;
    1416        this.importIsRunning              = false;
     17        this.notice                       = kinguin.notice;
    1518    }
    1619
     
    9295                let statusContainer = parent.setupContainer.querySelector( '.status_cache' );
    9396
     97                parent.limit = response.data.limit;
    9498                parent.totalPages = response.data.of;            // Set total pages to import from Kinguin.
    9599                parent.cachedFiles.push( response.data.file );   // Add file to array of existing files.
     
    127131                    statusContainer.classList.add( 'success' );
    128132                    statusContainer.innerHTML = 'Done';
     133                    parent.ProcessStart();
    129134                }
    130135            }
     
    156161                },
    157162                error: function( xhr, textStatus, errorThrown ) {
     163
    158164                    parent.importIsRunning = false;
     165                    parent.setupContainer.querySelector( '.kinguin-dynamic-text' ).style.display = "none";
    159166
    160167                    if (textStatus === 'timeout') {
     
    168175                        return;
    169176                    }
     177
     178                    if (textStatus === 'error') {
     179                        parent.setupContainer.querySelector( '.import-setup__process' ).classList.add( 'error' );
     180                        parent.setupContainer.querySelector( '.progress' ).innerHTML = 'An error has occurred';
     181                        return;
     182                    }
    170183                }
    171184            }).done( function( response ) {
    172 
    173185                let progressContainer = parent.setupContainer.querySelector( '.progress' );
     186                let progressCount = parent.setupContainer.querySelector( '.status_cache' );
    174187
    175188                if( parent.totalPages === 0 ) {
     189                    // nothing found
     190                    parent.setupContainer.querySelector( '.kinguin-dynamic-text' ).style.display = "none";
    176191                    let empty_response = document.createElement('div');
    177192                    empty_response.classList.add( 'kinguin-empty-response' );
    178193                    empty_response.innerHTML = '<b style="color:red; font-size:1.1em">Nothing found</b>';
    179194                    progressContainer.innerHTML = '';
     195                    progressCount.innerHTML = '';
    180196                    progressContainer.appendChild(empty_response);
    181197                }
    182198
    183199                if ( response.success === true ) {
     200
    184201                    let statusContainer = parent.setupContainer.querySelector( '.status_import' );
    185 
    186                     // Update progress position once, only at the beginning.
    187                     if ( parseInt( response.data.page ) > 1 && parent.progressImportProductsUpdate == false ) {
    188                         parent.progress = parent.progress + parseInt( response.data.page );
     202                    let pg = parent.setupContainer.querySelector( '.progress-bar-kinguin' );
     203                    let koeff = 100 / parent.totalPages;
     204                    let interrupt_step = 0;
     205
     206                    if ( parseInt( response.data.page ) > 0 && parent.progressImportProductsUpdate == false ) {
     207                        // after break
    189208                        parent.progressImportProductsUpdate = true;
     209                        parent.progressDB++;
     210                        let interrupt_step = parseInt( parent.progressDB ) * koeff * response.data.page;
     211                        let step = parseInt( parent.progressDB ) * koeff * response.data.page + '%';
     212                        pg.style.width = step;
     213
    190214                    } else {
    191                         // Progress update.
    192                         parent.progress++;
    193                     }
    194                     parent.setProgressBar();
    195                     parent.cachedFiles.shift();
     215
     216                        if ( parseInt( response.data.page ) > 1 && parent.progressImportProductsUpdate == false ) {
     217                            parent.progress = parent.progress + parseInt( response.data.page );
     218                            parent.progressDB++;
     219                            let step = parseInt( parent.progressDB ) * koeff  + '%';
     220                            pg.style.width = step;
     221
     222                        } else {
     223                            parent.progressDB++;
     224                            let step =  koeff * response.data.page;
     225                            let progress_step = step + '%';
     226                            pg.style.width = progress_step;
     227                        }
     228                    }
     229                    // if filter setting where changed and page is not reload - avoid incorrect progress bars
     230                    if( parent.totalPages > 0 && ( response.data.page > parent.totalPages ) ) {
     231                        let progressBar = parent.setupContainer.querySelector( '.progress-db' );
     232                        progressBar.innerHTML = '<b style="color:red; font-size:1.1em">' +
     233                            parent.notice +
     234                            '</b>';
     235                        return;
     236
     237                    } else {
     238                        // show not qty of products but qty of proccessed cached files
     239                        statusContainer.innerHTML = 'Proccessing file ' + response.data.page + ' of ' + parent.totalPages;
     240
     241                    }
     242
     243                    if( response.data.page < 5 ) {
     244                        parent.ProcessStart();
     245                    }
     246
     247                    parent.cachedFiles.shift();
    196248                    parent.importProducts();
    197249
     
    215267        let importProgress   = this.setupContainer.querySelector( '#import-progress' );
    216268        if( null !== importProgress && importProgress !== undefined ) {
    217             importProgress.max   = parseInt( this.totalPages ) * 2;
     269            importProgress.max   = parseInt( this.totalPages );
    218270            importProgress.value = parseInt( this.progress );
    219271        }
    220272    }
     273
     274
     275    ProcessStart() {
     276
     277        let parent = this;
     278        let dynamic_text   = parent.setupContainer.querySelector( '.kinguin-dynamic-text' );
     279        let statusContainer = parent.setupContainer.querySelector( '.status_import' );
     280
     281        var Processes = [
     282            { Percent: 1, ProgressText: 'Please take a little patience' },
     283            { Percent: 4, ProgressText: 'Please take a little patience.' },
     284            { Percent: 6, ProgressText: 'Please take a little patience..' },
     285            { Percent: 8, ProgressText: 'Please take a little patience...' },
     286            { Percent: 10, ProgressText: 'Please take a little patience...' },
     287            { Percent: 10, ProgressText: 'Please take a little patience' },
     288            { Percent: 12, ProgressText: 'Please take a little patience.' },
     289            { Percent: 14, ProgressText: 'Please take a little patience..' },
     290            { Percent: 18, ProgressText: 'Please take a little patience...' },
     291            { Percent: 20, ProgressText: 'Please take a little patience' },
     292            { Percent: 24, ProgressText: 'Please take a little patience.' },
     293            { Percent: 26, ProgressText: 'Please take a little patience..' },
     294            { Percent: 28, ProgressText: 'Please take a little patience...' },
     295            { Percent: 30, ProgressText: 'Please take a little patience' },
     296            { Percent: 31, ProgressText: 'Please take a little patience.' },
     297            { Percent: 32, ProgressText: 'Please take a little patience..' },
     298            { Percent: 33, ProgressText: 'Please take a little patience...' },
     299            { Percent: 34, ProgressText: 'We\'re proccessing files' },
     300            { Percent: 36, ProgressText: 'We\'re proccessing files.' },
     301            { Percent: 38, ProgressText: 'We\'re proccessing files..' },
     302            { Percent: 40, ProgressText: 'We\'re proccessing files...' },
     303            { Percent: 42, ProgressText: 'We\'re proccessing files' },
     304            { Percent: 44, ProgressText: 'We\'re proccessing files.' },
     305            { Percent: 46, ProgressText: 'We\'re proccessing files..' },
     306            { Percent: 48, ProgressText: 'We\'re proccessing files...' },
     307            { Percent: 50, ProgressText: 'We\'re proccessing files' },
     308            { Percent: 52, ProgressText: 'We\'re proccessing files.' },
     309            { Percent: 54, ProgressText: 'We\'re proccessing files..' },
     310            { Percent: 56, ProgressText: 'We\'re proccessing files...' },
     311            { Percent: 58, ProgressText: 'We\'re proccessing files' },
     312            { Percent: 60, ProgressText: 'We\'re proccessing files.' },
     313            { Percent: 62, ProgressText: 'We\'re proccessing files..' },
     314            { Percent: 64, ProgressText: 'We\'re proccessing files...' },
     315            { Percent: 66, ProgressText: 'We\'re proccessing files' },
     316            { Percent: 70, ProgressText: 'We\'re proccessing files.' },
     317            { Percent: 74, ProgressText: 'We\'re proccessing files..' },
     318            { Percent: 78, ProgressText: 'We\'re proccessing files...' },
     319            { Percent: 80, ProgressText: 'We\'re proccessing files' },
     320            { Percent: 82, ProgressText: 'We\'re proccessing files.' },
     321            { Percent: 86, ProgressText: 'We\'re proccessing files..' },
     322            { Percent: 90, ProgressText: 'We\'re proccessing files...' },
     323            { Percent: 94, ProgressText: 'We\'re proccessing files' },
     324            { Percent: 96, ProgressText: 'We\'re proccessing files.' },
     325            { Percent: 98, ProgressText: 'We\'re proccessing files..' },
     326            { Percent: 100, ProgressText: 'We\'re proccessing files...' }
     327        ];
     328        var Current = 0;
     329
     330        statusContainer.addEventListener("DOMSubtreeModified", function () {
     331            // To cancel an interval, pass the timer to clearInterval()
     332            clearInterval(IntervalProgress);
     333        });
     334
     335        var IntervalProgress = setInterval(function() {
     336            dynamic_text.innerHTML = Processes[Current].ProgressText;
     337            Current++;
     338            if (Current >= Processes.length) {
     339                clearInterval(IntervalProgress);
     340            }
     341        }, 1000);
     342    }
    221343}
    222344
  • kinguin/trunk/kinguin.php

    r2745667 r2777307  
    44    Description: Import over 70,000 digital products to your online store, including video games, software, gift cards and in-game content.
    55    Product: Kinguin
    6     Version: 1.0.4
     6    Version: 1.0.5
    77    Author: iLabs.dev
    88    Author URI: https://ilabs.dev/
     
    3434
    3535/* THESE TWO VARIABLES CAN BE CHANGED AUTOMATICALLY */
    36 $plugin_version     = '1.0.4';
     36$plugin_version     = '1.0.5';
    3737
    38 $plugin_name                = 'Kinguin';
    39 $plugin_class_name          = '\WPDesk\ILKinguin\Plugin';
    40 $plugin_text_domain         = 'kinguin';
    41 $product_id                 = 'kinguin';
    42 $plugin_file                = __FILE__;
    43 $kinguin_plugin_dir         = dirname( __FILE__ );
     38$plugin_name        = 'Kinguin';
     39$plugin_class_name  = '\WPDesk\ILKinguin\Plugin';
     40$plugin_text_domain = 'kinguin';
     41$product_id         = 'kinguin';
     42$plugin_file        = __FILE__;
     43$plugin_dir         = dirname( __FILE__ );
     44$kinguin_plugin_dir = dirname( __FILE__ );
    4445
    4546$requirements = [
  • kinguin/trunk/lang/kinguin-pl_PL.po

    r2712632 r2777307  
    33"Project-Id-Version: Kinguin 1.0\n"
    44"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/kinguin\n"
    5 "POT-Creation-Date: 2021-11-29T10:36:12+00:00\n"
    6 "PO-Revision-Date: 2022-04-19 13:11+0300\n"
    7 "Last-Translator: \n"
    8 "Language-Team: \n"
    9 "Language: pl_PL\n"
     5"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
     6"Language-Team: LANGUAGE <LL@li.org>\n"
    107"MIME-Version: 1.0\n"
    118"Content-Type: text/plain; charset=UTF-8\n"
    129"Content-Transfer-Encoding: 8bit\n"
    13 "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
    14 "X-Generator: Poedit 3.0.1\n"
     10"POT-Creation-Date: 2021-11-29T10:36:12+00:00\n"
     11"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
     12"Language: pl_PL\n"
     13"X-Generator: WP-CLI 2.4.0\n"
    1514"X-Domain: kinguin\n"
    1615"X-Poedit-Basepath: ../src\n"
    17 "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;\"\n"
     16"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
     17"X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"\n"
     18"X-Poedit-SearchPath-0: .\n"
    1819"X-Poedit-SourceCharset: UTF-8\n"
    19 "X-Poedit-SearchPath-0: .\n"
    2020"X-Poedit-SearchPathExcluded-0: *.js\n"
    2121
     
    127127msgstr ""
    128128
    129 #: src/Plugin/Admin/Import.php:193 src/Plugin/Admin/Import.php:249
     129#: src/Plugin/Admin/Import.php:193
     130#: src/Plugin/Admin/Import.php:249
    130131msgid "Access denied."
    131132msgstr ""
    132133
    133 #: src/Plugin/Admin/MainAdmin.php:98 src/Plugin/Admin/MainAdmin.php:99
     134#: src/Plugin/Admin/MainAdmin.php:98
     135#: src/Plugin/Admin/MainAdmin.php:99
    134136msgid "Import products"
    135137msgstr ""
    136138
    137 #: src/Plugin/Admin/MainAdmin.php:108 src/Plugin/Admin/MainAdmin.php:109
    138 #: Page/SettingsPage.php:52 Page/SettingsPage.php:53
     139#: src/Plugin/Admin/MainAdmin.php:108
     140#: src/Plugin/Admin/MainAdmin.php:109
     141#: Page/SettingsPage.php:52
     142#: Page/SettingsPage.php:53
    139143msgid "Settings"
    140144msgstr "Ustawienia"
     
    258262msgstr ""
    259263
    260 #: src/Plugin/Admin/SettingsPage.php:112 src/Plugin/Admin/SettingsPage.php:143
     264#: src/Plugin/Admin/SettingsPage.php:112
     265#: src/Plugin/Admin/SettingsPage.php:143
    261266msgid "Webhook Url"
    262267msgstr ""
     
    266271msgstr ""
    267272
    268 #: src/Plugin/Admin/SettingsPage.php:121 src/Plugin/Admin/SettingsPage.php:152
     273#: src/Plugin/Admin/SettingsPage.php:121
     274#: src/Plugin/Admin/SettingsPage.php:152
    269275msgid "Secret"
    270276msgstr ""
     
    415421msgstr ""
    416422
     423#: src/Plugin/Admin/Import.php:101
     424msgid "Filter settings have been changed - please update this page (or close / re-open)"
     425msgstr ""
     426
    417427#: Basic_Requirement_Checker.php:202
    418428#, php-format
     
    488498msgstr "WP Desk Debug Log"
    489499
    490 #: Integration/LogsIntegration.php:62 Integration/TrackerIntegration.php:80
     500#: Integration/LogsIntegration.php:62
     501#: Integration/TrackerIntegration.php:80
    491502msgid "Enable"
    492503msgstr "Włącz"
     
    515526msgstr "Żadne wrażliwe dane nie będą zbierane, %sprzeczytaj więcej%s."
    516527
    517 #: Page/LibraryDebugPage.php:34 Page/LibraryDebugPage.php:35
     528#: Page/LibraryDebugPage.php:34
     529#: Page/LibraryDebugPage.php:35
    518530msgid "Library report"
    519531msgstr "Raport bibliotek"
     
    725737msgstr "Pobierz klucze API <a href=\"%s\" target=\"_blank\">tutaj</a>. Możesz aktywować i dezaktywować klucze API <strong>dowolną ilość razy na różnych domenach</strong>, pod warunkiem, że subskrypcja jest aktywna."
    726738
    727 #: Page/LicensePage.php:45 Page/LicensePage.php:46
     739#: Page/LicensePage.php:45
     740#: Page/LicensePage.php:46
    728741msgid "Subscriptions"
    729742msgstr "Subskrypcje"
  • kinguin/trunk/src/Plugin/Admin/Configuration.php

    r2745667 r2777307  
    142142     */
    143143    public function get_currency_rate( string $currency ) : float {
    144         return ( new CurrencyExchange() )->get_currency_rate( $currency );
     144        try{
     145            return ( new CurrencyExchange() )->get_currency_rate( $currency );
     146        } catch ( \Exception $e ) {
     147            error_log( $e->getMessage() );
     148        }
    145149    }
    146150
     
    392396
    393397    /**
    394      * Get regions.
     398     * Get genres.
    395399     *
    396400     * @return array
     
    433437            '34' => 'XBOX LIVE Gold Card',
    434438            '35' => 'XBOX LIVE Points',
     439            '36' => 'Adult Games',
    435440        );
    436441    }
     
    466471    }
    467472
     473
     474    /**
     475     * Get PC platforms.
     476     *
     477     * @return array
     478     */
     479    public function get_pc_platforms() : array {
     480        return array(
     481            'EA Origin'      => 'ea-origin',
     482            'Steam'          => 'steam',
     483            'Battle.net'     => 'battle-net',
     484            'NCSoft'         => 'ncsoft',
     485            'Uplay'          => 'uplay',
     486            'GOG COM'        => 'gog-com',
     487            'Epic Games'     => 'epic-games',
     488            'Bethesda'       => 'bethesda',
     489            'Rockstar Games' => 'rockstar-games',
     490            'Mog Station'    => 'mog-station',
     491        );
     492    }
     493
     494
     495    /**
     496     * Get default categories to create during insert new products.
     497     *
     498     * @return array
     499     */
     500    public function get_default_categories() : array {
     501        return array(
     502            'XBOX 360'         => 'xbox-360-platform',
     503            'XBOX ONE'         => 'xbox-one',
     504            'XBOX Series X|S'  => 'xbox-series-xs',
     505            'PlayStation 3'    => 'playstation-3-platform',
     506            'PlayStation 4'    => 'playstation-4-platform',
     507            'PlayStation 5'    => 'playstation-5-platform',
     508            'PlayStation Vita' => 'vita-playstation',
     509            'Android'          => 'android',
     510            'Nintendo'         => 'nintendo',
     511            'Prepaid'          => 'prepaid',
     512            'Software'         => 'software',
     513            'PC'               => 'pc-platform',
     514            'Others'           => 'others-platforms'
     515        );
     516    }
     517
     518    /**
     519     * Helper function to get correct names of some categories for frontend.
     520     *
     521     * @return array
     522     */
     523    public function rename_genre_for_category() : array {
     524        return array(
     525            'Co-op'                => 'Cooperation',
     526            'Fighting'             => 'Fight',
     527            'Hidden Object'        => 'Hidden items',
     528            'Puzzle'               => 'Logic',
     529            'Story rich'           => 'Narrative',
     530            'Third-Person Shooter' => 'TPS',
     531            'Music / Soundtrack'   => 'Soundtrack',
     532            'Life Simulation'      => 'Life',
     533            'Dating Simulator'     => 'Dating',
     534        );
     535    }
     536
     537    /**
     538     * Helper function to get slugs for categories based on genres
     539     *
     540     * @return array
     541     */
     542    public function get_genre_slug() : array {
     543        return array(
     544            'Action'               => 'action',
     545            'Adventure'            => 'adventure',
     546            'Anime'                => 'anime',
     547            'Casual'               => 'casual',
     548            'Co-op'                => 'cooperation',
     549            'Dating Simulator'     => 'dating',
     550            'Fighting'             => 'fighting',
     551            'FPS'                  => 'fps',
     552            'Hack and Slash'       => 'hack-and-slash',
     553            'Hidden Object'        => 'hidden-items',
     554            'Horror'               => 'horror',
     555            'Indie'                => 'indie',
     556            'Open World'           => 'open-world',
     557            'Platformer'           => 'platformer',
     558            'Point & click'        => 'point-and-click',
     559            'PSN Card'             => 'psn-card',
     560            'Puzzle'               => 'logic',
     561            'Racing'               => 'racing',
     562            'RPG'                  => 'rpg',
     563            'Simulation'           => 'simulation',
     564            'Life Simulation'      => 'life-simulation',
     565            'Software'             => 'subcat-software',
     566            'Sport'                => 'sport',
     567            'Story rich'           => 'narrative',
     568            'Strategy'             => 'strategy',
     569            'Survival'             => 'survival',
     570            'XBOX LIVE Gold Card'  => 'xbox-live-gold-card',
     571            'Third-Person Shooter' => 'tps',
     572            'MMO'                  => 'mmo',
     573            'Music / Soundtrack'   => 'soundtrack',
     574            'Visual Novel'         => 'visual-novel',
     575            'VR Games'             => 'vr-games',
     576            'Subscription'         => 'subscription',
     577            'Adult Games'          => 'adult-games',
     578            'Online Courses'       => 'online-courses',
     579        );
     580    }
     581
    468582}
  • kinguin/trunk/src/Plugin/Admin/CurrencyExchange.php

    r2712632 r2777307  
    1111use WPDesk\ILKinguin\Admin\Exceptions\FrankfurterStatusCodeException;
    1212use WPDesk\ILKinguin\Admin\Exceptions\FrankfurterNoConnectionException;
     13use WPDesk\ILKinguin\Admin\Exceptions\FrankfurterUnsupportedCurrencyException;
    1314
    1415class CurrencyExchange {
     
    9091                $current_rate = $this->get( $currency );
    9192                $this->save_rates( $current_rate );
     93                if ( isset( $current_rate['rates'][ $currency ] ) ) {
     94                    return (float) $current_rate['rates'][ $currency ];
     95                } else {
     96                    throw new FrankfurterUnsupportedCurrencyException();
     97                }
    9298            }
    9399        } catch ( \Exception $e ) {
  • kinguin/trunk/src/Plugin/Admin/Import.php

    r2745667 r2777307  
    8585                $this->plugin_info->get_plugin_url() . '/assets/js/kinguin-products-import.js',
    8686                array(),
    87                 $this->plugin_info->get_version(),
     87                bin2hex( random_bytes( 16 ) ), //$this->plugin_info->get_version(),
    8888                true
    8989            );
     
    9999                    'cacheDir'    => $this->get_cache_dir(),
    100100                    'cachedFiles' => $this->get_cached_files(),
     101                    'notice'      => __('Filter settings have been changed - please update this page (or close / re-open)', 'kinguin'),
    101102                )
    102103            );
     
    288289            $filter_param = $this->get_filter_preset();
    289290            $products        = $import_products->get( $this->get_api_url() . '/v1/products?page=' . $page . '&limit=' . $this->limit . $filter_param);
     291
    290292            if ( property_exists( $products, 'results' ) ) {
    291293                $file  = $this->get_cache_dir()  . 'kinguin-' . $page . '.json';
     
    298300                    'file'     => 'kinguin-' . $page . '.json',
    299301                    'of'       => ceil( $products->item_count / $this->limit ),
    300                     'total'    => $products->item_count
     302                    'total'    => $products->item_count,
     303                    'limit'    => $this->limit
    301304                );
    302305            } else {
     
    335338                $import = new InsertUpdate();
    336339                $import->set_currency_rate();
     340
    337341                foreach ($products as $key => $product) {
    338342                    $import->manage($product, 1);
  • kinguin/trunk/src/Plugin/Admin/MainAdmin.php

    r2745667 r2777307  
    1616
    1717class MainAdmin {
     18    use Configuration;
    1819
    1920    /**
     
    6970
    7071
     72
    7173    /**
    7274     * Integrate with WordPress admin actions and filters.
     
    7678    public function hooks() {
    7779        add_action( 'admin_menu', array( $this, 'admin_menu_items' ) );
     80        add_action( 'before_delete_post', array( $this, 'kinguin_delete_thumbnail') );       
    7881    }
    79 
    8082
    8183
     
    123125    }
    124126
     127
     128    /**
     129     * Remove product image if deleting products to save disk quota
     130     */
     131    public function kinguin_delete_thumbnail( $pid ) {
     132
     133        if( 'product' == get_post_type( $pid ) ) {
     134            $product = new \WC_product( $pid );
     135            $product_id = $product->get_id();
     136            $sku_label = explode('-', $product->get_sku())[0];
     137
     138            if ( $product_id && $sku_label === 'kinguin' ) {
     139                $product_thumbnail = get_post_thumbnail_id( $product_id );
     140                wp_delete_attachment($product_thumbnail, true);
     141            }
     142        }
     143
     144    }
     145
    125146}
  • kinguin/trunk/src/Plugin/Admin/Product/Attributes.php

    r2745667 r2777307  
    4040        add_action( 'admin_init', array( $this, 'platform_attribute' ) );
    4141        add_action( 'admin_init', array( $this, 'languages_attribute' ) );
    42     }
     42    }
    4343
    4444
    45     /**
     45
     46    /**
    4647     * Register developers product attribute taxonomy
    4748     */
  • kinguin/trunk/src/Plugin/Admin/Product/DataTabs.php

    r2745667 r2777307  
    4949
    5050        add_action( 'woocommerce_product_options_pricing', array( $this, 'kinguin_price_before_margin'), 10, 0 );
    51         add_filter('gettext',  array( $this, 'kinguin_change_backend_product_regular_price'), 100, 3 );
     51        add_filter( 'gettext',  array( $this, 'kinguin_change_backend_product_regular_price'), 100, 3 );
    5252    }
    5353
     
    166166     */
    167167    public function save_product_data_tab_inputs( $post_id ) {
    168         update_post_meta( $post_id, '_kinguinPrice', sanitize_text_field( $_POST['_kinguinPrice'] ) );
    169         update_post_meta( $post_id, '_steam', sanitize_text_field( $_POST['_steam'] ) );
    170         update_post_meta( $post_id, '_ageRating', sanitize_text_field( $_POST['_ageRating'] ) );
    171         update_post_meta( $post_id, '_regionId', sanitize_text_field( $_POST['_regionId'] ) );
    172         update_post_meta( $post_id, '_activationDetails', sanitize_textarea_field( $_POST['_activationDetails'] ) );
     168        if( isset( $_POST['_kinguinPrice'] ) ) {
     169            update_post_meta( $post_id, '_kinguinPrice', sanitize_text_field($_POST['_kinguinPrice'] ) );
     170        }
     171        if( isset( $_POST['_steam'] ) ) {
     172            update_post_meta( $post_id, '_steam', sanitize_text_field( $_POST['_steam'] ) );
     173        }
     174        if( isset( $_POST['_ageRating'] ) ) {
     175            update_post_meta( $post_id, '_ageRating', sanitize_text_field( $_POST['_ageRating'] ) );
     176        }
     177        if( isset( $_POST['_regionId'] ) ) {
     178            update_post_meta( $post_id, '_regionId', sanitize_text_field( $_POST['_regionId'] ) );
     179        }
     180        if( isset( $_POST['_activationDetails'] ) ) {
     181            update_post_meta( $post_id, '_activationDetails', sanitize_textarea_field( $_POST['_activationDetails'] ) );
     182        }
    173183    }
    174184
     
    218228    public function kinguin_price_before_margin() {
    219229        global $post;
    220         $product = wc_get_product( $post->ID );
    221         woocommerce_wp_text_input( array(
    222             'custom_attributes' => array('readonly' => 'readonly'),
    223             'id' => 'wholesaler_price',
    224             'placeholder' => $product->get_price(),
    225             'class' => 'wc_input_price short',
    226             'label' => __( 'Price after margin', 'kinguin' ) . ' (' . get_woocommerce_currency_symbol() . ')',
    227         ) );
     230        if ( metadata_exists( 'post', $post->ID, '_kinguinId' ) ) {
     231            $product = wc_get_product($post->ID);
     232            woocommerce_wp_text_input(array(
     233                'custom_attributes' => array('readonly' => 'readonly'),
     234                'id' => 'wholesaler_price',
     235                'placeholder' => $product->get_price(),
     236                'class' => 'wc_input_price short',
     237                'label' => __('Price after margin', 'kinguin') . ' (' . get_woocommerce_currency_symbol() . ')',
     238            ));
     239        }
    228240    }
    229241
     
    233245     */
    234246    public function kinguin_change_backend_product_regular_price( $translated_text, $text, $domain ) {
    235         global $pagenow, $post_type;
    236 
    237         if ( is_admin() && in_array( $pagenow, ['post.php', 'post-new.php'] )
    238             && 'product' === $post_type && 'Regular price' === $text  && 'woocommerce' === $domain )
    239         {
    240             $translated_text =  __( 'Kinguin price', 'kinguin' );
    241         }
     247        global $pagenow, $post_type, $post;
     248
     249            if (is_admin() && in_array($pagenow, ['post.php', 'post-new.php'])
     250                && 'product' === $post_type && 'Regular price' === $text && 'woocommerce' === $domain) {
     251                if ( metadata_exists( 'post', $post->ID, '_kinguinId' ) ) {
     252                    $translated_text = __('Kinguin price', 'kinguin');
     253                }
     254            }
     255
    242256        return $translated_text;
    243257    }
  • kinguin/trunk/src/Plugin/Admin/Product/InsertUpdate.php

    r2745667 r2777307  
    5353    public function manage( array $product, bool $manual_import = null ) {
    5454        $post_id = $this->get_post_id( $product['productId'] );
     55
    5556        if ( $post_id ) {
    5657            return $this->update( $post_id, $product );
     
    107108     */
    108109    public function prepare_post( array $product , bool $is_new_item = null) {
     110
     111        //write_log($product);
    109112
    110113        $post = array(
     
    200203     *
    201204     * @param array $product Kinguin single product from API response.
     205     * @return int|string post ID
    202206     */
    203207    public function insert( array $product ) {
    204208        $post_id = wp_insert_post( $this->prepare_post( $product, 1 ) );
    205209        if ( ! is_wp_error( $post_id ) ) {
     210            // assign main category
     211            $kinguin_main_category_id = $this->get_kinguin_main_category( $product );
     212            $res = wp_set_object_terms( $post_id, (int) $kinguin_main_category_id, 'product_cat', false );
     213
     214            // assign subcategories
     215            if ( ! is_wp_error( $res ) ) {
     216                $this->kinguin_set_subcategory( $product, (int) $kinguin_main_category_id, $post_id );
     217            }
     218
    206219            return $post_id;
    207220        }
     
    209222
    210223
    211     public function check_filter_conditions(array $product) {
     224    public function check_filter_conditions( array $product ) {
    212225        $filter = get_option( 'kinguin_settings_import' );
    213226
    214         if(!empty($filter['kinguinId'])) {
    215             $arr_ids = explode(',', $filter['kinguinId']);
    216             if(!empty($arr_ids)) {
    217                 foreach ($arr_ids as $id) {
    218                     if(!empty($id)) {
    219                         if($id != $product['kinguinId']) {
     227        if( !empty( $filter['kinguinId'] ) ) {
     228            $arr_ids = explode(',', $filter['kinguinId'] );
     229            if( !empty( $arr_ids ) ) {
     230                foreach( $arr_ids as $id) {
     231                    if(!empty( $id ) ) {
     232                        if( $id != $product['kinguinId'] ) {
    220233                            return false;
    221234                        }
     
    287300     * @param int $post_id product ID.
    288301     * @param array $product Kinguin single product from API response.
     302     * @return int|string post ID
    289303     */
    290304    public function update( int $post_id, array $product ) {
     
    416430     * Get product tags ids
    417431     *
    418      * @param string[] $names    Array of terms to look for and instert.
     432     * @param string[] $names    Array of terms to look for and insert.
    419433     * @param string   $taxonomy Taxonomy name.
    420434     *
     
    454468    }
    455469
     470
     471    /**
     472     * Get ID of main category for Kinguin product
     473     *
     474     * @param array $product Kinguin single product from API response.
     475     * @return int Product Category ID.
     476     */
     477    public function get_kinguin_main_category( array $product ) {
     478
     479        // map main category based on platform
     480        $mapped_main_category = $this->define_main_category( $product );
     481
     482        $id = term_exists( $mapped_main_category['slug'], 'product_cat' );
     483        if( $id == NULL )
     484        {
     485            $id = wp_insert_term(
     486                $mapped_main_category['term'],
     487                'product_cat',
     488                array(
     489                    'description'=> $mapped_main_category['term'],
     490                    'slug' => $mapped_main_category['slug']
     491                )
     492            );
     493            if ( ! is_wp_error( $id ) ) {
     494                return $id['term_id'];
     495            }
     496
     497        } else {
     498            return $id['term_id'];
     499        }
     500
     501    }
     502
     503
     504    /**
     505     * Map main category for product based on platform, tag
     506     *
     507     * @param array $product Kinguin single product from API response.
     508     * @return array Product Category slug and Category name.
     509     */
     510    public function define_main_category( $product )
     511    {
     512        if ( in_array( 'prepaid', $product['tags'] ) ) {
     513            return array( 'term' => 'Prepaid', 'slug' => 'prepaid' );
     514
     515        } else if ( in_array('software', $product['tags'] ) ) {
     516            return array( 'term' => 'Software', 'slug' => 'software' );
     517
     518        } else if ( array_key_exists( $product['platform'], $this->get_default_categories() ) ) {
     519            $slug = $this->get_default_categories()[$product['platform']];
     520            return array( 'term' => $product['platform'], 'slug' => $slug );
     521
     522        } else if ( array_key_exists( $product['platform'], $this->get_pc_platforms() ) ) {
     523            return array( 'term' => 'PC', 'slug' => 'pc-platform' );
     524
     525        } else {
     526            // it will be 'Others' category
     527            return array( 'term' => 'Others', 'slug' => 'others-platforms' );
     528        }
     529    }
     530
     531
     532    /**
     533     * Assign sub-categories 2 and 3 level
     534     *
     535     * @param array $product Kinguin single product from API response.
     536     * @param int  parent category ID.
     537     * @param int|string post ID
     538     * @return void
     539     */
     540    public function kinguin_set_subcategory( $product, $parent_cat_id, $post_id ) {
     541
     542        // PC categories proccessing
     543        if ( array_key_exists( $product['platform'], $this->get_pc_platforms() )
     544            && !in_array( 'prepaid', $product['tags'] )
     545            && !in_array( 'software', $product['tags'] )
     546        ) {
     547
     548            $id = term_exists( $product['platform'], 'product_cat', $parent_cat_id );
     549            if( $id == NULL )
     550            {
     551
     552                $slug = $this->get_pc_platforms()[$product['platform']];
     553
     554                $id = wp_insert_term(
     555                    $product['platform'],
     556                    'product_cat',
     557                    array(
     558                        'description'=> $product['platform'],
     559                        'slug' => $slug,
     560                        'parent'=> $parent_cat_id
     561                    )
     562                );
     563            }
     564            $res =  wp_set_object_terms( $post_id, (int) $id['term_id'], 'product_cat',true );
     565
     566            if( ! empty( $product['genres'] ) && ! is_wp_error( $res ) ) {
     567                foreach( $product['genres'] as $key => $genre ) {
     568
     569                    // WordPress does not allow child categories/terms to have same name even tough they have a different parent
     570                    $slug = strtolower( $product['platform'] ) . '-' . $this->get_genre_slug()[$genre];
     571
     572                    $sub_id = term_exists( $slug, 'product_cat', (int) $id['term_id'] );
     573                    if( $sub_id == NULL )
     574                    {
     575                        $genre = $this->fix_genre_cat_name( $genre );
     576
     577                        $sub_id = wp_insert_term(
     578                            $genre,
     579                            'product_cat',
     580                            array(
     581                                'description'=> $genre,
     582                                'slug' => $slug,
     583                                'parent'=> (int) $id['term_id']
     584                            )
     585                        );
     586                    }
     587                    wp_set_object_terms( $post_id, (int) $sub_id['term_id'], 'product_cat',true );
     588                }
     589            }
     590
     591        } else if ( array_key_exists( $product['platform'], $this->get_default_categories() )
     592            && !in_array( 'prepaid', $product['tags'] )
     593            && !in_array( 'software', $product['tags'] )
     594        ) {
     595            // assign genre-subcategories for main categories except PC
     596            if( ! empty( $product['genres'] ) ) {
     597                foreach( $product['genres'] as $key => $genre ) {
     598                    // WordPress does not allow child categories/terms to have same name even tough they have a different parent
     599                    $slug = strtolower( $product['platform'] ) . '-' . $this->get_genre_slug()[$genre];
     600                    $id = term_exists( $slug, 'product_cat', $parent_cat_id );
     601                    if( $id == NULL )
     602                    {
     603                        $genre = $this->fix_genre_cat_name( $genre );
     604
     605                        $id = wp_insert_term(
     606                            $genre,
     607                            'product_cat',
     608                            array(
     609                                'description'=> $genre,
     610                                'slug' => $slug,
     611                                'parent'=> $parent_cat_id
     612                            )
     613                        );
     614                    }
     615                    wp_set_object_terms( $post_id, (int) $id['term_id'], 'product_cat',true );
     616                }
     617            }
     618        }
     619
     620    }
     621
     622    /**
     623     * Return corrected Category name for frontend
     624     *
     625     * @param string  Genre name.
     626     * @return string  Category name.
     627     */
     628    public function fix_genre_cat_name( $genre ) {
     629        if( array_key_exists( $genre, $this->rename_genre_for_category() ) ) {
     630            return $this->rename_genre_for_category()[$genre];
     631        }
     632        return $genre;
     633    }
     634
     635
    456636}
  • kinguin/trunk/src/Plugin/Admin/SettingsPage.php

    r2745667 r2777307  
    4949    public function hooks() {
    5050        add_action( 'admin_init', array( $this, 'register_plugin_settings' ) );
    51         add_action( 'admin_enqueue_scripts', array( $this, 'settings_scripts' ) );
     51        add_action( 'admin_enqueue_scripts', array( $this, 'kinguin_import_settings' ) );
     52    }
     53
     54
     55    /**
     56     * Enqueue styles and script for import filter tab.
     57     *
     58     * @return void
     59     */
     60    public function kinguin_import_settings() {
     61        $current_screen = get_current_screen();
     62        if ( is_a( $current_screen, 'WP_Screen' ) && 'import-products_page_kinguin-settings' === $current_screen->id ) {
     63            if( isset($_GET['page']) && 'kinguin-settings' === $_GET['page']
     64            ) {
     65                wp_enqueue_style('kinguin_import_settings', $this->plugin_info->get_plugin_url() . '/assets/css/kinguin-import-settings.css', array(), $this->plugin_info->get_version(), false);
     66                wp_enqueue_script('kinguin_import_settings-js', $this->plugin_info->get_plugin_url() . '/assets/js/kinguin-import-settings.js', array(), $this->plugin_info->get_version(), false);
     67            }
    5268        }
    53 
    54 
    55     public function settings_scripts() {
    56         wp_enqueue_style( 'kinguin-test', $this->plugin_info->get_plugin_url() . '/assets/css/kinguin-import-settings.css', array(), $this->plugin_info->get_version(), false );
    57         wp_enqueue_script( 'kinguin-test-js', $this->plugin_info->get_plugin_url() . '/assets/js/kinguin-import-settings.js', array(), $this->plugin_info->get_version(), false );
    58 
    5969    }
    6070
     
    8191            array( $this, 'validate_api_key' )
    8292        );
     93
     94        add_settings_section( 'kinguin_settings', '', false, 'kinguin_settings' );
     95
    8396        add_settings_field(
    8497            'kinguin_api_key',
     
    420433    public function kinguin_product_margin_callback() {
    421434
    422         $options = get_option( 'kinguin_product_margin' ); ?>
    423 
    424         <input type="radio" id="kinguin_product_margin_fix" name="kinguin_product_margin[kinguin_margin_type]" value="1" <?php echo ' ' . checked( 1, $options['kinguin_margin_type'], false )?> />
    425 
    426         <label for="kinguin_product_margin_fix">
    427             <?php echo esc_html_e('Flat fee', 'kinguin') ?>
    428             (<?php echo esc_html( get_woocommerce_currency_symbol() ) ?>)
    429         </label>
    430 
    431         <input type="radio" id="kinguin_product_margin_percent" name="kinguin_product_margin[kinguin_margin_type]" value="2" <?php echo ' ' . checked( 2, $options['kinguin_margin_type'], false ) ?> />
    432 
    433         <label for="kinguin_product_margin_percent">
    434             <?php echo esc_html_e('Percent', 'kinguin') ?>
    435         </label>
    436 
    437 
    438     <?php }
     435        $options = get_option( 'kinguin_product_margin' );
     436
     437        if( isset( $options['kinguin_margin_type'] ) ) { ?>
     438
     439            <input type="radio" id="kinguin_product_margin_fix" name="kinguin_product_margin[kinguin_margin_type]"
     440                   value="1" <?php echo ' ' . checked(1, $options['kinguin_margin_type'], false); ?> />
     441
     442            <label for="kinguin_product_margin_fix">
     443                <?php echo esc_html_e('Flat fee', 'kinguin') ?>
     444                (<?php echo esc_html(get_woocommerce_currency_symbol()) ?>)
     445            </label>
     446
     447            <input type="radio" id="kinguin_product_margin_percent" name="kinguin_product_margin[kinguin_margin_type]"
     448                   value="2" <?php echo ' ' .  checked(2, $options['kinguin_margin_type'], false); ?> />
     449
     450            <label for="kinguin_product_margin_percent">
     451                <?php echo esc_html_e('Percent', 'kinguin') ?>
     452            </label>
     453
     454        <?php } else { ?>
     455
     456            <input type="radio" id="kinguin_product_margin_fix" name="kinguin_product_margin[kinguin_margin_type]"
     457                   value="1" checked />
     458
     459            <label for="kinguin_product_margin_fix">
     460                <?php echo esc_html_e('Flat fee', 'kinguin') ?>
     461                (<?php echo esc_html(get_woocommerce_currency_symbol()) ?>)
     462            </label>
     463
     464            <input type="radio" id="kinguin_product_margin_percent" name="kinguin_product_margin[kinguin_margin_type]"
     465                   value="2" />
     466
     467            <label for="kinguin_product_margin_percent">
     468                <?php echo esc_html_e('Percent', 'kinguin') ?>
     469            </label>
     470
     471        <?php }
     472    }
    439473
    440474
     
    910944            </div>
    911945
    912        
     946
    913947        </div>
    914948    <?php }
  • kinguin/trunk/src/Plugin/Admin/templates/import_template.php

    r2712632 r2777307  
    2929        </header>
    3030
    31         <div class="import-setup__begin">
    32             <div class="message">
     31        <div class="import-setup__begin">
     32            <div class="message">
    3333                <?php if ( ! $memory_limit_error ) : ?>
    34 
    35                     <p>
    36                         <?php esc_attr_e( 'Due to huge Kinguin games library (above 32.000) this process is rather long and take easily couple of hours. However its duration is heavily dependent of Your server configuration - it is quicker on servers with greater RAM amount. We recommend to import products during low site traffic like for e.g on the night time. You can always interrupt this process and it will automatically resumes where You left.', 'kinguin' ); ?>
    37                     </p>
    38                     <p>
    39                         <?php esc_attr_e( 'Click - Import Products - to begin with product import.', 'kinguin' ); ?>
    40                     </p>
     34                <p>
     35                    <?php esc_attr_e( 'Due to huge Kinguin games library (above 32.000) this process is rather long and take easily couple of hours. However its duration is heavily dependent of Your server configuration - it is quicker on servers with greater RAM amount. We recommend to import products during low site traffic like for e.g on the night time. You can always interrupt this process and it will automatically resumes where You left.', 'kinguin' ); ?>
     36                </p>
     37                <p>
     38                    <?php esc_attr_e( 'Click - Import Products - to begin with product import.', 'kinguin' ); ?>
     39                </p>
    4140                <?php else : ?>
    4241                    <?php esc_attr_e( 'Unfortunately the amount of memory limit is set too low to import such huge number products efficiently. Please contact with Your server administrator to increase memory limit to at least 160 MB. Remember that the higher memory limit allow You to get Kinguin products quicker into Your store.', 'kinguin' ); ?>
    4342                <?php endif; ?>
     43            </div>
     44        </div>
     45
     46        <div class="import-setup__process">
     47            <dl>
     48                <dt>
     49                    <?php esc_attr_e( 'Create cache directory', 'kinguin' ); ?>
     50                </dt>
     51                <dd>
     52                    <span class="status_cache_dir"></span>
     53                </dd>
     54                <dt>
     55                    <?php esc_attr_e( 'Importing products sets from Kinguin', 'kinguin' ); ?>
     56                </dt>
     57                <dd>
     58                    <span class="status_cache"></span>
     59                </dd>
     60            </dl>
     61            <div class="progress">
     62                <progress id="import-progress" max="0" value="0"></progress>
     63            </div>
     64            <dl>
     65                <dt>
     66                    <span class="kinguin-dynamic-text">
     67                        <?php esc_attr_e( 'Creating products from cached files', 'kinguin' ); ?>
     68                    </span>
     69                </dt>
     70                <dd>
     71                    <span class="status_import"></span>
     72                </dd>
     73            </dl>
     74            <div class="progress-db progress-infinite">
     75                <div class="progress-bar-kinguin">
     76                </div>
    4477            </div>
    4578        </div>
    46 
    47         <div class="import-setup__process">
    48             <dl>
    49                 <dt>
    50                     <?php esc_attr_e( 'Create cache directory', 'kinguin' ); ?>
    51                 </dt>
    52                 <dd>
    53                     <span class="status_cache_dir"></span>
    54                 </dd>
    55                 <dt>
    56                     <?php esc_attr_e( 'Importing products sets from Kinguin', 'kinguin' ); ?>
    57                 </dt>
    58                 <dd>
    59                     <span class="status_cache"></span>
    60                 </dd>
    61                 <dt>
    62                     <?php esc_attr_e( 'Creating products', 'kinguin' ); ?>
    63                 </dt>
    64                 <dd>
    65                     <span class="status_import"></span>
    66                 </dd>
    67             </dl>
    68             <div class="progress">
    69                 <progress id="import-progress" max="0" value="0"></progress>
    70             </div>
    71         </div>
    7279
    7380        <div class="import-setup__done">
  • kinguin/trunk/src/Plugin/Common/ProductMargin.php

    r2745667 r2777307  
    5454            }
    5555        }
     56       
    5657        return $price;
    5758    }
  • kinguin/trunk/src/Plugin/Common/ProductWebHook.php

    r2745667 r2777307  
    109109        $post = new InsertUpdate();
    110110        $post->set_currency_rate();
    111 
    112         if ( $post->manage( $product ) ) {
    113             return array(
    114                 'status'   => 200,
    115                 'response' => 'Product updated'
    116             );
    117         } else {
    118             return array(
    119                 'status'   => 404,
    120                 'response' => 'Product not found'
    121             );
    122         }
    123 
     111        if ( $post->manage( $product ) ) {
     112            return array(
     113                'status'   => 200,
     114                'response' => 'Product updated'
     115            );
     116        } else {
     117            return array(
     118                'status'   => 404,
     119                'response' => 'Product not found'
     120            );
     121        }
    124122    }
    125123
  • kinguin/trunk/src/Plugin/Frontend/MainFrontend.php

    r2745667 r2777307  
    5252        add_action( 'woocommerce_new_order', array( new NewOrder(), 'order' ), 1, 2 );
    5353        add_action( 'pre_get_posts', array( $this, 'product_filter' ) );
    54     }
     54        add_action( 'woocommerce_archive_description', array( $this, 'kinguin_filter_search_results_title' ) );
     55    }
    5556
    5657
     
    8889    }
    8990
     91
     92    /**
     93     * Show title for filtered results on shop archive page
     94     *
     95     */
     96    public function kinguin_filter_search_results_title() {
     97        if ( ! is_admin() && is_post_type_archive( 'product' ) ) {
     98            $attributes = wc_get_attribute_taxonomies();
     99            if ( $attributes ) {
     100                $attributes = wp_list_pluck( $attributes, 'attribute_name' );
     101
     102                $params = array_filter(
     103                    $_GET,
     104                    function( $param ) {
     105                        return sanitize_text_field( $param );
     106                    }
     107                );
     108
     109                if ( isset( $params ) ) {
     110                    foreach ( $params as $param => $value ) {
     111                        if ( in_array($param, $attributes ) ) {
     112                            echo '<h2>' . __( 'All products that meet the criteria', 'kinguin' ) . ' "' . $param . ' - ' . ucfirst( $value ) . '":</h2>';
     113                        }
     114                    }
     115                }
     116            }
     117        }
     118    }
     119
    90120}
  • kinguin/trunk/src/Plugin/Plugin.php

    r2745667 r2777307  
    9696        add_action( 'rest_api_init', array( new OrderWebHook(), 'register_route' ) );
    9797        add_action( 'rest_api_init', array( new ProductWebHook(), 'register_route' ) );
    98 
    99     }
     98    }
    10099
    101100
  • kinguin/trunk/vendor/autoload.php

    r2720754 r2777307  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInit4ea417124d576bddbefffedfa0c43822::getLoader();
     7return ComposerAutoloaderInitcc4a59561dee07d5b0b9c74b6e9b762e::getLoader();
  • kinguin/trunk/vendor/composer/autoload_real.php

    r2720754 r2777307  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInit4ea417124d576bddbefffedfa0c43822
     5class ComposerAutoloaderInitcc4a59561dee07d5b0b9c74b6e9b762e
    66{
    77    private static $loader;
     
    2525        require __DIR__ . '/platform_check.php';
    2626
    27         spl_autoload_register(array('ComposerAutoloaderInit4ea417124d576bddbefffedfa0c43822', 'loadClassLoader'), true, true);
     27        spl_autoload_register(array('ComposerAutoloaderInitcc4a59561dee07d5b0b9c74b6e9b762e', 'loadClassLoader'), true, true);
    2828        self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
    29         spl_autoload_unregister(array('ComposerAutoloaderInit4ea417124d576bddbefffedfa0c43822', 'loadClassLoader'));
     29        spl_autoload_unregister(array('ComposerAutoloaderInitcc4a59561dee07d5b0b9c74b6e9b762e', '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\ComposerStaticInit4ea417124d576bddbefffedfa0c43822::getInitializer($loader));
     35            call_user_func(\Composer\Autoload\ComposerStaticInitcc4a59561dee07d5b0b9c74b6e9b762e::getInitializer($loader));
    3636        } else {
    3737            $map = require __DIR__ . '/autoload_namespaces.php';
     
    5454
    5555        if ($useStaticLoader) {
    56             $includeFiles = Composer\Autoload\ComposerStaticInit4ea417124d576bddbefffedfa0c43822::$files;
     56            $includeFiles = Composer\Autoload\ComposerStaticInitcc4a59561dee07d5b0b9c74b6e9b762e::$files;
    5757        } else {
    5858            $includeFiles = require __DIR__ . '/autoload_files.php';
    5959        }
    6060        foreach ($includeFiles as $fileIdentifier => $file) {
    61             composerRequire4ea417124d576bddbefffedfa0c43822($fileIdentifier, $file);
     61            composerRequirecc4a59561dee07d5b0b9c74b6e9b762e($fileIdentifier, $file);
    6262        }
    6363
     
    6666}
    6767
    68 function composerRequire4ea417124d576bddbefffedfa0c43822($fileIdentifier, $file)
     68function composerRequirecc4a59561dee07d5b0b9c74b6e9b762e($fileIdentifier, $file)
    6969{
    7070    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • kinguin/trunk/vendor/composer/autoload_static.php

    r2745667 r2777307  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInit4ea417124d576bddbefffedfa0c43822
     7class ComposerStaticInitcc4a59561dee07d5b0b9c74b6e9b762e
    88{
    99    public static $files = array (
     
    349349    {
    350350        return \Closure::bind(function () use ($loader) {
    351             $loader->prefixLengthsPsr4 = ComposerStaticInit4ea417124d576bddbefffedfa0c43822::$prefixLengthsPsr4;
    352             $loader->prefixDirsPsr4 = ComposerStaticInit4ea417124d576bddbefffedfa0c43822::$prefixDirsPsr4;
    353             $loader->classMap = ComposerStaticInit4ea417124d576bddbefffedfa0c43822::$classMap;
     351            $loader->prefixLengthsPsr4 = ComposerStaticInitcc4a59561dee07d5b0b9c74b6e9b762e::$prefixLengthsPsr4;
     352            $loader->prefixDirsPsr4 = ComposerStaticInitcc4a59561dee07d5b0b9c74b6e9b762e::$prefixDirsPsr4;
     353            $loader->classMap = ComposerStaticInitcc4a59561dee07d5b0b9c74b6e9b762e::$classMap;
    354354
    355355        }, null, ClassLoader::class);
  • kinguin/trunk/vendor/composer/installed.php

    r2745667 r2777307  
    11<?php return array(
    22    'root' => array(
    3         'pretty_version' => '1.0.0+no-version-set',
    4         'version' => '1.0.0.0',
     3        'pretty_version' => 'dev-master',
     4        'version' => 'dev-master',
    55        'type' => 'library',
    66        'install_path' => __DIR__ . '/../../',
    77        'aliases' => array(),
    8         'reference' => NULL,
     8        'reference' => 'cfdfaeb7df61da06d6f75a52c27c6abb3453cd91',
    99        'name' => 'wpdesk/kinguin',
    1010        'dev' => false,
     
    2121        ),
    2222        'wpdesk/kinguin' => array(
    23             'pretty_version' => '1.0.0+no-version-set',
    24             'version' => '1.0.0.0',
     23            'pretty_version' => 'dev-master',
     24            'version' => 'dev-master',
    2525            'type' => 'library',
    2626            'install_path' => __DIR__ . '/../../',
    2727            'aliases' => array(),
    28             'reference' => NULL,
     28            'reference' => 'cfdfaeb7df61da06d6f75a52c27c6abb3453cd91',
    2929            'dev_requirement' => false,
    3030        ),
  • kinguin/trunk/vendor_prefixed/wpdesk/wp-logs/src/deprecated/wpdesk-logger-factory.php

    r2712632 r2777307  
    4545        {
    4646            $message = 'Error: ' . \get_class($e) . ' Code: ' . $e->get_error_code() . ' Message: ' . $e->get_error_message();
    47             self::log_message_backtrace($message, \ILKinguinVendor\WPDesk_Logger::ERROR, $backtrace);
     47            self::log_message_backtrace($message, $backtrace, \ILKinguinVendor\WPDesk_Logger::ERROR );
    4848        }
    4949        /**
     
    7777         * @param array  $backtrace Backtrace information with snapshot of error env.
    7878         */
    79         public static function log_message_backtrace($message, $level = \ILKinguinVendor\WPDesk_Logger::DEBUG, array $backtrace)
     79        public static function log_message_backtrace( $message, array $backtrace, $level = \ILKinguinVendor\WPDesk_Logger::DEBUG )
    8080        {
    8181            $message .= ' Backtrace: ' . \json_encode($backtrace);
  • kinguin/trunk/vendor_prefixed/wpdesk/wp-plugin-flow/composer.json

    r2720754 r2777307  
    1010        "php": ">=5.6",
    1111        "wpdesk\/wp-basic-requirements": "^3.2.3",
    12         "wpdesk\/wp-builder": "^1.4.4"
     12        "wpdesk\/wp-builder": "^1.4.4",
     13        "wpdesk\/wp-wpdesk-license": "^2.10.1",
     14        "wpdesk\/wp-wpdesk-helper": "^2.4",
     15        "wpdesk\/wp-wpdesk-tracker": "^2.3.1"
    1316    },
    1417    "require-dev": {
     
    1720        "squizlabs\/php_codesniffer": "^3.4.2",
    1821        "10up\/wp_mock": "^0.2",
    19         "wpdesk\/wp-wpdesk-composer": "^2.3",
    20         "wpdesk\/wp-wpdesk-license": "^2.10.1",
    21         "wpdesk\/wp-wpdesk-helper": "^2.4",
    22         "wpdesk\/wp-wpdesk-tracker": "^2.3.1"
     22        "wpdesk\/wp-wpdesk-composer": "^2.3"
    2323    },
    2424    "autoload": {
  • kinguin/trunk/vendor_prefixed/wpdesk/wp-plugin-flow/src/plugin-init-php52-free.php

    r2745667 r2777307  
    88 * @var string $plugin_class_name
    99 * @var string $plugin_text_domain
    10  * @var string $kinguin_plugin_dir
     10 * @var string $plugin_dir
    1111 * @var string $plugin_file
    1212 * @var array  $requirements
     
    1818// Code in PHP >= 5.3 but understandable by older parsers
    1919if (\PHP_VERSION_ID > 50300) {
    20     require_once $kinguin_plugin_dir . '/vendor/autoload.php';
     20    require_once $plugin_dir . '/vendor/autoload.php';
    2121    $plugin_init_factory = new \ILKinguinVendor\WPDesk\Plugin\Flow\Initialization\Simple\SimpleFactory(\true);
    2222}
  • kinguin/trunk/vendor_prefixed/wpdesk/wp-plugin-flow/src/plugin-init-php52.php

    r2745667 r2777307  
    88 * @var string                                                       $plugin_class_name
    99 * @var string                                                       $plugin_text_domain
    10  * @var string                                                       $kinguin_plugin_dir
     10 * @var string                                                       $plugin_dir
    1111 * @var string                                                       $plugin_file
    1212 * @var array                                                        $requirements
     
    1919// Code in PHP >= 5.3 but understandable by older parsers
    2020if (\PHP_VERSION_ID > 50300) {
    21     require_once $kinguin_plugin_dir . '/vendor/autoload.php';
     21    require_once $plugin_dir . '/vendor/autoload.php';
    2222    if (!isset($plugin_init_factory)) {
    2323        $plugin_init_factory = new \ILKinguinVendor\WPDesk\Plugin\Flow\Initialization\Simple\SimpleFactory();
     
    3030        $plugin_class_name,
    3131        $plugin_text_domain,
    32         $kinguin_plugin_dir,
     32        $plugin_dir,
    3333        $plugin_file,
    3434        $requirements,
  • kinguin/trunk/vendor_prefixed/wpdesk/wp-wpdesk-helper/composer.json

    r2720754 r2777307  
    1010        "php": ">=5.6",
    1111        "wpdesk\/wp-logs": "^1.6.0",
     12        "wpdesk\/wp-wpdesk-license": "^2.6",
     13        "wpdesk\/wp-wpdesk-tracker": "^2.0.4",
    1214        "wpdesk\/wp-builder": "^1.2",
    1315        "wpdesk\/wp-notice": "^3.1.1",
     
    2022        "mockery\/mockery": "*",
    2123        "10up\/wp_mock": "*",
    22         "wimg\/php-compatibility": "^8",
    23         "wpdesk\/wp-wpdesk-license": "^2.6",
    24         "wpdesk\/wp-wpdesk-tracker": "^2.0.4"
     24        "wimg\/php-compatibility": "^8"
    2525    },
    2626    "autoload": {
  • kinguin/trunk/vendor_prefixed/wpdesk/wp-wpdesk-helper/src/PrefixedHelperAsLibrary.php

    r2720754 r2777307  
    6363    {
    6464        $this->add_wpdesk_menu();
    65         //$subscription_integration = new \ILKinguinVendor\WPDesk\Helper\Integration\LicenseIntegration();
    66         //$subscription_integration->hooks();
     65        $subscription_integration = new \ILKinguinVendor\WPDesk\Helper\Integration\LicenseIntegration();
     66        $subscription_integration->hooks();
    6767        $settingsPage = new \ILKinguinVendor\WPDesk\Helper\Page\SettingsPage();
    6868        $settings_integration = new \ILKinguinVendor\WPDesk\Helper\Integration\SettingsIntegration($settingsPage);
    69         //$tracker_integration = new \ILKinguinVendor\WPDesk\Helper\Integration\TrackerIntegration($settingsPage);
     69        $tracker_integration = new \ILKinguinVendor\WPDesk\Helper\Integration\TrackerIntegration($settingsPage);
    7070        $logger_integration = new \ILKinguinVendor\WPDesk\Helper\Integration\LogsIntegration($settingsPage);
    7171        $settings_integration->add_hookable($logger_integration);
    72         //$settings_integration->add_hookable($tracker_integration);
     72        $settings_integration->add_hookable($tracker_integration);
    7373        $settings_integration->hooks();
    74         //self::$tracker = $tracker_integration->get_tracker();
     74        self::$tracker = $tracker_integration->get_tracker();
    7575        self::$logger = $logger_integration->get_logger();
    7676        (new \ILKinguinVendor\WPDesk\Helper\UpgradeSoonNotice())->show_info_about_upgrade_if_old_env();
  • kinguin/trunk/vendor_prefixed/wpdesk/wp-wpdesk-license/src/ApiManager/class-wc-key-api.php

    r2720754 r2777307  
    4848                        \ILKinguinVendor\WPDesk_Logger_Factory::log_wp_error($request, \debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS));
    4949                    } else {
    50                         \ILKinguinVendor\WPDesk_Logger_Factory::log_message_backtrace('Response is invalid. Response: ' . \json_encode($request), \ILKinguinVendor\WPDesk_Logger::ERROR, \debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS));
     50                        \ILKinguinVendor\WPDesk_Logger_Factory::log_message_backtrace('Response is invalid. Response: ' . \json_encode($request), \debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS), \ILKinguinVendor\WPDesk_Logger::ERROR );
    5151                    }
    5252                }
     
    6868                        \ILKinguinVendor\WPDesk_Logger_Factory::log_wp_error($request, \debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS));
    6969                    } else {
    70                         \ILKinguinVendor\WPDesk_Logger_Factory::log_message_backtrace('Response is invalid. Response: ' . \json_encode($request), \ILKinguinVendor\WPDesk_Logger::ERROR, \debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS));
     70                        \ILKinguinVendor\WPDesk_Logger_Factory::log_message_backtrace('Response is invalid. Response: ' . \json_encode($request), \debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS), \ILKinguinVendor\WPDesk_Logger::ERROR );
    7171                    }
    7272                }
     
    9797                        \ILKinguinVendor\WPDesk_Logger_Factory::log_wp_error($request, \debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS));
    9898                    } else {
    99                         \ILKinguinVendor\WPDesk_Logger_Factory::log_message_backtrace('Response is invalid. Response: ' . \json_encode($request), \ILKinguinVendor\WPDesk_Logger::ERROR, \debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS));
     99                        \ILKinguinVendor\WPDesk_Logger_Factory::log_message_backtrace('Response is invalid. Response: ' . \json_encode($request), \debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS), \ILKinguinVendor\WPDesk_Logger::ERROR );
    100100                    }
    101101                }
  • kinguin/trunk/vendor_prefixed/wpdesk/wp-wpdesk-license/src/ApiManager/class-wc-plugin-update.php

    r2720754 r2777307  
    202202                        \ILKinguinVendor\WPDesk_Logger_Factory::log_wp_error($request, \debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS));
    203203                    } else {
    204                         \ILKinguinVendor\WPDesk_Logger_Factory::log_message_backtrace('Response is invalid. Response: ' . \json_encode($request), \ILKinguinVendor\WPDesk_Logger::ERROR, \debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS));
     204                        \ILKinguinVendor\WPDesk_Logger_Factory::log_message_backtrace('Response is invalid. Response: ' . \json_encode($request), \debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS), \ILKinguinVendor\WPDesk_Logger::ERROR );
    205205                    }
    206206                }
     
    235235            } else {
    236236                if (\class_exists('ILKinguinVendor\\WPDesk_Logger_Factory')) {
    237                     \ILKinguinVendor\WPDesk_Logger_Factory::log_message_backtrace('Response is not an object', \ILKinguinVendor\WPDesk_Logger::DEBUG, \debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS));
     237                    \ILKinguinVendor\WPDesk_Logger_Factory::log_message_backtrace('Response is not an object', \debug_backtrace(\DEBUG_BACKTRACE_PROVIDE_OBJECT | \DEBUG_BACKTRACE_IGNORE_ARGS), \ILKinguinVendor\WPDesk_Logger::DEBUG );
    238238                } else {
    239239                    \error_log("Unserialize error. Please send this report to support@wpdesk.net. Request: {$request}. Raw Response: {$raw_response}");
Note: See TracChangeset for help on using the changeset viewer.