diff --git a/composer.lock b/composer.lock index 697cda12..8ec3024e 100644 --- a/composer.lock +++ b/composer.lock @@ -180,18 +180,18 @@ "source": { "type": "git", "url": "https://github.com/byteever/byteever-sniffs.git", - "reference": "12bbcbbd8bbdda2bd325ee7d744bbfb2378f3a02" + "reference": "edea620f99832e84079dfdcda634d805a9573c62" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/byteever/byteever-sniffs/zipball/12bbcbbd8bbdda2bd325ee7d744bbfb2378f3a02", - "reference": "12bbcbbd8bbdda2bd325ee7d744bbfb2378f3a02", + "url": "https://api.github.com/repos/byteever/byteever-sniffs/zipball/edea620f99832e84079dfdcda634d805a9573c62", + "reference": "edea620f99832e84079dfdcda634d805a9573c62", "shasum": "" }, "require": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", - "phpcompatibility/phpcompatibility-wp": "2.1.0", - "wp-coding-standards/wpcs": "^2.3.0" + "dealerdirect/phpcodesniffer-composer-installer": "^0.7", + "phpcompatibility/phpcompatibility-wp": "^2.1", + "wp-coding-standards/wpcs": "^3.0" }, "require-dev": { "roave/security-advisories": "dev-latest" @@ -233,7 +233,7 @@ "source": "https://github.com/byteever/byteever-sniffs/tree/master", "issues": "https://github.com/byteever/byteever-sniffs/issues" }, - "time": "2022-11-21T08:46:53+00:00" + "time": "2023-10-12T09:08:28+00:00" }, { "name": "codeception/codeception", @@ -2043,16 +2043,16 @@ }, { "name": "league/mime-type-detection", - "version": "1.13.0", + "version": "1.14.0", "source": { "type": "git", "url": "https://github.com/thephpleague/mime-type-detection.git", - "reference": "a6dfb1194a2946fcdc1f38219445234f65b35c96" + "reference": "b6a5854368533df0295c5761a0253656a2e52d9e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/a6dfb1194a2946fcdc1f38219445234f65b35c96", - "reference": "a6dfb1194a2946fcdc1f38219445234f65b35c96", + "url": "https://api.github.com/repos/thephpleague/mime-type-detection/zipball/b6a5854368533df0295c5761a0253656a2e52d9e", + "reference": "b6a5854368533df0295c5761a0253656a2e52d9e", "shasum": "" }, "require": { @@ -2083,7 +2083,7 @@ "description": "Mime-type detection for Flysystem", "support": { "issues": "https://github.com/thephpleague/mime-type-detection/issues", - "source": "https://github.com/thephpleague/mime-type-detection/tree/1.13.0" + "source": "https://github.com/thephpleague/mime-type-detection/tree/1.14.0" }, "funding": [ { @@ -2095,7 +2095,7 @@ "type": "tidelift" } ], - "time": "2023-08-05T12:09:49+00:00" + "time": "2023-10-17T14:13:20+00:00" }, { "name": "level-level/wp-browser-woocommerce", @@ -2737,16 +2737,16 @@ }, { "name": "php-webdriver/webdriver", - "version": "1.15.0", + "version": "1.15.1", "source": { "type": "git", "url": "https://github.com/php-webdriver/php-webdriver.git", - "reference": "a1578689290055586f1ee51eaf0ec9d52895bb6d" + "reference": "cd52d9342c5aa738c2e75a67e47a1b6df97154e8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/a1578689290055586f1ee51eaf0ec9d52895bb6d", - "reference": "a1578689290055586f1ee51eaf0ec9d52895bb6d", + "url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/cd52d9342c5aa738c2e75a67e47a1b6df97154e8", + "reference": "cd52d9342c5aa738c2e75a67e47a1b6df97154e8", "shasum": "" }, "require": { @@ -2755,7 +2755,7 @@ "ext-zip": "*", "php": "^7.3 || ^8.0", "symfony/polyfill-mbstring": "^1.12", - "symfony/process": "^5.0 || ^6.0" + "symfony/process": "^5.0 || ^6.0 || ^7.0" }, "replace": { "facebook/webdriver": "*" @@ -2797,9 +2797,9 @@ ], "support": { "issues": "https://github.com/php-webdriver/php-webdriver/issues", - "source": "https://github.com/php-webdriver/php-webdriver/tree/1.15.0" + "source": "https://github.com/php-webdriver/php-webdriver/tree/1.15.1" }, - "time": "2023-08-29T13:52:26+00:00" + "time": "2023-10-20T12:21:20+00:00" }, { "name": "phpcompatibility/php-compatibility", @@ -2922,16 +2922,16 @@ }, { "name": "phpcompatibility/phpcompatibility-wp", - "version": "2.1.0", + "version": "2.1.4", "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibilityWP.git", - "reference": "41bef18ba688af638b7310666db28e1ea9158b2f" + "reference": "b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/41bef18ba688af638b7310666db28e1ea9158b2f", - "reference": "41bef18ba688af638b7310666db28e1ea9158b2f", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibilityWP/zipball/b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5", + "reference": "b6c1e3ee1c35de6c41a511d5eb9bd03e447480a5", "shasum": "" }, "require": { @@ -2939,10 +2939,10 @@ "phpcompatibility/phpcompatibility-paragonie": "^1.0" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5" + "dealerdirect/phpcodesniffer-composer-installer": "^0.7" }, "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || This Composer plugin will sort out the PHP_CodeSniffer 'installed_paths' automatically.", "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues." }, "type": "phpcodesniffer-standard", @@ -2966,13 +2966,150 @@ "compatibility", "phpcs", "standards", + "static analysis", "wordpress" ], "support": { "issues": "https://github.com/PHPCompatibility/PHPCompatibilityWP/issues", "source": "https://github.com/PHPCompatibility/PHPCompatibilityWP" }, - "time": "2019-08-28T14:22:28+00:00" + "time": "2022-10-24T09:00:36+00:00" + }, + { + "name": "phpcsstandards/phpcsextra", + "version": "1.1.2", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", + "reference": "746c3190ba8eb2f212087c947ba75f4f5b9a58d5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/746c3190ba8eb2f212087c947ba75f4f5b9a58d5", + "reference": "746c3190ba8eb2f212087c947ba75f4f5b9a58d5", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "phpcsstandards/phpcsutils": "^1.0.8", + "squizlabs/php_codesniffer": "^3.7.1" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpcsstandards/phpcsdevcs": "^1.1.6", + "phpcsstandards/phpcsdevtools": "^1.2.1", + "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSExtra/graphs/contributors" + } + ], + "description": "A collection of sniffs and standards for use with PHP_CodeSniffer.", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues", + "source": "https://github.com/PHPCSStandards/PHPCSExtra" + }, + "time": "2023-09-20T22:06:18+00:00" + }, + { + "name": "phpcsstandards/phpcsutils", + "version": "1.0.8", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", + "reference": "69465cab9d12454e5e7767b9041af0cd8cd13be7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/69465cab9d12454e5e7767b9041af0cd8cd13be7", + "reference": "69465cab9d12454e5e7767b9041af0cd8cd13be7", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^3.7.1 || 4.0.x-dev@dev" + }, + "require-dev": { + "ext-filter": "*", + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", + "phpcsstandards/phpcsdevcs": "^1.1.6", + "yoast/phpunit-polyfills": "^1.0.5 || ^2.0.0" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHPCSUtils/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors" + } + ], + "description": "A suite of utility functions for use with PHP_CodeSniffer", + "homepage": "https://phpcsutils.com/", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "phpcs3", + "standards", + "static analysis", + "tokens", + "utility" + ], + "support": { + "docs": "https://phpcsutils.com/", + "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues", + "source": "https://github.com/PHPCSStandards/PHPCSUtils" + }, + "time": "2023-07-16T21:39:41+00:00" }, { "name": "phpunit/php-code-coverage", @@ -6978,30 +7115,38 @@ }, { "name": "wp-coding-standards/wpcs", - "version": "2.3.0", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", - "reference": "7da1894633f168fe244afc6de00d141f27517b62" + "reference": "b4caf9689f1a0e4a4c632679a44e638c1c67aff1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/7da1894633f168fe244afc6de00d141f27517b62", - "reference": "7da1894633f168fe244afc6de00d141f27517b62", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/b4caf9689f1a0e4a4c632679a44e638c1c67aff1", + "reference": "b4caf9689f1a0e4a4c632679a44e638c1c67aff1", "shasum": "" }, "require": { + "ext-filter": "*", + "ext-libxml": "*", + "ext-tokenizer": "*", + "ext-xmlreader": "*", "php": ">=5.4", - "squizlabs/php_codesniffer": "^3.3.1" + "phpcsstandards/phpcsextra": "^1.1.0", + "phpcsstandards/phpcsutils": "^1.0.8", + "squizlabs/php_codesniffer": "^3.7.2" }, "require-dev": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || ^0.6", + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.3.2", "phpcompatibility/php-compatibility": "^9.0", - "phpcsstandards/phpcsdevtools": "^1.0", + "phpcsstandards/phpcsdevtools": "^1.2.0", "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" }, "suggest": { - "dealerdirect/phpcodesniffer-composer-installer": "^0.6 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically." + "ext-iconv": "For improved results", + "ext-mbstring": "For improved results" }, "type": "phpcodesniffer-standard", "notification-url": "https://packagist.org/downloads/", @@ -7018,6 +7163,7 @@ "keywords": [ "phpcs", "standards", + "static analysis", "wordpress" ], "support": { @@ -7025,7 +7171,13 @@ "source": "https://github.com/WordPress/WordPress-Coding-Standards", "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" }, - "time": "2020-05-13T23:57:56+00:00" + "funding": [ + { + "url": "https://opencollective.com/thewpcc/contribute/wp-php-63406", + "type": "custom" + } + ], + "time": "2023-09-14T07:06:09+00:00" }, { "name": "zordius/lightncandy", diff --git a/examples/api-test.php b/examples/api-test.txt similarity index 99% rename from examples/api-test.php rename to examples/api-test.txt index 2dc12629..680db184 100644 --- a/examples/api-test.php +++ b/examples/api-test.txt @@ -4,7 +4,6 @@ if ( ! current_user_can( 'manage_options' ) ) { die(); } - // API variables, please override. $base_url = 'http://domain.com'; $email = 'example@domain.com'; diff --git a/languages/wc-serial-numbers.pot b/languages/wc-serial-numbers.pot index efc89bbc..0ab17146 100644 --- a/languages/wc-serial-numbers.pot +++ b/languages/wc-serial-numbers.pot @@ -4,7 +4,7 @@ msgid "" msgstr "" "Project-Id-Version: Serial Numbers for WooCommerce 1.6.3\n" "Report-Msgid-Bugs-To: https://pluginever.com/plugins/wc-serial-numbers/\n" -"POT-Creation-Date: 2023-10-08 10:13:10+00:00\n" +"POT-Creation-Date: 2023-10-25 06:00:24+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -53,7 +53,7 @@ msgstr "" msgid "More Plugins" msgstr "" -#: lib/Lib/Plugin.php:692 src/Admin/Menus.php:179 src/Admin/Menus.php:180 +#: lib/Lib/Plugin.php:692 src/Admin/Menus.php:169 src/Admin/Menus.php:170 msgid "Settings" msgstr "" @@ -87,14 +87,6 @@ msgstr "" msgid "Report a Bug" msgstr "" -#: lib/classes/wp-background-process.php:653 -msgid "Every Minute" -msgstr "" - -#: lib/classes/wp-background-process.php:655 -msgid "Every %d Minutes" -msgstr "" - #: src/API.php:60 msgid "Invalid action." msgstr "" @@ -175,11 +167,11 @@ msgstr "" msgid "Serial key is deactivated." msgstr "" -#: src/Admin/Actions.php:223 +#: src/Admin/Actions.php:222 msgid "Key added successfully." msgstr "" -#: src/Admin/Actions.php:225 +#: src/Admin/Actions.php:224 msgid "Key updated successfully." msgstr "" @@ -223,68 +215,68 @@ msgstr "" msgid "Version %s" msgstr "" -#: src/Admin/Admin.php:141 src/Admin/Menus.php:56 src/Admin/Menus.php:97 -#: src/Admin/Menus.php:98 src/Admin/Menus.php:440 src/Admin/Metaboxes.php:33 -#: src/Admin/Metaboxes.php:229 src/Functions/Template.php:226 +#: src/Admin/Admin.php:141 src/Admin/Menus.php:52 src/Admin/Menus.php:87 +#: src/Admin/Menus.php:88 src/Admin/Menus.php:429 src/Admin/Metaboxes.php:35 +#: src/Admin/Metaboxes.php:247 src/Functions/Template.php:226 msgid "Serial Numbers" msgstr "" #: src/Admin/ListTables/ActivationsTable.php:39 -#: src/Admin/ListTables/KeysTable.php:320 +#: src/Admin/ListTables/KeysTable.php:319 msgid "Activation" msgstr "" -#: src/Admin/ListTables/ActivationsTable.php:40 src/Admin/Menus.php:128 -#: src/Admin/Menus.php:129 src/Admin/views/html-list-activations.php:18 +#: src/Admin/ListTables/ActivationsTable.php:40 src/Admin/Menus.php:118 +#: src/Admin/Menus.php:119 src/Admin/views/html-list-activations.php:18 msgid "Activations" msgstr "" -#: src/Admin/ListTables/ActivationsTable.php:101 +#: src/Admin/ListTables/ActivationsTable.php:100 msgid "No activations found. Once a serial key is activated, it will appear here." msgstr "" -#: src/Admin/ListTables/ActivationsTable.php:125 -#: src/Admin/ListTables/KeysTable.php:244 -#: src/Admin/ListTables/StockTable.php:92 +#: src/Admin/ListTables/ActivationsTable.php:113 +#: src/Admin/ListTables/KeysTable.php:243 +#: src/Admin/ListTables/StockTable.php:82 msgid "Filter" msgstr "" -#: src/Admin/ListTables/ActivationsTable.php:177 -#: src/Admin/ListTables/ActivationsTable.php:252 -#: src/Admin/ListTables/KeysTable.php:300 +#: src/Admin/ListTables/ActivationsTable.php:165 +#: src/Admin/ListTables/ActivationsTable.php:240 +#: src/Admin/ListTables/KeysTable.php:299 #: src/Admin/ListTables/KeysTable.php:391 src/Admin/views/html-edit-key.php:130 msgid "Delete" msgstr "" -#: src/Admin/ListTables/ActivationsTable.php:189 +#: src/Admin/ListTables/ActivationsTable.php:177 #: src/Admin/views/html-api-actions.php:141 src/Frontend/Shortcodes.php:141 msgid "Instance" msgstr "" -#: src/Admin/ListTables/ActivationsTable.php:190 -#: src/Admin/ListTables/KeysTable.php:314 -#: src/Admin/ListTables/StockTable.php:105 src/Admin/views/html-add-key.php:33 +#: src/Admin/ListTables/ActivationsTable.php:178 +#: src/Admin/ListTables/KeysTable.php:313 +#: src/Admin/ListTables/StockTable.php:95 src/Admin/views/html-add-key.php:33 #: src/Admin/views/html-api-actions.php:118 #: src/Admin/views/html-api-validation.php:121 -#: src/Admin/views/html-edit-key.php:37 src/Deprecated/Functions.php:359 +#: src/Admin/views/html-edit-key.php:37 src/Deprecated/Functions.php:358 #: src/Frontend/Shortcodes.php:40 src/Frontend/Shortcodes.php:136 msgid "Product" msgstr "" -#: src/Admin/ListTables/ActivationsTable.php:191 -#: src/Admin/ListTables/KeysTable.php:313 src/Admin/Orders.php:192 +#: src/Admin/ListTables/ActivationsTable.php:179 +#: src/Admin/ListTables/KeysTable.php:312 src/Admin/Orders.php:192 #: src/Admin/views/html-api-actions.php:131 #: src/Admin/views/html-api-validation.php:134 src/Functions/Template.php:42 -#: src/functions.php:998 +#: src/functions.php:1009 msgid "Key" msgstr "" -#: src/Admin/ListTables/ActivationsTable.php:192 +#: src/Admin/ListTables/ActivationsTable.php:180 #: src/Admin/views/html-api-actions.php:152 src/Frontend/Shortcodes.php:143 msgid "Platform" msgstr "" -#: src/Admin/ListTables/ActivationsTable.php:193 +#: src/Admin/ListTables/ActivationsTable.php:181 msgid "Activation Time" msgstr "" @@ -296,135 +288,137 @@ msgstr "" msgid "keys" msgstr "" -#: src/Admin/ListTables/KeysTable.php:170 +#: src/Admin/ListTables/KeysTable.php:169 msgid "No keys found." msgstr "" -#: src/Admin/ListTables/KeysTable.php:170 +#: src/Admin/ListTables/KeysTable.php:169 msgid "Add new key" msgstr "" -#: src/Admin/ListTables/KeysTable.php:174 +#: src/Admin/ListTables/KeysTable.php:173 msgid "Keys can have one of the following statuses:" msgstr "" -#: src/Admin/ListTables/KeysTable.php:178 -#: src/Admin/ListTables/KeysTable.php:223 src/functions.php:46 +#: src/Admin/ListTables/KeysTable.php:177 +#: src/Admin/ListTables/KeysTable.php:222 src/functions.php:46 msgid "Available" msgstr "" -#: src/Admin/ListTables/KeysTable.php:180 +#: src/Admin/ListTables/KeysTable.php:179 msgid "This means the key is available for purchase." msgstr "" -#: src/Admin/ListTables/KeysTable.php:183 -#: src/Admin/ListTables/KeysTable.php:224 src/functions.php:47 +#: src/Admin/ListTables/KeysTable.php:182 +#: src/Admin/ListTables/KeysTable.php:223 src/functions.php:47 msgid "Pending" msgstr "" -#: src/Admin/ListTables/KeysTable.php:185 +#: src/Admin/ListTables/KeysTable.php:184 msgid "This means the key has been sold, but the order has not been completed yet." msgstr "" -#: src/Admin/ListTables/KeysTable.php:188 -#: src/Admin/ListTables/KeysTable.php:225 -#: src/Admin/ListTables/StockTable.php:107 src/functions.php:48 +#: src/Admin/ListTables/KeysTable.php:187 +#: src/Admin/ListTables/KeysTable.php:224 +#: src/Admin/ListTables/StockTable.php:97 src/functions.php:48 msgid "Sold" msgstr "" -#: src/Admin/ListTables/KeysTable.php:190 +#: src/Admin/ListTables/KeysTable.php:189 msgid "This means the key has been sold, and the order has been completed." msgstr "" -#: src/Admin/ListTables/KeysTable.php:193 -#: src/Admin/ListTables/KeysTable.php:226 src/Functions/Template.php:72 +#: src/Admin/ListTables/KeysTable.php:192 +#: src/Admin/ListTables/KeysTable.php:225 src/Functions/Template.php:72 #: src/functions.php:49 msgid "Expired" msgstr "" -#: src/Admin/ListTables/KeysTable.php:195 +#: src/Admin/ListTables/KeysTable.php:194 msgid "This means the key has expired and is no longer valid." msgstr "" -#: src/Admin/ListTables/KeysTable.php:198 -#: src/Admin/ListTables/KeysTable.php:227 src/functions.php:50 +#: src/Admin/ListTables/KeysTable.php:197 +#: src/Admin/ListTables/KeysTable.php:226 src/functions.php:50 msgid "Cancelled" msgstr "" -#: src/Admin/ListTables/KeysTable.php:200 +#: src/Admin/ListTables/KeysTable.php:199 msgid "" "This means the key has been cancelled and is no longer available for " "purchase or use." msgstr "" -#: src/Admin/ListTables/KeysTable.php:222 +#: src/Admin/ListTables/KeysTable.php:221 msgid "All keys." msgstr "" -#: src/Admin/ListTables/KeysTable.php:222 +#: src/Admin/ListTables/KeysTable.php:221 msgid "All" msgstr "" -#: src/Admin/ListTables/KeysTable.php:223 +#: src/Admin/ListTables/KeysTable.php:222 msgid "Available for sell." msgstr "" -#: src/Admin/ListTables/KeysTable.php:224 +#: src/Admin/ListTables/KeysTable.php:223 msgid "Pending payment." msgstr "" -#: src/Admin/ListTables/KeysTable.php:225 +#: src/Admin/ListTables/KeysTable.php:224 msgid "Sold keys." msgstr "" -#: src/Admin/ListTables/KeysTable.php:226 +#: src/Admin/ListTables/KeysTable.php:225 msgid "Expired keys." msgstr "" -#: src/Admin/ListTables/KeysTable.php:227 +#: src/Admin/ListTables/KeysTable.php:226 msgid "Cancelled keys." msgstr "" -#: src/Admin/ListTables/KeysTable.php:301 +#: src/Admin/ListTables/KeysTable.php:300 msgid "Reset Activations" msgstr "" -#: src/Admin/ListTables/KeysTable.php:315 src/Admin/views/html-add-key.php:120 +#: src/Admin/ListTables/KeysTable.php:314 src/Admin/views/html-add-key.php:120 msgid "Order" msgstr "" -#: src/Admin/ListTables/KeysTable.php:316 +#: src/Admin/ListTables/KeysTable.php:315 msgid "Validity" msgstr "" -#: src/Admin/ListTables/KeysTable.php:323 +#: src/Admin/ListTables/KeysTable.php:322 msgid "Order Date" msgstr "" -#: src/Admin/ListTables/KeysTable.php:324 src/Admin/Menus.php:328 +#: src/Admin/ListTables/KeysTable.php:323 src/Admin/Menus.php:316 #: src/Admin/Orders.php:204 src/Admin/views/html-add-key.php:91 #: src/Admin/views/html-edit-key.php:92 src/Functions/Template.php:78 -#: src/functions.php:1023 +#: src/functions.php:1034 msgid "Status" msgstr "" #: src/Admin/ListTables/KeysTable.php:389 +#. translators: %d: key id. msgid "ID: %d" msgstr "" #: src/Admin/ListTables/KeysTable.php:390 -#: src/Admin/ListTables/StockTable.php:153 +#: src/Admin/ListTables/StockTable.php:143 msgid "Edit" msgstr "" -#: src/Admin/ListTables/KeysTable.php:481 +#: src/Admin/ListTables/KeysTable.php:485 +#. translators: %1$s: validity, %2$s: validity. msgid "%s Day
After purchase" msgid_plural "%s Days
After purchase" msgstr[0] "" msgstr[1] "" -#: src/Admin/ListTables/KeysTable.php:481 src/Admin/Orders.php:197 -#: src/Functions/Template.php:63 src/functions.php:1019 +#: src/Admin/ListTables/KeysTable.php:495 src/Admin/Orders.php:197 +#: src/Functions/Template.php:63 src/functions.php:1030 msgid "Lifetime" msgstr "" @@ -453,161 +447,156 @@ msgstr "" msgid "No products selling serial keys from \"stock\" found." msgstr "" -#: src/Admin/ListTables/StockTable.php:106 +#: src/Admin/ListTables/StockTable.php:96 msgid "Source" msgstr "" -#: src/Admin/ListTables/StockTable.php:108 src/Admin/Menus.php:287 +#: src/Admin/ListTables/StockTable.php:98 src/Admin/Menus.php:277 msgid "Stock" msgstr "" -#: src/Admin/ListTables/StockTable.php:182 +#: src/Admin/ListTables/StockTable.php:172 msgid "Manual" msgstr "" -#: src/Admin/ListTables/StockTable.php:184 +#: src/Admin/ListTables/StockTable.php:174 msgid "Generator Rule" msgstr "" -#: src/Admin/ListTables/StockTable.php:186 +#: src/Admin/ListTables/StockTable.php:176 msgid "Auto Generated" msgstr "" -#: src/Admin/ListTables/StockTable.php:188 +#: src/Admin/ListTables/StockTable.php:178 msgid "Unknown" msgstr "" -#: src/Admin/Menus.php:108 src/Admin/Menus.php:109 +#: src/Admin/Menus.php:98 src/Admin/Menus.php:99 #: src/Admin/views/html-list-keys.php:18 msgid "Serial Keys" msgstr "" -#: src/Admin/Menus.php:145 src/Admin/Menus.php:146 +#: src/Admin/Menus.php:135 src/Admin/Menus.php:136 msgid "Tools" msgstr "" -#: src/Admin/Menus.php:162 src/Admin/Menus.php:163 +#: src/Admin/Menus.php:152 src/Admin/Menus.php:153 msgid "Reports" msgstr "" -#: src/Admin/Menus.php:199 src/Admin/Metaboxes.php:125 -#: src/Admin/Metaboxes.php:144 +#: src/Admin/Menus.php:189 src/Admin/Metaboxes.php:135 +#: src/Admin/Metaboxes.php:156 msgid "Upgrade to Pro" msgstr "" -#: src/Admin/Menus.php:253 src/Admin/Menus.php:389 +#: src/Admin/Menus.php:243 src/Admin/Menus.php:377 msgid "Generators" msgstr "" -#: src/Admin/Menus.php:254 +#: src/Admin/Menus.php:244 msgid "API Toolkit" msgstr "" -#: src/Admin/Menus.php:255 src/Admin/views/html-list-keys.php:25 +#: src/Admin/Menus.php:245 src/Admin/views/html-list-keys.php:25 msgid "Import" msgstr "" -#: src/Admin/Menus.php:256 src/Admin/views/html-list-keys.php:29 +#: src/Admin/Menus.php:246 src/Admin/views/html-list-keys.php:29 msgid "Export" msgstr "" -#: src/Admin/Menus.php:343 src/Admin/Menus.php:350 src/Admin/Menus.php:368 -#: src/Admin/Menus.php:386 +#: src/Admin/Menus.php:331 src/Admin/Menus.php:338 src/Admin/Menus.php:356 +#: src/Admin/Menus.php:374 msgid "Available in Pro Version" msgstr "" -#: src/Admin/Menus.php:344 src/Admin/Menus.php:351 src/Admin/Menus.php:369 -#: src/Admin/Menus.php:387 +#: src/Admin/Menus.php:332 src/Admin/Menus.php:339 src/Admin/Menus.php:357 +#: src/Admin/Menus.php:375 msgid "Upgrade to Pro Now" msgstr "" -#: src/Admin/Menus.php:346 src/Admin/Menus.php:353 +#: src/Admin/Menus.php:334 src/Admin/Menus.php:341 msgid "Import Serial Numbers" msgstr "" -#: src/Admin/Menus.php:371 +#: src/Admin/Menus.php:359 msgid "Export Serial Numbers" msgstr "" -#: src/Admin/Menus.php:416 +#: src/Admin/Menus.php:404 msgid "Table exists" msgstr "" -#: src/Admin/Menus.php:418 +#: src/Admin/Menus.php:406 msgid "Table does not exist" msgstr "" -#: src/Admin/Menus.php:424 +#: src/Admin/Menus.php:412 msgid "Hourly cron" msgstr "" -#: src/Admin/Menus.php:425 +#: src/Admin/Menus.php:413 msgid "Daily cron" msgstr "" -#: src/Admin/Menus.php:430 +#: src/Admin/Menus.php:419 +#. translators: %s: Next scheduled time. msgid "Next run: %s" msgstr "" -#: src/Admin/Menus.php:432 +#: src/Admin/Menus.php:421 msgid "Not scheduled" msgstr "" -#: src/Admin/Metaboxes.php:54 +#: src/Admin/Metaboxes.php:56 msgid "Sell keys" msgstr "" -#: src/Admin/Metaboxes.php:55 +#: src/Admin/Metaboxes.php:57 msgid "Enable this if you are selling keys or licensing this product." msgstr "" -#: src/Admin/Metaboxes.php:68 +#: src/Admin/Metaboxes.php:70 msgid "Delivery quantity" msgstr "" -#: src/Admin/Metaboxes.php:69 +#: src/Admin/Metaboxes.php:71 msgid "Number of key(s) will be delivered per item. Available in PRO." msgstr "" -#: src/Admin/Metaboxes.php:89 +#: src/Admin/Metaboxes.php:91 src/Admin/Metaboxes.php:123 msgid "Key source" msgstr "" -#: src/Admin/Metaboxes.php:107 +#: src/Admin/Metaboxes.php:109 msgid "Software version" msgstr "" -#: src/Admin/Metaboxes.php:108 +#: src/Admin/Metaboxes.php:110 msgid "Version number for the software. Ignore if it's not a software." msgstr "" -#: src/Admin/Metaboxes.php:109 +#: src/Admin/Metaboxes.php:111 msgid "e.g. 1.0" msgstr "" -#: src/Admin/Metaboxes.php:120 -msgid "Stock status" -msgstr "" - -#: src/Admin/Metaboxes.php:122 +#: src/Admin/Metaboxes.php:125 msgid "key available." msgid_plural "keys available." msgstr[0] "" msgstr[1] "" -#: src/Admin/Metaboxes.php:125 -msgid "" -"Want the keys to be generated automatically, auto assign with orders, and " -"many more?" +#: src/Admin/Metaboxes.php:133 +msgid "Want to sell keys for variable products?" msgstr "" -#: src/Admin/Metaboxes.php:144 +#: src/Admin/Metaboxes.php:154 msgid "" "The free version of Serial Numbers for WooCommerce does not support product " "variation." msgstr "" -#: src/Admin/Metaboxes.php:214 +#: src/Admin/Metaboxes.php:229 msgid "Order missing serial numbers for this item." msgstr "" @@ -1145,7 +1134,7 @@ msgstr "" #: src/Admin/views/html-api-actions.php:162 #: src/Admin/views/html-api-validation.php:144 -#: src/Admin/views/html-edit-key.php:154 src/Deprecated/Functions.php:361 +#: src/Admin/views/html-edit-key.php:154 src/Deprecated/Functions.php:360 #: src/Frontend/Shortcodes.php:43 src/Frontend/Shortcodes.php:139 msgid "Email" msgstr "" @@ -1184,6 +1173,7 @@ msgid "API response" msgstr "" #: src/Admin/views/html-api-actions.php:195 src/Frontend/Shortcodes.php:146 +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:284 msgid "Submit" msgstr "" @@ -1358,20 +1348,20 @@ msgstr "" msgid "Serial Numbers stock running low" msgstr "" -#: src/Deprecated/Functions.php:155 +#: src/Deprecated/Functions.php:154 msgid "Serial number not found." msgstr "" -#: src/Deprecated/Functions.php:360 +#: src/Deprecated/Functions.php:359 msgid "Serial Number" msgstr "" -#: src/Deprecated/Functions.php:362 src/Functions/Template.php:52 -#: src/functions.php:1008 +#: src/Deprecated/Functions.php:361 src/Functions/Template.php:52 +#: src/functions.php:1019 msgid "Activation Limit" msgstr "" -#: src/Deprecated/Functions.php:363 +#: src/Deprecated/Functions.php:362 msgid "Expires" msgstr "" @@ -1420,20 +1410,20 @@ msgstr "" msgid "Could not find any products with serial numbers enabled." msgstr "" -#: src/Functions/Template.php:47 src/functions.php:1003 +#: src/Functions/Template.php:47 src/functions.php:1014 msgid "Activation Email" msgstr "" #: src/Functions/Template.php:53 src/Functions/Template.php:58 -#: src/functions.php:1009 src/functions.php:1014 +#: src/functions.php:1020 src/functions.php:1025 msgid "None" msgstr "" -#: src/Functions/Template.php:57 src/functions.php:1013 +#: src/Functions/Template.php:57 src/functions.php:1024 msgid "Activation Count" msgstr "" -#: src/Functions/Template.php:62 src/functions.php:1018 +#: src/Functions/Template.php:62 src/functions.php:1029 msgid "Expire Date" msgstr "" @@ -1478,13 +1468,14 @@ msgstr "" msgid "Order id is invalid." msgstr "" -#: src/Orders.php:66 +#: src/Orders.php:67 +#. translators: %1$s: product title, %2$s: stock quantity. msgid "" "Sorry, there aren’t enough Serial Keys for %1$s. Please remove this item or " "lower the quantity. For now, we have %2$s Serial Keys for this product." msgstr "" -#: src/Orders.php:109 +#: src/Orders.php:110 msgid "Order automatically completed by the Serial Numbers for WooCommerce." msgstr "" @@ -1501,29 +1492,252 @@ msgstr "" msgid "Manually added" msgstr "" -#: src/functions.php:537 +#: src/functions.php:533 #. translators: 1: product title 2: source and 3: Quantity msgid "" "There is not enough serial numbers for the product %1$s from selected " "source %2$s, needed total %3$d." msgstr "" -#: templates/email-stock-notification.php:12 +#: templates/email-stock-notification.php:14 msgid "Hi There," msgstr "" -#: templates/email-stock-notification.php:13 +#: templates/email-stock-notification.php:15 msgid "" "There are few products stock running low, please add serial numbers for " "these products" msgstr "" -#: templates/email-stock-notification.php:30 +#: templates/email-stock-notification.php:37 +#. translators: %s: plugin url. msgid "" "The email is sent by Serial Numbers for " "WooCommerce" msgstr "" +#: vendor/lucatume/wp-browser/src/data/plugins/internationalized-plugin.php:11 +msgid "This is a dummy plugin" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/parsers.php:42 +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/parsers.php:72 +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/parsers.php:80 +msgid "There was an error when reading this WXR file" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/parsers.php:43 +msgid "" +"Details are shown above. The importer will now try again with a different " +"parser..." +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/parsers.php:84 +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/parsers.php:89 +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/parsers.php:306 +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/parsers.php:495 +msgid "This does not appear to be a WXR file, missing/invalid WXR version number" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:132 +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:141 +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:192 +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:196 +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:205 +msgid "Sorry, there has been an error." +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:133 +msgid "The file does not exist, please try again." +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:176 +msgid "All done." +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:176 +msgid "Have fun!" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:177 +msgid "Remember to update the passwords and roles of imported users." +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:197 +msgid "" +"The export file could not be found at %s. It is likely that " +"this was caused by a permissions problem." +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:213 +msgid "" +"This WXR file (version %s) may not be supported by this version of the " +"importer. Please consider updating." +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:238 +msgid "" +"Failed to import author %s. Their posts will be attributed to the current " +"user." +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:264 +msgid "Assign Authors" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:265 +msgid "" +"To make it easier for you to edit and save the imported content, you may " +"want to reassign the author of the imported item to an existing user of " +"this site. For example, you may want to import all the entries as " +"admins entries." +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:267 +msgid "" +"If a new user is created by WordPress, a new password will be randomly " +"generated and the new user’s role will be set as %s. Manually " +"changing the new user’s details will be necessary." +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:277 +msgid "Import Attachments" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:280 +msgid "Download and import file attachments" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:297 +msgid "Import author:" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:308 +msgid "or create new user with login name:" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:311 +msgid "as a new user:" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:319 +msgid "assign posts to an existing user:" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:321 +msgid "or assign posts to an existing user:" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:322 +msgid "- Select -" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:372 +msgid "" +"Failed to create new user for %s. Their posts will be attributed to the " +"current user." +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:424 +msgid "Failed to import category %s" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:467 +msgid "Failed to import post tag %s" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:516 +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:738 +msgid "Failed to import %s %s" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:605 +msgid "Failed to import “%s”: Invalid post type %s" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:642 +msgid "%s “%s” already exists." +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:704 +msgid "Failed to import %s “%s”" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:869 +msgid "Menu item skipped due to missing menu slug" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:876 +msgid "Menu item skipped due to invalid menu slug: %s" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:939 +msgid "Fetching attachments is not enabled" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:952 +msgid "Invalid file type" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:996 +msgid "Remote server did not respond" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:1002 +msgid "Remote server returned error response %1$d %2$s" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:1009 +msgid "Remote file is incorrect size" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:1014 +msgid "Zero size file downloaded" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:1020 +msgid "Remote file is too large, limit is %s" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:1119 +msgid "Import WordPress" +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:1126 +msgid "" +"A new version of this importer is available. Please update to version %s to " +"ensure compatibility with newer export files." +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:1141 +msgid "" +"Howdy! Upload your WordPress eXtended RSS (WXR) file and we’ll import " +"the posts, pages, comments, custom fields, categories, and tags into this " +"site." +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:1142 +msgid "Choose a WXR (.xml) file to upload, then click Upload file and import." +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/plugins/wordpress-importer/wordpress-importer.php:1216 +msgid "" +"Import posts, pages, comments, custom fields, categories, and " +"tags from a WordPress export file." +msgstr "" + +#: vendor/lucatume/wp-browser/src/data/themedir1/internationalized-theme/functions.php:7 +msgid "This is a dummy theme" +msgstr "" + +#: vendor/wp-cli/wp-cli/php/utils-wp.php:238 +msgid "Inactive Widgets" +msgstr "" + +#: vendor/wp-cli/wp-cli/php/utils-wp.php:241 +msgid "Drag widgets here to remove them from the sidebar but keep their settings." +msgstr "" + #. Plugin Name of the plugin/theme msgid "WC Serial Numbers" msgstr "" diff --git a/lib/classes/wp-async-request.php b/lib/classes/wp-async-request.php deleted file mode 100644 index 9759ab09..00000000 --- a/lib/classes/wp-async-request.php +++ /dev/null @@ -1,202 +0,0 @@ -identifier = $this->prefix . '_' . $this->action; - - add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); - add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); - } - - /** - * Set data used during the request. - * - * @param array $data Data. - * - * @return $this - */ - public function data( $data ) { - $this->data = $data; - - return $this; - } - - /** - * Dispatch the async request. - * - * @return array|WP_Error|false HTTP Response array, WP_Error on failure, or false if not attempted. - */ - public function dispatch() { - $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); - $args = $this->get_post_args(); - - return wp_remote_post( esc_url_raw( $url ), $args ); - } - - /** - * Get query args. - * - * @return array - */ - protected function get_query_args() { - if ( property_exists( $this, 'query_args' ) ) { - return $this->query_args; - } - - $args = array( - 'action' => $this->identifier, - 'nonce' => wp_create_nonce( $this->identifier ), - ); - - /** - * Filters the post arguments used during an async request. - * - * @param array $url - */ - return apply_filters( $this->identifier . '_query_args', $args ); - } - - /** - * Get query URL. - * - * @return string - */ - protected function get_query_url() { - if ( property_exists( $this, 'query_url' ) ) { - return $this->query_url; - } - - $url = admin_url( 'admin-ajax.php' ); - - /** - * Filters the post arguments used during an async request. - * - * @param string $url - */ - return apply_filters( $this->identifier . '_query_url', $url ); - } - - /** - * Get post args. - * - * @return array - */ - protected function get_post_args() { - if ( property_exists( $this, 'post_args' ) ) { - return $this->post_args; - } - - $args = array( - 'timeout' => 0.01, - 'blocking' => false, - 'body' => $this->data, - 'cookies' => $_COOKIE, // Passing cookies ensures request is performed as initiating user. - 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), // Local requests, fine to pass false. - ); - - /** - * Filters the post arguments used during an async request. - * - * @param array $args - */ - return apply_filters( $this->identifier . '_post_args', $args ); - } - - /** - * Maybe handle a dispatched request. - * - * Check for correct nonce and pass to handler. - * - * @return void|mixed - */ - public function maybe_handle() { - // Don't lock up other requests while processing. - session_write_close(); - - check_ajax_referer( $this->identifier, 'nonce' ); - - $this->handle(); - - return $this->maybe_wp_die(); - } - - /** - * Should the process exit with wp_die? - * - * @param mixed $return What to return if filter says don't die, default is null. - * - * @return void|mixed - */ - protected function maybe_wp_die( $return = null ) { - /** - * Should wp_die be used? - * - * @return bool - */ - if ( apply_filters( $this->identifier . '_wp_die', true ) ) { - wp_die(); - } - - return $return; - } - - /** - * Handle a dispatched request. - * - * Override this method to perform any actions required - * during the async request. - */ - abstract protected function handle(); -} diff --git a/lib/classes/wp-background-process.php b/lib/classes/wp-background-process.php deleted file mode 100644 index fbc81fff..00000000 --- a/lib/classes/wp-background-process.php +++ /dev/null @@ -1,733 +0,0 @@ -cron_hook_identifier = $this->identifier . '_cron'; - $this->cron_interval_identifier = $this->identifier . '_cron_interval'; - - add_action( $this->cron_hook_identifier, array( $this, 'handle_cron_healthcheck' ) ); - add_filter( 'cron_schedules', array( $this, 'schedule_cron_healthcheck' ) ); - } - - /** - * Schedule the cron healthcheck and dispatch an async request to start processing the queue. - * - * @access public - * @return array|WP_Error|false HTTP Response array, WP_Error on failure, or false if not attempted. - */ - public function dispatch() { - if ( $this->is_processing() ) { - // Process already running. - return false; - } - - // Schedule the cron healthcheck. - $this->schedule_event(); - - // Perform remote post. - return parent::dispatch(); - } - - /** - * Push to the queue. - * - * Note, save must be called in order to persist queued items to a batch for processing. - * - * @param mixed $data Data. - * - * @return $this - */ - public function push_to_queue( $data ) { - $this->data[] = $data; - - return $this; - } - - /** - * Save the queued items for future processing. - * - * @return $this - */ - public function save() { - $key = $this->generate_key(); - - if ( ! empty( $this->data ) ) { - update_site_option( $key, $this->data ); - } - - // Clean out data so that new data isn't prepended with closed session's data. - $this->data = array(); - - return $this; - } - - /** - * Update a batch's queued items. - * - * @param string $key Key. - * @param array $data Data. - * - * @return $this - */ - public function update( $key, $data ) { - if ( ! empty( $data ) ) { - update_site_option( $key, $data ); - } - - return $this; - } - - /** - * Delete a batch of queued items. - * - * @param string $key Key. - * - * @return $this - */ - public function delete( $key ) { - delete_site_option( $key ); - - return $this; - } - - /** - * Delete entire job queue. - */ - public function delete_all() { - $batches = $this->get_batches(); - - foreach ( $batches as $batch ) { - $this->delete( $batch->key ); - } - - delete_site_option( $this->get_status_key() ); - - $this->cancelled(); - } - - /** - * Cancel job on next batch. - */ - public function cancel() { - update_site_option( $this->get_status_key(), self::STATUS_CANCELLED ); - - // Just in case the job was paused at the time. - $this->dispatch(); - } - - /** - * Has the process been cancelled? - * - * @return bool - */ - public function is_cancelled() { - $status = get_site_option( $this->get_status_key(), 0 ); - - if ( absint( $status ) === self::STATUS_CANCELLED ) { - return true; - } - - return false; - } - - /** - * Called when background process has been cancelled. - */ - protected function cancelled() { - do_action( $this->identifier . '_cancelled' ); - } - - /** - * Pause job on next batch. - */ - public function pause() { - update_site_option( $this->get_status_key(), self::STATUS_PAUSED ); - } - - /** - * Is the job paused? - * - * @return bool - */ - public function is_paused() { - $status = get_site_option( $this->get_status_key(), 0 ); - - if ( absint( $status ) === self::STATUS_PAUSED ) { - return true; - } - - return false; - } - - /** - * Called when background process has been paused. - */ - protected function paused() { - do_action( $this->identifier . '_paused' ); - } - - /** - * Resume job. - */ - public function resume() { - delete_site_option( $this->get_status_key() ); - - $this->schedule_event(); - $this->dispatch(); - $this->resumed(); - } - - /** - * Called when background process has been resumed. - */ - protected function resumed() { - do_action( $this->identifier . '_resumed' ); - } - - /** - * Is queued? - * - * @return bool - */ - public function is_queued() { - return ! $this->is_queue_empty(); - } - - /** - * Is the tool currently active, e.g. starting, working, paused or cleaning up? - * - * @return bool - */ - public function is_active() { - return $this->is_queued() || $this->is_processing() || $this->is_paused() || $this->is_cancelled(); - } - - /** - * Generate key for a batch. - * - * Generates a unique key based on microtime. Queue items are - * given a unique key so that they can be merged upon save. - * - * @param int $length Optional max length to trim key to, defaults to 64 characters. - * @param string $key Optional string to append to identifier before hash, defaults to "batch". - * - * @return string - */ - protected function generate_key( $length = 64, $key = 'batch' ) { - $unique = md5( microtime() . wp_rand() ); - $prepend = $this->identifier . '_' . $key . '_'; - - return substr( $prepend . $unique, 0, $length ); - } - - /** - * Get the status key. - * - * @return string - */ - protected function get_status_key() { - return $this->identifier . '_status'; - } - - /** - * Maybe process a batch of queued items. - * - * Checks whether data exists within the queue and that - * the process is not already running. - */ - public function maybe_handle() { - // Don't lock up other requests while processing. - session_write_close(); - - if ( $this->is_processing() ) { - // Background process already running. - return $this->maybe_wp_die(); - } - - if ( $this->is_cancelled() ) { - $this->clear_scheduled_event(); - $this->delete_all(); - - return $this->maybe_wp_die(); - } - - if ( $this->is_paused() ) { - $this->clear_scheduled_event(); - $this->paused(); - - return $this->maybe_wp_die(); - } - - if ( $this->is_queue_empty() ) { - // No data to process. - return $this->maybe_wp_die(); - } - - check_ajax_referer( $this->identifier, 'nonce' ); - - $this->handle(); - - return $this->maybe_wp_die(); - } - - /** - * Is queue empty? - * - * @return bool - */ - protected function is_queue_empty() { - return empty( $this->get_batch() ); - } - - /** - * Is process running? - * - * Check whether the current process is already running - * in a background process. - * - * @return bool - * - * @deprecated 1.1.0 Superseded. - * @see is_processing() - */ - protected function is_process_running() { - return $this->is_processing(); - } - - /** - * Is the background process currently running? - * - * @return bool - */ - public function is_processing() { - if ( get_site_transient( $this->identifier . '_process_lock' ) ) { - // Process already running. - return true; - } - - return false; - } - - /** - * Lock process. - * - * Lock the process so that multiple instances can't run simultaneously. - * Override if applicable, but the duration should be greater than that - * defined in the time_exceeded() method. - */ - protected function lock_process() { - $this->start_time = time(); // Set start time of current process. - - $lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : 60; // 1 minute - $lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration ); - - set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration ); - } - - /** - * Unlock process. - * - * Unlock the process so that other instances can spawn. - * - * @return $this - */ - protected function unlock_process() { - delete_site_transient( $this->identifier . '_process_lock' ); - - return $this; - } - - /** - * Get batch. - * - * @return stdClass Return the first batch of queued items. - */ - protected function get_batch() { - return array_reduce( - $this->get_batches( 1 ), - function ( $carry, $batch ) { - return $batch; - }, - array() - ); - } - - /** - * Get batches. - * - * @param int $limit Number of batches to return, defaults to all. - * - * @return array of stdClass - */ - public function get_batches( $limit = 0 ) { - global $wpdb; - - if ( empty( $limit ) || ! is_int( $limit ) ) { - $limit = 0; - } - - $table = $wpdb->options; - $column = 'option_name'; - $key_column = 'option_id'; - $value_column = 'option_value'; - - if ( is_multisite() ) { - $table = $wpdb->sitemeta; - $column = 'meta_key'; - $key_column = 'meta_id'; - $value_column = 'meta_value'; - } - - $key = $wpdb->esc_like( $this->identifier . '_batch_' ) . '%'; - - $sql = ' - SELECT * - FROM ' . $table . ' - WHERE ' . $column . ' LIKE %s - ORDER BY ' . $key_column . ' ASC - '; - - $args = array( $key ); - - if ( ! empty( $limit ) ) { - $sql .= ' LIMIT %d'; - - $args[] = $limit; - } - - $items = $wpdb->get_results( $wpdb->prepare( $sql, $args ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared - - $batches = array(); - - if ( ! empty( $items ) ) { - $batches = array_map( - function ( $item ) use ( $column, $value_column ) { - $batch = new stdClass(); - $batch->key = $item->{$column}; - $batch->data = maybe_unserialize( $item->{$value_column} ); - - return $batch; - }, - $items - ); - } - - return $batches; - } - - /** - * Handle a dispatched request. - * - * Pass each queue item to the task handler, while remaining - * within server memory and time limit constraints. - */ - protected function handle() { - $this->lock_process(); - - /** - * Number of seconds to sleep between batches. Defaults to 0 seconds, minimum 0. - * - * @param int $seconds - */ - $throttle_seconds = max( - 0, - apply_filters( - $this->identifier . '_seconds_between_batches', - apply_filters( - $this->prefix . '_seconds_between_batches', - 0 - ) - ) - ); - - do { - $batch = $this->get_batch(); - - foreach ( $batch->data as $key => $value ) { - $task = $this->task( $value ); - - if ( false !== $task ) { - $batch->data[ $key ] = $task; - } else { - unset( $batch->data[ $key ] ); - } - - // Keep the batch up to date while processing it. - if ( ! empty( $batch->data ) ) { - $this->update( $batch->key, $batch->data ); - } - - // Let the server breathe a little. - sleep( $throttle_seconds ); - - // Batch limits reached, or pause or cancel request. - if ( $this->time_exceeded() || $this->memory_exceeded() || $this->is_paused() || $this->is_cancelled() ) { - break; - } - } - - // Delete current batch if fully processed. - if ( empty( $batch->data ) ) { - $this->delete( $batch->key ); - } - } while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() && ! $this->is_paused() && ! $this->is_cancelled() ); - - $this->unlock_process(); - - // Start next batch or complete process. - if ( ! $this->is_queue_empty() ) { - $this->dispatch(); - } else { - $this->complete(); - } - - return $this->maybe_wp_die(); - } - - /** - * Memory exceeded? - * - * Ensures the batch process never exceeds 90% - * of the maximum WordPress memory. - * - * @return bool - */ - protected function memory_exceeded() { - $memory_limit = $this->get_memory_limit() * 0.9; // 90% of max memory - $current_memory = memory_get_usage( true ); - $return = false; - - if ( $current_memory >= $memory_limit ) { - $return = true; - } - - return apply_filters( $this->identifier . '_memory_exceeded', $return ); - } - - /** - * Get memory limit in bytes. - * - * @return int - */ - protected function get_memory_limit() { - if ( function_exists( 'ini_get' ) ) { - $memory_limit = ini_get( 'memory_limit' ); - } else { - // Sensible default. - $memory_limit = '128M'; - } - - if ( ! $memory_limit || -1 === intval( $memory_limit ) ) { - // Unlimited, set to 32GB. - $memory_limit = '32000M'; - } - - return wp_convert_hr_to_bytes( $memory_limit ); - } - - /** - * Time limit exceeded? - * - * Ensures the batch never exceeds a sensible time limit. - * A timeout limit of 30s is common on shared hosting. - * - * @return bool - */ - protected function time_exceeded() { - $finish = $this->start_time + apply_filters( $this->identifier . '_default_time_limit', 20 ); // 20 seconds - $return = false; - - if ( time() >= $finish ) { - $return = true; - } - - return apply_filters( $this->identifier . '_time_exceeded', $return ); - } - - /** - * Complete processing. - * - * Override if applicable, but ensure that the below actions are - * performed, or, call parent::complete(). - */ - protected function complete() { - delete_site_option( $this->get_status_key() ); - - // Remove the cron healthcheck job from the cron schedule. - $this->clear_scheduled_event(); - - $this->completed(); - } - - /** - * Called when background process has completed. - */ - protected function completed() { - do_action( $this->identifier . '_completed' ); - } - - /** - * Schedule the cron healthcheck job. - * - * @access public - * - * @param mixed $schedules Schedules. - * - * @return mixed - */ - public function schedule_cron_healthcheck( $schedules ) { - $interval = apply_filters( $this->cron_interval_identifier, 5 ); - - if ( property_exists( $this, 'cron_interval' ) ) { - $interval = apply_filters( $this->cron_interval_identifier, $this->cron_interval ); - } - - if ( 1 === $interval ) { - $display = __( 'Every Minute', 'wc-serial-numbers' ); - } else { - $display = sprintf( __( 'Every %d Minutes', 'wc-serial-numbers' ), $interval ); - } - - // Adds an "Every NNN Minute(s)" schedule to the existing cron schedules. - $schedules[ $this->cron_interval_identifier ] = array( - 'interval' => MINUTE_IN_SECONDS * $interval, - 'display' => $display, - ); - - return $schedules; - } - - /** - * Handle cron healthcheck event. - * - * Restart the background process if not already running - * and data exists in the queue. - */ - public function handle_cron_healthcheck() { - if ( $this->is_processing() ) { - // Background process already running. - exit; - } - - if ( $this->is_queue_empty() ) { - // No data to process. - $this->clear_scheduled_event(); - exit; - } - - $this->dispatch(); - } - - /** - * Schedule the cron healthcheck event. - */ - protected function schedule_event() { - if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) { - wp_schedule_event( time(), $this->cron_interval_identifier, $this->cron_hook_identifier ); - } - } - - /** - * Clear scheduled cron healthcheck event. - */ - protected function clear_scheduled_event() { - $timestamp = wp_next_scheduled( $this->cron_hook_identifier ); - - if ( $timestamp ) { - wp_unschedule_event( $timestamp, $this->cron_hook_identifier ); - } - } - - /** - * Cancel the background process. - * - * Stop processing queue items, clear cron job and delete batch. - * - * @deprecated 1.1.0 Superseded. - * @see cancel() - */ - public function cancel_process() { - $this->cancel(); - } - - /** - * Perform task with queued item. - * - * Override this method to perform any actions required on each - * queue item. Return the modified item for further processing - * in the next pass through. Or, return false to remove the - * item from the queue. - * - * @param mixed $item Queue item to iterate over. - * - * @return mixed - */ - abstract protected function task( $item ); -} diff --git a/src/API.php b/src/API.php index 6d8f1432..6f4270f3 100644 --- a/src/API.php +++ b/src/API.php @@ -38,7 +38,7 @@ public static function process_request() { $product_id = isset( $_REQUEST['product_id'] ) ? absint( $_REQUEST['product_id'] ) : 0; $key = isset( $_REQUEST['serial_key'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['serial_key'] ) ) : ''; $action = isset( $_REQUEST['request'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['request'] ) ) : ''; - $email = isset( $_REQUEST['email'] ) ? sanitize_text_field( strtolower( wp_unslash( $_REQUEST['email'] ) ) ) : ''; + $email = isset( $_REQUEST['email'] ) ? strtolower( sanitize_text_field( wp_unslash( $_REQUEST['email'] ) ) ) : ''; WCSN()->log( 'API request', @@ -208,7 +208,7 @@ public static function validate_key( $serial_key ) { * @since 1.0.0 */ public static function activate_key( $serial_key ) { - $user_agent = ! empty( $_SERVER['HTTP_USER_AGENT'] ) ? md5( sanitize_textarea_field( $_SERVER['HTTP_USER_AGENT'] ) . time() ) : md5( time() ); + $user_agent = ! empty( $_SERVER['HTTP_USER_AGENT'] ) ? md5( sanitize_textarea_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) . time() ) : md5( time() ); $instance = ! empty( $_REQUEST['instance'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['instance'] ) ) : $user_agent; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $platform = ! empty( $_REQUEST['platform'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['platform'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended diff --git a/src/Actions.php b/src/Actions.php index 457325c1..b26fe1f2 100644 --- a/src/Actions.php +++ b/src/Actions.php @@ -121,7 +121,6 @@ public static function revoke_order_item_keys( $revoke ) { * @since 1.0.0 */ public static function update_activation_count( $activation ) { - error_log($activation->get_serial_id()); $key = Key::get( $activation->get_serial_id() ); if ( $key ) { $key->recount_remaining_activation(); diff --git a/src/Admin/Actions.php b/src/Admin/Actions.php index 5b194ccb..77365bf4 100644 --- a/src/Admin/Actions.php +++ b/src/Admin/Actions.php @@ -194,7 +194,6 @@ public static function handle_add_key() { update_post_meta( $product_id, '_is_serial_number', 'yes' ); update_post_meta( $product_id, '_serial_key_source', 'custom_source' ); $status = isset( $data['status'] ) ? $data['status'] : ''; - } /** diff --git a/src/Admin/Admin.php b/src/Admin/Admin.php index e4afeff9..9d10ad4c 100644 --- a/src/Admin/Admin.php +++ b/src/Admin/Admin.php @@ -76,7 +76,7 @@ public function enqueue_scripts( $hook ) { ) ); - // add inline style for select2 --wp-admin-theme-color + // add inline style for select2 --wp-admin-theme-color. wp_add_inline_style( 'common', ':root{--wp-admin-theme-color:#0073aa;}' ); } @@ -139,7 +139,7 @@ public function update_footer( $footer_text ) { */ public static function get_screen_ids() { $screen_id = sanitize_title( __( 'Serial Numbers', 'wc-serial-numbers' ) ); - $screen_ids = [ + $screen_ids = array( 'toplevel_page_' . $screen_id, 'toplevel_page_wc-serial-numbers', $screen_id . '_page_wc-serial-numbers-activations', @@ -147,7 +147,7 @@ public static function get_screen_ids() { $screen_id . '_page_wc-serial-numbers-tools', $screen_id . '_page_wc-serial-numbers-reports', $screen_id . '_page_wc-serial-numbers-settings', - ]; + ); return apply_filters( 'wc_serial_numbers_screen_ids', $screen_ids ); } @@ -162,7 +162,7 @@ public static function get_screen_ids() { * @since 1.0.0 * @return void */ - public static function view( $view, $args = [], $path = '' ) { + public static function view( $view, $args = array(), $path = '' ) { if ( empty( $path ) ) { $path = __DIR__ . '/views/'; } diff --git a/src/Admin/ListTables/ActivationsTable.php b/src/Admin/ListTables/ActivationsTable.php index a2677a8d..c90d2fdf 100644 --- a/src/Admin/ListTables/ActivationsTable.php +++ b/src/Admin/ListTables/ActivationsTable.php @@ -51,13 +51,13 @@ public function __construct() { public function prepare_items() { $per_page = $this->get_items_per_page( 'wcsn_activations_per_page' ); $columns = $this->get_columns(); - $hidden = []; + $hidden = array(); $sortable = $this->get_sortable_columns(); $this->_column_headers = array( $columns, $hidden, $sortable ); $current_page = $this->get_pagenum(); $orderby = isset( $_GET['orderby'] ) ? sanitize_key( $_GET['orderby'] ) : 'order_date'; $order = isset( $_GET['order'] ) ? sanitize_key( $_GET['order'] ) : 'desc'; - $search = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : null; + $search = isset( $_GET['s'] ) ? sanitize_text_field( wp_unslash( $_GET['s'] ) ) : null; $product_id = isset( $_GET['product_id'] ) ? absint( $_GET['product_id'] ) : ''; $order_id = isset( $_GET['order_id'] ) ? absint( $_GET['order_id'] ) : ''; $customer_id = isset( $_GET['customer_id'] ) ? absint( $_GET['customer_id'] ) : ''; @@ -91,7 +91,6 @@ public function prepare_items() { 'total_pages' => $this->total_count > 0 ? ceil( $this->total_count / $per_page ) : 0, ) ); - } /** @@ -101,27 +100,16 @@ public function no_items() { esc_html_e( 'No activations found. Once a serial key is activated, it will appear here.', 'wc-serial-numbers' ); } - /** - * Retrieve the view types - * - * @since 1.0.0 - * @return array $views All the views sellable - */ - public function get_views() { - return parent::get_views(); - } - /** * Adds the order and product filters to the licenses list. * - * @param string $which + * @param string $which Which nav. */ protected function extra_tablenav( $which ) { - if ( $which === 'top' ) { + if ( 'top' === $which ) { echo '
'; $this->order_dropdown(); $this->product_dropdown(); - // $this->customer_dropdown(); submit_button( __( 'Filter', 'wc-serial-numbers' ), '', 'filter-action', false ); echo '
'; } @@ -137,7 +125,7 @@ protected function extra_tablenav( $which ) { public function process_bulk_actions( $doaction ) { if ( $doaction ) { if ( isset( $_REQUEST['id'] ) ) { - $ids = wp_parse_id_list( $_REQUEST['id'] ); + $ids = wp_parse_id_list( wp_unslash( $_REQUEST['id'] ) ); $doaction = ( - 1 !== $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2']; // phpcs:ignore } elseif ( isset( $_REQUEST['ids'] ) ) { $ids = array_map( 'absint', $_REQUEST['ids'] ); @@ -201,7 +189,7 @@ public function get_columns() { * * @return array */ - function get_sortable_columns() { + public function get_sortable_columns() { $sortable_columns = array( 'instance' => array( 'instance', false ), 'serial_id' => array( 'serial_id', false ), @@ -243,10 +231,10 @@ protected function column_cb( $item ) { */ protected function column_instance( $activation ) { $delete_url = add_query_arg( - [ + array( 'id' => $activation->id, 'action' => 'delete', - ], + ), admin_url( 'admin.php?page=wc-serial-numbers-activations' ) ); $actions['delete'] = sprintf( '%2$s', esc_url( $delete_url ), __( 'Delete', 'wc-serial-numbers' ) ); @@ -299,5 +287,4 @@ protected function column_platform( $activation ) { protected function column_activation_time( $activation ) { return empty( $activation->get_activation_time() ) ? '—' : esc_html( $activation->get_activation_time() ); } - } diff --git a/src/Admin/ListTables/KeysTable.php b/src/Admin/ListTables/KeysTable.php index 401cb9fe..0f914244 100644 --- a/src/Admin/ListTables/KeysTable.php +++ b/src/Admin/ListTables/KeysTable.php @@ -90,14 +90,14 @@ public function __construct() { public function prepare_items() { $per_page = $this->get_items_per_page( 'wc_serial_numbers_keys_per_page' ); $columns = $this->get_columns(); - $hidden = []; + $hidden = array(); $sortable = $this->get_sortable_columns(); $this->_column_headers = array( $columns, $hidden, $sortable ); $current_page = $this->get_pagenum(); - $status = isset( $_GET['status'] ) ? $_GET['status'] : ''; + $status = isset( $_GET['status'] ) ? sanitize_text_field( wp_unslash( $_GET['status'] ) ) : ''; $orderby = isset( $_GET['orderby'] ) ? sanitize_key( $_GET['orderby'] ) : 'order_date'; $order = isset( $_GET['order'] ) ? sanitize_key( $_GET['order'] ) : 'desc'; - $search = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : null; + $search = isset( $_GET['s'] ) ? sanitize_text_field( wp_unslash( $_GET['s'] ) ) : null; $product_id = isset( $_GET['product_id'] ) ? absint( $_GET['product_id'] ) : ''; $order_id = isset( $_GET['order_id'] ) ? absint( $_GET['order_id'] ) : ''; $customer_id = isset( $_GET['customer_id'] ) ? absint( $_GET['customer_id'] ) : ''; @@ -124,12 +124,12 @@ public function prepare_items() { ); $this->items = Key::query( $args ); - $this->available_count = Key::count( array_merge( $args, [ 'status' => 'available' ] ) ); - $this->pending_count = Key::count( array_merge( $args, [ 'status' => 'pending' ] ) ); - $this->sold_count = Key::count( array_merge( $args, [ 'status' => 'sold' ] ) ); - $this->expired_count = Key::count( array_merge( $args, [ 'status' => 'expired' ] ) ); - $this->cancelled_count = Key::count( array_merge( $args, [ 'status' => 'cancelled' ] ) ); - $this->total_count = array_sum( [ $this->available_count, $this->sold_count, $this->pending_count, $this->expired_count, $this->cancelled_count ] ); + $this->available_count = Key::count( array_merge( $args, array( 'status' => 'available' ) ) ); + $this->pending_count = Key::count( array_merge( $args, array( 'status' => 'pending' ) ) ); + $this->sold_count = Key::count( array_merge( $args, array( 'status' => 'sold' ) ) ); + $this->expired_count = Key::count( array_merge( $args, array( 'status' => 'expired' ) ) ); + $this->cancelled_count = Key::count( array_merge( $args, array( 'status' => 'cancelled' ) ) ); + $this->total_count = array_sum( array( $this->available_count, $this->sold_count, $this->pending_count, $this->expired_count, $this->cancelled_count ) ); switch ( $status ) { case 'available': @@ -160,14 +160,13 @@ public function prepare_items() { 'total_pages' => $total_items > 0 ? ceil( $total_items / $per_page ) : 0, ) ); - } /** * No items found text. */ public function no_items() { - echo sprintf( '%s %s', esc_html__( 'No keys found.', 'wc-serial-numbers' ), '' . esc_html__( 'Add new key', 'wc-serial-numbers' ) . '' ); + printf( '%s %s', esc_html__( 'No keys found.', 'wc-serial-numbers' ), '' . esc_html__( 'Add new key', 'wc-serial-numbers' ) . '' ); // Show a documentation about key's statuses. ?>

@@ -210,7 +209,7 @@ public function no_items() { * @return array $views All the views sellable */ public function get_views() { - $current = isset( $_GET['status'] ) ? sanitize_key( $_GET['status'] ) : ''; + $current = isset( $_GET['status'] ) ? sanitize_key( wp_unslash( $_GET['status'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $available_count = ' (' . $this->available_count . ')'; $pending_count = ' (' . $this->pending_count . ')'; $sold_count = ' (' . $this->sold_count . ')'; @@ -219,12 +218,48 @@ public function get_views() { $total_count = ' (' . $this->total_count . ')'; $url = admin_url( 'admin.php?page=wc-serial-numbers' ); $views = array( - 'all' => sprintf( '%s', remove_query_arg( 'status', $url ), __( 'All keys.', 'wc-serial-numbers' ), $current === 'all' || $current == '' ? ' class="current"' : '', __( 'All', 'wc-serial-numbers' ) . $total_count ), - 'available' => sprintf( '%s', add_query_arg( 'status', 'available', $url ), __( 'Available for sell.', 'wc-serial-numbers' ), $current === 'available' ? ' class="current"' : '', __( 'Available', 'wc-serial-numbers' ) . $available_count ), - 'pending' => sprintf( '%s', add_query_arg( 'status', 'pending', $url ), __( 'Pending payment.', 'wc-serial-numbers' ), $current === 'pending' ? ' class="current"' : '', __( 'Pending', 'wc-serial-numbers' ) . $pending_count ), - 'sold' => sprintf( '%s', add_query_arg( 'status', 'sold', $url ), __( 'Sold keys.', 'wc-serial-numbers' ), $current === 'sold' ? ' class="current"' : '', __( 'Sold', 'wc-serial-numbers' ) . $sold_count ), - 'expired' => sprintf( '%s', add_query_arg( 'status', 'expired', $url ), __( 'Expired keys.', 'wc-serial-numbers' ), $current === 'expired' ? ' class="current"' : '', __( 'Expired', 'wc-serial-numbers' ) . $expired_count ), - 'cancelled' => sprintf( '%s', add_query_arg( 'status', 'cancelled', $url ), __( 'Cancelled keys.', 'wc-serial-numbers' ), $current === 'cancelled' ? ' class="current"' : '', __( 'Cancelled', 'wc-serial-numbers' ) . $cancelled_count ), + 'all' => sprintf( + '%s', + remove_query_arg( 'status', $url ), + __( 'All keys.', 'wc-serial-numbers' ), + 'all' === $current || '' === $current ? ' class="current"' : '', + __( 'All', 'wc-serial-numbers' ) . $total_count + ), + 'available' => sprintf( + '%s', + add_query_arg( 'status', 'available', $url ), + __( 'Available for sell.', 'wc-serial-numbers' ), + 'available' === $current ? ' class="current"' : '', + __( 'Available', 'wc-serial-numbers' ) . $available_count + ), + 'pending' => sprintf( + '%s', + add_query_arg( 'status', 'pending', $url ), + __( 'Pending payment.', 'wc-serial-numbers' ), + 'pending' === $current ? ' class="current"' : '', + __( 'Pending', 'wc-serial-numbers' ) . $pending_count + ), + 'sold' => sprintf( + '%s', + add_query_arg( 'status', 'sold', $url ), + __( 'Sold keys.', 'wc-serial-numbers' ), + 'sold' === $current ? ' class="current"' : '', + __( 'Sold', 'wc-serial-numbers' ) . $sold_count + ), + 'expired' => sprintf( + '%s', + add_query_arg( 'status', 'expired', $url ), + __( 'Expired keys.', 'wc-serial-numbers' ), + 'expired' === $current ? ' class="current"' : '', + __( 'Expired', 'wc-serial-numbers' ) . $expired_count + ), + 'cancelled' => sprintf( + '%s', + add_query_arg( 'status', 'cancelled', $url ), + __( 'Cancelled keys.', 'wc-serial-numbers' ), + 'cancelled' === $current ? ' class="current"' : '', + __( 'Cancelled', 'wc-serial-numbers' ) . $cancelled_count + ), ); return $views; @@ -236,7 +271,7 @@ public function get_views() { * @param string $which The location of the extra table nav markup: 'top' or 'bottom'. */ protected function extra_tablenav( $which ) { - if ( $which === 'top' ) { + if ( 'top' === $which ) { echo '
'; $this->order_dropdown(); $this->product_dropdown(); @@ -256,8 +291,8 @@ protected function extra_tablenav( $which ) { */ public function process_bulk_actions( $doaction ) { if ( $doaction ) { - if ( isset( $_REQUEST['id'] ) ) { - $ids = wp_parse_id_list( $_REQUEST['id'] ); + if ( wp_unslash( isset( $_REQUEST['id'] ) ) ) { + $ids = wp_parse_id_list( wp_unslash( $_REQUEST['id'] ) ); $doaction = ( - 1 !== $_REQUEST['action'] ) ? $_REQUEST['action'] : $_REQUEST['action2']; // phpcs:ignore } elseif ( isset( $_REQUEST['ids'] ) ) { $ids = array_map( 'absint', $_REQUEST['ids'] ); @@ -331,7 +366,7 @@ public function get_columns() { * * @return array */ - function get_sortable_columns() { + public function get_sortable_columns() { $sortable_columns = array( 'key' => array( 'serial_key', false ), 'product' => array( 'product_id', false ), @@ -361,7 +396,7 @@ protected function get_primary_column_name() { /** * since 1.0.0 * - * @param object $item + * @param \StdClass $item Item. * * @return string|void */ @@ -372,21 +407,22 @@ protected function column_cb( $item ) { /** * Display key. * - * @param $item + * @param Key $item Item. * * @since 1.4.6 */ protected function column_key( $item ) { - $is_hidden = 'yes' === get_option( 'wc_serial_numbers_hide_serial_number', 'yes' ); - $edit_url = add_query_arg( [ 'edit' => $item->id ], admin_url( 'admin.php?page=wc-serial-numbers' ) ); - $delete_url = add_query_arg( - [ + $is_hidden = 'yes' === get_option( 'wc_serial_numbers_hide_serial_number', 'yes' ); + $edit_url = add_query_arg( array( 'edit' => $item->id ), admin_url( 'admin.php?page=wc-serial-numbers' ) ); + $delete_url = add_query_arg( + array( 'id' => $item->id, 'action' => 'delete', - ], + ), admin_url( 'admin.php?page=wc-serial-numbers' ) ); - $actions['id'] = sprintf( __( 'ID: %d', 'wc-serial-numbers' ), $item->id ); + // translators: %d: key id. + $actions['id'] = sprintf( __( 'ID: %d', 'wc-serial-numbers' ), esc_html( $item->id ) ); $actions['edit'] = sprintf( '%2$s', $edit_url, __( 'Edit', 'wc-serial-numbers' ) ); $actions['delete'] = sprintf( '%2$s', $delete_url, __( 'Delete', 'wc-serial-numbers' ) ); @@ -396,7 +432,7 @@ protected function column_key( $item ) { /** * Display column product. * - * @param Key $key Key object. + * @param Key $item Item. * * @since 1.4.6 */ @@ -409,7 +445,7 @@ protected function column_product( $item ) { /** * Display column order. * - * @param Key $key Key object. + * @param Key $item Item. * * @since 1.4.6 */ @@ -425,7 +461,7 @@ protected function column_order( $item ) { /** * Display column customer. * - * @param Key $key Key object. + * @param \StdClass $item Item. * * @since 1.4.6 */ @@ -458,10 +494,10 @@ protected function column_activation( $key ) { $limit = ! empty( $key->activation_limit ) ? $key->activation_limit : '∞'; $count = (int) $key->activation_count; $link = add_query_arg( - [ + array( 'serial_id' => $key->id, 'page' => 'wc-serial-numbers-activations', - ], + ), admin_url( 'admin.php' ) ); @@ -478,7 +514,21 @@ protected function column_activation( $key ) { * @since 1.4.6 */ protected function column_valid_for( $key ) { - return ! empty( $key->get_validity() ) ? sprintf( _n( '%s Day
After purchase', '%s Days
After purchase', $key->get_validity(), 'wc-serial-numbers' ), number_format_i18n( $key->get_validity() ) ) : __( 'Lifetime', 'wc-serial-numbers' ); + if ( ! empty( $key->get_validity() ) ) { + return wp_kses_post( + sprintf( + // translators: %1$s: validity, %2$s: validity. + _n( + '%s Day
After purchase', + '%s Days
After purchase', + $key->get_validity(), + 'wc-serial-numbers' + ), + number_format_i18n( $key->get_validity() ) + ) + ); + } + return __( 'Lifetime', 'wc-serial-numbers' ); } /** @@ -489,7 +539,10 @@ protected function column_valid_for( $key ) { * @since 1.4.6 */ protected function column_order_date( $key ) { - return ! empty( $key->order_date ) && '0000-00-00 00:00:00' !== $key->order_date ? date( get_option( 'date_format' ), strtotime( $key->order_date ) ) : '—'; + if ( ! empty( $key->order_date ) && '0000-00-00 00:00:00' !== $key->order_date ) { + return wp_date( get_option( 'date_format' ), strtotime( $key->order_date ) ); + } + return '—'; } /** diff --git a/src/Admin/ListTables/ListTable.php b/src/Admin/ListTables/ListTable.php index f42e3ba7..56895364 100644 --- a/src/Admin/ListTables/ListTable.php +++ b/src/Admin/ListTables/ListTable.php @@ -28,15 +28,15 @@ class ListTable extends \WP_List_Table { /** * Get a request var, or return the default if not set. * - * @param string $var Request var name. - * @param mixed $default Default value. + * @param string $param Request var name. + * @param mixed $fallback Default value. * * @since 1.4.6 * * @return mixed Un-sanitized request var */ - protected function get_request_var( $var = '', $default = false ) { - return isset( $_REQUEST[ $var ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $var ] ) ) : $default; // phpcs:ignore WordPress.Security.NonceVerification + protected function get_request_var( $param = '', $fallback = false ) { + return isset( $_REQUEST[ $param ] ) ? sanitize_text_field( wp_unslash( $_REQUEST[ $param ] ) ) : $fallback; // phpcs:ignore WordPress.Security.NonceVerification } /** @@ -202,14 +202,14 @@ public function customer_dropdown() { * @since 1.4.6 */ public function process_bulk_actions( $doaction ) { - if ( ! empty( $_GET['_wp_http_referer'] ) ) { - wp_redirect( + if ( isset( $_GET['_wp_http_referer'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification + wp_safe_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce', ), - wp_unslash( $_SERVER['REQUEST_URI'] ) + wp_get_referer() ) ); exit; diff --git a/src/Admin/ListTables/StockTable.php b/src/Admin/ListTables/StockTable.php index 42f3e45b..4fc2b87b 100644 --- a/src/Admin/ListTables/StockTable.php +++ b/src/Admin/ListTables/StockTable.php @@ -30,15 +30,16 @@ public function __construct() { * @since 1.4.6 */ public function prepare_items() { + check_admin_referer( 'wc-serial-numbers-stock' ); $per_page = 20; $columns = $this->get_columns(); - $hidden = []; + $hidden = array(); $sortable = $this->get_sortable_columns(); $this->_column_headers = array( $columns, $hidden, $sortable ); $current_page = $this->get_pagenum(); $orderby = isset( $_GET['orderby'] ) ? sanitize_key( $_GET['orderby'] ) : 'order_date'; $order = isset( $_GET['order'] ) ? sanitize_key( $_GET['order'] ) : 'desc'; - $search = isset( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : null; + $search = isset( $_GET['s'] ) ? sanitize_text_field( wp_unslash( $_GET['s'] ) ) : null; $product_id = isset( $_GET['product_id'] ) ? absint( $_GET['product_id'] ) : ''; $query_args = array( @@ -70,23 +71,13 @@ public function no_items() { esc_html_e( 'No products selling serial keys from "stock" found.', 'wc-serial-numbers' ); } - /** - * Retrieve the view types - * - * @since 1.0.0 - * @return array $views All the views sellable - */ - public function get_views() { - return parent::get_views(); - } - /** * Adds the order and product filters to the licenses list. * * @param string $which The location of the extra table nav markup: 'top' or 'bottom'. */ protected function extra_tablenav( $which ) { - if ( $which === 'top' ) { + if ( 'top' === $which ) { echo '
'; $this->product_dropdown(); submit_button( __( 'Filter', 'wc-serial-numbers' ), '', 'filter-action', false ); @@ -116,7 +107,7 @@ public function get_columns() { * * @return array */ - function get_sortable_columns() { + public function get_sortable_columns() { $columns = array( 'product' => array( 'product_id', false ), ); @@ -169,7 +160,7 @@ public function column_default( $item, $column_name ) { case 'sold': $sold_count = wcsn_get_keys( array( - 'status__in' => [ 'sold', 'expired' ], + 'status__in' => array( 'sold', 'expired' ), 'product_id' => $item->get_id(), 'count' => true, ) diff --git a/src/Admin/Menus.php b/src/Admin/Menus.php index 2d96cfaf..9c790cb9 100644 --- a/src/Admin/Menus.php +++ b/src/Admin/Menus.php @@ -19,10 +19,6 @@ class Menus { * @since 1.0.0 */ public function __construct() { - // add_action( 'current_screen', array( $this, 'setup_screen' ) ); - // add_action( 'check_ajax_referer', array( $this, 'setup_screen' ) ); - // add_filter( 'set-screen-option', array( __CLASS__, 'save_screen_options' ), 10, 3 ); - // Register the menus. add_action( 'admin_menu', array( $this, 'main_menu' ) ); add_action( 'admin_menu', array( $this, 'activations_menu' ), 40 ); @@ -59,12 +55,6 @@ public function setup_screen() { $screen_id = isset( $screen, $screen->id ) ? $screen->id : ''; } - // switch ( $screen_id ) { - // case $plugin_screen_id . '-page-wc-serial-numbers': - // $this->list_table = new ListTables\KeysTable(); - // break; - // } - // Ensure the table handler is only loaded once. Prevents multiple loads if a plugin calls check_ajax_referer many times. remove_action( 'current_screen', array( $this, 'setup_screen' ) ); remove_action( 'check_ajax_referer', array( $this, 'setup_screen' ) ); @@ -223,11 +213,11 @@ public function output_main_page() { if ( $add ) { $key = new Key(); - include dirname( __FILE__ ) . '/views/html-edit-key.php'; + include __DIR__ . '/views/html-edit-key.php'; } elseif ( $edit ) { - include dirname( __FILE__ ) . '/views/html-edit-key.php'; + include __DIR__ . '/views/html-edit-key.php'; } else { - include dirname( __FILE__ ) . '/views/html-list-keys.php'; + include __DIR__ . '/views/html-list-keys.php'; } } @@ -263,8 +253,8 @@ public function output_tools_page() { $tabs = apply_filters( 'wc_serial_numbers_tools_tabs', $tabs ); $tab_ids = array_keys( $tabs ); - $current_tab = isset( $_GET['tab'] ) ? sanitize_key( $_GET['tab'] ) : reset( $tab_ids ); - $page = isset( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : ''; + $current_tab = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : reset( $tab_ids ); + $page = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : ''; Admin::view( 'html-tools.php', @@ -285,14 +275,12 @@ public function output_tools_page() { public function output_reports_page() { $tabs = array( 'stock' => __( 'Stock', 'wc-serial-numbers' ), - // 'sales' => __( 'Sales', 'wc-serial-numbers' ), - // 'activations' => __( 'Activations', 'wc-serial-numbers' ), ); $tabs = apply_filters( 'wc_serial_numbers_reports_tabs', $tabs ); $tab_ids = array_keys( $tabs ); - $current_tab = isset( $_GET['tab'] ) ? sanitize_key( $_GET['tab'] ) : reset( $tab_ids ); - $page = isset( $_GET['page'] ) ? sanitize_key( $_GET['page'] ) : ''; + $current_tab = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : reset( $tab_ids ); + $page = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : ''; Admin::view( 'html-reports.php', @@ -311,8 +299,8 @@ public function output_reports_page() { * @return void */ public function go_pro_redirect() { - if ( isset( $_GET['page'] ) && 'go_wcsn_pro' === $_GET['page'] ) { - wp_redirect( 'https://pluginever.com/plugins/woocommerce-serial-numbers-pro/?utm_source=admin-menu&utm_medium=link&utm_campaign=upgrade&utm_id=wc-serial-numbers' ); + if ( isset( $_GET['page'] ) && 'go_wcsn_pro' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended + wp_redirect( 'https://pluginever.com/plugins/woocommerce-serial-numbers-pro/?utm_source=admin-menu&utm_medium=link&utm_campaign=upgrade&utm_id=wc-serial-numbers' ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect die; } } @@ -427,7 +415,8 @@ public static function status_tab() { foreach ( $cron_jobs as $cron_job => $cron_job_name ) { $next_scheduled = wp_next_scheduled( $cron_job ); if ( $next_scheduled ) { - $statuses[ $cron_job_name ] = sprintf( __( 'Next run: %s', 'wc-serial-numbers' ), date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $next_scheduled ) ); + // translators: %s: Next scheduled time. + $statuses[ $cron_job_name ] = sprintf( __( 'Next run: %s', 'wc-serial-numbers' ), esc_html( date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $next_scheduled ) ) ); } else { $statuses[ $cron_job_name ] = __( 'Not scheduled', 'wc-serial-numbers' ); } diff --git a/src/Admin/Metaboxes.php b/src/Admin/Metaboxes.php index 3c4760a0..8aa38054 100644 --- a/src/Admin/Metaboxes.php +++ b/src/Admin/Metaboxes.php @@ -25,8 +25,11 @@ public function __construct() { } /** - * product - * since 1.0.0 + * Add product data tab. + * + * @param array $tabs product data tabs. + * + * @return mixed */ public static function product_data_tab( $tabs ) { $tabs['wc_serial_numbers'] = array( @@ -46,7 +49,7 @@ public static function product_write_panel() { global $post, $woocommerce; ?> @@ -132,18 +145,19 @@ public static function product_write_panel() { /** * Show promo box. * - * @param $variation_data - * @param $variation - * - * @param $loop - * * @since 1.2.0 */ - public static function variable_product_content( $loop, $variation_data, $variation ) { + public static function variable_product_content() { if ( ! WCSN()->is_premium_active() ) { - echo sprintf( '

%s %s

', __( 'The free version of Serial Numbers for WooCommerce does not support product variation.', 'wc-serial-numbers' ), 'https://www.pluginever.com/plugins/woocommerce-serial-numbers-pro/?utm_source=product_page_license_area&utm_medium=link&utm_campaign=wc-serial-numbers&utm_content=Upgrade%20to%20Pro', __( 'Upgrade to Pro', 'wc-serial-numbers' ) ); + echo wp_kses_post( + sprintf( + '

%s %s

', + __( 'The free version of Serial Numbers for WooCommerce does not support product variation.', 'wc-serial-numbers' ), + 'https://www.pluginever.com/plugins/woocommerce-serial-numbers-pro/?utm_source=product_page_license_area&utm_medium=link&utm_campaign=wc-serial-numbers&utm_content=Upgrade%20to%20Pro', + __( 'Upgrade to Pro', 'wc-serial-numbers' ) + ) + ); } - } /** @@ -152,12 +166,13 @@ public static function variable_product_content( $loop, $variation_data, $variat public static function product_save_data() { global $post; $status = isset( $_POST['_is_serial_number'] ) ? 'yes' : 'no'; - $source = isset( $_POST['_serial_key_source'] ) ? sanitize_text_field( $_POST['_serial_key_source'] ) : 'custom_source'; + $source = isset( $_POST['_serial_key_source'] ) ? sanitize_text_field( wp_unslash( $_POST['_serial_key_source'] ) ) : 'custom_source'; update_post_meta( $post->ID, '_is_serial_number', $status ); update_post_meta( $post->ID, '_serial_key_source', $source ); - // save only if software licensing enabled - if ( ! wc_serial_numbers_software_support_disabled() ) { - update_post_meta( $post->ID, '_software_version', ! empty( $_POST['_software_version'] ) ? sanitize_text_field( $_POST['_software_version'] ) : '' ); + // save only if software licensing enabled. + if ( wcsn_is_software_support_enabled() ) { + $software_version = isset( $_POST['_software_version'] ) ? sanitize_text_field( wp_unslash( $_POST['_software_version'] ) ) : ''; + update_post_meta( $post->ID, '_software_version', $software_version ); } do_action( 'wcsn_save_simple_product_meta', $post ); @@ -165,42 +180,40 @@ public static function product_save_data() { /** + * Display serial numbers in order item meta. * - * @param $o_item - * @param $product - * - * @param $o_item_id + * @param int $o_item_id order item id. + * @param \WC_Order_Item $o_item order item object. + * @param \WC_Product $product product object. * * @since 1.1.6 * - * @return bool|string + * @return void */ public function order_itemmeta( $o_item_id, $o_item, $product ) { global $post; if ( ! is_object( $post ) || ! isset( $post->ID ) ) { - return false; + return; } $order = wc_get_order( $post->ID ); - // bail for no order + // bail for no order. if ( ! $order ) { - return false; + return; } if ( 'completed' !== $order->get_status( 'edit' ) ) { - return ''; + return; } - // if this is not product then no need to process + // if this is not product then no need to process. if ( empty( $product ) ) { - return false; + return; } - $is_serial_product = 'yes' == get_post_meta( $product->get_id(), '_is_serial_number', true ); - - if ( ! $is_serial_product ) { - return false; + if ( 'yes' !== get_post_meta( $product->get_id(), '_is_serial_number', true ) ) { + return; } $items = wcsn_get_keys( @@ -211,22 +224,28 @@ public function order_itemmeta( $o_item_id, $o_item, $product ) { ); if ( empty( $items ) && $order ) { - echo sprintf( '
%s
', __( 'Order missing serial numbers for this item.', 'wc-serial-numbers' ) ); - - return true; + echo wp_kses_post( + sprintf( + '
%s
', + __( 'Order missing serial numbers for this item.', 'wc-serial-numbers' ) + ) + ); + return; } $url = admin_url( 'admin.php?page=wc-serial-numbers' ); - echo sprintf( + printf( '
%s→', - add_query_arg( - [ - 'order_id' => $post->ID, - 'product_id' => $product->get_id(), - ], - $url + esc_url( + add_query_arg( + array( + 'order_id' => $post->ID, + 'product_id' => $product->get_id(), + ), + $url + ) ), - __( 'Serial Numbers', 'wc-serial-numbers' ) + esc_html__( 'Serial Numbers', 'wc-serial-numbers' ) ); $url = admin_url( 'admin.php?page=wc-serial-numbers' ); @@ -237,15 +256,19 @@ public function order_itemmeta( $o_item_id, $o_item, $product ) { $li .= sprintf( '
  •  %s
  • ', add_query_arg( - [ + array( 'edit' => $item->id, - ], + ), $url ), - wc_serial_numbers_decrypt_key( $item->serial_key ) + wcsn_decrypt_key( $item->serial_key ) ); } - - echo sprintf( '
      %s
    ', $li ); + echo wp_kses_post( + sprintf( + '
      %s
    ', + $li + ) + ); } } diff --git a/src/Admin/Notices.php b/src/Admin/Notices.php index 3972933b..014fc9d6 100644 --- a/src/Admin/Notices.php +++ b/src/Admin/Notices.php @@ -25,10 +25,10 @@ class Notices { * @since 1.0.0 */ public function __construct() { - add_action( 'admin_init', [ $this, 'add_notices' ] ); - add_action( 'admin_notices', [ $this, 'output_notices' ] ); - add_action( 'wp_ajax_wc_serial_numbers_dismiss_notice', [ $this, 'dismiss_notice' ] ); - add_action( 'admin_footer', [ $this, 'add_notice_script' ] ); + add_action( 'admin_init', array( $this, 'add_notices' ) ); + add_action( 'admin_notices', array( $this, 'output_notices' ) ); + add_action( 'wp_ajax_wc_serial_numbers_dismiss_notice', array( $this, 'dismiss_notice' ) ); + add_action( 'admin_footer', array( $this, 'add_notice_script' ) ); } /** @@ -39,7 +39,7 @@ public function __construct() { public function add_notices() { $is_outdated_pro = defined( 'WC_SERIAL_NUMBER_PRO_PLUGIN_VERSION' ) && version_compare( WC_SERIAL_NUMBER_PRO_PLUGIN_VERSION, '1.2.1', '<' ); if ( ! $is_outdated_pro ) { - $is_outdated_pro = function_exists( 'wc_serial_numbers_pro' ) && is_callable( [ 'wc_serial_numbers_pro', 'get_version' ] ) && wc_serial_numbers_pro()->get_version() && version_compare( wc_serial_numbers_pro()->get_version(), '1.2.1', '<' ); + $is_outdated_pro = function_exists( 'wc_serial_numbers_pro' ) && is_callable( array( 'wc_serial_numbers_pro', 'get_version' ) ) && wc_serial_numbers_pro()->get_version() && version_compare( wc_serial_numbers_pro()->get_version(), '1.2.1', '<' ); } if ( $is_outdated_pro ) { $this->notices[] = array( diff --git a/src/Admin/Orders.php b/src/Admin/Orders.php index 0524a153..92ce2635 100644 --- a/src/Admin/Orders.php +++ b/src/Admin/Orders.php @@ -97,7 +97,7 @@ public static function add_order_serial_column( $columns ) { public static function add_order_serial_column_content( $column, $order_id ) { $order_status = wc_get_order( $order_id )->get_status(); if ( 'order_serials' === $column ) { - if ( ! wcsn_order_has_products( $order_id ) || ! in_array( $order_status, [ 'completed', 'processing' ], true ) ) { + if ( ! wcsn_order_has_products( $order_id ) || ! in_array( $order_status, array( 'completed', 'processing' ), true ) ) { echo '—'; } else { if ( wcsn_order_is_fullfilled( $order_id ) ) { @@ -107,8 +107,8 @@ public static function add_order_serial_column_content( $column, $order_id ) { $style = 'color:red'; $title = __( 'Order is not fullfilled.', 'wc-serial-numbers' ); } - $url = add_query_arg( [ 'order_id' => $order_id ], admin_url( 'admin.php?page=wc-serial-numbers' ) ); - echo sprintf( '', esc_url( $url ), esc_html( $title ), esc_attr( $style ) ); + $url = add_query_arg( array( 'order_id' => $order_id ), admin_url( 'admin.php?page=wc-serial-numbers' ) ); + printf( '', esc_url( $url ), esc_html( $title ), esc_attr( $style ) ); } } } @@ -139,7 +139,7 @@ public function add_order_bulk_action( $actions ) { * @return string */ public function handle_order_bulk_action( $redirect_to, $action, $order_ids ) { - if ( in_array( $action, [ 'wcsn_add_keys', 'wcsn_remove_keys' ], true ) ) { + if ( in_array( $action, array( 'wcsn_add_keys', 'wcsn_remove_keys' ), true ) ) { foreach ( $order_ids as $order_id ) { switch ( $action ) { case 'wcsn_add_keys': @@ -217,7 +217,7 @@ public static function display_order_item_meta( $item_id, $item, $product ) { - + $field ) : ?> diff --git a/src/Admin/Products.php b/src/Admin/Products.php index b7cbdf2b..d5e1e7b9 100644 --- a/src/Admin/Products.php +++ b/src/Admin/Products.php @@ -27,7 +27,6 @@ public function __construct() { * @since 1.0.0 */ public static function print_style() { - ob_start(); ?> __( 'General Settings', 'wc-serial-numbers' ), 'type' => 'title', 'desc' => __( 'These options determine the behavior and operation of the plugin.', 'wc-serial-numbers' ), 'id' => 'section_serial_numbers', - ], - [ + ), + array( 'title' => __( 'Auto-complete orders', 'wc-serial-numbers' ), 'id' => 'wc_serial_numbers_autocomplete_order', 'desc' => __( 'Automatically completes orders after successful payments.', 'wc-serial-numbers' ), 'type' => 'checkbox', 'default' => 'no', - ], - [ + ), + array( 'title' => __( 'Reuse keys', 'wc-serial-numbers' ), 'id' => 'wc_serial_numbers_reuse_serial_number', 'desc' => __( 'Recover failed, refunded keys for selling again.', 'wc-serial-numbers' ), 'desc_tip' => __( 'If you enable this option, the keys will be available for selling again if the order is refunded or failed.', 'wc-serial-numbers' ), 'type' => 'checkbox', 'default' => 'no', - ], + ), // Revoke serial keys. - [ + array( 'title' => __( 'Revoke keys', 'wc-serial-numbers' ), 'id' => 'wc_serial_numbers_revoke_keys', 'desc' => __( 'Revoke keys when the order status changes to cancelled or refunded.', 'wc-serial-numbers' ), 'desc_tip' => __( 'If you enable this option, the keys will be revoked when the order status changes to cancelled or refunded.', 'wc-serial-numbers' ), 'type' => 'checkbox', 'default' => 'no', - ], - [ + ), + array( 'title' => __( 'Hide keys', 'wc-serial-numbers' ), 'id' => 'wc_serial_numbers_hide_serial_number', 'desc' => __( 'Keys will be masked in the list table.', 'wc-serial-numbers' ), 'default' => 'yes', 'type' => 'checkbox', - ], - [ - 'title' => __( 'Disable software support', 'wc-serial-numbers' ), - 'id' => 'wc_serial_numbers_disable_software_support', - 'desc' => __( 'Disable Software Licensing support & API functionalities.', 'wc-serial-numbers' ), + ), + array( + 'title' => __( 'Disable software support', 'wc-serial-numbers' ), + 'id' => 'wc_serial_numbers_disable_software_support', + 'desc' => __( 'Disable Software Licensing support & API functionalities.', 'wc-serial-numbers' ), 'desc_tip' => __( 'If you enable this option, the activation menu and it’s functionality will be turned off.', 'wc-serial-numbers' ), - 'default' => 'no', - 'type' => 'checkbox', - ], - [ + 'default' => 'no', + 'type' => 'checkbox', + ), + array( 'type' => 'sectionend', 'id' => 'section_serial_numbers', - ], - [ + ), + array( 'title' => __( 'Stock Notification', 'wc-serial-numbers' ), 'type' => 'title', 'desc' => __( 'These options determine the operation of the key\'s stock notification.', 'wc-serial-numbers' ), 'id' => 'stock_section', - ], - [ + ), + array( 'title' => __( 'Stock notification email', 'wc-serial-numbers' ), 'id' => 'wc_serial_numbers_enable_stock_notification', 'desc' => __( 'Sends notification emails when key stock is low.', 'wc-serial-numbers' ), 'type' => 'checkbox', 'sanitize_callback' => 'intval', 'default' => 'yes', - ], + ), array( 'title' => __( 'Stock threshold', 'wc-serial-numbers' ), 'id' => 'wc_serial_numbers_stock_threshold', @@ -119,10 +119,10 @@ public function get_settings( $tab ) { 'type' => 'text', 'default' => get_option( 'admin_email' ), ), - [ + array( 'type' => 'sectionend', 'id' => 'stock_section', - ], + ), ); break; } @@ -187,7 +187,7 @@ protected function output_premium_widget() { public function output_tabs( $tabs ) { parent::output_tabs( $tabs ); if ( WCSN()->get_docs_url() ) { - echo sprintf( '%s', WCSN()->get_docs_url(), __( 'Documentation', 'wc-serial-numbers' ) ); + printf( '%s', esc_url( WCSN()->get_docs_url() ), esc_html__( 'Documentation', 'wc-serial-numbers' ) ); } } } diff --git a/src/Admin/views/html-edit-key.php b/src/Admin/views/html-edit-key.php index d99d676f..e018c16a 100644 --- a/src/Admin/views/html-edit-key.php +++ b/src/Admin/views/html-edit-key.php @@ -39,7 +39,7 @@ $option ) : ?> - %s', esc_attr( $status ), selected( $key->get_status(), $status, false ), esc_html( $option ) ); ?> + %s', esc_attr( $status ), selected( $key->get_status(), $status, false ), esc_html( $option ) ); ?>

    @@ -105,7 +105,7 @@