diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist index 7c03f0c..3b5be7e 100644 --- a/.phpcs.xml.dist +++ b/.phpcs.xml.dist @@ -34,6 +34,7 @@ + diff --git a/composer.json b/composer.json index 11ed6bb..b98f1e1 100644 --- a/composer.json +++ b/composer.json @@ -25,33 +25,41 @@ "php": ">=7.4.1", "automattic/jetpack-autoloader": "^5.0.0", "rpnzl/arrch": "dev-master#994258bbefb7722243211654c4f78813312cd5ed", - "amphp/amp": "v2.6.2", - "psr/log": "1.1.4", - "delight-im/cookie": "v3.4.0", - "berlindb/core": "2.0.1", - "mexitek/phpcolors": "v1.0.4", - "phpdocumentor/reflection-docblock": "5.3.0", - "stripe/stripe-php": "v10.21.0", - "hashids/hashids": "4.1.0", + "amphp/amp": "^2.6.2", + "psr/log": "^1.1.4", + "delight-im/cookie": "^3.4.0", + "berlindb/core": "^2.0.1", + "mexitek/phpcolors": "^1.0.4", + "phpdocumentor/reflection-docblock": "^5.3.0", + "stripe/stripe-php": "^10.21.0", + "hashids/hashids": "^4.1.0", "rakit/validation": "dev-master#ff003a35cdf5030a5f2482299f4c93f344a35b29", - "ifsnop/mysqldump-php": "v2.12", - "mpdf/mpdf": "v8.2.0", - "remotelyliving/php-dns": "4.3.0", - "jasny/sso": "v0.4.2", - "nyholm/psr7": "1.8.0", - "symfony/cache": "v5.4.29", - "scssphp/scssphp": "v1.11.1", + "ifsnop/mysqldump-php": "^2.12", + "mpdf/mpdf": "^8.2.0", + "remotelyliving/php-dns": "^4.3.0", + "jasny/sso": "^0.4.2", + "nyholm/psr7": "^1.8.0", + "symfony/cache": "^5.4.29", + "scssphp/scssphp": "^1.11.1", "cweagans/composer-patches": "^1.7", "woocommerce/action-scheduler": "^3.9.1", - "ext-json": "*" + "ext-json": "*", + "symfony/polyfill-php80": "^1.31.0", + "symfony/polyfill-php81": "^1.31.0", + "symfony/polyfill-php82": "^1.31.0", + "symfony/polyfill-php83": "^1.31.0", + "symfony/polyfill-php84": "^1.31.0" }, "require-dev": { - "composer/installers": "1.9.0", + "composer/installers": "^1.9.0", "phpunit/phpunit": "^9.6.22", "yoast/phpunit-polyfills": "^1.1.3", "woocommerce/woocommerce-sniffs": "^1.0.0", "symplify/vendor-patches": "^11.3", - "fakerphp/faker": "^1.24" + "fakerphp/faker": "^1.24", + "rector/rector": "^2.0.8", + "szepeviktor/phpstan-wordpress": "^2.0.1", + "phpstan/extension-installer": "^1.1" }, "config": { "platform": { @@ -61,7 +69,8 @@ "composer/installers": true, "dealerdirect/phpcodesniffer-composer-installer": true, "automattic/jetpack-autoloader": true, - "cweagans/composer-patches": true + "cweagans/composer-patches": true, + "phpstan/extension-installer": true } }, "archive": { @@ -99,6 +108,6 @@ } }, "scripts": { - "post-update-cmd": "cd vendor/mpdf/mpdf/ttfonts && rm -f AboriginalSansREGULAR.ttf Aegean.otf Aegyptus.otf Akkadian.otf ayar.ttf damase_v.2.ttf DBSILBR.ttf DejaVuSerif.ttf Dhyana-Regular.ttf DejaVuSansMono-Oblique.ttf DejaVuSerif-BoldItalic.ttf DhyanaOFL.txt DejaVuSerifCondensed-BoldItalic.ttf DejaVuSansMono-Bold.ttf DejaVuSerif-Italic.ttf DejaVuSerifCondensed-Bold.ttf DejaVuSansMono.ttf DejaVuSansMono-BoldOblique.ttf DejaVuSerif-Bold.ttf Dhyana-Bold.ttf DejaVuSerifCondensed-Italic.ttf DejaVuSansCondensed-BoldOblique.ttf DejaVuSansCondensed-Oblique.ttf DejaVuSans-Oblique.ttf DejaVuSans-BoldOblique.ttf DejaVuSans-Bold.ttf DejaVuSans.ttf FreeMonoBoldOblique.ttf FreeMonoOblique.ttf FreeSans.ttf FreeSansBold.ttf FreeSansBoldOblique.ttf FreeSansOblique.ttf FreeSerifBoldItalic.ttf FreeSerifItalic.ttf Garuda.ttf Garuda-Bold.ttf Garuda-BoldOblique.ttf Garuda-Oblique.ttf GNUFreeFontinfo.txt Jomolhari.ttf Jomolhari-OFL.txt kaputaunicode.ttf KhmerOFL.txt KhmerOS.ttf lannaalif-v1-03.ttf 'Lateef font OFL.txt' LateefRegOT.ttf Lohit-Kannada.ttf LohitKannadaOFL.txt ocrb10.ttf ocrbinfo.txt Padauk-book.ttf Pothana2000.ttf Quivira.otf Sun-ExtA.ttf Sun-ExtB.ttf SundaneseUnicode-1.0.5.ttf SyrCOMEdessa.otf SyrCOMEdessa_license.txt TaameyDavidCLM-LICENSE.txt TaameyDavidCLM-Medium.ttf TaiHeritagePro.ttf Tharlon-Regular.ttf TharlonOFL.txt UnBatang_0613.ttf Uthman.otf 'XB Riyaz.ttf' 'XB RiyazBd.ttf' 'XB RiyazBdIt.ttf' 'XB RiyazIt.ttf' 'XW Zar Font Info.txt' ZawgyiOne.ttf" + "post-update-cmd": "cd vendor/mpdf/mpdf/ttfonts && rm -f AboriginalSansREGULAR.ttf Aegean.otf Aegyptus.otf Akkadian.otf ayar.ttf damase_v.2.ttf DBSILBR.ttf DejaVuSerif.ttf Dhyana-Regular.ttf DejaVuSansMono-Oblique.ttf DejaVuSerif-BoldItalic.ttf DhyanaOFL.txt DejaVuSerifCondensed-BoldItalic.ttf DejaVuSansMono-Bold.ttf DejaVuSerif-Italic.ttf DejaVuSansMono.ttf DejaVuSansMono-BoldOblique.ttf DejaVuSerif-Bold.ttf Dhyana-Bold.ttf DejaVuSerifCondensed-Italic.ttf DejaVuSansCondensed-BoldOblique.ttf DejaVuSansCondensed-Oblique.ttf DejaVuSans-Oblique.ttf DejaVuSans-BoldOblique.ttf DejaVuSans-Bold.ttf DejaVuSans.ttf FreeMonoBoldOblique.ttf FreeMonoOblique.ttf FreeSans.ttf FreeSansBold.ttf FreeSansBoldOblique.ttf FreeSansOblique.ttf FreeSerif.ttf FreeSerifBold.ttf FreeSerifBoldItalic.ttf FreeSerifItalic.ttf Garuda.ttf Garuda-Bold.ttf Garuda-BoldOblique.ttf Garuda-Oblique.ttf GNUFreeFontinfo.txt Jomolhari.ttf Jomolhari-OFL.txt kaputaunicode.ttf KhmerOFL.txt KhmerOS.ttf lannaalif-v1-03.ttf 'Lateef font OFL.txt' LateefRegOT.ttf Lohit-Kannada.ttf LohitKannadaOFL.txt ocrb10.ttf ocrbinfo.txt Padauk-book.ttf Pothana2000.ttf Quivira.otf Sun-ExtA.ttf Sun-ExtB.ttf SundaneseUnicode-1.0.5.ttf SyrCOMEdessa.otf SyrCOMEdessa_license.txt TaameyDavidCLM-LICENSE.txt TaameyDavidCLM-Medium.ttf TaiHeritagePro.ttf Tharlon-Regular.ttf TharlonOFL.txt UnBatang_0613.ttf Uthman.otf 'XB Riyaz.ttf' 'XB RiyazBd.ttf' 'XB RiyazBdIt.ttf' 'XB RiyazIt.ttf' 'XW Zar Font Info.txt' ZawgyiOne.ttf Abyssinica_SIL.ttf" } } diff --git a/composer.lock b/composer.lock index 8895d15..4785893 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "b82b320cecc6701508316d46bc4335c3", + "content-hash": "c27fa56bfcbf860f1ae2a70ef5153e7a", "packages": [ { "name": "amphp/amp", - "version": "v2.6.2", + "version": "v2.6.4", "source": { "type": "git", "url": "https://github.com/amphp/amp.git", - "reference": "9d5100cebffa729aaffecd3ad25dc5aeea4f13bb" + "reference": "ded3d9be08f526089eb7ee8d9f16a9768f9dec2d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/amphp/amp/zipball/9d5100cebffa729aaffecd3ad25dc5aeea4f13bb", - "reference": "9d5100cebffa729aaffecd3ad25dc5aeea4f13bb", + "url": "https://api.github.com/repos/amphp/amp/zipball/ded3d9be08f526089eb7ee8d9f16a9768f9dec2d", + "reference": "ded3d9be08f526089eb7ee8d9f16a9768f9dec2d", "shasum": "" }, "require": { @@ -29,8 +29,8 @@ "ext-json": "*", "jetbrains/phpstorm-stubs": "^2019.3", "phpunit/phpunit": "^7 | ^8 | ^9", - "psalm/phar": "^3.11@dev", - "react/promise": "^2" + "react/promise": "^2", + "vimeo/psalm": "^3.12" }, "type": "library", "extra": { @@ -85,7 +85,7 @@ "support": { "irc": "irc://irc.freenode.org/amphp", "issues": "https://github.com/amphp/amp/issues", - "source": "https://github.com/amphp/amp/tree/v2.6.2" + "source": "https://github.com/amphp/amp/tree/v2.6.4" }, "funding": [ { @@ -93,7 +93,7 @@ "type": "github" } ], - "time": "2022-02-20T17:52:18+00:00" + "time": "2024-03-21T18:52:26+00:00" }, { "name": "automattic/jetpack-autoloader", @@ -978,16 +978,16 @@ }, { "name": "mpdf/mpdf", - "version": "v8.2.0", + "version": "v8.2.5", "source": { "type": "git", "url": "https://github.com/mpdf/mpdf.git", - "reference": "170a236a588d177c2aa7447ce490a030ca68e6f4" + "reference": "e175b05e3e00977b85feb96a8cccb174ac63621f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/mpdf/mpdf/zipball/170a236a588d177c2aa7447ce490a030ca68e6f4", - "reference": "170a236a588d177c2aa7447ce490a030ca68e6f4", + "url": "https://api.github.com/repos/mpdf/mpdf/zipball/e175b05e3e00977b85feb96a8cccb174ac63621f", + "reference": "e175b05e3e00977b85feb96a8cccb174ac63621f", "shasum": "" }, "require": { @@ -997,7 +997,7 @@ "mpdf/psr-log-aware-trait": "^2.0 || ^3.0", "myclabs/deep-copy": "^1.7", "paragonie/random_compat": "^1.4|^2.0|^9.99.99", - "php": "^5.6 || ^7.0 || ~8.0.0 || ~8.1.0 || ~8.2.0", + "php": "^5.6 || ^7.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", "psr/http-message": "^1.0 || ^2.0", "psr/log": "^1.0 || ^2.0 || ^3.0", "setasign/fpdi": "^2.1" @@ -1045,7 +1045,7 @@ "utf-8" ], "support": { - "docs": "http://mpdf.github.io", + "docs": "https://mpdf.github.io", "issues": "https://github.com/mpdf/mpdf/issues", "source": "https://github.com/mpdf/mpdf" }, @@ -1055,7 +1055,7 @@ "type": "custom" } ], - "time": "2023-09-01T11:44:52+00:00" + "time": "2024-11-18T15:30:42+00:00" }, { "name": "mpdf/psr-http-message-shim", @@ -1211,16 +1211,16 @@ }, { "name": "nyholm/psr7", - "version": "1.8.0", + "version": "1.8.2", "source": { "type": "git", "url": "https://github.com/Nyholm/psr7.git", - "reference": "3cb4d163b58589e47b35103e8e5e6a6a475b47be" + "reference": "a71f2b11690f4b24d099d6b16690a90ae14fc6f3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Nyholm/psr7/zipball/3cb4d163b58589e47b35103e8e5e6a6a475b47be", - "reference": "3cb4d163b58589e47b35103e8e5e6a6a475b47be", + "url": "https://api.github.com/repos/Nyholm/psr7/zipball/a71f2b11690f4b24d099d6b16690a90ae14fc6f3", + "reference": "a71f2b11690f4b24d099d6b16690a90ae14fc6f3", "shasum": "" }, "require": { @@ -1273,7 +1273,7 @@ ], "support": { "issues": "https://github.com/Nyholm/psr7/issues", - "source": "https://github.com/Nyholm/psr7/tree/1.8.0" + "source": "https://github.com/Nyholm/psr7/tree/1.8.2" }, "funding": [ { @@ -1285,7 +1285,7 @@ "type": "github" } ], - "time": "2023-05-02T11:26:24+00:00" + "time": "2024-09-09T07:06:30+00:00" }, { "name": "paragonie/random_compat", @@ -1392,28 +1392,35 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.3.0", + "version": "5.6.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" + "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", + "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", "shasum": "" }, "require": { + "doctrine/deprecations": "^1.1", "ext-filter": "*", - "php": "^7.2 || ^8.0", + "php": "^7.4 || ^8.0", "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.3", + "phpdocumentor/type-resolver": "^1.7", + "phpstan/phpdoc-parser": "^1.7|^2.0", "webmozart/assert": "^1.9.1" }, "require-dev": { - "mockery/mockery": "~1.3.2", - "psalm/phar": "^4.8" + "mockery/mockery": "~1.3.5 || ~1.6.0", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-mockery": "^1.1", + "phpstan/phpstan-webmozart-assert": "^1.2", + "phpunit/phpunit": "^9.5", + "psalm/phar": "^5.26" }, "type": "library", "extra": { @@ -1437,15 +1444,15 @@ }, { "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" + "email": "opensource@ijaap.nl" } ], "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.1" }, - "time": "2021-10-19T17:43:47+00:00" + "time": "2024-12-07T09:39:29+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -2163,16 +2170,16 @@ }, { "name": "scssphp/scssphp", - "version": "v1.11.1", + "version": "v1.13.0", "source": { "type": "git", "url": "https://github.com/scssphp/scssphp.git", - "reference": "ace2503684bab0dcc817d7614c8a54b865122414" + "reference": "63d1157457e5554edf00b0c1fabab4c1511d2520" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/scssphp/scssphp/zipball/ace2503684bab0dcc817d7614c8a54b865122414", - "reference": "ace2503684bab0dcc817d7614c8a54b865122414", + "url": "https://api.github.com/repos/scssphp/scssphp/zipball/63d1157457e5554edf00b0c1fabab4c1511d2520", + "reference": "63d1157457e5554edf00b0c1fabab4c1511d2520", "shasum": "" }, "require": { @@ -2237,9 +2244,9 @@ ], "support": { "issues": "https://github.com/scssphp/scssphp/issues", - "source": "https://github.com/scssphp/scssphp/tree/v1.11.1" + "source": "https://github.com/scssphp/scssphp/tree/v1.13.0" }, - "time": "2023-09-24T13:38:17+00:00" + "time": "2024-08-17T21:02:11+00:00" }, { "name": "setasign/fpdi", @@ -2433,16 +2440,16 @@ }, { "name": "symfony/cache", - "version": "v5.4.29", + "version": "v5.4.46", "source": { "type": "git", "url": "https://github.com/symfony/cache.git", - "reference": "e29c5a97bc2d81269973c3e1d7ceb9d48b4d5151" + "reference": "0fe08ee32cec2748fbfea10c52d3ee02049e0f6b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/cache/zipball/e29c5a97bc2d81269973c3e1d7ceb9d48b4d5151", - "reference": "e29c5a97bc2d81269973c3e1d7ceb9d48b4d5151", + "url": "https://api.github.com/repos/symfony/cache/zipball/0fe08ee32cec2748fbfea10c52d3ee02049e0f6b", + "reference": "0fe08ee32cec2748fbfea10c52d3ee02049e0f6b", "shasum": "" }, "require": { @@ -2470,8 +2477,8 @@ "require-dev": { "cache/integration-tests": "dev-master", "doctrine/cache": "^1.6|^2.0", - "doctrine/dbal": "^2.13.1|^3.0", - "predis/predis": "^1.1", + "doctrine/dbal": "^2.13.1|^3|^4", + "predis/predis": "^1.1|^2.0", "psr/simple-cache": "^1.0|^2.0", "symfony/config": "^4.4|^5.0|^6.0", "symfony/dependency-injection": "^4.4|^5.0|^6.0", @@ -2510,7 +2517,7 @@ "psr6" ], "support": { - "source": "https://github.com/symfony/cache/tree/v5.4.29" + "source": "https://github.com/symfony/cache/tree/v5.4.46" }, "funding": [ { @@ -2526,7 +2533,7 @@ "type": "tidelift" } ], - "time": "2023-09-19T13:25:51+00:00" + "time": "2024-11-04T11:43:55+00:00" }, { "name": "symfony/cache-contracts", @@ -2994,6 +3001,310 @@ ], "time": "2024-09-09T11:45:10+00:00" }, + { + "name": "symfony/polyfill-php81", + "version": "v1.31.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php81.git", + "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", + "reference": "4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php81\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php81/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-php82", + "version": "v1.31.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php82.git", + "reference": "5d2ed36f7734637dacc025f179698031951b1692" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php82/zipball/5d2ed36f7734637dacc025f179698031951b1692", + "reference": "5d2ed36f7734637dacc025f179698031951b1692", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php82\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.2+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php82/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-php83", + "version": "v1.31.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php83.git", + "reference": "2fb86d65e2d424369ad2905e83b236a8805ba491" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php83/zipball/2fb86d65e2d424369ad2905e83b236a8805ba491", + "reference": "2fb86d65e2d424369ad2905e83b236a8805ba491", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php83\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php83/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T11:45:10+00:00" + }, + { + "name": "symfony/polyfill-php84", + "version": "v1.31.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php84.git", + "reference": "e5493eb51311ab0b1cc2243416613f06ed8f18bd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php84/zipball/e5493eb51311ab0b1cc2243416613f06ed8f18bd", + "reference": "e5493eb51311ab0b1cc2243416613f06ed8f18bd", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php84\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.4+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php84/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-09-09T12:04:04+00:00" + }, { "name": "symfony/process", "version": "v5.4.47", @@ -3317,16 +3628,16 @@ "packages-dev": [ { "name": "composer/installers", - "version": "v1.9.0", + "version": "v1.12.0", "source": { "type": "git", "url": "https://github.com/composer/installers.git", - "reference": "b93bcf0fa1fccb0b7d176b0967d969691cd74cca" + "reference": "d20a64ed3c94748397ff5973488761b22f6d3f19" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/installers/zipball/b93bcf0fa1fccb0b7d176b0967d969691cd74cca", - "reference": "b93bcf0fa1fccb0b7d176b0967d969691cd74cca", + "url": "https://api.github.com/repos/composer/installers/zipball/d20a64ed3c94748397ff5973488761b22f6d3f19", + "reference": "d20a64ed3c94748397ff5973488761b22f6d3f19", "shasum": "" }, "require": { @@ -3337,17 +3648,18 @@ "shama/baton": "*" }, "require-dev": { - "composer/composer": "1.6.* || 2.0.*@dev", - "composer/semver": "1.0.* || 2.0.*@dev", - "phpunit/phpunit": "^4.8.36", - "sebastian/comparator": "^1.2.4", + "composer/composer": "1.6.* || ^2.0", + "composer/semver": "^1 || ^3", + "phpstan/phpstan": "^0.12.55", + "phpstan/phpstan-phpunit": "^0.12.16", + "symfony/phpunit-bridge": "^4.2 || ^5", "symfony/process": "^2.3" }, "type": "composer-plugin", "extra": { "class": "Composer\\Installers\\Plugin", "branch-alias": { - "dev-master": "1.0-dev" + "dev-main": "1.x-dev" } }, "autoload": { @@ -3385,6 +3697,7 @@ "Porto", "RadPHP", "SMF", + "Starbug", "Thelia", "Whmcs", "WolfCMS", @@ -3418,13 +3731,16 @@ "majima", "mako", "mediawiki", + "miaoxing", "modulework", "modx", "moodle", "osclass", + "pantheon", "phpbb", "piwik", "ppi", + "processwire", "puppet", "pxcms", "reindex", @@ -3434,6 +3750,7 @@ "sydes", "sylius", "symfony", + "tastyigniter", "typo3", "wordpress", "yawik", @@ -3442,19 +3759,23 @@ ], "support": { "issues": "https://github.com/composer/installers/issues", - "source": "https://github.com/composer/installers/tree/v1.9.0" + "source": "https://github.com/composer/installers/tree/v1.12.0" }, "funding": [ { "url": "https://packagist.com", "type": "custom" }, + { + "url": "https://github.com/composer", + "type": "github" + }, { "url": "https://tidelift.com/funding/github/packagist/composer/composer", "type": "tidelift" } ], - "time": "2020-04-07T06:57:05+00:00" + "time": "2021-09-13T08:19:44+00:00" }, { "name": "dealerdirect/phpcodesniffer-composer-installer", @@ -3843,6 +4164,54 @@ }, "time": "2022-02-21T01:04:05+00:00" }, + { + "name": "php-stubs/wordpress-stubs", + "version": "v6.7.2", + "source": { + "type": "git", + "url": "https://github.com/php-stubs/wordpress-stubs.git", + "reference": "27f32faacb65a1230d9dac09f1b6c5ce78a6e61a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-stubs/wordpress-stubs/zipball/27f32faacb65a1230d9dac09f1b6c5ce78a6e61a", + "reference": "27f32faacb65a1230d9dac09f1b6c5ce78a6e61a", + "shasum": "" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "nikic/php-parser": "^4.13", + "php": "^7.4 || ^8.0", + "php-stubs/generator": "^0.8.3", + "phpdocumentor/reflection-docblock": "^5.4.1", + "phpstan/phpstan": "^1.11", + "phpunit/phpunit": "^9.5", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.1.1", + "wp-coding-standards/wpcs": "3.1.0 as 2.3.0" + }, + "suggest": { + "paragonie/sodium_compat": "Pure PHP implementation of libsodium", + "symfony/polyfill-php80": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "szepeviktor/phpstan-wordpress": "WordPress extensions for PHPStan" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WordPress function and class declaration stubs for static analysis.", + "homepage": "https://github.com/php-stubs/wordpress-stubs", + "keywords": [ + "PHPStan", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/php-stubs/wordpress-stubs/issues", + "source": "https://github.com/php-stubs/wordpress-stubs/tree/v6.7.2" + }, + "time": "2025-02-05T17:57:54+00:00" + }, { "name": "phpcompatibility/php-compatibility", "version": "9.3.5", @@ -4213,6 +4582,112 @@ ], "time": "2024-05-20T13:34:27+00:00" }, + { + "name": "phpstan/extension-installer", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/phpstan/extension-installer.git", + "reference": "85e90b3942d06b2326fba0403ec24fe912372936" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/extension-installer/zipball/85e90b3942d06b2326fba0403ec24fe912372936", + "reference": "85e90b3942d06b2326fba0403ec24fe912372936", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.0", + "php": "^7.2 || ^8.0", + "phpstan/phpstan": "^1.9.0 || ^2.0" + }, + "require-dev": { + "composer/composer": "^2.0", + "php-parallel-lint/php-parallel-lint": "^1.2.0", + "phpstan/phpstan-strict-rules": "^0.11 || ^0.12 || ^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPStan\\ExtensionInstaller\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPStan\\ExtensionInstaller\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Composer plugin for automatic installation of PHPStan extensions", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpstan/extension-installer/issues", + "source": "https://github.com/phpstan/extension-installer/tree/1.4.3" + }, + "time": "2024-09-04T20:21:43+00:00" + }, + { + "name": "phpstan/phpstan", + "version": "2.1.3", + "source": { + "type": "git", + "url": "https://github.com/phpstan/phpstan.git", + "reference": "64ae44e48214f3deebdaeebf2694297a10a2bea9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/64ae44e48214f3deebdaeebf2694297a10a2bea9", + "reference": "64ae44e48214f3deebdaeebf2694297a10a2bea9", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0" + }, + "conflict": { + "phpstan/phpstan-shim": "*" + }, + "bin": [ + "phpstan", + "phpstan.phar" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHPStan - PHP Static Analysis Tool", + "keywords": [ + "dev", + "static analysis" + ], + "support": { + "docs": "https://phpstan.org/user-guide/getting-started", + "forum": "https://github.com/phpstan/phpstan/discussions", + "issues": "https://github.com/phpstan/phpstan/issues", + "security": "https://github.com/phpstan/phpstan/security/policy", + "source": "https://github.com/phpstan/phpstan-src" + }, + "funding": [ + { + "url": "https://github.com/ondrejmirtes", + "type": "github" + }, + { + "url": "https://github.com/phpstan", + "type": "github" + } + ], + "time": "2025-02-07T15:05:24+00:00" + }, { "name": "phpunit/php-code-coverage", "version": "9.2.32", @@ -4635,6 +5110,65 @@ ], "time": "2024-12-05T13:48:26+00:00" }, + { + "name": "rector/rector", + "version": "2.0.8", + "source": { + "type": "git", + "url": "https://github.com/rectorphp/rector.git", + "reference": "3c70238bc677eb98866000a05b19a34f12955954" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/rectorphp/rector/zipball/3c70238bc677eb98866000a05b19a34f12955954", + "reference": "3c70238bc677eb98866000a05b19a34f12955954", + "shasum": "" + }, + "require": { + "php": "^7.4|^8.0", + "phpstan/phpstan": "^2.1.2" + }, + "conflict": { + "rector/rector-doctrine": "*", + "rector/rector-downgrade-php": "*", + "rector/rector-phpunit": "*", + "rector/rector-symfony": "*" + }, + "suggest": { + "ext-dom": "To manipulate phpunit.xml via the custom-rule command" + }, + "bin": [ + "bin/rector" + ], + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Instant Upgrade and Automated Refactoring of any PHP code", + "keywords": [ + "automation", + "dev", + "migration", + "refactoring" + ], + "support": { + "issues": "https://github.com/rectorphp/rector/issues", + "source": "https://github.com/rectorphp/rector/tree/2.0.8" + }, + "funding": [ + { + "url": "https://github.com/tomasvotruba", + "type": "github" + } + ], + "time": "2025-02-06T14:02:49+00:00" + }, { "name": "sebastian/cli-parser", "version": "1.0.2", @@ -5725,6 +6259,68 @@ ], "time": "2024-01-23T17:12:30+00:00" }, + { + "name": "szepeviktor/phpstan-wordpress", + "version": "v2.0.1", + "source": { + "type": "git", + "url": "https://github.com/szepeviktor/phpstan-wordpress.git", + "reference": "f7beb13cd22998e3d913fdb897a1e2553ccd637e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/szepeviktor/phpstan-wordpress/zipball/f7beb13cd22998e3d913fdb897a1e2553ccd637e", + "reference": "f7beb13cd22998e3d913fdb897a1e2553ccd637e", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "php-stubs/wordpress-stubs": "^6.6.2", + "phpstan/phpstan": "^2.0" + }, + "require-dev": { + "composer/composer": "^2.1.14", + "dealerdirect/phpcodesniffer-composer-installer": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.1", + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^9.0", + "szepeviktor/phpcs-psr-12-neutron-hybrid-ruleset": "^1.0", + "wp-coding-standards/wpcs": "3.1.0 as 2.3.0" + }, + "suggest": { + "swissspidy/phpstan-no-private": "Detect usage of internal core functions, classes and methods" + }, + "type": "phpstan-extension", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "SzepeViktor\\PHPStan\\WordPress\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "WordPress extensions for PHPStan", + "keywords": [ + "PHPStan", + "code analyse", + "code analysis", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/szepeviktor/phpstan-wordpress/issues", + "source": "https://github.com/szepeviktor/phpstan-wordpress/tree/v2.0.1" + }, + "time": "2024-12-01T02:13:05+00:00" + }, { "name": "theseer/tokenizer", "version": "1.2.3", @@ -5953,7 +6549,8 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=7.4.1" + "php": ">=7.4.1", + "ext-json": "*" }, "platform-dev": {}, "platform-overrides": { diff --git a/data/translatable-strings.php b/data/translatable-strings.php index c4061e5..83cff06 100644 --- a/data/translatable-strings.php +++ b/data/translatable-strings.php @@ -9,7 +9,7 @@ // Exit if accessed directly defined('ABSPATH') || exit; -return array( +return [ 'day' => __('day', 'wp-ultimo'), 'days' => __('days', 'wp-ultimo'), 'week' => __('week', 'wp-ultimo'), @@ -18,4 +18,4 @@ return array( 'months' => __('months', 'wp-ultimo'), 'year' => __('year', 'wp-ultimo'), 'years' => __('years', 'wp-ultimo'), -); +]; diff --git a/inc/admin-pages/class-about-admin-page.php b/inc/admin-pages/class-about-admin-page.php index ac0f48d..c6da15f 100644 --- a/inc/admin-pages/class-about-admin-page.php +++ b/inc/admin-pages/class-about-admin-page.php @@ -74,9 +74,9 @@ class About_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'manage_network', - ); + ]; /** * Returns the title of the page. @@ -117,7 +117,7 @@ class About_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function output() { + public function output(): void { wu_get_template('about'); } @@ -128,7 +128,7 @@ class About_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { parent::register_scripts(); @@ -140,7 +140,7 @@ class About_Admin_Page extends Base_Admin_Page { background: url("%s") right bottom no-repeat; background-size: 60%%; }', - wu_get_asset('bg-setup.png', 'img') + wu_get_asset('bg-setup.webp', 'img') ) ); } diff --git a/inc/admin-pages/class-base-admin-page.php b/inc/admin-pages/class-base-admin-page.php index 31f5655..2b7d1e2 100644 --- a/inc/admin-pages/class-base-admin-page.php +++ b/inc/admin-pages/class-base-admin-page.php @@ -57,7 +57,7 @@ abstract class Base_Admin_Page { * @since 1.8.2 * @var array */ - public $action_links = array(); + public $action_links = []; /** * Holds the page title @@ -159,9 +159,9 @@ abstract class Base_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'manage_network', - ); + ]; /** * Creates the page with the necessary hooks. @@ -173,9 +173,9 @@ abstract class Base_Admin_Page { * Adds the page to all the necessary admin panels. */ foreach ($this->supported_panels as $panel => $capability) { - add_action($panel, array($this, 'add_menu_page')); + add_action($panel, [$this, 'add_menu_page']); - add_action($panel, array($this, 'fix_subdomain_name'), 100); + add_action($panel, [$this, 'fix_subdomain_name'], 100); } /* @@ -186,7 +186,7 @@ abstract class Base_Admin_Page { /* * Add forms */ - add_action('plugins_loaded', array($this, 'register_forms')); + add_action('plugins_loaded', [$this, 'register_forms']); /** * Allow plugin developers to run additional things when pages are registered. @@ -236,7 +236,7 @@ abstract class Base_Admin_Page { * @since 1.8.2 * @return void */ - public function fix_subdomain_name() { + public function fix_subdomain_name(): void { global $submenu; @@ -271,7 +271,7 @@ abstract class Base_Admin_Page { * @since 1.8.2 * @return void */ - public function install_hooks() { + public function install_hooks(): void { /** * Get the action links @@ -309,9 +309,9 @@ abstract class Base_Admin_Page { /** * Fixes menu highlights when necessary. */ - add_filter('parent_file', array($this, 'fix_menu_highlight'), 99); + add_filter('parent_file', [$this, 'fix_menu_highlight'], 99); - add_filter('submenu_file', array($this, 'fix_menu_highlight'), 99); + add_filter('submenu_file', [$this, 'fix_menu_highlight'], 99); } /** @@ -335,7 +335,7 @@ abstract class Base_Admin_Page { * @since 1.8.2 * @return void */ - final public function display() { + final public function display(): void { /** * 'Hack-y' solution for the customer facing title problem... but good enough for now. @@ -411,7 +411,7 @@ abstract class Base_Admin_Page { * @since 1.8.2 * @return void */ - public function add_menu_page() { + public function add_menu_page(): void { /** * Create the admin page or sub-page @@ -441,7 +441,7 @@ abstract class Base_Admin_Page { $this->get_menu_label(), $this->get_capability(), $this->id, - array($this, 'display'), + [$this, 'display'], $this->menu_icon, $this->position ); @@ -465,7 +465,7 @@ abstract class Base_Admin_Page { $this->get_menu_label(), $this->get_capability(), $this->id, - array($this, 'display') + [$this, 'display'] ); } @@ -475,14 +475,14 @@ abstract class Base_Admin_Page { * @since 2.0.0 * @return void */ - public function add_branding() { + public function add_branding(): void { if (apply_filters('wp_ultimo_remove_branding', false) === false) { - add_action('in_admin_header', array($this, 'brand_header')); + add_action('in_admin_header', [$this, 'brand_header']); - add_action('wu_header_right', array($this, 'add_container_toggle')); + add_action('wu_header_right', [$this, 'add_container_toggle']); - add_action('in_admin_footer', array($this, 'brand_footer')); + add_action('in_admin_footer', [$this, 'brand_footer']); add_filter('admin_footer_text', '__return_empty_string', 1000); @@ -496,13 +496,13 @@ abstract class Base_Admin_Page { * @since 2.0.0 * @return void */ - public function add_container_toggle() { + public function add_container_toggle(): void { wu_get_template( 'ui/container-toggle', - array( + [ 'page' => $this, - ) + ] ); } @@ -512,13 +512,13 @@ abstract class Base_Admin_Page { * @since 2.0.0 * @return void */ - public function brand_header() { + public function brand_header(): void { wu_get_template( 'ui/branding/header', - array( + [ 'page' => $this, - ) + ] ); } @@ -528,13 +528,13 @@ abstract class Base_Admin_Page { * @since 2.0.0 * @return void */ - public function brand_footer() { + public function brand_footer(): void { wu_get_template( 'ui/branding/footer', - array( + [ 'page' => $this, - ) + ] ); } @@ -544,7 +544,7 @@ abstract class Base_Admin_Page { * @since 2.0.0 * @return void */ - public function add_admin_body_classes() { + public function add_admin_body_classes(): void { add_action( 'admin_body_class', @@ -579,28 +579,28 @@ abstract class Base_Admin_Page { * @since 1.8.2 * @return void */ - final public function enqueue_default_hooks() { + final public function enqueue_default_hooks(): void { if ($this->page_hook) { - add_action("load-$this->page_hook", array($this, 'install_hooks')); + add_action("load-$this->page_hook", [$this, 'install_hooks']); - add_action("load-$this->page_hook", array($this, 'page_loaded')); + add_action("load-$this->page_hook", [$this, 'page_loaded']); - add_action("load-$this->page_hook", array($this, 'hooks')); + add_action("load-$this->page_hook", [$this, 'hooks']); - add_action("load-$this->page_hook", array($this, 'register_scripts'), 10); + add_action("load-$this->page_hook", [$this, 'register_scripts'], 10); - add_action("load-$this->page_hook", array($this, 'screen_options'), 10); + add_action("load-$this->page_hook", [$this, 'screen_options'], 10); - add_action("load-$this->page_hook", array($this, 'register_widgets'), 20); + add_action("load-$this->page_hook", [$this, 'register_widgets'], 20); - add_action("load-$this->page_hook", array($this, 'add_admin_body_classes'), 20); + add_action("load-$this->page_hook", [$this, 'add_admin_body_classes'], 20); /* * Add the page to WP Multisite WaaS branding (aka top-bar and footer) */ if (is_network_admin()) { - add_action("load-$this->page_hook", array($this, 'add_branding')); + add_action("load-$this->page_hook", [$this, 'add_branding']); } /** @@ -622,11 +622,11 @@ abstract class Base_Admin_Page { public function get_title_links() { if (wu_get_documentation_url($this->get_id(), false)) { - $this->action_links[] = array( + $this->action_links[] = [ 'url' => wu_get_documentation_url($this->get_id()), 'label' => __('Documentation'), 'icon' => 'wu-open-book', - ); + ]; } /** @@ -647,7 +647,7 @@ abstract class Base_Admin_Page { */ public function action_links() { - return array(); + return []; } /** diff --git a/inc/admin-pages/class-base-customer-facing-admin-page.php b/inc/admin-pages/class-base-customer-facing-admin-page.php index c3bd7c0..5e135af 100644 --- a/inc/admin-pages/class-base-customer-facing-admin-page.php +++ b/inc/admin-pages/class-base-customer-facing-admin-page.php @@ -46,7 +46,7 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @var array */ - protected $original_parameters = array(); + protected $original_parameters = []; /** * If this customer facing page has menu settings. @@ -62,7 +62,7 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function init() { + public function init(): void { $this->change_parameters(); @@ -70,17 +70,17 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page { $this->editing = wu_request('customize'); - add_action('wu_enqueue_extra_hooks', array($this, 'additional_hooks')); + add_action('wu_enqueue_extra_hooks', [$this, 'additional_hooks']); - add_action('updated_user_meta', array($this, 'save_settings'), 10, 4); + add_action('updated_user_meta', [$this, 'save_settings'], 10, 4); wu_register_form( "edit_admin_page_$this->id", - array( - 'render' => array($this, 'render_edit_page'), - 'handler' => array($this, 'handle_edit_page'), + [ + 'render' => [$this, 'render_edit_page'], + 'handler' => [$this, 'handle_edit_page'], 'capability' => 'exist', - ) + ] ); $this->register_page_settings(); @@ -92,13 +92,13 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function change_parameters() { + public function change_parameters(): void { - $this->original_parameters = array( + $this->original_parameters = [ 'title' => $this->get_title(), 'position' => $this->position, 'menu_icon' => $this->menu_icon, - ); + ]; $new_parameters = $this->get_page_settings(); @@ -114,71 +114,71 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function render_edit_page() { + public function render_edit_page(): void { $settings = $this->get_page_settings(); - $fields = array(); + $fields = []; - $fields['title'] = array( + $fields['title'] = [ 'type' => 'text', 'title' => __('Page & Menu Title', 'wp-ultimo'), 'value' => wu_get_isset($settings, 'title', ''), 'tooltip' => '', - ); + ]; if ($this->menu_settings) { - $fields['position'] = array( + $fields['position'] = [ 'type' => 'number', 'title' => __('Menu', 'wp-ultimo'), 'value' => wu_get_isset($settings, 'position', ''), 'tooltip' => '', - ); + ]; - $fields['menu_icon'] = array( + $fields['menu_icon'] = [ 'type' => 'dashicon', 'title' => __('Menu Icon', 'wp-ultimo'), 'value' => wu_get_isset($settings, 'menu_icon', ''), 'tooltip' => '', - ); + ]; } - $fields['save_line'] = array( + $fields['save_line'] = [ 'type' => 'group', 'classes' => 'wu-justify-between', 'wrapper_classes' => 'wu-bg-gray-100', - 'fields' => array( - 'reset' => array( + 'fields' => [ + 'reset' => [ 'type' => 'submit', 'title' => __('Reset Settings', 'wp-ultimo'), 'value' => 'edit', 'classes' => 'button', 'wrapper_classes' => 'wu-mb-0', - ), - 'submit' => array( + ], + 'submit' => [ 'type' => 'submit', 'title' => __('Save Changes', 'wp-ultimo'), 'value' => 'edit', 'classes' => 'button button-primary', 'wrapper_classes' => 'wu-mb-0', - ), - ), - ); + ], + ], + ]; $fields = apply_filters("wu_customer_facing_page_{$this->id}_fields", $fields); $form = new \WP_Ultimo\UI\Form( 'edit_page', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => "{$this->id}_page_customize", 'data-state' => wu_convert_to_state(), - ), - ) + ], + ] ); echo '
'; @@ -194,16 +194,16 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_edit_page() { + public function handle_edit_page(): void { - $settings_to_save = wu_request('submit') !== 'restore' ? $_POST : array(); // don't worry, this gets cleaned later on. + $settings_to_save = wu_request('submit') !== 'restore' ? $_POST : []; // don't worry, this gets cleaned later on. $this->save_page_settings($settings_to_save); wp_send_json_success( - array( + [ 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']), - ) + ] ); } @@ -239,14 +239,14 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function register_page_settings() { + public function register_page_settings(): void { wu_register_settings_field( 'core', $this->get_page_unique_id() . '_settings', - array( + [ 'raw' => true, - ) + ] ); } @@ -258,7 +258,7 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page { */ public function get_page_settings() { - $atts = wu_get_setting($this->get_page_unique_id() . '_settings', array()); + $atts = wu_get_setting($this->get_page_unique_id() . '_settings', []); return wp_parse_args($atts, $this->get_defaults()); } @@ -284,13 +284,13 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function additional_hooks() { + public function additional_hooks(): void { - add_action("load-$this->page_hook", array($this, 'register_additional_scripts')); + add_action("load-$this->page_hook", [$this, 'register_additional_scripts']); - add_action("load-$this->page_hook", array($this, 'add_additional_body_classes')); + add_action("load-$this->page_hook", [$this, 'add_additional_body_classes']); - add_action("load-$this->page_hook", array($this, 'additional_on_page_load')); + add_action("load-$this->page_hook", [$this, 'additional_on_page_load']); } /** @@ -299,13 +299,13 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function additional_on_page_load() { + public function additional_on_page_load(): void { - add_filter('wu_element_display_super_admin_notice', array($this, 'is_edit_mode')); + add_filter('wu_element_display_super_admin_notice', [$this, 'is_edit_mode']); - add_action("get_user_option_meta-box-order_{$this->page_hook}", array($this, 'get_settings'), 10, 3); + add_action("get_user_option_meta-box-order_{$this->page_hook}", [$this, 'get_settings'], 10, 3); - add_action("get_user_option_screen_layout_{$this->page_hook}", array($this, 'get_settings'), 10, 3); + add_action("get_user_option_screen_layout_{$this->page_hook}", [$this, 'get_settings'], 10, 3); /** * 'Hack-y' solution for the customer facing title problem... but good enough for now. @@ -330,7 +330,7 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function add_additional_body_classes() { + public function add_additional_body_classes(): void { add_action( 'admin_body_class', @@ -349,7 +349,7 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function register_additional_scripts() { + public function register_additional_scripts(): void { \WP_Ultimo\Scripts::get_instance()->register_style('wu-admin-screen', wu_get_asset('admin-screen.css', 'css')); @@ -360,21 +360,21 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page { } if (current_user_can($this->edit_capability)) { - \WP_Ultimo\Scripts::get_instance()->register_script('wu-admin-screen', wu_get_asset('admin-screen.js', 'js'), array('jquery', 'wu-fonticonpicker')); + \WP_Ultimo\Scripts::get_instance()->register_script('wu-admin-screen', wu_get_asset('admin-screen.js', 'js'), ['jquery', 'wu-fonticonpicker']); wp_localize_script( 'wu-admin-screen', 'wu_admin_screen', - array( + [ 'page_customize_link' => wu_get_form_url("edit_admin_page_$this->id"), 'customize_link' => add_query_arg('customize', 1), 'close_link' => remove_query_arg('customize'), - 'i18n' => array( + 'i18n' => [ 'page_customize_label' => __('Customize Page', 'wp-ultimo'), 'customize_label' => __('Customize Elements', 'wp-ultimo'), 'close_label' => __('Exit Customize Mode', 'wp-ultimo'), - ), - ) + ], + ] ); wp_enqueue_script('wu-admin-screen'); @@ -411,13 +411,13 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page { * @param mixed $_meta_value The original saved value. * @return void */ - public function save_settings($meta_id, $user_id, $meta_key, $_meta_value) { + public function save_settings($meta_id, $user_id, $meta_key, $_meta_value): void { if (wu_request('action') !== 'meta-box-order') { return; } - $is_this_page = strpos((string) wu_request('page'), $this->id) !== false; + $is_this_page = str_contains((string) wu_request('page'), $this->id); if ( ! $is_this_page) { return; @@ -460,7 +460,7 @@ abstract class Base_Customer_Facing_Admin_Page extends Base_Admin_Page { $this->title . ' ' . $this->get_badge(), $this->get_capability(), $this->id, - array($this, 'display'), + [$this, 'display'], $this->menu_icon, $this->position ); diff --git a/inc/admin-pages/class-broadcast-edit-admin-page.php b/inc/admin-pages/class-broadcast-edit-admin-page.php index 9343509..0ae617d 100644 --- a/inc/admin-pages/class-broadcast-edit-admin-page.php +++ b/inc/admin-pages/class-broadcast-edit-admin-page.php @@ -76,9 +76,9 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_edit_broadcasts', - ); + ]; /** * Allow child classes to register widgets, if they need them. @@ -86,72 +86,72 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { parent::register_widgets(); $this->add_list_table_widget( 'events', - array( + [ 'title' => __('Events', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(), - 'query_filter' => array($this, 'events_query_filter'), - ) + 'query_filter' => [$this, 'events_query_filter'], + ] ); $this->add_save_widget( 'save', - array( - 'html_attr' => array( + [ + 'html_attr' => [ 'data-wu-app' => 'save_broadcast', 'data-state' => wu_convert_to_state( - array( + [ 'type' => $this->get_object()->get_type(), - ) + ] ), - ), - 'fields' => array( - 'type' => array( + ], + 'fields' => [ + 'type' => [ 'type' => 'select', 'title' => __('Broadcast Type', 'wp-ultimo'), 'placeholder' => __('Type', 'wp-ultimo'), 'desc' => __('Broadcast type cannot be edited.', 'wp-ultimo'), - 'options' => array( + 'options' => [ 'broadcast_email' => __('Email', 'wp-ultimo'), 'broadcast_notice' => __('Admin Notice', 'wp-ultimo'), - ), + ], 'value' => $this->get_object()->get_type(), 'tooltip' => '', - 'html_attr' => array( + 'html_attr' => [ 'disabled' => 'disabled', 'name' => '', - ), - ), - 'notice_type' => array( + ], + ], + 'notice_type' => [ 'type' => 'select', 'title' => __('Broadcast Status', 'wp-ultimo'), 'placeholder' => __('Status', 'wp-ultimo'), 'desc' => __('This option determines the color of the admin notice.', 'wp-ultimo'), - 'options' => array( + 'options' => [ 'info' => __('Info (blue)', 'wp-ultimo'), 'success' => __('Success (green)', 'wp-ultimo'), 'warning' => __('Warning (yellow)', 'wp-ultimo'), 'error' => __('Error (red)', 'wp-ultimo'), - ), + ], 'value' => $this->get_object()->get_notice_type(), 'tooltip' => '', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'type === "broadcast_notice"', 'v-cloak' => 1, - ), - ), - ), - ) + ], + ], + ], + ] ); - add_meta_box('wp-ultimo-broadcast-customer-targets', __('Customer Targets', 'wp-ultimo'), array($this, 'output_default_widget_customer_targets'), get_current_screen()->id, 'side'); + add_meta_box('wp-ultimo-broadcast-customer-targets', __('Customer Targets', 'wp-ultimo'), [$this, 'output_default_widget_customer_targets'], get_current_screen()->id, 'side'); - add_meta_box('wp-ultimo-broadcast-product-targets', __('Product Targets', 'wp-ultimo'), array($this, 'output_default_widget_product_targets'), get_current_screen()->id, 'side'); + add_meta_box('wp-ultimo-broadcast-product-targets', __('Product Targets', 'wp-ultimo'), [$this, 'output_default_widget_product_targets'], get_current_screen()->id, 'side'); } /** @@ -160,13 +160,13 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function output_default_widget_customer_targets() { + public function output_default_widget_customer_targets(): void { $object = $this->get_object(); $all_targets = $object->get_message_targets(); - $targets = array(); + $targets = []; $customer_targets = wu_get_isset($all_targets, 'customers', ''); @@ -198,9 +198,9 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page { case $targets_count === 1: $customer = wu_get_customer($targets[0]); - $url_atts = array( + $url_atts = [ 'id' => $customer->get_id(), - ); + ]; $customer_link = wu_network_admin_url('wp-ultimo-edit-customer', $url_atts); @@ -209,10 +209,10 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page { 32, 'identicon', '', - array( + [ 'force_display' => true, 'class' => 'wu-rounded-full wu-border-solid wu-border-1 wu-border-white hover:wu-border-gray-400', - ) + ] ); $display_name = $customer->get_display_name(); @@ -242,14 +242,14 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page { 32, 'identicon', '', - array( + [ 'class' => 'wu-rounded-full wu-border-solid wu-border-1 wu-border-white hover:wu-border-gray-400', - ) + ] ); - $url_atts = array( + $url_atts = [ 'id' => $customer->get_id(), - ); + ]; $customer_link = wu_network_admin_url('wp-ultimo-edit-customer', $url_atts); @@ -257,13 +257,13 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page { } if ($targets_count < 7) { - $modal_atts = array( + $modal_atts = [ 'action' => 'wu_modal_targets_display', 'object_id' => $object->get_id(), 'width' => '400', 'height' => '360', 'target_type' => 'customers', - ); + ]; $html .= sprintf( '
@@ -277,13 +277,13 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page { } else { $count = $targets_count - 6; - $modal_atts = array( + $modal_atts = [ 'action' => 'wu_modal_targets_display', 'object_id' => $object->get_id(), 'width' => '400', 'height' => '360', 'target_type' => 'customers', - ); + ]; $html .= sprintf( '
@@ -310,25 +310,25 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function output_default_widget_product_targets() { + public function output_default_widget_product_targets(): void { $object = $this->get_object(); $targets = wu_get_broadcast_targets($object->get_id(), 'products'); - $product_targets = array(); + $product_targets = []; if ($targets) { foreach ($targets as $key => $value) { $product = wu_get_product($value); if ($product) { - $modal_atts = array( + $modal_atts = [ 'action' => 'wu_modal_product_targets_display', 'product_id' => $product->get_id(), 'width' => '400', 'height' => '360', - ); + ]; $link = wu_get_form_url('view_broadcast_targets', $modal_atts); @@ -347,23 +347,23 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page { // translators: %s is the number of customers. $description = sprintf(__('%s customer(s) targeted.', 'wp-ultimo'), $customer_count); - $product_targets[ $key ] = array( + $product_targets[ $key ] = [ 'link' => $link, 'avatar' => $image, 'display_name' => $product->get_name(), 'id' => $product->get_id(), 'description' => $description, - ); + ]; } } } - $args = array( + $args = [ 'targets' => $product_targets, 'loading_text' => __('Loading...', 'wp-ultimo'), 'wrapper_class' => 'wu-bg-gray-100 wu--mt-3 wu--mb-6 wu--mx-3', 'modal_class' => 'wubox', - ); + ]; wu_get_template('broadcast/widget-targets', $args); } @@ -398,7 +398,7 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page { */ public function action_links() { - return array(); + return []; } /** @@ -409,7 +409,7 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page { */ public function get_labels() { - return array( + return [ 'edit_label' => __('Edit Broadcast', 'wp-ultimo'), 'add_new_label' => __('Add new Broadcast', 'wp-ultimo'), 'updated_message' => __('Broadcast updated with success!', 'wp-ultimo'), @@ -419,7 +419,7 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page { 'save_description' => '', 'delete_button_label' => __('Delete Broadcast', 'wp-ultimo'), 'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'), - ); + ]; } /** @@ -432,10 +432,10 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page { */ public function query_filter($args) { - $extra_args = array( + $extra_args = [ 'object_type' => 'broadcast', 'object_id' => absint($this->get_object()->get_id()), - ); + ]; return array_merge($args, $extra_args); } @@ -495,10 +495,10 @@ class Broadcast_Edit_Admin_Page extends Edit_Admin_Page { */ public function events_query_filter($args) { - $extra_args = array( + $extra_args = [ 'object_type' => 'broadcast', 'object_id' => absint($this->get_object()->get_id()), - ); + ]; return array_merge($args, $extra_args); } diff --git a/inc/admin-pages/class-broadcast-list-admin-page.php b/inc/admin-pages/class-broadcast-list-admin-page.php index 54293a6..0aab802 100644 --- a/inc/admin-pages/class-broadcast-list-admin-page.php +++ b/inc/admin-pages/class-broadcast-list-admin-page.php @@ -52,9 +52,9 @@ class Broadcast_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_read_broadcasts', - ); + ]; /** * Register ajax forms that we use for send broadcasts. @@ -62,28 +62,28 @@ class Broadcast_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function register_forms() { + public function register_forms(): void { /* * Add new broadcast notice. */ wu_register_form( 'add_new_broadcast_message', - array( - 'render' => array($this, 'render_add_new_broadcast_modal'), - 'handler' => array($this, 'handle_add_new_broadcast_modal'), + [ + 'render' => [$this, 'render_add_new_broadcast_modal'], + 'handler' => [$this, 'handle_add_new_broadcast_modal'], 'capability' => 'wu_add_broadcasts', - ) + ] ); /** * Ajax to render the broadcast targets modal. */ - add_action('wu_ajax_wu_modal_targets_display', array($this, 'display_targets_modal')); + add_action('wu_ajax_wu_modal_targets_display', [$this, 'display_targets_modal']); /** * Ajax to render the targets modal with customers from a specific membership. */ - add_action('wu_ajax_wu_modal_product_targets_display', array($this, 'display_product_targets_modal')); + add_action('wu_ajax_wu_modal_product_targets_display', [$this, 'display_product_targets_modal']); } /** @@ -92,7 +92,7 @@ class Broadcast_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { parent::register_scripts(); @@ -105,7 +105,7 @@ class Broadcast_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function display_targets_modal() { + public function display_targets_modal(): void { $broadcast_id = wu_request('object_id'); @@ -115,16 +115,16 @@ class Broadcast_List_Admin_Page extends List_Admin_Page { $targets = wu_get_broadcast_targets($object->get_id(), $target_type); - $display_targets = array(); + $display_targets = []; if ($targets) { if ($target_type === 'customers') { foreach ($targets as $key => $value) { $customer = wu_get_customer($value); - $url_atts = array( + $url_atts = [ 'id' => $customer->get_id(), - ); + ]; $link = wu_network_admin_url('wp-ultimo-edit-customer', $url_atts); @@ -133,19 +133,19 @@ class Broadcast_List_Admin_Page extends List_Admin_Page { 48, 'identicon', '', - array( + [ 'force_display' => true, 'class' => 'wu-rounded-full', - ) + ] ); - $display_targets[ $key ] = array( + $display_targets[ $key ] = [ 'link' => $link, 'avatar' => $avatar, 'display_name' => $customer->get_display_name(), 'id' => $customer->get_id(), 'description' => $customer->get_email_address(), - ); + ]; } } @@ -153,9 +153,9 @@ class Broadcast_List_Admin_Page extends List_Admin_Page { foreach ($targets as $key => $value) { $product = wu_get_product($value); - $url_atts = array( + $url_atts = [ 'id' => $product->get_id(), - ); + ]; $link = wu_network_admin_url('wp-ultimo-edit-product', $url_atts); @@ -178,22 +178,22 @@ class Broadcast_List_Admin_Page extends List_Admin_Page { // translators: %s is the number of customers. $description = sprintf(__('%s customer(s) targeted.', 'wp-ultimo'), $customer_count); - $display_targets[ $key ] = array( + $display_targets[ $key ] = [ 'link' => $link, 'avatar' => $avatar, 'display_name' => $product->get_name(), 'id' => $product->get_id(), 'description' => $description, - ); + ]; } } } - $args = array( + $args = [ 'targets' => $display_targets, 'wrapper_class' => 'wu-bg-gray-100 wu--mt-3 wu--mb-6 wu-max-h-2', 'modal_class' => '', - ); + ]; wu_get_template('broadcast/widget-targets', $args); @@ -206,21 +206,21 @@ class Broadcast_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function display_product_targets_modal() { + public function display_product_targets_modal(): void { $product_id = wu_request('product_id'); $customers = wu_get_membership_customers($product_id); - $display_targets = array(); + $display_targets = []; if ($customers) { foreach ($customers as $key => $value) { $customer = wu_get_customer($value); - $url_atts = array( + $url_atts = [ 'id' => $customer->get_id(), - ); + ]; $link = wu_network_admin_url('wp-ultimo-edit-customer', $url_atts); @@ -229,27 +229,27 @@ class Broadcast_List_Admin_Page extends List_Admin_Page { 48, 'identicon', '', - array( + [ 'force_display' => true, 'class' => 'wu-rounded-full', - ) + ] ); - $display_targets[ $key ] = array( + $display_targets[ $key ] = [ 'link' => $link, 'avatar' => $avatar, 'display_name' => $customer->get_display_name(), 'id' => $customer->get_id(), 'description' => $customer->get_email_address(), - ); + ]; } } - $args = array( + $args = [ 'targets' => $display_targets, 'wrapper_class' => 'wu-bg-gray-100 wu--mt-3 wu--mb-6 wu-max-h-2', 'modal_class' => '', - ); + ]; wu_get_template('broadcast/widget-targets', $args); @@ -262,10 +262,10 @@ class Broadcast_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function render_add_new_broadcast_modal() { + public function render_add_new_broadcast_modal(): void { - $fields = array( - 'type' => array( + $fields = [ + 'type' => [ 'type' => 'select-icon', 'title' => __('Broadcast Type', 'wp-ultimo'), 'desc' => __('Select the type of message you want to send.', 'wp-ultimo'), @@ -273,171 +273,171 @@ class Broadcast_List_Admin_Page extends List_Admin_Page { 'tooltip' => '', 'value' => '', 'classes' => 'wu-w-1/2', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'type', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'step === 1', - ), - 'options' => array( - 'broadcast_notice' => array( + ], + 'options' => [ + 'broadcast_notice' => [ 'title' => __('Message', 'wp-ultimo'), 'tooltip' => __('Display a message on your customers\' dashboard.', 'wp-ultimo'), 'icon' => 'dashicons-before dashicons-excerpt-view', - ), - 'broadcast_email' => array( + ], + 'broadcast_email' => [ 'title' => __('Email', 'wp-ultimo'), 'tooltip' => __('Send an email to your customers.', 'wp-ultimo'), 'icon' => 'dashicons-before dashicons-email', - ), - ), - ), - 'step_note' => array( + ], + ], + ], + 'step_note' => [ 'type' => 'note', 'desc' => sprintf('%s', __('← Back to Type Selection', 'wp-ultimo')), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'step === 2', - ), - ), - 'target_customers' => array( + ], + ], + 'target_customers' => [ 'type' => 'model', 'title' => __('Target Customers', 'wp-ultimo'), 'desc' => __('This broadcast will be sent to the user or users that are selected here. You can select more than one.', 'wp-ultimo'), 'placeholder' => __('Search a customer...', 'wp-ultimo'), 'min' => 1, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'target_customers', 'data-model' => 'customer', 'data-value-field' => 'id', 'data-label-field' => 'display_name', 'data-search-field' => 'display_name', 'data-max-items' => 10000, - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'step === 2', - ), - ), - 'target_products' => array( + ], + ], + 'target_products' => [ 'type' => 'model', 'title' => __('Target Product', 'wp-ultimo'), 'desc' => __('This broadcast will be sent to the users that have this product. You can select more than one.', 'wp-ultimo'), 'placeholder' => __('Search for a product..', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'target_products', 'data-model' => 'product', 'data-value-field' => 'id', 'data-label-field' => 'name', 'data-search-field' => 'name', 'data-max-items' => 99, - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'step === 2', - ), - ), - 'notice_type' => array( + ], + ], + 'notice_type' => [ 'title' => __('Message Type', 'wp-ultimo'), 'desc' => __('The color of the notice is based on the type.', 'wp-ultimo'), 'type' => 'select', 'default' => 'success', - 'options' => array( + 'options' => [ 'success' => __('Success (green)', 'wp-ultimo'), 'info' => __('Info (blue)', 'wp-ultimo'), 'warning' => __('Warning (orange)', 'wp-ultimo'), 'error' => __('Error (red)', 'wp-ultimo'), - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => "step === 2 && require('type', 'broadcast_notice')", 'v-cloak' => 1, - ), - ), - 'step_note_2' => array( + ], + ], + 'step_note_2' => [ 'type' => 'note', 'desc' => sprintf('%s', __('← Back to Target Selection', 'wp-ultimo')), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'step === 3', - ), - ), - 'subject' => array( + ], + ], + 'subject' => [ 'type' => 'text', 'title' => __('Message Subject', 'wp-ultimo'), 'desc' => __('The title will appear above the main content in the notice or used as subject of the email.', 'wp-ultimo'), 'placeholder' => __('Enter a title for your broadcast.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'subject', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'step === 3', - ), - ), - 'content' => array( + ], + ], + 'content' => [ 'id' => 'content', 'title' => __('Content', 'wp-ultimo'), 'desc' => __('The main content of your broadcast.', 'wp-ultimo'), 'type' => 'wp-editor', - 'settings' => array( - 'tinymce' => array('toolbar1' => 'bold,italic,strikethrough,link,unlink,undo,redo,pastetext'), - ), - 'html_attr' => array( + 'settings' => [ + 'tinymce' => ['toolbar1' => 'bold,italic,strikethrough,link,unlink,undo,redo,pastetext'], + ], + 'html_attr' => [ 'v-model' => 'content', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'step === 3', - ), - ), - 'submit_button' => array( + ], + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Next Step →', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'step === 1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-bind:disabled' => 'type === ""', 'v-on:click.prevent' => 'step = 2', - ), - ), - 'submit_button_2' => array( + ], + ], + 'submit_button_2' => [ 'type' => 'submit', 'title' => __('Next Step →', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'step === 2', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-bind:disabled' => 'target_customers === "" && target_products === ""', // phpcs:ignore 'v-on:click.prevent' => 'step = 3', - ), - ), - 'submit_button_3' => array( + ], + ], + 'submit_button_3' => [ 'type' => 'submit', 'title' => __('Send →', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:disabled' => 'subject === ""', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'step === 3', - ), - ), - ); + ], + ], + ]; $form = new \WP_Ultimo\UI\Form( 'add_new_broadcast', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'add_new_broadcast', 'data-state' => wu_convert_to_state( - array( + [ 'type' => 'broadcast_notice', 'content' => '', 'step' => 1, @@ -445,10 +445,10 @@ class Broadcast_List_Admin_Page extends List_Admin_Page { 'target_customers' => '', 'target_products' => '', 'subject' => '', - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -460,7 +460,7 @@ class Broadcast_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_add_new_broadcast_modal() { + public function handle_add_new_broadcast_modal(): void { $broadcast = Broadcast_Manager::get_instance(); @@ -483,10 +483,10 @@ class Broadcast_List_Admin_Page extends List_Admin_Page { */ public function get_labels() { - return array( + return [ 'deleted_message' => __('Broadcast removed successfully.', 'wp-ultimo'), 'search_label' => __('Search Broadcast', 'wp-ultimo'), - ); + ]; } /** @@ -530,19 +530,19 @@ class Broadcast_List_Admin_Page extends List_Admin_Page { */ public function action_links() { - return array( - array( + return [ + [ 'label' => __('Add Broadcast', 'wp-ultimo'), 'icon' => 'wu-circle-with-plus', 'classes' => 'wubox', 'url' => wu_get_form_url('add_new_broadcast_message'), - ), - array( + ], + [ 'url' => wu_network_admin_url('wp-ultimo-emails'), 'label' => __('System Emails'), 'icon' => 'wu-mail', - ), - ); + ], + ]; } /** diff --git a/inc/admin-pages/class-checkout-form-edit-admin-page.php b/inc/admin-pages/class-checkout-form-edit-admin-page.php index 0415859..ef7b823 100644 --- a/inc/admin-pages/class-checkout-form-edit-admin-page.php +++ b/inc/admin-pages/class-checkout-form-edit-admin-page.php @@ -77,9 +77,9 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_edit_checkout_forms', - ); + ]; /** * Overrides the init method to add additional hooks. @@ -87,15 +87,15 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { parent::init(); - add_action('init', array($this, 'generate_checkout_form_preview'), 9); + add_action('init', [$this, 'generate_checkout_form_preview'], 9); - add_action('wp_ajax_wu_save_editor_session', array($this, 'save_editor_session')); + add_action('wp_ajax_wu_save_editor_session', [$this, 'save_editor_session']); - add_action('load-admin_page_wp-ultimo-edit-checkout-form', array($this, 'add_width_control_script')); + add_action('load-admin_page_wp-ultimo-edit-checkout-form', [$this, 'add_width_control_script']); } /** @@ -105,9 +105,9 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { * * @return void */ - public function add_width_control_script() { + public function add_width_control_script(): void { - wp_enqueue_script('wu-checkout-form-edit-modal', wu_get_asset('checkout-form-editor-modal.js', 'js'), array(), wu_get_version()); + wp_enqueue_script('wu-checkout-form-edit-modal', wu_get_asset('checkout-form-editor-modal.js', 'js'), [], wu_get_version()); } /** @@ -118,21 +118,21 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { */ public function action_links() { - $actions = array(); + $actions = []; if ($this->get_object()->exists()) { - $url_atts = array( + $url_atts = [ 'id' => $this->get_object()->get_id(), 'slug' => $this->get_object()->get_slug(), 'model' => 'checkout_form', - ); + ]; - $actions[] = array( + $actions[] = [ 'label' => __('Generate Shortcode'), 'icon' => 'wu-copy', 'classes' => 'wubox', 'url' => wu_get_form_url('shortcode_checkout', $url_atts), - ); + ]; } return $actions; @@ -144,7 +144,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function generate_checkout_form_preview() { + public function generate_checkout_form_preview(): void { if (wu_request('action') === 'wu_generate_checkout_form_preview') { @@ -153,7 +153,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { add_filter('wu_is_jumper_enabled', '__return_false'); add_filter('wu_is_toolbox_enabled', '__return_false'); - add_action('wp', array($this, 'content_checkout_form_by_settings')); + add_action('wp', [$this, 'content_checkout_form_by_settings']); } } @@ -163,7 +163,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function content_checkout_form_by_settings() { + public function content_checkout_form_by_settings(): void { $checkout_form = wu_get_checkout_form(wu_request('form_id')); @@ -177,7 +177,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { $session = \WP_Session_Tokens::get_instance(get_current_user_id()); - $settings_session = wu_get_isset($session->get($key), 'wu_checkout_form_editor', array()); + $settings_session = wu_get_isset($session->get($key), 'wu_checkout_form_editor', []); if ( ! empty($settings_session)) { $checkout_form->set_settings($settings_session); @@ -200,7 +200,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { $content .= wu_get_template_contents( 'checkout/form', - array( + [ 'step' => $step, 'step_name' => $step['id'], 'final_fields' => $final_fields, @@ -208,7 +208,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { 'password_strength' => false, 'apply_styles' => true, 'display_title' => true, - ) + ] ); if ($index < $count - 1) { @@ -241,9 +241,9 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function save_editor_session() { + public function save_editor_session(): void { - $settings = wu_request('settings', array()); + $settings = wu_request('settings', []); $form = wu_get_checkout_form(wu_request('form_id')); @@ -270,7 +270,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function page_loaded() { + public function page_loaded(): void { parent::page_loaded(); @@ -290,9 +290,9 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { $screen = get_current_screen(); - add_action("wu_edit_{$screen->id}_after_normal", array($this, 'render_steps')); + add_action("wu_edit_{$screen->id}_after_normal", [$this, 'render_steps']); - add_action('admin_footer', array($this, 'render_js_templates')); + add_action('admin_footer', [$this, 'render_js_templates']); } // Forms @@ -303,17 +303,17 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function register_forms() { + public function register_forms(): void { /* * Add new Section */ wu_register_form( 'add_new_form_step', - array( - 'render' => array($this, 'render_add_new_form_step_modal'), - 'handler' => array($this, 'handle_add_new_form_step_modal'), + [ + 'render' => [$this, 'render_add_new_form_step_modal'], + 'handler' => [$this, 'handle_add_new_form_step_modal'], 'capability' => 'wu_edit_checkout_forms', - ) + ] ); /* @@ -321,11 +321,11 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { */ wu_register_form( 'add_new_form_field', - array( - 'render' => array($this, 'render_add_new_form_field_modal'), - 'handler' => array($this, 'handle_add_new_form_field_modal'), + [ + 'render' => [$this, 'render_add_new_form_field_modal'], + 'handler' => [$this, 'handle_add_new_form_field_modal'], 'capability' => 'wu_edit_checkout_forms', - ) + ] ); } @@ -365,32 +365,32 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { * @param array $attributes The field attributes. * @return array */ - public function get_create_field_fields($attributes = array()) { + public function get_create_field_fields($attributes = []) { $field_types = $this->field_types(); - $fields = array( + $fields = [ // Tab - 'tab' => array( + 'tab' => [ 'type' => 'tab-select', 'value' => 'field', 'order' => 0, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'tab', - ), - 'options' => array( + ], + 'options' => [ 'content' => __('Field', 'wp-ultimo'), 'advanced' => __('Additional Settings', 'wp-ultimo'), 'style' => __('Style', 'wp-ultimo'), - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'type', - ), - ), + ], + ], // Content Tab - 'type' => array( + 'type' => [ 'type' => 'select-icon', 'title' => __('Field Type', 'wp-ultimo'), 'desc' => __('Select the type of field you want to add to the checkout form.', 'wp-ultimo'), @@ -399,79 +399,79 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { 'value' => '', 'classes' => 'wu-w-1/4', 'options' => $field_types, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'type', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'type == ""', 'v-cloak' => 1, - ), - ), - 'type_note' => array( + ], + ], + 'type_note' => [ 'type' => 'note', 'order' => 0, 'desc' => sprintf('%s', __('← Back to Field Type Selection', 'wp-ultimo')), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'type && (!saved && !name)', 'v-cloak' => '1', - ), - ), - 'step' => array( + ], + ], + 'step' => [ 'type' => 'hidden', 'value' => wu_request('step'), - ), - 'checkout_form' => array( + ], + 'checkout_form' => [ 'type' => 'hidden', 'value' => wu_request('checkout_form'), - ), + ], // Advanced Tab - 'from_request' => array( + 'from_request' => [ 'type' => 'toggle', 'title' => __('Pre-fill from Request', 'wp-ultimo'), 'tooltip' => __('The key is the field slug. If your field has the slug "my-color" for example, adding ?my-color=blue will pre-fill this field with the value "blue".', 'wp-ultimo'), 'desc' => __('Enable this to allow this field to be pre-filled based on the request parameters.', 'wp-ultimo'), 'value' => 1, 'order' => 100, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'from_request', 'v-initempty:from_request' => 'true', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'type && require("tab", "advanced")', 'v-cloak' => 1, - ), - ), + ], + ], - 'logged' => array( + 'logged' => [ 'type' => 'select', 'value' => 'always', 'title' => __('Field Visibility', 'wp-ultimo'), 'desc' => __('Select the visibility of this field.', 'wp-ultimo'), - 'options' => array( + 'options' => [ 'always' => __('Always show', 'wp-ultimo'), 'logged_only' => __('Only show for logged in users', 'wp-ultimo'), 'guests_only' => __('Only show for guests', 'wp-ultimo'), - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'logged', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'type && require("tab", "advanced")', 'v-cloak' => 1, - ), - ), + ], + ], - 'original_id' => array( + 'original_id' => [ 'type' => 'hidden', 'value' => wu_request('id', ''), - 'html_attr' => array( + 'html_attr' => [ 'v-bind:value' => 'original_id', - ), - ), + ], + ], // Style Tab - 'width' => array( + 'width' => [ 'type' => 'number', 'title' => __('Wrapper Width', 'wp-ultimo'), 'placeholder' => __('100', 'wp-ultimo'), @@ -480,47 +480,47 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { 'max' => 100, 'value' => 100, 'order' => 52, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'width', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'type && require("tab", "style")', 'v-cloak' => 1, - ), - ), - 'wrapper_element_classes' => array( + ], + ], + 'wrapper_element_classes' => [ 'type' => 'text', 'title' => __('Wrapper CSS Classes', 'wp-ultimo'), 'placeholder' => __('e.g. custom-field example-class', 'wp-ultimo'), 'desc' => __('You can enter multiple CSS classes separated by spaces. These will be applied to the field wrapper element.', 'wp-ultimo'), 'value' => '', 'order' => 54, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'wrapper_element_classes', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'type && require("tab", "style")', 'v-cloak' => 1, - ), - ), - 'element_classes' => array( + ], + ], + 'element_classes' => [ 'type' => 'text', 'title' => __('Field CSS Classes', 'wp-ultimo'), 'placeholder' => __('e.g. custom-field example-class', 'wp-ultimo'), 'desc' => __('You can enter multiple CSS classes separated by spaces. These will be applied to the field element itself, when possible.', 'wp-ultimo'), 'value' => '', 'order' => 56, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'element_classes', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'type && require("tab", "style")', 'v-cloak' => 1, - ), - ), - ); + ], + ], + ]; - $additional_fields = array(); + $additional_fields = []; foreach ($field_types as $field_type) { $_fields = call_user_func($field_type['fields'], $attributes); @@ -542,11 +542,11 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { $tab = wu_get_isset($default_field, 'tab', 'content'); $default_field['wrapper_html_attr'] = array_merge( - wu_get_isset($default_field, 'wrapper_html_attr', array()), - array( + wu_get_isset($default_field, 'wrapper_html_attr', []), + [ 'v-if' => sprintf('type && require("type", %s) && require("tab", "%s")', json_encode($reqs), $tab), 'v-cloak' => '1', - ) + ] ); if ($default_field_slug === 'name' || $default_field_slug === 'id' || $default_field_slug === 'default_value') { @@ -564,20 +564,20 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { $fields, $default_fields, $additional_fields, - array( - 'submit_button' => array( + [ + 'submit_button' => [ 'type' => 'submit', 'title' => empty($attributes) ? __('Add Field', 'wp-ultimo') : __('Save Field', 'wp-ultimo'), 'value' => 'save', 'order' => 100, 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'type', 'v-cloak' => '1', - ), - ), - ) + ], + ], + ] ); return $fields; @@ -598,9 +598,9 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { $field = $checkout_form->get_field($step_name, $field_name); if ( ! $field) { - $field = array( + $field = [ 'saved' => false, - ); + ]; } else { $field['saved'] = true; } @@ -609,7 +609,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { $session = \WP_Session_Tokens::get_instance(get_current_user_id()); - $settings = wu_get_isset($session->get($key), 'wu_checkout_form_editor', array()); + $settings = wu_get_isset($session->get($key), 'wu_checkout_form_editor', []); if ( ! empty($settings)) { $checkout_form->set_settings($settings); @@ -638,9 +638,9 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { $step = $checkout_form->get_step($step_name); if ( ! $step) { - $step = array( + $step = [ 'saved' => false, - ); + ]; } else { $step['saved'] = true; } @@ -666,7 +666,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function render_add_new_form_field_modal() { + public function render_add_new_form_field_modal(): void { $checkout_form = wu_get_checkout_form_by_slug(wu_request('checkout_form')); @@ -717,17 +717,17 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { } if ( ! wu_get_isset($state, 'period_options', false)) { - $state['period_options'] = array( - array( + $state['period_options'] = [ + [ 'duration' => 1, 'duration_unit' => 'month', 'label' => __('Monthly'), - ), - ); + ], + ]; } if ( ! wu_get_isset($state, 'options', false)) { - $state['options'] = array(); + $state['options'] = []; } if ( ! wu_get_isset($state, 'save_as', false)) { @@ -749,15 +749,15 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { $form = new \WP_Ultimo\UI\Form( 'add_edit_fields_modal', $edit_fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'add_checkout_form_field', 'data-state' => wu_convert_to_state($state), - ), - ) + ], + ] ); $form->render(); @@ -769,7 +769,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_add_new_form_field_modal() { + public function handle_add_new_form_field_modal(): void { $checkout_form = wu_get_checkout_form_by_slug(wu_request('checkout_form')); @@ -782,14 +782,14 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { ); } - $data = array( + $data = [ 'id' => wu_request('id', ''), 'original_id' => wu_request('original_id', ''), 'step' => wu_request('step'), 'name' => wu_request('label', ''), 'type' => wu_request('type', 'text'), 'from_request' => wu_request('from_request', false), - ); + ]; $type = wu_request('type', 'text'); @@ -816,13 +816,13 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { $data['id'] = apply_filters("wu_checkout_form_field_{$type}_id", $data['id'], $data, $checkout_form, $type); wp_send_json_success( - array( - 'send' => array( + [ + 'send' => [ 'scope' => 'wu_checkout_forms_editor_app', 'function_name' => 'add_field', 'data' => $data, - ), - ) + ], + ] ); } @@ -832,7 +832,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function render_add_new_form_step_modal() { + public function render_add_new_form_step_modal(): void { $checkout_form = wu_get_checkout_form_by_slug(wu_request('checkout_form')); @@ -846,147 +846,147 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { $_step = $this->get_step($checkout_form, $step_name); - $fields = array( - 'tab' => array( + $fields = [ + 'tab' => [ 'type' => 'tab-select', 'value' => 'content', 'order' => 0, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'tab', - ), - 'options' => array( + ], + 'options' => [ 'content' => __('Content', 'wp-ultimo'), 'visibility' => __('Visibility', 'wp-ultimo'), 'style' => __('Style', 'wp-ultimo'), - ), - ), + ], + ], // Content Tab - 'id' => array( + 'id' => [ 'type' => 'text', 'title' => __('Step ID', 'wp-ultimo'), 'placeholder' => __('e.g. step-name', 'wp-ultimo'), 'desc' => __('This will be used on the URL. Only alpha-numeric and hyphens allowed.', 'wp-ultimo'), 'value' => '', - 'html_attr' => array( + 'html_attr' => [ 'v-on:input' => 'id = $event.target.value.toLowerCase().replace(/[^a-z0-9-_]+/g, "")', 'v-bind:value' => 'id', 'required' => 'require("tab", "content")', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "content")', 'v-cloak' => 1, - ), - ), - 'original_id' => array( + ], + ], + 'original_id' => [ 'type' => 'hidden', 'value' => wu_request('id', ''), - 'html_attr' => array( + 'html_attr' => [ 'v-bind:value' => 'original_id', - ), - ), - 'name' => array( + ], + ], + 'name' => [ 'type' => 'text', 'title' => __('Step Title', 'wp-ultimo'), 'placeholder' => __('e.g. My Extra Step', 'wp-ultimo'), 'desc' => __('Mostly used internally, but made available for templates.', 'wp-ultimo'), 'tooltip' => '', 'value' => '', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'name', 'required' => 'require("tab", "content")', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "content")', 'v-cloak' => 1, - ), - ), - 'desc' => array( + ], + ], + 'desc' => [ 'type' => 'textarea', 'title' => __('Step Description', 'wp-ultimo'), 'placeholder' => __('e.g. This is the last step!', 'wp-ultimo'), 'desc' => __('Mostly used internally, but made available for templates.', 'wp-ultimo'), 'tooltip' => '', 'value' => '', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'desc', 'rows' => 3, - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "content")', 'v-cloak' => 1, - ), - ), + ], + ], // Visibility Tab - 'logged' => array( + 'logged' => [ 'type' => 'select', 'value' => 'always', 'title' => __('Logged Status', 'wp-ultimo'), 'desc' => __('Select the visibility of this step.', 'wp-ultimo'), - 'options' => array( + 'options' => [ 'always' => __('Always show', 'wp-ultimo'), 'logged_only' => __('Only show for logged in users', 'wp-ultimo'), 'guests_only' => __('Only show for guests', 'wp-ultimo'), - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'logged', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "visibility")', 'v-cloak' => 1, - ), - ), + ], + ], // Style Tab - 'element_id' => array( + 'element_id' => [ 'type' => 'text', 'title' => __('Element ID', 'wp-ultimo'), 'placeholder' => __('myfield', 'wp-ultimo'), 'desc' => __('A custom ID to be added to the form element. Do not add the # symbol.', 'wp-ultimo'), 'value' => '', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'element_id', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "style")', 'v-cloak' => 1, - ), - ), + ], + ], - 'classes' => array( + 'classes' => [ 'type' => 'text', 'title' => __('Extra CSS Classes', 'wp-ultimo'), 'placeholder' => __('custom-field example-class', 'wp-ultimo'), 'desc' => __('You can enter multiple CSS classes separated by spaces.', 'wp-ultimo'), 'value' => '', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'classes', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "style")', 'v-cloak' => 1, - ), - ), + ], + ], // Submit Button - 'submit_button' => array( + 'submit_button' => [ 'type' => 'submit', 'title' => empty($_step) ? __('Add Step', 'wp-ultimo') : __('Save Step', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'wrapper_html_attr' => array(), - ), - 'step' => array( + 'wrapper_html_attr' => [], + ], + 'step' => [ 'type' => 'hidden', 'value' => wu_request('step'), - ), - 'checkout_form' => array( + ], + 'checkout_form' => [ 'type' => 'hidden', 'value' => wu_request('checkout_form'), - ), - ); + ], + ]; $state = array_map('__return_empty_string', $fields); @@ -1005,15 +1005,15 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { $form = new \WP_Ultimo\UI\Form( 'add_new_form_step', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'add_checkout_form_field', 'data-state' => wu_convert_to_state($state), - ), - ) + ], + ] ); $form->render(); @@ -1025,7 +1025,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_add_new_form_step_modal() { + public function handle_add_new_form_step_modal(): void { $checkout_form = wu_get_checkout_form_by_slug(wu_request('checkout_form')); @@ -1038,7 +1038,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { ); } - $data = array( + $data = [ 'id' => wu_request('id', ''), 'original_id' => wu_request('original_id', ''), 'name' => wu_request('name', ''), @@ -1046,17 +1046,17 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { 'element_id' => wu_request('element_id', ''), 'classes' => wu_request('classes', ''), 'logged' => wu_request('logged', 'always'), - 'fields' => array(), - ); + 'fields' => [], + ]; wp_send_json_success( - array( - 'send' => array( + [ + 'send' => [ 'scope' => 'wu_checkout_forms_editor_app', 'function_name' => 'add_step', 'data' => $data, - ), - ) + ], + ] ); } @@ -1072,12 +1072,12 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { $fields = \Arrch\Arrch::find( $field_types, - array( + [ 'sort_key' => 'order', - 'where' => array( - array('default_fields', '~', $field_slug), - ), - ) + 'where' => [ + ['default_fields', '~', $field_slug], + ], + ] ); return array_keys($fields); @@ -1091,13 +1091,13 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function render_steps() { + public function render_steps(): void { wu_get_template( 'base/checkout-forms/steps', - array( + [ 'checkout_form' => $this->get_object()->get_slug(), - ) + ] ); } @@ -1107,13 +1107,13 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function render_js_templates() { + public function render_js_templates(): void { wu_get_template( 'base/checkout-forms/js-templates', - array( + [ 'checkout_form' => $this->get_object()->get_slug(), - ) + ] ); } @@ -1125,17 +1125,17 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { parent::register_scripts(); - wp_enqueue_code_editor(array('type' => 'text/html')); + wp_enqueue_code_editor(['type' => 'text/html']); wp_enqueue_script('csslint'); wp_enqueue_script('htmlhint'); - WP_Ultimo()->scripts->register_script('wu-checkout-form-editor', wu_get_asset('checkout-forms-editor.js', 'js'), array('jquery')); + WP_Ultimo()->scripts->register_script('wu-checkout-form-editor', wu_get_asset('checkout-forms-editor.js', 'js'), ['jquery']); $index = 0; @@ -1144,25 +1144,25 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { wp_localize_script( 'wu-checkout-form-editor', 'wu_checkout_form', - array( + [ 'form_id' => $this->get_object()->get_id(), 'checkout_form' => $this->get_object()->get_slug(), 'register_page' => wu_get_registration_url(), 'steps' => $steps, - 'headers' => array( + 'headers' => [ 'order' => __('Order', 'wp-ultimo'), 'name' => __('Label', 'wp-ultimo'), 'type' => __('Type', 'wp-ultimo'), 'slug' => __('Slug', 'wp-ultimo'), 'move' => '', - ), - ) + ], + ] ); wp_enqueue_script('wu-checkout-form-editor'); - wp_enqueue_script('wu-vue-sortable', '//cdn.jsdelivr.net/npm/sortablejs@1.8.4/Sortable.min.js', array(), wu_get_version()); - wp_enqueue_script('wu-vue-draggable', '//cdnjs.cloudflare.com/ajax/libs/Vue.Draggable/2.20.0/vuedraggable.umd.min.js', array(), wu_get_version()); + wp_enqueue_script('wu-vue-sortable', '//cdn.jsdelivr.net/npm/sortablejs@1.8.4/Sortable.min.js', [], wu_get_version()); + wp_enqueue_script('wu-vue-draggable', '//cdnjs.cloudflare.com/ajax/libs/Vue.Draggable/2.20.0/vuedraggable.umd.min.js', [], wu_get_version()); wp_enqueue_style('wu-checkout-form-editor', wu_get_asset('checkout-editor.css', 'css')); } @@ -1179,7 +1179,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { $fields = \WP_Ultimo\UI\Thank_You_Element::get_instance()->fields(); - $new_fields = array(); + $new_fields = []; foreach ($fields as $index => $field) { if ($field['type'] === 'header') { @@ -1193,7 +1193,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { $new_fields[ "meta[wu_thank_you_settings][$index]" ] = $field; } - $placeholders = array( + $placeholders = [ 'CUSTOMER_ID', 'CUSTOMER_EMAIL', 'MEMBERSHIP_DURATION', @@ -1203,18 +1203,18 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { 'ORDER_CURRENCY', 'ORDER_PRODUCTS', 'ORDER_AMOUNT', - ); + ]; $fields_placeholder = '%%' . implode('%% | %%', $placeholders) . '%%'; - $new_fields['conversion_snippets'] = array( + $new_fields['conversion_snippets'] = [ 'type' => 'code-editor', 'title' => __('Conversion Snippets', 'wp-ultimo'), // translators: %s is a list of placeholders. 'desc' => sprintf(__('Add custom snippets in HTML (with javascript support) to add conversion tracking pixels and such. This code is only run on the successful Thank You step.
Available placeholders are: %s', 'wp-ultimo'), $fields_placeholder), 'value' => $this->get_object()->get_conversion_snippets(), 'lang' => 'htmlmixed', - ); + ]; return $new_fields; } @@ -1240,185 +1240,185 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { parent::register_widgets(); $this->add_tabs_widget( 'advanced', - array( + [ 'title' => __('Advanced Options', 'wp-ultimo'), 'position' => 'advanced', - 'html_attr' => array( + 'html_attr' => [ 'data-on-load' => 'wu_initialize_code_editors', - ), - 'sections' => array( - 'thank-you' => array( + ], + 'sections' => [ + 'thank-you' => [ 'title' => __('Thank You', 'wp-ultimo'), 'desc' => __('Configure the Thank You page for this Checkout Form.', 'wp-ultimo'), 'icon' => 'dashicons-wu-emoji-happy', - 'state' => array( + 'state' => [ 'enable_thank_you_page' => $this->get_object()->has_thank_you_page(), 'thank_you_page' => $this->get_object()->get_thank_you_page_id(), - ), + ], 'fields' => $this->get_thank_you_page_fields(), - ), - 'scripts' => array( + ], + 'scripts' => [ 'title' => __('Scripts', 'wp-ultimo'), 'desc' => __('Configure the Thank You page for this Checkout Form.', 'wp-ultimo'), 'icon' => 'dashicons-wu-code', - 'state' => array( + 'state' => [ 'enable_thank_you_page' => $this->get_object()->has_thank_you_page(), 'thank_you_page' => $this->get_object()->get_thank_you_page_id(), - ), - 'fields' => array( - 'custom_css' => array( + ], + 'fields' => [ + 'custom_css' => [ 'type' => 'code-editor', 'title' => __('Custom CSS', 'wp-ultimo'), 'desc' => __('Add custom CSS code to your checkout form. SCSS syntax is supported.', 'wp-ultimo'), 'value' => $this->get_object()->get_custom_css(), 'lang' => 'css', - ), - ), - ), - 'restrictions' => array( + ], + ], + ], + 'restrictions' => [ 'title' => __('Restrictions', 'wp-ultimo'), 'desc' => __('Control the access to this checkout form.', 'wp-ultimo'), 'icon' => 'dashicons-wu-block', - 'state' => array( + 'state' => [ 'restrict_by_country' => $this->get_object()->has_country_lock(), - ), - 'fields' => array( - 'restrict_by_country' => array( + ], + 'fields' => [ + 'restrict_by_country' => [ 'type' => 'toggle', 'title' => __('Restrict by Country', 'wp-ultimo'), 'desc' => __('Restrict this checkout form to specific countries.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'restrict_by_country', - ), - ), - 'allowed_countries' => array( + ], + ], + 'allowed_countries' => [ 'type' => 'select', 'title' => __('Allowed Countries', 'wp-ultimo'), 'desc' => __('Select the allowed countries.', 'wp-ultimo'), 'placeholder' => __('Type to search countries...', 'wp-ultimo'), 'options' => 'wu_get_countries', 'value' => $this->get_object()->get_allowed_countries(), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("restrict_by_country", true)', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-cloak' => 1, 'data-selectize' => 1, 'multiple' => true, - ), - ), - ), - ), - ), - ) + ], + ], + ], + ], + ], + ] ); $this->add_list_table_widget( 'events', - array( + [ 'title' => __('Events', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(), - 'query_filter' => array($this, 'query_filter'), + 'query_filter' => [$this, 'query_filter'], 'position' => 'advanced', - ) + ] ); $this->add_save_widget( 'save', - array( - 'html_attr' => array( + [ + 'html_attr' => [ 'data-wu-app' => 'checkout-form', 'data-state' => wu_convert_to_state( - array( + [ 'original_slug' => $this->get_object()->get_slug(), 'slug' => $this->get_object()->get_slug(), - ) + ] ), - ), - 'fields' => array( - 'slug' => array( + ], + 'fields' => [ + 'slug' => [ 'type' => 'text', 'title' => __('Checkout Form Slug', 'wp-ultimo'), 'desc' => __('This is used to create shortcodes and more.', 'wp-ultimo'), 'value' => $this->get_object()->get_slug(), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'required' => 'required', 'v-on:input' => 'slug = $event.target.value.toLowerCase().replace(/[^a-z0-9-_]+/g, "")', 'v-bind:value' => 'slug', - ), - ), - 'slug_change_note' => array( + ], + ], + 'slug_change_note' => [ 'type' => 'note', 'desc' => __('You are changing the form slug. If you save this change, all the shortcodes and blocks referencing this slug will stop working until you update them with the new slug.', 'wp-ultimo'), 'classes' => 'wu-p-2 wu-bg-yellow-200 wu-text-yellow-700 wu-rounded wu-w-full', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => '(original_slug != slug) && slug', 'v-cloak' => '1', - ), - ), - ), - ) + ], + ], + ], + ] ); $this->add_fields_widget( 'active', - array( + [ 'title' => __('Active', 'wp-ultimo'), - 'fields' => array( - 'active' => array( + 'fields' => [ + 'active' => [ 'type' => 'toggle', 'title' => __('Active', 'wp-ultimo'), 'desc' => __('Use this option to manually enable or disable this checkout form.', 'wp-ultimo'), 'value' => $this->get_object()->is_active(), - ), - ), - ) + ], + ], + ] ); \WP_Ultimo\UI\Tours::get_instance()->create_tour( 'checkout-form-editor', - array( - array( + [ + [ 'id' => 'checkout-form-editor', 'title' => __('Welcome to the Checkout Form builder!', 'wp-ultimo'), - 'text' => array( + 'text' => [ __('You should be able to create registration forms in any way, shape, and form you desire. This editor allows you to do just that 😃', 'wp-ultimo'), __('Want a registration form with multiple steps? Check! A single step? Check! Control the visibility of certain steps and fields based on the context of the customer? Check!', 'wp-ultimo'), - ), - ), - array( + ], + ], + [ 'id' => 'add-new-step', 'title' => __('Adding new Steps', 'wp-ultimo'), - 'text' => array( + 'text' => [ __('To add a new step to the registration form, use this button here.', 'wp-ultimo'), - ), - 'attachTo' => array( + ], + 'attachTo' => [ 'element' => '#wp-ultimo-list-table-add-new-1 > div > div.wu-w-1\/2.wu-text-right > ul > li:nth-child(2) > a', 'on' => 'left', - ), - ), - array( + ], + ], + [ 'id' => 'add-new-field', 'title' => __('Adding new Fields', 'wp-ultimo'), - 'text' => array( + 'text' => [ __('To add a new field to a step, use this button here. You can add fields to capture additional data from your customers and use that data to populate site templates.', 'wp-ultimo'), sprintf('%s', wu_get_documentation_url('wp-ultimo-populate-site-template'), __('You can learn more about that here →', 'wp-ultimo')), - ), - 'attachTo' => array( + ], + 'attachTo' => [ 'element' => '#wp-ultimo-list-table-checkout > div.inside > div.wu-bg-gray-100.wu-px-4.wu-py-3.wu--m-3.wu-mt-3.wu-border-t.wu-border-l-0.wu-border-r-0.wu-border-b-0.wu-border-gray-400.wu-border-solid.wu-text-right > ul > li:nth-child(3) > a', 'on' => 'left', - ), - ), - ) + ], + ], + ] ); } @@ -1452,7 +1452,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { */ public function get_labels() { - return array( + return [ 'edit_label' => __('Edit Checkout Form', 'wp-ultimo'), 'add_new_label' => __('Add new Checkout Form', 'wp-ultimo'), 'updated_message' => __('Checkout Form updated with success!', 'wp-ultimo'), @@ -1462,7 +1462,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { 'save_description' => '', 'delete_button_label' => __('Delete Checkout Form', 'wp-ultimo'), 'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'), - ); + ]; } /** @@ -1475,10 +1475,10 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { */ public function query_filter($args) { - $extra_args = array( + $extra_args = [ 'object_type' => 'checkout_form', 'object_id' => absint($this->get_object()->get_id()), - ); + ]; return array_merge($args, $extra_args); } @@ -1519,7 +1519,7 @@ class Checkout_Form_Edit_Admin_Page extends Edit_Admin_Page { public function handle_save() { if ( ! wu_request('restrict_by_country') || empty($_POST['allowed_countries'])) { - $_POST['allowed_countries'] = array(); + $_POST['allowed_countries'] = []; } $_POST['settings'] = json_decode(stripslashes((string) $_POST['_settings']), true); diff --git a/inc/admin-pages/class-checkout-form-list-admin-page.php b/inc/admin-pages/class-checkout-form-list-admin-page.php index 14c53ed..7c1cc97 100644 --- a/inc/admin-pages/class-checkout-form-list-admin-page.php +++ b/inc/admin-pages/class-checkout-form-list-admin-page.php @@ -52,9 +52,9 @@ class Checkout_Form_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_read_checkout_forms', - ); + ]; /** * Register the list page tour. @@ -62,31 +62,31 @@ class Checkout_Form_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function register_widgets() { + public function register_widgets(): void { \WP_Ultimo\UI\Tours::get_instance()->create_tour( 'checkout-form-list', - array( - array( + [ + [ 'id' => 'checkout-form-list', 'title' => __('Checkout Forms', 'wp-ultimo'), - 'text' => array( + 'text' => [ __('Checkout Forms are an easy and flexible way to experiment with different approaches when trying to convert new customers.', 'wp-ultimo'), - ), - ), - array( + ], + ], + [ 'id' => 'default-form', 'title' => __('Experiment!', 'wp-ultimo'), - 'text' => array( + 'text' => [ __('You can create as many checkout forms as you want, with different fields, products on offer, etc.', 'wp-ultimo'), __('Planning on running some sort of promotion? Why not create a custom landing page with a tailor-maid checkout form to go with? The possibilities are endless.', 'wp-ultimo'), - ), - 'attachTo' => array( + ], + 'attachTo' => [ 'element' => '#wp-ultimo-wrap > h1 > a:first-child', 'on' => 'right', - ), - ), - ) + ], + ], + ] ); } @@ -96,17 +96,17 @@ class Checkout_Form_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function register_forms() { + public function register_forms(): void { /* * Add new Checkout Form */ wu_register_form( 'add_new_checkout_form', - array( - 'render' => array($this, 'render_add_new_checkout_form_modal'), - 'handler' => array($this, 'handle_add_new_checkout_form_modal'), + [ + 'render' => [$this, 'render_add_new_checkout_form_modal'], + 'handler' => [$this, 'handle_add_new_checkout_form_modal'], 'capability' => 'wu_edit_checkout_forms', - ) + ] ); } @@ -116,10 +116,10 @@ class Checkout_Form_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function render_add_new_checkout_form_modal() { + public function render_add_new_checkout_form_modal(): void { - $fields = array( - 'template' => array( + $fields = [ + 'template' => [ 'type' => 'select-icon', 'title' => __('Checkout Form Template', 'wp-ultimo'), 'desc' => __('Select a starting point for a new Checkout Form.', 'wp-ultimo'), @@ -127,49 +127,49 @@ class Checkout_Form_List_Admin_Page extends List_Admin_Page { 'tooltip' => '', 'value' => '', 'classes' => 'wu-w-1/3', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'template', - ), - 'options' => array( - 'single-step' => array( + ], + 'options' => [ + 'single-step' => [ 'title' => __('Single Step', 'wp-ultimo'), 'icon' => 'dashicons-before dashicons-list-view', - ), - 'multi-step' => array( + ], + 'multi-step' => [ 'title' => __('Multi-Step', 'wp-ultimo'), 'icon' => 'dashicons-before dashicons-excerpt-view', - ), - 'blank' => array( + ], + 'blank' => [ 'title' => __('Blank', 'wp-ultimo'), 'icon' => 'dashicons-before dashicons-admin-page', - ), - ), - ), - 'submit_button' => array( + ], + ], + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Go to the Editor →', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'add_new_checkout_form', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'add_checkout_form_field', 'data-state' => json_encode( - array( + [ 'template' => 'single-step', - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -181,7 +181,7 @@ class Checkout_Form_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_add_new_checkout_form_modal() { + public function handle_add_new_checkout_form_modal(): void { $template = wu_request('template'); @@ -201,14 +201,14 @@ class Checkout_Form_List_Admin_Page extends List_Admin_Page { wp_send_json_error($status); } else { wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url( 'wp-ultimo-edit-checkout-form', - array( + [ 'id' => $checkout_form->get_id(), - ) + ] ), - ) + ] ); } } @@ -221,10 +221,10 @@ class Checkout_Form_List_Admin_Page extends List_Admin_Page { */ public function get_labels() { - return array( + return [ 'deleted_message' => __('Checkout Form removed successfully.', 'wp-ultimo'), 'search_label' => __('Search Checkout Form', 'wp-ultimo'), - ); + ]; } /** @@ -268,14 +268,14 @@ class Checkout_Form_List_Admin_Page extends List_Admin_Page { */ public function action_links() { - return array( - array( + return [ + [ 'label' => __('Add Checkout Form'), 'icon' => 'wu-circle-with-plus', 'classes' => 'wubox', 'url' => wu_get_form_url('add_new_checkout_form'), - ), - ); + ], + ]; } /** diff --git a/inc/admin-pages/class-customer-edit-admin-page.php b/inc/admin-pages/class-customer-edit-admin-page.php index 9e442d5..5a0d9b6 100644 --- a/inc/admin-pages/class-customer-edit-admin-page.php +++ b/inc/admin-pages/class-customer-edit-admin-page.php @@ -76,9 +76,9 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_edit_customers', - ); + ]; /** * Allow child classes to add hooks to be run once the page is loaded. @@ -87,13 +87,13 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { * @since 1.8.2 * @return void */ - public function hooks() { + public function hooks(): void { parent::hooks(); - add_action('wu_page_edit_redirect_handlers', array($this, 'handle_send_verification_notice')); + add_action('wu_page_edit_redirect_handlers', [$this, 'handle_send_verification_notice']); - add_filter('removable_query_args', array($this, 'remove_query_args')); + add_filter('removable_query_args', [$this, 'remove_query_args']); } /** @@ -102,7 +102,7 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { * @return void * @since 1.8.2 */ - public function register_scripts() { + public function register_scripts(): void { parent::register_scripts(); @@ -119,27 +119,27 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { * @return void * @since 2.0.0 */ - public function register_forms() { + public function register_forms(): void { /* * Transfer customer - Confirmation modal */ wu_register_form( 'transfer_customer', - array( - 'render' => array($this, 'render_transfer_customer_modal'), - 'handler' => array($this, 'handle_transfer_customer_modal'), + [ + 'render' => [$this, 'render_transfer_customer_modal'], + 'handler' => [$this, 'handle_transfer_customer_modal'], 'capability' => 'wu_transfer_customer', - ) + ] ); /* * Adds the hooks to handle deletion. */ - add_filter('wu_form_fields_delete_customer_modal', array($this, 'customer_extra_delete_fields'), 10, 2); + add_filter('wu_form_fields_delete_customer_modal', [$this, 'customer_extra_delete_fields'], 10, 2); - add_filter('wu_form_attributes_delete_customer_modal', array($this, 'customer_extra_form_attributes')); + add_filter('wu_form_attributes_delete_customer_modal', [$this, 'customer_extra_form_attributes']); - add_action('wu_after_delete_customer_modal', array($this, 'customer_after_delete_actions')); + add_action('wu_after_delete_customer_modal', [$this, 'customer_after_delete_actions']); } /** @@ -148,7 +148,7 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { * @return void * @since 2.0.0 */ - public function render_transfer_customer_modal() { + public function render_transfer_customer_modal(): void { $user = wu_get_customer(wu_request('id')); @@ -156,52 +156,52 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { return; } - $fields = array( - 'confirm' => array( + $fields = [ + 'confirm' => [ 'type' => 'toggle', 'title' => __('Confirm Transfer', 'wp-ultimo'), 'desc' => __('This will start the transfer of assets from one user to another.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'confirmed', - ), - ), - 'submit_button' => array( + ], + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Start Transfer', 'wp-ultimo'), 'placeholder' => __('Start Transfer', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:disabled' => '!confirmed', - ), - ), - 'id' => array( + ], + ], + 'id' => [ 'type' => 'hidden', 'value' => $user->get_id(), - ), - 'target_user_id' => array( + ], + 'target_user_id' => [ 'type' => 'hidden', 'value' => wu_request('target_user_id'), - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'total-actions', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'transfer_customer', 'data-state' => wp_json_encode( - array( + [ 'confirmed' => false, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -213,7 +213,7 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { * @return void * @since 2.0.0 */ - public function handle_transfer_customer_modal() { + public function handle_transfer_customer_modal(): void { global $wpdb; @@ -237,14 +237,14 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { } wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url( 'wp-ultimo-edit-customer', - array( + [ 'id' => $customer->get_id(), - ) + ] ), - ) + ] ); } @@ -258,33 +258,33 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { */ public function customer_extra_delete_fields($fields, $customer): array { - $custom_fields = array( - 'delete_all' => array( + $custom_fields = [ + 'delete_all' => [ 'type' => 'toggle', 'title' => __('Delete everything', 'wp-ultimo'), 'desc' => __('Sites, payments and memberships.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-bind:value' => 'delete_all_confirmed', 'v-model' => 'delete_all_confirmed', - ), - ), - 're_assignment_customer_id' => array( + ], + ], + 're_assignment_customer_id' => [ 'type' => 'model', 'title' => __('Re-assignment to customer', 'wp-ultimo'), 'placeholder' => __('Select Customer...', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'data-model' => 'customer', 'data-value-field' => 'id', 'data-label-field' => 'display_name', 'data-search-field' => 'display_name', 'data-max-items' => 1, - 'data-exclude' => wp_json_encode(array($customer->get_id())), - ), - 'wrapper_html_attr' => array( + 'data-exclude' => wp_json_encode([$customer->get_id()]), + ], + 'wrapper_html_attr' => [ 'v-show' => '!delete_all_confirmed', - ), - ), - ); + ], + ], + ]; if ( ! current_user_can('wu_delete_sites') || ! current_user_can('wu_delete_memberships') || ! current_user_can('wu_delete_payments')) { unset($custom_fields['delete_all']); @@ -324,7 +324,7 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { * @return void * @since 2.0.0 */ - public function customer_after_delete_actions($customer) { + public function customer_after_delete_actions($customer): void { $delete_all = wu_request('delete_all'); @@ -336,9 +336,9 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { */ wu_enqueue_async_action( 'wu_async_delete_membership', - array( + [ 'membership_id' => $membership->get_id(), - ), + ], 'membership' ); } @@ -350,9 +350,9 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { */ wu_enqueue_async_action( 'wu_async_delete_payment', - array( + [ 'payment_id' => $payment->get_id(), - ), + ], 'payment' ); } @@ -367,10 +367,10 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { */ wu_enqueue_async_action( 'wu_async_transfer_membership', - array( + [ 'membership_id' => $membership->get_id(), 'target_customer_id' => $re_assignment_customer->get_id(), - ), + ], 'membership' ); } @@ -382,10 +382,10 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { */ wu_enqueue_async_action( 'wu_async_transfer_payment', - array( + [ 'payment_id' => $payment->get_id(), 'target_customer_id' => $re_assignment_customer->get_id(), - ), + ], 'payment' ); } @@ -403,26 +403,26 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { $custom_meta_keys = wu_get_all_customer_meta($this->get_object()->get_id(), true); - $meta_fields_set = array(); + $meta_fields_set = []; - $meta_fields_unset = array(); + $meta_fields_unset = []; foreach ($custom_meta_keys as $key => $value) { - $field_location_breadcrumbs = array( + $field_location_breadcrumbs = [ __( 'orphan field - the original form no longer exists', 'wp-ultimo' ), - ); + ]; $form = wu_get_isset($value, 'form'); if ($form) { - $field_location_breadcrumbs = array( + $field_location_breadcrumbs = [ $form, wu_get_isset($value, 'step'), wu_get_isset($value, 'id'), - ); + ]; } $location = sprintf( @@ -431,7 +431,7 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { implode(' → ', array_filter($field_location_breadcrumbs)) ); - $options = wu_get_isset($value, 'options', array()); + $options = wu_get_isset($value, 'options', []); if ($options) { $options = array_combine( @@ -440,16 +440,16 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { ); } - $options = array_merge(array('' => '--'), $options); + $options = array_merge(['' => '--'], $options); - $field_data = array( + $field_data = [ 'title' => wu_get_isset($value, 'title', wu_slug_to_name($key)), 'type' => wu_get_isset($value, 'type', 'text'), 'desc' => wu_get_isset($value, 'description', '') . $location, 'options' => $options, 'tooltip' => wu_get_isset($value, 'tooltip', ''), 'value' => wu_get_customer_meta($this->get_object()->get_id(), $key), - ); + ]; if ($field_data['type'] === 'hidden') { $field_data['type'] = 'text'; @@ -463,18 +463,18 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { if (wu_get_isset($value, 'exists')) { $meta_fields_set[ "meta_key_$key" ] = $field_data; } else { - $field_data['wrapper_html_attr'] = array( + $field_data['wrapper_html_attr'] = [ 'v-show' => 'display_unset_fields', - ); + ]; $meta_fields_unset[ "meta_key_$key" ] = $field_data; } } - $collapsible_header = array(); + $collapsible_header = []; if ($meta_fields_unset) { - $collapsible_header['display_unset_fields'] = array( + $collapsible_header['display_unset_fields'] = [ 'title' => __('Display unset fields', 'wp-ultimo'), 'desc' => __( 'If fields were added after the customer creation or onto a different form, they will not have a set value for this customer. You can manually set those here.', @@ -482,133 +482,133 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { ), 'type' => 'toggle', 'wrapper_classes' => 'wu-bg-gray-100', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'display_unset_fields', - ), - ); + ], + ]; } $final_fields = array_merge($meta_fields_set, $collapsible_header, $meta_fields_unset); if (empty($final_fields)) { - $final_fields['empty'] = array( + $final_fields['empty'] = [ 'type' => 'note', 'desc' => __('No custom meta data collected and no custom fields found.', 'wp-ultimo'), 'classes' => 'wu-text-center', - ); + ]; } - $final_fields['display_new_meta_repeater'] = array( + $final_fields['display_new_meta_repeater'] = [ 'title' => __('Manually add custom meta fields', 'wp-ultimo'), 'desc' => __('Add new custom meta fields to this customer.', 'wp-ultimo'), 'type' => 'toggle', 'wrapper_classes' => 'wu-bg-gray-100', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'new_meta_fields_show', - ), - ); + ], + ]; - $default_meta_value = fn(string $type, $value = '', bool $is_default = false) => array( + $default_meta_value = fn(string $type, $value = '', bool $is_default = false) => [ 'title' => __('Value', 'wp-ultimo'), 'type' => $type, 'value' => $value, 'wrapper_classes' => 'wu-w-1/4 wu-ml-2', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => ($is_default ? '!new_meta_field.type || ' : '') . "new_meta_field.type === '$type'", - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'new_meta_field.value', 'v-bind:name' => '"new_meta_fields[" + index + "][value]"', - ), - ); + ], + ]; - $new_meta_fields = array( - 'new_meta_fields' => array( + $new_meta_fields = [ + 'new_meta_fields' => [ 'type' => 'group', 'wrapper_classes' => 'wu-relative', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-for' => '(new_meta_field, index) in new_meta_fields', - ), - 'fields' => array( - 'new_meta_remove' => array( + ], + 'fields' => [ + 'new_meta_remove' => [ 'type' => 'note', 'desc' => sprintf( '', __('Remove', 'wp-ultimo') ), 'wrapper_classes' => 'wu-absolute wu-top-0 wu-right-0', - ), - 'new_meta_slug' => array( + ], + 'new_meta_slug' => [ 'title' => __('Slug', 'wp-ultimo'), 'type' => 'text', 'value' => '', 'wrapper_classes' => 'wu-w-1/4', - 'html_attr' => array( + 'html_attr' => [ 'v-on:input' => "new_meta_field.slug = \$event.target.value.toLowerCase().replace(/[^a-z0-9-_]+/g, '')", 'v-model' => 'new_meta_field.slug', 'v-bind:name' => '"new_meta_fields[" + index + "][slug]"', - ), - ), - 'new_meta_title' => array( + ], + ], + 'new_meta_title' => [ 'title' => __('Title', 'wp-ultimo'), 'type' => 'text', 'value' => '', 'wrapper_classes' => 'wu-w-1/4 wu-ml-2', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:name' => '"new_meta_fields[" + index + "][title]"', - ), - ), - 'new_meta_type' => array( + ], + ], + 'new_meta_type' => [ 'title' => __('Type', 'wp-ultimo'), 'type' => 'select', - 'options' => array( + 'options' => [ 'text' => __('Text', 'wp-ultimo'), 'textarea' => __('Textarea', 'wp-ultimo'), 'checkbox' => __('Checkbox', 'wp-ultimo'), 'color' => __('Color', 'wp-ultimo'), 'image' => __('Image', 'wp-ultimo'), - ), + ], 'wrapper_classes' => 'wu-w-1/4 wu-ml-2', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'new_meta_field.type', 'v-bind:name' => '"new_meta_fields[" + index + "][type]"', - ), - ), + ], + ], 'new_meta_value_text' => $default_meta_value('text', '', true), 'new_meta_value_textarea' => $default_meta_value('textarea'), 'new_meta_value_checkbox' => $default_meta_value('checkbox', true), 'new_meta_value_color' => $default_meta_value('color', '#4299e1'), 'new_meta_value_image' => array_merge( $default_meta_value('image'), - array( + [ 'content_wrapper_classes' => 'wu-mt-2', 'stacked' => true, - ) + ] ), - ), - ), - 'repeat_option' => array( + ], + ], + 'repeat_option' => [ 'type' => 'submit', 'title' => __('+ Add meta field', 'wp-ultimo'), 'classes' => 'button wu-self-end', 'wrapper_classes' => 'wu-bg-whiten wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'v-on:click.prevent' => '() => new_meta_fields.push({ type: "text", slug: "", })', - ), - ), - ); + ], + ], + ]; - $final_fields['new_meta_fields_wrapper'] = array( + $final_fields['new_meta_fields_wrapper'] = [ 'type' => 'group', 'classes' => 'wu-grid', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'new_meta_fields_show', - ), + ], 'fields' => $new_meta_fields, - ); + ]; return $final_fields; } @@ -619,7 +619,7 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { * @return void * @since 1.8.2 */ - public function register_widgets() { + public function register_widgets(): void { parent::register_widgets(); @@ -627,23 +627,23 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { $this->add_fields_widget( 'at_a_glance', - array( + [ 'title' => __('At a Glance', 'wp-ultimo'), 'position' => 'normal', 'classes' => 'wu-overflow-hidden wu-m-0 wu--mt-1 wu--mx-3 wu--mb-3', 'field_wrapper_classes' => 'wu-w-1/3 wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t-0 wu-border-l-0 wu-border-r wu-border-b-0 wu-border-gray-300 wu-border-solid wu-float-left wu-relative', - 'html_attr' => array( + 'html_attr' => [ 'style' => 'margin-top: -6px;', - ), - 'fields' => array( - 'id' => array( + ], + 'fields' => [ + 'id' => [ 'type' => 'text-display', 'copy' => true, 'title' => __('Customer ID', 'wp-ultimo'), 'display_value' => $this->get_object()->get_id(), 'tooltip' => '', - ), - 'last_login' => array( + ], + 'last_login' => [ 'edit' => false, 'title' => __('Last Login', 'wp-ultimo'), 'type' => 'text-edit', @@ -652,71 +652,71 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { 'wp-ultimo' ), 'display_value' => $this->edit ? $this->get_object()->get_last_login(false) : false, - ), - 'total_grossed' => array( + ], + 'total_grossed' => [ 'type' => 'text-display', 'title' => __('Total Grossed', 'wp-ultimo'), 'display_value' => wu_format_currency($this->get_object()->get_total_grossed()), 'tooltip' => '', - ), - ), - ) + ], + ], + ] ); $this->add_list_table_widget( 'memberships', - array( + [ 'title' => __('Memberships', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Customers_Membership_List_Table(), - 'query_filter' => array($this, 'memberships_query_filter'), - ) + 'query_filter' => [$this, 'memberships_query_filter'], + ] ); $this->add_tabs_widget( 'options', - array( + [ 'title' => __('Customer Options', 'wp-ultimo'), 'position' => 'normal', 'sections' => apply_filters( 'wu_customer_options_sections', - array( - 'general' => array( + [ + 'general' => [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General options for the customer.', 'wp-ultimo'), 'icon' => 'dashicons-wu-globe', - 'fields' => array( - 'vip' => array( + 'fields' => [ + 'vip' => [ 'type' => 'toggle', 'title' => __('VIP', 'wp-ultimo'), 'desc' => __('Set this customer as a VIP.', 'wp-ultimo'), 'tooltip' => '', 'value' => $this->get_object()->is_vip(), - ), - ), - ), - 'billing_info' => array( + ], + ], + ], + 'billing_info' => [ 'title' => __('Billing Info', 'wp-ultimo'), 'desc' => __('Billing information for this particular customer', 'wp-ultimo'), 'icon' => 'dashicons-wu-address', 'fields' => $this->get_object()->get_billing_address()->get_fields(), - ), - 'custom_meta' => array( + ], + 'custom_meta' => [ 'title' => __('Custom Meta', 'wp-ultimo'), 'desc' => __('Custom data collected via WP Multisite WaaS forms.', 'wp-ultimo'), 'icon' => 'dashicons-wu-database wu-pt-px', 'fields' => $this->generate_customer_meta_fields(), - 'state' => array( + 'state' => [ 'display_unset_fields' => false, 'new_meta_fields_show' => false, - 'new_meta_fields' => array( - array( + 'new_meta_fields' => [ + [ 'type' => 'text', 'slug' => '', - ), - ), - ), - ), - // @todo: bring these back + ], + ], + ], + ], + // @todo: bring these back // phpcs:disable // 'payment_methods' => array( // 'title' => __('Payment Methods', 'wp-ultimo'), @@ -725,62 +725,62 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { // 'fields' => apply_filters('wu_customer_payment_methods', array(), $this->get_object(), $this), // ), // phpcs:enable - ), + ], $this->get_object() ), - ) + ] ); $this->add_list_table_widget( 'payments', - array( + [ 'title' => __('Payments', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Customers_Payment_List_Table(), - 'query_filter' => array($this, 'memberships_query_filter'), - ) + 'query_filter' => [$this, 'memberships_query_filter'], + ] ); $this->add_list_table_widget( 'sites', - array( + [ 'title' => __('Sites', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Customers_Site_List_Table(), - 'query_filter' => array($this, 'sites_query_filter'), - ) + 'query_filter' => [$this, 'sites_query_filter'], + ] ); $this->add_list_table_widget( 'events', - array( + [ 'title' => __('Events', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(), - 'query_filter' => array($this, 'events_query_filter'), - ) + 'query_filter' => [$this, 'events_query_filter'], + ] ); $this->add_fields_widget( 'save', - array( - 'html_attr' => array( + [ + 'html_attr' => [ 'data-wu-app' => 'customer_save', 'data-state' => json_encode( - array( + [ 'original_user_id' => $this->get_object()->get_user_id(), 'user_id' => $this->get_object()->get_user_id(), 'original_email_verification' => $this->get_object()->get_email_verification(), 'email_verification' => $this->get_object()->get_email_verification(), - ) + ] ), - ), + ], 'before' => wu_get_template_contents( 'customers/widget-avatar', - array( + [ 'customer' => $this->get_object(), 'user' => $this->get_object()->get_user(), - ) + ] ), - 'fields' => array( - 'user_id' => array( + 'fields' => [ + 'user_id' => [ 'type' => 'model', 'title' => __('User', 'wp-ultimo'), 'placeholder' => __('Search WordPress user...', 'wp-ultimo'), @@ -788,7 +788,7 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { 'value' => $this->get_object()->get_user_id(), 'tooltip' => '', 'min' => 1, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'user_id', 'data-model' => 'user', 'data-value-field' => 'ID', @@ -796,24 +796,24 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { 'data-search-field' => 'display_name', 'data-max-items' => 1, 'data-selected' => json_encode($this->get_object()->get_user()->data), - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - ), - 'transfer_note' => array( + ], + ], + 'transfer_note' => [ 'type' => 'note', 'desc' => __( 'Changing the user will transfer the customer and all its assets to the new user.', 'wp-ultimo' ), 'classes' => 'wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-w-full', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => '(original_user_id != user_id) && user_id', 'v-cloak' => '1', - ), - ), - 'email_verification' => array( + ], + ], + 'email_verification' => [ 'type' => 'select', 'title' => __('Email Verification', 'wp-ultimo'), 'placeholder' => __('Select Status', 'wp-ultimo'), @@ -821,21 +821,21 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { 'The email verification status. This gets automatically switched to Verified when the customer verifies their email address.', 'wp-ultimo' ), - 'options' => array( + 'options' => [ 'none' => __('None', 'wp-ultimo'), 'pending' => __('Pending', 'wp-ultimo'), 'verified' => __('Verified', 'wp-ultimo'), - ), + ], 'value' => $this->get_object()->get_email_verification(), 'tooltip' => '', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'email_verification', - ), - ), - 'confirm_membership' => array( + ], + ], + 'confirm_membership' => [ 'type' => 'toggle', 'title' => __('Activate Memberships', 'wp-ultimo'), 'desc' => __( @@ -843,62 +843,62 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { 'wp-ultimo' ), 'value' => 0, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'email_verification !== original_email_verification && email_verification === "verified" && original_email_verification === "pending"', 'v-cloak' => '1', - ), - ), - 'send_verification' => array( + ], + ], + 'send_verification' => [ 'type' => 'submit', 'title' => __('Re-send Verification Email →', 'wp-ultimo'), 'value' => 'send_verification', 'classes' => 'button wu-w-full', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'email_verification === "pending" && original_email_verification == "pending"', 'v-cloak' => '1', - ), - ), - 'submit_save' => array( + ], + ], + 'submit_save' => [ 'type' => 'submit', 'title' => $labels['save_button_label'], 'placeholder' => $labels['save_button_label'], 'value' => 'save', 'classes' => 'button button-primary wu-w-full', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'original_user_id == user_id || !user_id', 'v-cloak' => '1', - ), - ), - 'transfer' => array( + ], + ], + 'transfer' => [ 'type' => 'link', 'display_value' => __('Transfer Customer', 'wp-ultimo'), 'wrapper_classes' => 'wu-bg-gray-200', 'classes' => 'button wubox wu-w-full wu-text-center', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'original_user_id != user_id && user_id', 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-bind:href' => "'" . wu_get_form_url( 'transfer_customer', - array( + [ 'id' => $this->get_object()->get_id(), 'target_user_id' => '', - ) + ] ) . "=' + user_id", 'title' => __('Transfer Customer', 'wp-ultimo'), - ), - ), - ), - ) + ], + ], + ], + ] ); $this->add_fields_widget( 'last-login', - array( + [ 'title' => __('Last Login & IPs', 'wp-ultimo'), - 'fields' => array( - 'last_login' => array( + 'fields' => [ + 'last_login' => [ 'edit' => true, 'title' => __('Last Login', 'wp-ultimo'), 'type' => 'text-edit', @@ -909,24 +909,24 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { ), 'display_value' => $this->edit ? $this->get_object()->get_last_login(false) : false, 'placeholder' => '2020-04-04 12:00:00', - 'html_attr' => array( + 'html_attr' => [ 'wu-datepicker' => 'true', 'data-format' => 'Y-m-d H:i:S', 'data-allow-time' => 'true', - ), - ), - 'ips' => array( + ], + ], + 'ips' => [ 'title' => __('IP Address', 'wp-ultimo'), 'type' => 'text-edit', 'display_value' => $this->get_object()->get_last_ip(), - ), - 'country' => array( + ], + 'country' => [ 'title' => __('IP Address Country', 'wp-ultimo'), 'type' => 'text-edit', - 'display_value' => array($this, 'render_country'), - ), - ), - ) + 'display_value' => [$this, 'render_country'], + ], + ], + ] ); } @@ -986,7 +986,7 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { */ public function action_links() { - return array(); + return []; } /** @@ -997,7 +997,7 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { */ public function get_labels() { - return array( + return [ 'edit_label' => __('Edit Customer', 'wp-ultimo'), 'add_new_label' => __('Add new Customer', 'wp-ultimo'), 'updated_message' => __('Customer updated with success!', 'wp-ultimo'), @@ -1007,7 +1007,7 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { 'save_description' => '', 'delete_button_label' => __('Delete Customer', 'wp-ultimo'), 'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'), - ); + ]; } /** @@ -1035,12 +1035,12 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { */ public function sites_query_filter($args) { - $args['meta_query'] = array( - 'customer_id' => array( + $args['meta_query'] = [ + 'customer_id' => [ 'key' => 'wu_customer_id', 'value' => $this->get_object()->get_id(), - ), - ); + ], + ]; return $args; } @@ -1055,10 +1055,10 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { */ public function events_query_filter($args) { - $extra_args = array( + $extra_args = [ 'object_type' => 'customer', 'object_id' => absint($this->get_object()->get_id()), - ); + ]; return array_merge($args, $extra_args); } @@ -1106,7 +1106,7 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { * @return void * @since 2.0.0 */ - public function handle_save() { + public function handle_save(): void { if ($_POST['submit_button'] === 'send_verification') { $customer = $this->get_object(); @@ -1115,10 +1115,10 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { $redirect_url = wu_network_admin_url( 'wp-ultimo-edit-customer', - array( + [ 'id' => $customer->get_id(), 'notice_verification_sent' => 1, - ) + ] ); wp_redirect($redirect_url); @@ -1170,7 +1170,7 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { ); } - foreach (wu_get_isset($_POST, 'new_meta_fields', array()) as $meta_field) { + foreach (wu_get_isset($_POST, 'new_meta_fields', []) as $meta_field) { $slug = sanitize_key(wu_get_isset($meta_field, 'slug', '')); if (empty($slug) || $this->restricted_customer_meta_keys($slug)) { @@ -1199,14 +1199,14 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { */ public function restricted_customer_meta_keys(string $meta_slug): bool { - $restricted_meta = array( + $restricted_meta = [ 'wu_verification_key', 'wu_billing_address', 'ip_state', 'ip_country', 'wu_has_trialed', 'wu_custom_meta_keys', - ); + ]; return in_array($meta_slug, $restricted_meta, true); } @@ -1217,7 +1217,7 @@ class Customer_Edit_Admin_Page extends Edit_Admin_Page { * @return void * @since 2.0.0 */ - public function handle_send_verification_notice() { + public function handle_send_verification_notice(): void { if (isset($_GET['notice_verification_sent'])) : ?> diff --git a/inc/admin-pages/class-customer-list-admin-page.php b/inc/admin-pages/class-customer-list-admin-page.php index b83212c..7f4b6fb 100644 --- a/inc/admin-pages/class-customer-list-admin-page.php +++ b/inc/admin-pages/class-customer-list-admin-page.php @@ -46,11 +46,11 @@ class Customer_List_Admin_Page extends List_Admin_Page { * @since 2.1 * @return void */ - public function init() { + public function init(): void { parent::init(); - add_action('plugins_loaded', array($this, 'export_customers')); + add_action('plugins_loaded', [$this, 'export_customers']); } /** @@ -59,7 +59,7 @@ class Customer_List_Admin_Page extends List_Admin_Page { * @since 2.1 * @return void */ - public function export_customers() { + public function export_customers(): void { if (wu_request('wu_action') !== 'wu_export_customers') { return; @@ -81,7 +81,7 @@ class Customer_List_Admin_Page extends List_Admin_Page { $billing_address = array_map(fn($field) => $field['value'], $customer->get_billing_address()->get_fields()); return array_merge( - array( + [ $customer->get_id(), $customer->get_user_id(), $customer->get_hash(), @@ -93,12 +93,12 @@ class Customer_List_Admin_Page extends List_Admin_Page { $customer->get_signup_form(), $membership_amount, implode('|', $memberships_ids), - ), + ], $billing_address, - array( + [ $customer->get_last_login(), $customer->get_date_registered(), - ) + ] ); }, wu_get_customers() @@ -107,7 +107,7 @@ class Customer_List_Admin_Page extends List_Admin_Page { $billing_fields = array_keys(\WP_Ultimo\Objects\Billing_Address::fields()); $headers = array_merge( - array( + [ 'id', 'user_id', 'customer_hash', @@ -119,17 +119,17 @@ class Customer_List_Admin_Page extends List_Admin_Page { 'signup_form', 'membership_amount', 'membership_ids', - ), + ], $billing_fields, - array( + [ 'last_login', 'date_registered', - ) + ] ); $file_name = sprintf('wp-ultimo-customers-(%s)', gmdate('Y-m-d', wu_get_current_time('timestamp'))); - wu_generate_csv($file_name, array_merge(array($headers), $customer_data)); + wu_generate_csv($file_name, array_merge([$headers], $customer_data)); die; } @@ -144,9 +144,9 @@ class Customer_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_read_customers', - ); + ]; /** * Register ajax forms that we use for payments. @@ -154,17 +154,17 @@ class Customer_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function register_forms() { + public function register_forms(): void { /* * Add new Customer */ wu_register_form( 'add_new_customer', - array( - 'render' => array($this, 'render_add_new_customer_modal'), - 'handler' => array($this, 'handle_add_new_customer_modal'), + [ + 'render' => [$this, 'render_add_new_customer_modal'], + 'handler' => [$this, 'handle_add_new_customer_modal'], 'capability' => 'wu_invite_customers', - ) + ] ); } @@ -174,100 +174,100 @@ class Customer_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function render_add_new_customer_modal() { + public function render_add_new_customer_modal(): void { - $fields = array( - 'type' => array( + $fields = [ + 'type' => [ 'type' => 'tab-select', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'type', - ), - 'options' => array( + ], + 'options' => [ 'existing' => __('Existing User', 'wp-ultimo'), 'new' => __('Invite New', 'wp-ultimo'), - ), - ), - 'user_id' => array( + ], + ], + 'user_id' => [ 'type' => 'model', 'title' => __('Existing User', 'wp-ultimo'), 'placeholder' => __('Search WordPress user...', 'wp-ultimo'), 'tooltip' => '', 'min' => 1, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "require('type', 'existing')", - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'data-model' => 'user', 'data-value-field' => 'ID', 'data-label-field' => 'display_name', 'data-search-field' => 'display_name', 'data-max-items' => 1, - ), - ), - 'username' => array( + ], + ], + 'username' => [ 'type' => 'text', 'title' => __('Username', 'wp-ultimo'), 'placeholder' => __('E.g. johnsmith', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "require('type', 'new')", - ), - ), - 'email_address' => array( + ], + ], + 'email_address' => [ 'type' => 'email', 'title' => __('Email Address', 'wp-ultimo'), 'placeholder' => __('E.g. customer@wpultimo.dev', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "require('type', 'new')", - ), - ), - 'set_password' => array( + ], + ], + 'set_password' => [ 'type' => 'toggle', 'title' => __('Set Password', 'wp-ultimo'), 'desc' => __('If not set, the user will be asked to set a password after accepting the invite.', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "require('type', 'new')", - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'set_password', - ), - ), - 'password' => array( + ], + ], + 'password' => [ 'type' => 'password', 'title' => __('Password', 'wp-ultimo'), 'placeholder' => __('E.g. p@$$w0rd', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "require('type', 'new') && require('set_password', true)", - ), - ), - 'submit_button' => array( + ], + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Create Customer', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ // 'v-bind:disabled' => '!confirmed', - ), - ), - ); + ], + ], + ]; $form = new \WP_Ultimo\UI\Form( 'add_new_customer', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'add_new_customer', 'data-state' => json_encode( - array( + [ 'set_password' => false, 'type' => 'existing', - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -279,19 +279,19 @@ class Customer_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_add_new_customer_modal() { + public function handle_add_new_customer_modal(): void { if (wu_request('type', 'existing') === 'new') { - $customer_data = array( + $customer_data = [ 'email' => wu_request('email_address'), 'username' => wu_request('username'), 'password' => wu_request('password', false), - 'meta' => array(), - ); + 'meta' => [], + ]; } else { - $customer_data = array( + $customer_data = [ 'user_id' => wu_request('user_id', 0), - ); + ]; } /* @@ -304,14 +304,14 @@ class Customer_List_Admin_Page extends List_Admin_Page { } wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url( 'wp-ultimo-edit-customer', - array( + [ 'id' => $customer->get_id(), - ) + ] ), - ) + ] ); } @@ -331,10 +331,10 @@ class Customer_List_Admin_Page extends List_Admin_Page { */ public function get_labels() { - return array( + return [ 'deleted_message' => __('Customer removed successfully.', 'wp-ultimo'), 'search_label' => __('Search Customer', 'wp-ultimo'), - ); + ]; } /** @@ -378,24 +378,24 @@ class Customer_List_Admin_Page extends List_Admin_Page { */ public function action_links() { - return array( - array( + return [ + [ 'label' => __('Add Customer', 'wp-ultimo'), 'icon' => 'wu-circle-with-plus', 'classes' => 'wubox', 'url' => wu_get_form_url('add_new_customer'), - ), - array( + ], + [ 'label' => __('Export as CSV', 'wp-ultimo'), 'icon' => 'wu-export', 'url' => add_query_arg( - array( + [ 'wu_action' => 'wu_export_customers', 'nonce' => wp_create_nonce('wu_export_customers'), - ) + ] ), - ), - ); + ], + ]; } /** diff --git a/inc/admin-pages/class-customizer-admin-page.php b/inc/admin-pages/class-customizer-admin-page.php index 2702e54..05226ec 100644 --- a/inc/admin-pages/class-customizer-admin-page.php +++ b/inc/admin-pages/class-customizer-admin-page.php @@ -50,7 +50,7 @@ abstract class Customizer_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function page_loaded() { + public function page_loaded(): void { /** * Process save, if necessary @@ -59,7 +59,7 @@ abstract class Customizer_Admin_Page extends Edit_Admin_Page { $screen = get_current_screen(); - add_action("wu_edit_{$screen->id}_after_normal", array($this, 'display_preview_window')); + add_action("wu_edit_{$screen->id}_after_normal", [$this, 'display_preview_window']); } /** @@ -68,14 +68,14 @@ abstract class Customizer_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function display_preview_window() { + public function display_preview_window(): void { wu_get_template( 'base/edit/editor-customizer', - array( + [ 'preview_iframe_url' => $this->get_preview_url(), 'preview_height' => $this->preview_height, - ) + ] ); } @@ -85,11 +85,11 @@ abstract class Customizer_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { parent::register_scripts(); - wp_enqueue_script('wu-customizer', wu_get_asset('customizer.js', 'js'), array('jquery', 'wu-vue', 'wu-block-ui')); + wp_enqueue_script('wu-customizer', wu_get_asset('customizer.js', 'js'), ['jquery', 'wu-vue', 'wu-block-ui']); wp_enqueue_style('wp-color-picker'); diff --git a/inc/admin-pages/class-dashboard-admin-page.php b/inc/admin-pages/class-dashboard-admin-page.php index bcff1e5..547647a 100644 --- a/inc/admin-pages/class-dashboard-admin-page.php +++ b/inc/admin-pages/class-dashboard-admin-page.php @@ -60,9 +60,9 @@ class Dashboard_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_read_dashboard', - ); + ]; /** * The tab being displayed. @@ -94,7 +94,7 @@ class Dashboard_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { parent::init(); @@ -113,11 +113,11 @@ class Dashboard_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function hooks() { + public function hooks(): void { - add_action('wu_dash_after_full_metaboxes', array($this, 'render_filter')); + add_action('wu_dash_after_full_metaboxes', [$this, 'render_filter']); - add_action('wu_dashboard_general_widgets', array($this, 'register_general_tab_widgets'), 10, 2); + add_action('wu_dashboard_general_widgets', [$this, 'register_general_tab_widgets'], 10, 2); } /** @@ -128,32 +128,32 @@ class Dashboard_Admin_Page extends Base_Admin_Page { * @param WP_Ultimo\Admin_Pages\Base_Admin_Page $page The page object. * @return void */ - public function render_filter($page) { + public function render_filter($page): void { if (apply_filters('wu_dashboard_display_filter', true) === false) { return; } if ($page->id === 'wp-ultimo') { - $preset_options = array( - 'last_7_days' => array( + $preset_options = [ + 'last_7_days' => [ 'label' => __('Last 7 days', 'wp-ultimo'), 'start_date' => date_i18n('Y-m-d', strtotime('-7 days')), 'end_date' => date_i18n('Y-m-d'), - ), - 'last_30_days' => array( + ], + 'last_30_days' => [ 'label' => __('Last 30 days', 'wp-ultimo'), 'start_date' => date_i18n('Y-m-d', strtotime('-30 days')), 'end_date' => date_i18n('Y-m-d'), - ), - 'year_to_date' => array( + ], + 'year_to_date' => [ 'label' => __('Year to date', 'wp-ultimo'), 'start_date' => date_i18n('Y-m-d', strtotime('first day of january this year')), 'end_date' => date_i18n('Y-m-d'), - ), - ); + ], + ]; - $args = array( + $args = [ 'preset_options' => $preset_options, 'filters_el_id' => 'dashboard-filters', 'search_label' => '', @@ -162,7 +162,7 @@ class Dashboard_Admin_Page extends Base_Admin_Page { 'table' => $this, 'active_tab' => $this->tab, 'views' => $this->get_views(), - ); + ]; wu_get_template('dashboard-statistics/filter', $args); } @@ -176,14 +176,14 @@ class Dashboard_Admin_Page extends Base_Admin_Page { */ public function get_views() { - $dashboard_filters = array( - 'general' => array( + $dashboard_filters = [ + 'general' => [ 'field' => 'type', 'url' => add_query_arg('tab', 'general'), 'label' => __('General', 'wp-ultimo'), 'count' => 0, - ), - ); + ], + ]; return apply_filters('wu_dashboard_filter_bar', $dashboard_filters); } @@ -194,7 +194,7 @@ class Dashboard_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { $screen = get_current_screen(); @@ -227,49 +227,49 @@ class Dashboard_Admin_Page extends Base_Admin_Page { if (wu_request('tab', 'general') === 'general') { \WP_Ultimo\UI\Tours::get_instance()->create_tour( 'wp-ultimo-dashboard', - array( - array( + [ + [ 'id' => 'your-dashboard', 'title' => __('Our dashboard', 'wp-ultimo'), - 'text' => array( + 'text' => [ __('This is the WP Multisite WaaS Dashboard, where you will find most of the important information you will need regarding your business\' performance.', 'wp-ultimo'), - ), - ), - array( + ], + ], + [ 'id' => 'documentation', 'title' => __('Learning more', 'wp-ultimo'), - 'text' => array( + 'text' => [ __('Most of the WP Multisite WaaS admin pages will contain a link like this one at the top. These will link directly to the relevant knowledge base page on the WP Multisite WaaS site.', 'wp-ultimo'), - ), - 'attachTo' => array( + ], + 'attachTo' => [ 'element' => '#wp-ultimo-wrap > h1 > a:last-child', 'on' => 'left', - ), - ), - array( + ], + ], + [ 'id' => 'mrr-growth', 'title' => __('It\'s all about growth!', 'wp-ultimo'), - 'text' => array( + 'text' => [ __('This graph allows you to follow how your monthly recurring revenue is growing this year.', 'wp-ultimo'), - ), - 'attachTo' => array( + ], + 'attachTo' => [ 'element' => '#wp-ultimo-mrr-growth', 'on' => 'bottom', - ), - ), - array( + ], + ], + [ 'id' => 'tailor-made', 'title' => __('Date-range support', 'wp-ultimo'), - 'text' => array( + 'text' => [ __('Checking statistics and comparing data for different periods is key in maintaining a good grasp on your business.', 'wp-ultimo'), __('You can use the date-range selectors to have access to just the data you need and nothing more.', 'wp-ultimo'), - ), - 'attachTo' => array( + ], + 'attachTo' => [ 'element' => '#dashboard-filters', 'on' => 'bottom', - ), - ), - ) + ], + ], + ] ); } } @@ -283,21 +283,21 @@ class Dashboard_Admin_Page extends Base_Admin_Page { * @param \WP_Screen $screen The screen object. * @return void */ - public function register_general_tab_widgets($tab, $screen) { + public function register_general_tab_widgets($tab, $screen): void { if (current_user_can('wu_read_financial')) { - add_meta_box('wp-ultimo-mrr-growth', __('Monthly Recurring Revenue Growth', 'wp-ultimo'), array($this, 'output_widget_mrr_growth'), $screen->id, 'full', 'high'); + add_meta_box('wp-ultimo-mrr-growth', __('Monthly Recurring Revenue Growth', 'wp-ultimo'), [$this, 'output_widget_mrr_growth'], $screen->id, 'full', 'high'); - add_meta_box('wp-ultimo-revenue', __('Revenue', 'wp-ultimo'), array($this, 'output_widget_revenues'), $screen->id, 'normal', 'high'); + add_meta_box('wp-ultimo-revenue', __('Revenue', 'wp-ultimo'), [$this, 'output_widget_revenues'], $screen->id, 'normal', 'high'); } - add_meta_box('wp-ultimo-countries', __('Signups by Countries', 'wp-ultimo'), array($this, 'output_widget_countries'), $screen->id, 'side', 'high'); + add_meta_box('wp-ultimo-countries', __('Signups by Countries', 'wp-ultimo'), [$this, 'output_widget_countries'], $screen->id, 'side', 'high'); - add_meta_box('wp-ultimo-signups', __('Signups by Form', 'wp-ultimo'), array($this, 'output_widget_forms'), $screen->id, 'side', 'high'); + add_meta_box('wp-ultimo-signups', __('Signups by Form', 'wp-ultimo'), [$this, 'output_widget_forms'], $screen->id, 'side', 'high'); - add_meta_box('wp-ultimo-most-visited-sites', __('Most Visited Sites', 'wp-ultimo'), array($this, 'output_widget_most_visited_sites'), $screen->id, 'side', 'low'); + add_meta_box('wp-ultimo-most-visited-sites', __('Most Visited Sites', 'wp-ultimo'), [$this, 'output_widget_most_visited_sites'], $screen->id, 'side', 'low'); - add_meta_box('wp-ultimo-new-accounts', __('New Memberships', 'wp-ultimo'), array($this, 'output_widget_new_accounts'), $screen->id, 'normal', 'low'); + add_meta_box('wp-ultimo-new-accounts', __('New Memberships', 'wp-ultimo'), [$this, 'output_widget_new_accounts'], $screen->id, 'normal', 'low'); } /** @@ -306,7 +306,7 @@ class Dashboard_Admin_Page extends Base_Admin_Page { * @return void * @since 2.0.0 */ - public function output_widget_mrr_growth() { + public function output_widget_mrr_growth(): void { wu_get_template('dashboard-statistics/widget-mrr-growth'); } @@ -317,14 +317,14 @@ class Dashboard_Admin_Page extends Base_Admin_Page { * @return void * @since 2.0.0 */ - public function output_widget_countries() { + public function output_widget_countries(): void { wu_get_template( 'dashboard-statistics/widget-countries', - array( + [ 'countries' => wu_get_countries_of_customers(10, $this->start_date, $this->end_date), 'page' => $this, - ) + ] ); } @@ -334,14 +334,14 @@ class Dashboard_Admin_Page extends Base_Admin_Page { * @return void * @since 2.0.0 */ - public function output_widget_forms() { + public function output_widget_forms(): void { wu_get_template( 'dashboard-statistics/widget-forms', - array( + [ 'forms' => wu_calculate_signups_by_form($this->start_date, $this->end_date), 'page' => $this, - ) + ] ); } @@ -351,9 +351,9 @@ class Dashboard_Admin_Page extends Base_Admin_Page { * @return void * @since 2.0.0 */ - public function output_widget_most_visited_sites() { + public function output_widget_most_visited_sites(): void { - $sites = array(); + $sites = []; $site_results = \WP_Ultimo\Objects\Visits::get_sites_by_visit_count($this->start_date, $this->end_date, 10); @@ -364,18 +364,18 @@ class Dashboard_Admin_Page extends Base_Admin_Page { continue; } - $sites[] = (object) array( + $sites[] = (object) [ 'site' => $site, 'count' => $site_result->count, - ); + ]; } wu_get_template( 'dashboard-statistics/widget-most-visited-sites', - array( + [ 'sites' => $sites, 'page' => $this, - ) + ] ); } @@ -388,16 +388,16 @@ class Dashboard_Admin_Page extends Base_Admin_Page { * @param array $metabox With the metabox arguments passed when registered. * @return void. */ - public function output_widget_revenues($unknown = null, $metabox = null) { + public function output_widget_revenues($unknown = null, $metabox = null): void { wu_get_template( 'dashboard-statistics/widget-revenue', - array( + [ 'mrr' => wu_calculate_mrr(), 'gross_revenue' => wu_calculate_revenue($this->start_date, $this->end_date), 'refunds' => wu_calculate_refunds($this->start_date, $this->end_date), 'product_stats' => wu_calculate_financial_data_by_product($this->start_date, $this->end_date), - ) + ] ); } @@ -410,25 +410,25 @@ class Dashboard_Admin_Page extends Base_Admin_Page { * @param array $metabox With the metabox arguments passed when registered. * @return void. */ - public function output_widget_new_accounts($unknown = null, $metabox = array()) { + public function output_widget_new_accounts($unknown = null, $metabox = []): void { $new_accounts = wu_get_memberships( - array( - 'fields' => array('plan_id'), - 'date_query' => array( + [ + 'fields' => ['plan_id'], + 'date_query' => [ 'column' => 'date_created', 'after' => $this->start_date . ' 00:00:00', 'before' => $this->end_date . ' 23:59:59', 'inclusive' => true, - ), - ) + ], + ] ); $products = wu_get_products( - array( + [ 'type' => 'plan', - 'fields' => array('id', 'name', 'count'), - ) + 'fields' => ['id', 'name', 'count'], + ] ); $products_ids = array_column($products, 'id'); @@ -448,10 +448,10 @@ class Dashboard_Admin_Page extends Base_Admin_Page { /** * Add edge case for no plan. */ - $products['none'] = (object) array( + $products['none'] = (object) [ 'name' => __('No Product', 'wp-ultimo'), 'count' => 0, - ); + ]; foreach ($new_accounts as $new_account) { if (isset($products[ $new_account->plan_id ])) { @@ -463,10 +463,10 @@ class Dashboard_Admin_Page extends Base_Admin_Page { wu_get_template( 'dashboard-statistics/widget-new-accounts', - array( + [ 'new_accounts' => count($new_accounts), 'products' => $products, - ) + ] ); } @@ -476,9 +476,9 @@ class Dashboard_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { - $month_list = array(); + $month_list = []; $current_year = date_i18n('Y'); @@ -487,42 +487,42 @@ class Dashboard_Admin_Page extends Base_Admin_Page { } $statistics = new Dashboard_Statistics( - array( + [ 'start_date' => $this->start_date, 'end_date' => $this->end_date, - 'types' => array( + 'types' => [ 'mrr_growth' => 'mrr_growth', - ), - ) + ], + ] ); $data = $statistics->statistics_data(); - wp_register_script('wu-apex-charts', wu_get_asset('apexcharts.js', 'js/lib'), array(), wu_get_version(), true); + wp_register_script('wu-apex-charts', wu_get_asset('apexcharts.js', 'js/lib'), [], wu_get_version(), true); - wp_register_script('wu-vue-apex-charts', wu_get_asset('vue-apexcharts.js', 'js/lib'), array(), wu_get_version(), true); + wp_register_script('wu-vue-apex-charts', wu_get_asset('vue-apexcharts.js', 'js/lib'), [], wu_get_version(), true); - wp_register_script('wu-dashboard-stats', wu_get_asset('dashboard-statistics.js', 'js'), array('jquery', 'wu-functions', 'wu-ajax-list-table', 'moment', 'wu-block-ui', 'dashboard', 'wu-apex-charts', 'wu-vue-apex-charts'), wu_get_version(), true); + wp_register_script('wu-dashboard-stats', wu_get_asset('dashboard-statistics.js', 'js'), ['jquery', 'wu-functions', 'wu-ajax-list-table', 'moment', 'wu-block-ui', 'dashboard', 'wu-apex-charts', 'wu-vue-apex-charts'], wu_get_version(), true); wp_localize_script( 'wu-dashboard-stats', 'wu_dashboard_statistics_vars', - array( + [ 'mrr_array' => $data['mrr_growth'], 'start_date' => date_i18n('Y-m-d', strtotime((string) wu_request('start_date', '-1 month'))), 'end_date' => date_i18n('Y-m-d', strtotime((string) wu_request('end_date', 'tomorrow'))), 'today' => date_i18n('Y-m-d', strtotime('tomorrow')), 'month_list' => $month_list, - 'i18n' => array( + 'i18n' => [ 'new_mrr' => __('New MRR', 'wp-ultimo'), 'cancellations' => __('Cancellations', 'wp-ultimo'), - ), - ) + ], + ] ); wp_enqueue_script('wu-dashboard-stats'); - wp_enqueue_style('wu-apex-charts', wu_get_asset('apexcharts.css', 'css'), array(), wu_get_version()); + wp_enqueue_style('wu-apex-charts', wu_get_asset('apexcharts.css', 'css'), [], wu_get_version()); wp_enqueue_style('wu-flags'); } @@ -566,17 +566,17 @@ class Dashboard_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function output() { + public function output(): void { /* * Renders the base edit page layout, with the columns and everything else =) */ wu_get_template( 'base/dash', - array( + [ 'screen' => get_current_screen(), 'page' => $this, 'has_full_position' => true, - ) + ] ); } @@ -588,16 +588,16 @@ class Dashboard_Admin_Page extends Base_Admin_Page { * @param array $args Data array to convert to CSV. * @return void */ - public function render_csv_button($args) { + public function render_csv_button($args): void { $args = wp_parse_args( $args, - array( + [ 'slug' => 'csv', - 'headers' => array(), - 'data' => array(), + 'headers' => [], + 'data' => [], 'action' => apply_filters('wu_export_data_table_action', 'wu_generate_csv'), - ) + ] ); $slug = $args['slug']; diff --git a/inc/admin-pages/class-discount-code-edit-admin-page.php b/inc/admin-pages/class-discount-code-edit-admin-page.php index cc1c2c3..322b784 100644 --- a/inc/admin-pages/class-discount-code-edit-admin-page.php +++ b/inc/admin-pages/class-discount-code-edit-admin-page.php @@ -77,9 +77,9 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_edit_discount_codes', - ); + ]; /** * Allow child classes to register widgets, if they need them. @@ -87,150 +87,150 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { parent::register_widgets(); $this->add_fields_widget( 'description', - array( + [ 'title' => __('Description', 'wp-ultimo'), 'position' => 'normal', - 'fields' => array( - 'description' => array( + 'fields' => [ + 'description' => [ 'type' => 'textarea', 'title' => __('Description', 'wp-ultimo'), 'placeholder' => __('Tell your customers what this product is about.', 'wp-ultimo'), 'value' => $this->get_object()->get_description(), - 'html_attr' => array( + 'html_attr' => [ 'rows' => 3, - ), - ), - ), - ) + ], + ], + ], + ] ); $tz_note = sprintf('The site timezone is %s. The current time is %s', date_i18n('e'), date_i18n('r')); - $options = array( - 'general' => array( + $options = [ + 'general' => [ 'title' => __('Limit Uses', 'wp-ultimo'), 'icon' => 'dashicons-wu-lock', 'desc' => __('Rules and limitations to the applicability of this discount code.', 'wp-ultimo'), - 'fields' => array( - 'uses' => array( + 'fields' => [ + 'uses' => [ 'title' => __('Uses', 'wp-ultimo'), 'type' => 'text-display', // translators: %d is the number of times the coupon was used. 'display_value' => sprintf(__('This discount code was used %d times.', 'wp-ultimo'), $this->get_object()->get_uses()), 'tooltip' => __('The number of times that this discount code was used so far.', 'wp-ultimo'), - ), - 'max_uses' => array( + ], + 'max_uses' => [ 'title' => __('Max Uses', 'wp-ultimo'), 'desc' => __('Use this option to set a limit on how many times this discount code can be used. Leave blank or 0 for unlimited uses.', 'wp-ultimo'), 'type' => 'number', 'min' => 0, 'placeholder' => 0, 'value' => $this->get_object()->has_max_uses() ? $this->get_object()->get_max_uses() : __('Unlimited', 'wp-ultimo'), - ), - ), - ), - 'time' => array( + ], + ], + ], + 'time' => [ 'title' => __('Start & Expiration Dates', 'wp-ultimo'), 'desc' => __('Define a start and end date for this discount code. Useful when running campaigns for a pre-determined period.', 'wp-ultimo'), 'icon' => 'dashicons-wu-calendar', - 'state' => array( + 'state' => [ 'enable_date_start' => $this->get_object()->get_date_start(), 'enable_date_expiration' => $this->get_object()->get_date_expiration(), - ), - 'fields' => array( - 'enable_date_start' => array( + ], + 'fields' => [ + 'enable_date_start' => [ 'type' => 'toggle', 'title' => __('Enable Start Date', 'wp-ultimo'), 'desc' => __('Allows you to set a start date for this coupon code.', 'wp-ultimo'), 'value' => 1, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'enable_date_start', - ), - ), - 'date_start' => array( + ], + ], + 'date_start' => [ 'title' => __('Start Date', 'wp-ultimo'), 'desc' => __('The discount code will only be good to be used after this date.', 'wp-ultimo') . ' ' . $tz_note, 'type' => 'text', 'date' => true, 'value' => $this->edit ? $this->get_object()->get_date_start() : __('No date', 'wp-ultimo'), 'placeholder' => 'E.g. 2020-04-04 12:00:00', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => 1, 'v-show' => 'enable_date_start', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-bind:name' => 'enable_date_start ? "date_start" : ""', 'wu-datepicker' => 'true', 'data-format' => 'Y-m-d H:i:S', 'data-allow-time' => 'true', - ), - ), - 'enable_date_expiration' => array( + ], + ], + 'enable_date_expiration' => [ 'type' => 'toggle', 'title' => __('Enable Expiration Date', 'wp-ultimo'), 'desc' => __('Allows you to set an expiration date for this coupon code.', 'wp-ultimo'), 'value' => 1, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'enable_date_expiration', - ), - ), - 'date_expiration' => array( + ], + ], + 'date_expiration' => [ 'title' => __('Expiration Date', 'wp-ultimo'), 'desc' => __('The discount code will expire after this date.', 'wp-ultimo') . ' ' . $tz_note, 'type' => 'text', 'date' => true, 'value' => $this->edit ? $this->get_object()->get_date_expiration() : __('Never Expires', 'wp-ultimo'), 'placeholder' => 'E.g. 2020-04-04 12:00:00', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => 1, 'v-show' => 'enable_date_expiration', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-bind:name' => 'enable_date_expiration ? "date_expiration" : ""', 'wu-datepicker' => 'true', 'data-format' => 'Y-m-d H:i:S', 'data-allow-time' => 'true', - ), - ), - ), - ), - 'products' => array( + ], + ], + ], + ], + 'products' => [ 'title' => __('Limit Products', 'wp-ultimo'), 'desc' => __('Determine if you want this discount code to apply to all discountable products or not.', 'wp-ultimo'), 'icon' => 'dashicons-wu-price-tag', - 'state' => array( + 'state' => [ 'limit_products' => $this->get_object()->get_limit_products(), - ), + ], 'fields' => array_merge( - array( - 'limit_products' => array( + [ + 'limit_products' => [ 'type' => 'toggle', 'title' => __('Select Products', 'wp-ultimo'), 'desc' => __('Manually select to which products this discount code should be applicable.', 'wp-ultimo'), 'value' => 1, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'limit_products', - ), - ), - ), + ], + ], + ], $this->get_product_field_list() ), - ), - ); + ], + ]; $this->add_tabs_widget( 'options', - array( + [ 'title' => __('Advanced Options', 'wp-ultimo'), 'position' => 'normal', 'sections' => apply_filters('wu_discount_code_options_sections', $options, $this->get_object()), - ) + ] ); /* @@ -240,151 +240,151 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page { $this->add_list_table_widget( 'events', - array( + [ 'title' => __('Events', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(), - 'query_filter' => array($this, 'query_filter'), - ) + 'query_filter' => [$this, 'query_filter'], + ] ); $this->add_save_widget( 'save', - array( - 'html_attr' => array( + [ + 'html_attr' => [ 'data-wu-app' => 'save_discount_code', 'data-state' => wu_convert_to_state( - array( + [ 'apply_to_setup_fee' => $this->get_object()->get_setup_fee_value() > 0, 'code' => $this->get_object()->get_code(), 'type' => $this->get_object()->get_type(), 'value' => $this->get_object()->get_value(), 'setup_fee_type' => $this->get_object()->get_setup_fee_type(), 'setup_fee_value' => $this->get_object()->get_setup_fee_value(), - ) + ] ), - ), - 'fields' => array( - 'code' => array( + ], + 'fields' => [ + 'code' => [ 'title' => __('Coupon Code', 'wp-ultimo'), 'type' => 'text', 'placeholder' => __('E.g. XMAS10OFF', 'wp-ultimo'), 'desc' => __('The actual code your customers will enter during checkout.', 'wp-ultimo'), 'value' => $this->get_object()->get_code(), 'tooltip' => '', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-on:input' => 'code = $event.target.value.toUpperCase().replace(/[^A-Z0-9-_]+/g, "")', 'v-bind:value' => 'code', - ), - ), - 'value_group' => array( + ], + ], + 'value_group' => [ 'type' => 'group', 'title' => __('Discount', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - 'fields' => array( - 'type' => array( + ], + 'fields' => [ + 'type' => [ 'type' => 'select', 'value' => $this->get_object()->get_type(), 'placeholder' => '', 'wrapper_classes' => 'wu-w-2/3', - 'options' => array( + 'options' => [ 'percentage' => __('Percentage (%)', 'wp-ultimo'), // translators: %s is the currency symbol. e.g. $ 'absolute' => sprintf(__('Absolute (%s)', 'wp-ultimo'), wu_get_currency_symbol()), - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'type', - ), - ), - 'value' => array( + ], + ], + 'value' => [ 'type' => 'number', 'value' => $this->get_object()->get_value(), 'placeholder' => '', 'wrapper_classes' => 'wu-ml-2 wu-w-1/3', - 'html_attr' => array( + 'html_attr' => [ 'min' => 0, 'v-bind:max' => "type === 'percentage' ? 100 : 999999999", 'step' => 'any', - ), - ), - ), - ), - 'apply_to_renewals' => array( + ], + ], + ], + ], + 'apply_to_renewals' => [ 'type' => 'toggle', 'title' => __('Apply to Renewals', 'wp-ultimo'), 'desc' => __('By default, discounts are only applied to the first payment.', 'wp-ultimo'), 'value' => $this->get_object()->should_apply_to_renewals(), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - ), - 'apply_to_setup_fee' => array( + ], + ], + 'apply_to_setup_fee' => [ 'type' => 'toggle', 'title' => __('Setup Fee Discount', 'wp-ultimo'), 'desc' => __('Also set a discount for setup fee?', 'wp-ultimo'), 'value' => $this->get_object()->get_setup_fee_value() > 0, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'apply_to_setup_fee', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - ), - 'setup_fee_value_group' => array( + ], + ], + 'setup_fee_value_group' => [ 'type' => 'group', 'title' => __('Setup Fee Discount', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'apply_to_setup_fee', 'v-cloak' => '1', - ), - 'fields' => array( - 'setup_fee_type' => array( + ], + 'fields' => [ + 'setup_fee_type' => [ 'type' => 'select', 'value' => $this->get_object()->get_setup_fee_type(), 'placeholder' => '', 'wrapper_classes' => 'wu-w-2/3', - 'options' => array( + 'options' => [ 'percentage' => __('Percentage (%)', 'wp-ultimo'), // translators: %s is the currency symbol. e.g $ 'absolute' => sprintf(__('Absolute (%s)', 'wp-ultimo'), wu_get_currency_symbol()), - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'setup_fee_type', - ), - ), - 'setup_fee_value' => array( + ], + ], + 'setup_fee_value' => [ 'type' => 'number', 'value' => $this->get_object()->get_setup_fee_value(), 'placeholder' => '', 'wrapper_classes' => 'wu-ml-2 wu-w-1/3', - 'html_attr' => array( + 'html_attr' => [ 'min' => 0, 'v-bind:max' => "setup_fee_type === 'percentage' ? 100 : 999999999", - ), - ), - ), - ), - ), - ) + ], + ], + ], + ], + ], + ] ); $this->add_fields_widget( 'active', - array( + [ 'title' => __('Active', 'wp-ultimo'), - 'fields' => array( - 'active' => array( + 'fields' => [ + 'active' => [ 'type' => 'toggle', 'title' => __('Active', 'wp-ultimo'), 'desc' => __('Use this option to manually enable or disable this discount code for new sign-ups.', 'wp-ultimo'), 'value' => $this->get_object()->is_active(), - ), - ), - ) + ], + ], + ] ); } @@ -396,48 +396,48 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page { */ protected function get_product_field_list() { - $fields = array(); + $fields = []; foreach (wu_get_products() as $product) { $product_id = $product->get_id(); - $fields[ "allowed_products_{$product_id}" ] = array( + $fields[ "allowed_products_{$product_id}" ] = [ 'type' => 'toggle', 'title' => $product->get_name(), 'desc' => __('Make applicable to this product.', 'wp-ultimo'), 'tooltip' => '', 'wrapper_classes' => '', - 'html_attr' => array( + 'html_attr' => [ ':name' => "'allowed_products[]'", ':checked' => json_encode(!$this->get_object()->get_limit_products() || in_array($product_id, $this->get_object()->get_allowed_products())), // phpcs:ignore ':value' => $product_id, - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-cloak' => 1, 'v-show' => 'limit_products', - ), - ); + ], + ]; // TODO: this is a hack-y fix. Needs to be re-implemented. - $fields['allowed_products_none'] = array( + $fields['allowed_products_none'] = [ 'type' => 'hidden', 'value' => '__none', - 'html_attr' => array( + 'html_attr' => [ ':name' => "'allowed_products[]'", - ), - ); + ], + ]; } if (empty($fields)) { - $fields['allowed_products_no_products'] = array( + $fields['allowed_products_no_products'] = [ 'type' => 'note', 'title' => '', 'desc' => __('You do not have any products at this moment.', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => 1, 'v-show' => 'limit_products', - ), - ); + ], + ]; } return $fields; @@ -449,11 +449,11 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_legacy_options() { + public function handle_legacy_options(): void { global $wp_filter; - $tabs = array(__('Legacy Add-ons', 'wp-ultimo')); + $tabs = [__('Legacy Add-ons', 'wp-ultimo')]; if ( ! isset($wp_filter['wp_ultimo_coupon_advanced_options'])) { return; @@ -463,40 +463,40 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page { $priorities = $wp_filter['wp_ultimo_coupon_advanced_options']->callbacks; - $fields = array( - 'heading' => array( + $fields = [ + 'heading' => [ 'type' => 'header', 'title' => __('Legacy Options', 'wp-ultimo'), // translators: %s is the comma-separated list of legacy add-ons. 'desc' => sprintf(__('Options for %s, and others.', 'wp-ultimo'), implode(', ', $tabs)), - ), - ); + ], + ]; foreach ($priorities as $priority => $callbacks) { foreach ($callbacks as $id => $callable) { - $fields[ $id ] = array( + $fields[ $id ] = [ 'type' => 'html', 'classes' => 'wu--mt-2', 'content' => function () use ($callable) { call_user_func($callable['function'], $this->get_object()); }, - ); + ]; } } $this->add_fields_widget( 'legacy-options', - array( + [ 'title' => __('Legacy Options', 'wp-ultimo'), 'position' => 'normal', 'fields' => $fields, 'classes' => 'wu-legacy-options-panel', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'style' => 'margin-top: -5px;', - ), - ) + ], + ] ); } @@ -506,16 +506,16 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function register_forms() { + public function register_forms(): void { /* * Delete Discount code - Confirmation modal */ add_filter( 'wu_data_json_success_delete_discount_code_modal', - fn($data_json) => array( - 'redirect_url' => wu_network_admin_url('wp-ultimo-discount-codes', array('deleted' => 1)), - ) + fn($data_json) => [ + 'redirect_url' => wu_network_admin_url('wp-ultimo-discount-codes', ['deleted' => 1]), + ] ); } @@ -529,10 +529,10 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page { */ public function query_filter($args) { - $extra_args = array( + $extra_args = [ 'object_type' => 'discount_code', 'object_id' => absint($this->get_object()->get_id()), - ); + ]; return array_merge($args, $extra_args); } @@ -567,7 +567,7 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page { */ public function action_links() { - return array(); + return []; } /** @@ -578,7 +578,7 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page { */ public function get_labels() { - return array( + return [ 'edit_label' => __('Edit Discount Code', 'wp-ultimo'), 'add_new_label' => __('Add new Discount Code', 'wp-ultimo'), 'updated_message' => __('Discount Code updated successfully!', 'wp-ultimo'), @@ -588,7 +588,7 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page { 'save_description' => '', 'delete_button_label' => __('Delete Discount Code', 'wp-ultimo'), 'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'), - ); + ]; } /** @@ -639,7 +639,7 @@ class Discount_Code_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_save() { + public function handle_save(): void { /* * Set the recurring value to zero if the toggle is disabled. */ diff --git a/inc/admin-pages/class-discount-code-list-admin-page.php b/inc/admin-pages/class-discount-code-list-admin-page.php index 042a8f9..a31a898 100644 --- a/inc/admin-pages/class-discount-code-list-admin-page.php +++ b/inc/admin-pages/class-discount-code-list-admin-page.php @@ -50,9 +50,9 @@ class Discount_Code_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_read_discount_codes', - ); + ]; /** * Allow child classes to register widgets, if they need them. @@ -70,10 +70,10 @@ class Discount_Code_List_Admin_Page extends List_Admin_Page { */ public function get_labels() { - return array( + return [ 'deleted_message' => __('Discount Code removed successfully.', 'wp-ultimo'), 'search_label' => __('Search Discount Code', 'wp-ultimo'), - ); + ]; } /** @@ -117,13 +117,13 @@ class Discount_Code_List_Admin_Page extends List_Admin_Page { */ public function action_links() { - return array( - array( + return [ + [ 'url' => wu_network_admin_url('wp-ultimo-edit-discount-code'), 'label' => __('Add Discount Code'), 'icon' => 'wu-circle-with-plus', - ), - ); + ], + ]; } /** diff --git a/inc/admin-pages/class-domain-edit-admin-page.php b/inc/admin-pages/class-domain-edit-admin-page.php index fa364e7..1c5e214 100644 --- a/inc/admin-pages/class-domain-edit-admin-page.php +++ b/inc/admin-pages/class-domain-edit-admin-page.php @@ -76,9 +76,9 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_edit_domains', - ); + ]; /** * Register ajax forms. @@ -86,13 +86,13 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function register_forms() { + public function register_forms(): void { /* * Adds the hooks to handle deletion. */ - add_filter('wu_form_fields_delete_domain_modal', array($this, 'domain_extra_delete_fields'), 10, 2); + add_filter('wu_form_fields_delete_domain_modal', [$this, 'domain_extra_delete_fields'], 10, 2); - add_action('wu_after_delete_domain_modal', array($this, 'domain_after_delete_actions')); + add_action('wu_after_delete_domain_modal', [$this, 'domain_after_delete_actions']); } /** @@ -116,47 +116,47 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page { $has_other_domains = is_countable($other_domains) ? count($other_domains) - 1 : false; } - $custom_fields = array( - 'set_domain_as_primary' => array( + $custom_fields = [ + 'set_domain_as_primary' => [ 'type' => 'model', 'title' => __('Set another domain as primary', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'data-model' => 'domain', 'data-value-field' => 'id', 'data-label-field' => 'domain', 'data-search-field' => 'domain', 'data-max-items' => 1, - 'data-exclude' => json_encode(array($domain->get_id())), + 'data-exclude' => json_encode([$domain->get_id()]), 'data-include' => json_encode($domain->get_blog_id()), - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-if' => $is_primary_domain && $has_other_domains ? 'true' : 'false', - ), - ), - 'confirm' => array( + ], + ], + 'confirm' => [ 'type' => 'toggle', 'title' => __('Confirm Deletion', 'wp-ultimo'), 'desc' => __('This action can not be undone.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'confirmed', - ), - ), - 'submit_button' => array( + ], + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Delete', 'wp-ultimo'), 'placeholder' => __('Delete', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:disabled' => '!confirmed', - ), - ), - 'id' => array( + ], + ], + 'id' => [ 'type' => 'hidden', 'value' => $domain->get_id(), - ), - ); + ], + ]; return array_merge($custom_fields, $fields); } @@ -169,7 +169,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page { * @param object $domain The domain object. * @return void */ - public function domain_after_delete_actions($domain) { + public function domain_after_delete_actions($domain): void { $new_primary_domain_name = wu_request('set_domain_as_primary'); @@ -188,180 +188,180 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { parent::register_widgets(); $this->add_fields_widget( 'domain-url', - array( + [ 'title' => __('Domain URL', 'wp-ultimo'), 'position' => 'normal', - 'after' => array($this, 'render_dns_widget'), - 'fields' => array( - 'domain' => array( + 'after' => [$this, 'render_dns_widget'], + 'fields' => [ + 'domain' => [ 'type' => 'text-display', 'title' => __('Domain', 'wp-ultimo'), 'tooltip' => __('Editing an existing domain is not possible. If you want to make changes to this domain, first delete it, and then re-add the right domain.', 'wp-ultimo'), 'display_value' => '' . $this->get_object()->get_domain() . ' ', - ), - ), - ) + ], + ], + ] ); $this->add_tabs_widget( 'options', - array( + [ 'title' => __('Domain Options', 'wp-ultimo'), 'position' => 'normal', - 'sections' => array( - 'general' => array( + 'sections' => [ + 'general' => [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General options for the domain.', 'wp-ultimo'), 'icon' => 'dashicons-wu-globe', - 'state' => array( + 'state' => [ 'primary_domain' => $this->get_object()->is_primary_domain(), - ), - 'fields' => array( - 'primary_domain' => array( + ], + 'fields' => [ + 'primary_domain' => [ 'type' => 'toggle', 'title' => __('Is Primary Domain?', 'wp-ultimo'), 'desc' => __('Set as the primary domain.', 'wp-ultimo'), 'tooltip' => __('Setting this as the primary domain will remove any other domain mapping marked as the primary domain for this site.', 'wp-ultimo'), 'value' => $this->get_object()->is_primary_domain(), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'primary_domain', - ), - ), - 'primary_note' => array( + ], + ], + 'primary_note' => [ 'type' => 'note', 'desc' => __('By making this the primary domain, we will convert the previous primary domain for this site, if one exists, into an alias domain.', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => "require('primary_domain', true)", - ), - ), - 'secure' => array( + ], + ], + 'secure' => [ 'type' => 'toggle', 'title' => __('Is Secure?', 'wp-ultimo'), 'desc' => __('Force the load using HTTPS.', 'wp-ultimo'), 'value' => $this->get_object()->is_secure(), - ), - ), - ), - ), - ) + ], + ], + ], + ], + ] ); $this->add_list_table_widget( 'sites', - array( + [ 'title' => __('Linked Site', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Memberships_Site_List_Table(), - 'query_filter' => array($this, 'sites_query_filter'), - ) + 'query_filter' => [$this, 'sites_query_filter'], + ] ); - add_meta_box('wp-ultimo-domain-log', __('Domain Test Log', 'wp-ultimo'), array($this, 'render_log_widget'), get_current_screen()->id, 'normal', null); + add_meta_box('wp-ultimo-domain-log', __('Domain Test Log', 'wp-ultimo'), [$this, 'render_log_widget'], get_current_screen()->id, 'normal', null); $this->add_list_table_widget( 'events', - array( + [ 'title' => __('Events', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(), - 'query_filter' => array($this, 'query_filter'), - ) + 'query_filter' => [$this, 'query_filter'], + ] ); $this->add_save_widget( 'save', - array( - 'html_attr' => array( + [ + 'html_attr' => [ 'data-wu-app' => 'save', 'data-state' => wu_convert_to_state( - array( + [ 'stage' => $this->get_object()->get_stage(), - ) + ] ), - ), - 'fields' => array( - 'stage' => array( + ], + 'fields' => [ + 'stage' => [ 'type' => 'select', 'title' => __('Stage', 'wp-ultimo'), 'placeholder' => __('Select Stage', 'wp-ultimo'), 'desc' => __('The stage in the checking lifecycle of this domain.', 'wp-ultimo'), 'options' => Domain_Stage::to_array(), 'value' => $this->get_object()->get_stage(), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ '@change' => 'window.wu_basic.stage = $event.target.value', 'v-model' => 'stage', - ), - ), - 'blog_id' => array( + ], + ], + 'blog_id' => [ 'type' => 'model', 'title' => __('Site', 'wp-ultimo'), 'placeholder' => __('Search Site...', 'wp-ultimo'), 'desc' => __('The target site of this domain.', 'wp-ultimo'), 'value' => $this->get_object()->get_blog_id(), 'tooltip' => '', - 'html_attr' => array( + 'html_attr' => [ 'data-model' => 'site', 'data-value-field' => 'blog_id', 'data-label-field' => 'title', 'data-search-field' => 'title', 'data-max-items' => 1, 'data-selected' => $this->get_object()->get_site() ? json_encode($this->get_object()->get_site()->to_search_results()) : '', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - ), - ), - ) + ], + ], + ], + ] ); $check_for_active_string = sprintf('%s.includes(stage)', json_encode(\WP_Ultimo\Models\Domain::INACTIVE_STAGES)); $this->add_fields_widget( 'basic', - array( + [ 'title' => __('Active', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'basic', 'data-state' => wu_convert_to_state( - array( + [ 'stage' => $this->get_object()->get_stage(), - ) + ] ), - ), - 'fields' => array( - 'active' => array( + ], + 'fields' => [ + 'active' => [ 'type' => 'toggle', 'title' => __('Active', 'wp-ultimo'), 'desc' => __('Use this option to manually enable or disable this domain.', 'wp-ultimo'), 'value' => $this->get_object()->is_active(), - 'html_attr' => array( + 'html_attr' => [ 'v-cloak' => '1', 'v-bind:disabled' => $check_for_active_string, - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-bind:class' => "$check_for_active_string ? 'wu-cursor-not-allowed wu-opacity-75' : ''", - ), + ], - ), - 'note' => array( + ], + 'note' => [ 'type' => 'note', 'desc' => __('This domain has a domain stage that forces it to be inactive. Change the status to Ready or Ready (without SSL) to be able to control the active status directly.', 'wp-ultimo'), 'classes' => 'wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-w-full', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => $check_for_active_string, 'v-cloak' => '1', - ), - ), - ), - ) + ], + ], + ], + ] ); } @@ -371,13 +371,13 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function render_dns_widget() { + public function render_dns_widget(): void { wu_get_template( 'domain/dns-table', - array( + [ 'domain' => $this->get_object(), - ) + ] ); } @@ -387,14 +387,14 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function render_log_widget() { + public function render_log_widget(): void { wu_get_template( 'domain/log', - array( + [ 'domain' => $this->get_object(), 'log_path' => \WP_Ultimo\Logger::get_logs_folder(), - ) + ] ); } @@ -428,7 +428,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page { */ public function action_links() { - return array(); + return []; } /** @@ -439,7 +439,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page { */ public function get_labels() { - return array( + return [ 'edit_label' => __('Edit Domain', 'wp-ultimo'), 'add_new_label' => __('Add new Domain', 'wp-ultimo'), 'updated_message' => __('Domain updated with success!', 'wp-ultimo'), @@ -449,7 +449,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page { 'save_description' => '', 'delete_button_label' => __('Delete Domain', 'wp-ultimo'), 'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'), - ); + ]; } /** @@ -462,10 +462,10 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page { */ public function query_filter($args) { - $extra_args = array( + $extra_args = [ 'object_type' => 'domain', 'object_id' => absint($this->get_object()->get_id()), - ); + ]; return array_merge($args, $extra_args); } @@ -527,7 +527,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_save() { + public function handle_save(): void { if ( ! wu_request('primary_domain')) { $_POST['primary_domain'] = false; @@ -541,7 +541,7 @@ class Domain_Edit_Admin_Page extends Edit_Admin_Page { $_POST['secure'] = false; } - wu_enqueue_async_action('wu_async_process_domain_stage', array('domain_id' => $this->get_object()->get_id()), 'domain'); + wu_enqueue_async_action('wu_async_process_domain_stage', ['domain_id' => $this->get_object()->get_id()], 'domain'); parent::handle_save(); } diff --git a/inc/admin-pages/class-domain-list-admin-page.php b/inc/admin-pages/class-domain-list-admin-page.php index 811d219..bbc26ee 100644 --- a/inc/admin-pages/class-domain-list-admin-page.php +++ b/inc/admin-pages/class-domain-list-admin-page.php @@ -53,9 +53,9 @@ class Domain_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_read_domains', - ); + ]; /** * Register ajax forms that we use for payments. @@ -63,17 +63,17 @@ class Domain_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function register_forms() { + public function register_forms(): void { /* * Add new Domain */ wu_register_form( 'add_new_domain', - array( - 'render' => array($this, 'render_add_new_domain_modal'), - 'handler' => array($this, 'handle_add_new_domain_modal'), + [ + 'render' => [$this, 'render_add_new_domain_modal'], + 'handler' => [$this, 'handle_add_new_domain_modal'], 'capability' => 'wu_edit_domains', - ) + ] ); } @@ -83,127 +83,127 @@ class Domain_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function render_add_new_domain_modal() { + public function render_add_new_domain_modal(): void { $addon_url = wu_network_admin_url( 'wp-ultimo-addons', - array( + [ 's' => 'Domain Seller', - ) + ] ); // translators: %s is the URL to the add-on. $note_desc = sprintf(__('To activate this feature you need to install the WP Multisite WaaS: Domain Seller add-on.', 'wp-ultimo'), $addon_url); - $fields = array( - 'type' => array( + $fields = [ + 'type' => [ 'type' => 'tab-select', - 'options' => array( + 'options' => [ 'add' => __('Add Existing Domain', 'wp-ultimo'), 'register' => __('Register New', 'wp-ultimo'), - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'type', - ), - ), - 'domain' => array( + ], + ], + 'domain' => [ 'type' => 'text', 'title' => __('Domain', 'wp-ultimo'), 'placeholder' => __('E.g. mydomain.com', 'wp-ultimo'), 'desc' => __('Be sure the domain has the right DNS setup in place before adding it.', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "require('type', 'add')", - ), - ), - 'blog_id' => array( + ], + ], + 'blog_id' => [ 'type' => 'model', 'title' => __('Apply to Site', 'wp-ultimo'), 'placeholder' => __('Search Sites...', 'wp-ultimo'), 'desc' => __('The target site of the domain being added.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'data-model' => 'site', 'data-value-field' => 'blog_id', 'data-label-field' => 'title', 'data-search-field' => 'title', 'data-max-items' => 1, - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => "require('type', 'add')", - ), - ), - 'stage' => array( + ], + ], + 'stage' => [ 'type' => 'select', 'title' => __('Stage', 'wp-ultimo'), 'placeholder' => __('Select Stage', 'wp-ultimo'), 'desc' => __('The stage in the domain check lifecycle. Leave "Checking DNS" to have the domain go through WP Multisite WaaS\'s automated tests.', 'wp-ultimo'), 'options' => Domain_Stage::to_array(), 'value' => Domain_Stage::CHECKING_DNS, - ), - 'primary_domain' => array( + ], + 'primary_domain' => [ 'type' => 'toggle', 'title' => __('Primary Domain', 'wp-ultimo'), 'desc' => __('Check to set this domain as the primary', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'primary_domain', - ), - ), - 'primary_note' => array( + ], + ], + 'primary_note' => [ 'type' => 'note', 'desc' => __('By making this the primary domain, we will convert the previous primary domain for this site, if one exists, into an alias domain.', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "require('primary_domain', true)", - ), - ), - 'submit_button_new' => array( + ], + ], + 'submit_button_new' => [ 'type' => 'submit', 'title' => __('Add Existing Domain', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "require('type', 'add')", - ), - ), - 'addon_note' => array( + ], + ], + 'addon_note' => [ 'type' => 'note', 'desc' => $note_desc, 'classes' => 'wu-p-2 wu-bg-blue-100 wu-text-gray-600 wu-rounded wu-w-full', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "require('type', 'register')", - ), - ), - 'submit_button_register' => array( + ], + ], + 'submit_button_register' => [ 'type' => 'submit', 'title' => __('Register and Add Domain (soon)', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "require('type', 'register')", - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'disabled' => 'disabled', - ), - ), - ); + ], + ], + ]; $form = new \WP_Ultimo\UI\Form( 'add_new_domain', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'add_new_domain', 'data-state' => json_encode( - array( + [ 'type' => 'add', 'primary_domain' => false, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -215,7 +215,7 @@ class Domain_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_add_new_domain_modal() { + public function handle_add_new_domain_modal(): void { /** * Fires before handle the add new domain modal request. @@ -229,12 +229,12 @@ class Domain_List_Admin_Page extends List_Admin_Page { * Tries to create the domain */ $domain = wu_create_domain( - array( + [ 'domain' => wu_request('domain'), 'stage' => wu_request('stage'), 'blog_id' => (int) wu_request('blog_id'), 'primary_domain' => (bool) wu_request('primary_domain'), - ) + ] ); if (is_wp_error($domain)) { @@ -243,31 +243,31 @@ class Domain_List_Admin_Page extends List_Admin_Page { if (wu_request('primary_domain')) { $old_primary_domains = wu_get_domains( - array( + [ 'primary_domain' => true, 'blog_id' => wu_request('blog_id'), - 'id__not_in' => array($domain->get_id()), + 'id__not_in' => [$domain->get_id()], 'fields' => 'ids', - ) + ] ); /* * Trigger async action to update the old primary domains. */ - do_action('wu_async_remove_old_primary_domains', array($old_primary_domains)); + do_action('wu_async_remove_old_primary_domains', [$old_primary_domains]); } - wu_enqueue_async_action('wu_async_process_domain_stage', array('domain_id' => $domain->get_id()), 'domain'); + wu_enqueue_async_action('wu_async_process_domain_stage', ['domain_id' => $domain->get_id()], 'domain'); wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url( 'wp-ultimo-edit-domain', - array( + [ 'id' => $domain->get_id(), - ) + ] ), - ) + ] ); } } @@ -280,10 +280,10 @@ class Domain_List_Admin_Page extends List_Admin_Page { */ public function get_labels() { - return array( + return [ 'deleted_message' => __('Domains removed successfully.', 'wp-ultimo'), 'search_label' => __('Search Domains', 'wp-ultimo'), - ); + ]; } /** @@ -327,14 +327,14 @@ class Domain_List_Admin_Page extends List_Admin_Page { */ public function action_links() { - return array( - array( + return [ + [ 'label' => __('Add Domain'), 'icon' => 'wu-circle-with-plus', 'classes' => 'wubox', 'url' => wu_get_form_url('add_new_domain'), - ), - ); + ], + ]; } /** diff --git a/inc/admin-pages/class-edit-admin-page.php b/inc/admin-pages/class-edit-admin-page.php index fee0764..d826cab 100644 --- a/inc/admin-pages/class-edit-admin-page.php +++ b/inc/admin-pages/class-edit-admin-page.php @@ -75,7 +75,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function page_loaded() { + public function page_loaded(): void { /** * Setups the object @@ -106,11 +106,11 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { * * @return void */ - public function hooks() { + public function hooks(): void { parent::hooks(); - add_filter('removable_query_args', array($this, 'removable_query_args')); + add_filter('removable_query_args', [$this, 'removable_query_args']); } /** @@ -143,17 +143,17 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { // translators: %s is the date, using the site format options $message = sprintf(__('This item is locked from editions.
This is probably due to a background action being performed (like a transfer between different accounts, for example). You can manually unlock it, but be careful. The lock should be released automatically in %s seconds.', 'wp-ultimo'), wu_get_next_queue_run() + 10); - $actions = array( - 'preview' => array( + $actions = [ + 'preview' => [ 'title' => __('Unlock', 'wp-ultimo'), 'url' => add_query_arg( - array( + [ 'remove-lock' => 1, 'unlock_wpultimo_nonce' => wp_create_nonce(sprintf('unlocking_%s', $this->object_id)), - ) + ] ), - ), - ); + ], + ]; WP_Ultimo()->notices->add($message, 'warning', 'network-admin', false, $actions); } @@ -165,7 +165,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function remove_lock() { + public function remove_lock(): void { $unlock_tag = "unlocking_{$this->object_id}"; @@ -186,10 +186,10 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { wp_redirect( remove_query_arg( - array( + [ 'remove-lock', 'unlock_wpultimo_nonce', - ) + ] ) ); @@ -203,7 +203,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - final public function process_save() { + final public function process_save(): void { $saving_tag = "saving_{$this->object_id}"; @@ -234,7 +234,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - final public function process_delete() { + final public function process_delete(): void { $deleting_tag = "deleting_{$this->object_id}"; @@ -263,7 +263,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { */ public function get_labels() { - $default_labels = array( + $default_labels = [ 'edit_label' => __('Edit Object', 'wp-ultimo'), 'add_new_label' => __('Add New Object', 'wp-ultimo'), 'updated_message' => __('Object updated with success!', 'wp-ultimo'), @@ -273,7 +273,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { 'save_description' => '', 'delete_button_label' => __('Delete', 'wp-ultimo'), 'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'), - ); + ]; return apply_filters('wu_edit_admin_page_labels', $default_labels); } @@ -284,7 +284,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function register_scripts() { + public function register_scripts(): void { parent::register_scripts(); @@ -315,20 +315,20 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function register_widgets() { + public function register_widgets(): void { $screen = get_current_screen(); $this->add_info_widget( 'info', - array( + [ 'title' => __('Timestamps', 'wp-ultimo'), 'position' => 'side-bottom', - ) + ] ); if ($this->edit) { - $this->add_delete_widget('delete', array()); + $this->add_delete_widget('delete', []); } } @@ -341,7 +341,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { * @param array $atts Array containing the attributes to be passed to the widget. * @return void */ - protected function add_info_widget($id, $atts = array()) { + protected function add_info_widget($id, $atts = []) { $created_key = 'date_created'; @@ -349,38 +349,38 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { $created_key = 'date_registered'; } - $created_value = call_user_func(array($this->get_object(), "get_$created_key")); + $created_value = call_user_func([$this->get_object(), "get_$created_key"]); - $atts['fields'][ $created_key ] = array( + $atts['fields'][ $created_key ] = [ 'title' => __('Created at', 'wp-ultimo'), 'type' => 'text-display', 'date' => true, 'display_value' => $this->edit ? $created_value : false, 'value' => $created_value, 'placeholder' => '2020-04-04 12:00:00', - 'html_attr' => array( + 'html_attr' => [ 'wu-datepicker' => 'true', 'data-format' => 'Y-m-d H:i:S', 'data-allow-time' => 'true', - ), - ); + ], + ]; $show_modified = wu_get_isset($atts, 'modified', true); if ($this->edit && $show_modified === true) { - $atts['fields']['date_modified'] = array( + $atts['fields']['date_modified'] = [ 'title' => __('Last Modified at', 'wp-ultimo'), 'type' => 'text-display', 'date' => true, 'display_value' => $this->edit ? $this->get_object()->get_date_modified() : __('No date', 'wp-ultimo'), 'value' => $this->get_object()->get_date_modified(), 'placeholder' => '2020-04-04 12:00:00', - 'html_attr' => array( + 'html_attr' => [ 'wu-datepicker' => 'true', 'data-format' => 'Y-m-d H:i:S', 'data-allow-time' => 'true', - ), - ); + ], + ]; } $this->add_fields_widget($id, $atts); @@ -395,11 +395,11 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { * @param array $atts Array containing the attributes to be passed to the widget. * @return void */ - protected function add_list_table_widget($id, $atts = array()) { + protected function add_list_table_widget($id, $atts = []) { $atts = wp_parse_args( $atts, - array( + [ 'widget_id' => $id, 'before' => '', 'after' => '', @@ -412,7 +412,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { 'edit' => true, 'table' => false, 'query_filter' => false, - ) + ] ); $atts['table']->set_context('widget'); @@ -460,22 +460,22 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { * @param array $atts Array of attributes to pass to the form. * @return void */ - protected function add_fields_widget($id, $atts = array()) { + protected function add_fields_widget($id, $atts = []) { $atts = wp_parse_args( $atts, - array( + [ 'widget_id' => $id, 'before' => '', 'after' => '', 'title' => __('Fields', 'wp-ultimo'), 'position' => 'side', 'screen' => get_current_screen(), - 'fields' => array(), - 'html_attr' => array(), + 'fields' => [], + 'html_attr' => [], 'classes' => '', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - ) + ] ); add_meta_box( @@ -484,13 +484,13 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { function () use ($atts) { if (wu_get_isset($atts['html_attr'], 'data-wu-app')) { - $atts['fields']['loading'] = array( + $atts['fields']['loading'] = [ 'type' => 'note', 'desc' => sprintf('
%s
', __('Loading...', 'wp-ultimo')), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 0, - ), - ); + ], + ]; } /** @@ -501,14 +501,14 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { $form = new \WP_Ultimo\UI\Form( $atts['widget_id'], $atts['fields'], - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-widget-list wu-striped wu-m-0 wu--mt-2 wu--mb-3 wu--mx-3 ' . $atts['classes'], 'field_wrapper_classes' => $atts['field_wrapper_classes'], 'html_attr' => $atts['html_attr'], 'before' => $atts['before'], 'after' => $atts['after'], - ) + ] ); $form->render(); @@ -529,30 +529,30 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { * @param array $atts Array of attributes to pass to the form. * @return void */ - protected function add_tabs_widget($id, $atts = array()) { + protected function add_tabs_widget($id, $atts = []) { $atts = wp_parse_args( $atts, - array( + [ 'widget_id' => $id, 'before' => '', 'after' => '', 'title' => __('Tabs', 'wp-ultimo'), 'position' => 'advanced', 'screen' => get_current_screen(), - 'sections' => array(), - 'html_attr' => array(), - ) + 'sections' => [], + 'html_attr' => [], + ] ); $current_section = wu_request($id, current(array_keys($atts['sections']))); $atts['html_attr']['data-wu-app'] = $id; - $atts['html_attr']['data-state'] = array( + $atts['html_attr']['data-state'] = [ 'section' => $current_section, 'display_all' => false, - ); + ]; add_meta_box( "wp-ultimo-{$id}-widget", @@ -562,16 +562,16 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { foreach ($atts['sections'] as $section_id => &$section) { $section = wp_parse_args( $section, - array( + [ 'form' => '', 'before' => '', 'after' => '', 'v-show' => '1', - 'fields' => array(), - 'html_attr' => array(), - 'state' => array(), + 'fields' => [], + 'html_attr' => [], + 'state' => [], 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - ) + ] ); /** @@ -579,25 +579,25 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { */ $atts['html_attr']['data-state'] = array_merge($atts['html_attr']['data-state'], $section['state']); - $section['html_attr'] = array( + $section['html_attr'] = [ 'v-cloak' => 1, 'v-show' => "(section == '{$section_id}' || display_all) && " . $section['v-show'], - ); + ]; /** * Adds a header field */ $section['fields'] = array_merge( - array( - $section_id => array( + [ + $section_id => [ 'title' => $section['title'], 'desc' => $section['desc'], 'type' => 'header', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'display_all', - ), - ), - ), + ], + ], + ], $section['fields'] ); @@ -609,25 +609,25 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { $section['form'] = new \WP_Ultimo\UI\Form( $section_id, $section['fields'], - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-widget-list wu-striped wu-m-0 wu-border-solid wu-border-gray-300 wu-border-0 wu-border-b', 'field_wrapper_classes' => $section['field_wrapper_classes'], 'html_attr' => $section['html_attr'], 'before' => $section['before'], 'after' => $section['after'], - ) + ] ); } wu_get_template( 'base/edit/widget-tabs', - array( + [ 'sections' => $atts['sections'], 'html_attr' => $atts['html_attr'], 'before' => $atts['before'], 'after' => $atts['after'], - ) + ] ); }, $atts['screen']->id, @@ -645,11 +645,11 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { * @param array $atts Widget parameters. * @return void */ - protected function add_widget($id, $atts = array()) { + protected function add_widget($id, $atts = []) { $atts = wp_parse_args( $atts, - array( + [ 'widget_id' => $id, 'before' => '', 'after' => '', @@ -657,7 +657,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { 'screen' => get_current_screen(), 'position' => 'side', 'display' => '__return_empty_string', - ) + ] ); add_meta_box("wp-ultimo-{$id}-widget", $atts['title'], $atts['display'], $atts['screen']->id, $atts['position'], 'default'); @@ -672,7 +672,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { * @param array $atts Array containing the attributes to be passed to the widget. * @return void */ - protected function add_save_widget($id, $atts = array()) { + protected function add_save_widget($id, $atts = []) { $labels = $this->get_labels(); @@ -681,15 +681,15 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { /** * Adds Submit Button */ - $atts['fields']['submit_save'] = array( + $atts['fields']['submit_save'] = [ 'type' => 'submit', 'title' => $labels['save_button_label'], 'placeholder' => $labels['save_button_label'], 'value' => 'save', 'classes' => 'button button-primary wu-w-full', - 'html_attr' => array(), - 'wrapper_html_attr' => array(), - ); + 'html_attr' => [], + 'wrapper_html_attr' => [], + ]; if (isset($atts['html_attr']['data-wu-app'])) { $atts['fields']['submit_save']['wrapper_html_attr']['v-cloak'] = 1; @@ -713,28 +713,28 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { * @param array $atts Array containing the attributes to be passed to the widget. * @return void */ - protected function add_delete_widget($id, $atts = array()) { + protected function add_delete_widget($id, $atts = []) { $labels = $this->get_labels(); - $atts_default = array( + $atts_default = [ 'title' => __('Delete', 'wp-ultimo'), 'position' => 'side-bottom', - ); + ]; $atts = array_merge($atts_default, $atts); /** * Adds Note */ - $atts['fields']['note'] = array( + $atts['fields']['note'] = [ 'type' => 'note', 'desc' => $labels['delete_description'], - ); + ]; /** * Adds Submit Button */ - $default_delete_field_settings = array( + $default_delete_field_settings = [ 'type' => 'link', 'title' => '', 'display_value' => $labels['delete_button_label'] ?? '', @@ -742,19 +742,19 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { 'value' => 'delete', 'classes' => 'button wubox wu-w-full wu-text-center', 'wrapper_classes' => 'wu-bg-gray-100', - 'html_attr' => array( + 'html_attr' => [ 'title' => $labels['delete_button_label'], 'href' => wu_get_form_url( 'delete_modal', - array( + [ 'id' => $this->get_object()->get_id(), 'model' => $this->get_object()->model, - ) + ] ), - ), - ); + ], + ]; - $custom_delete_field_settings = wu_get_isset($atts['fields'], 'delete', array()); + $custom_delete_field_settings = wu_get_isset($atts['fields'], 'delete', []); $atts['fields']['delete'] = array_merge($default_delete_field_settings, $custom_delete_field_settings); @@ -767,18 +767,18 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function output() { + public function output(): void { /* * Renders the base edit page layout, with the columns and everything else =) */ wu_get_template( 'base/edit', - array( + [ 'screen' => get_current_screen(), 'page' => $this, 'labels' => $this->get_labels(), 'object' => $this->get_object(), - ) + ] ); } @@ -846,9 +846,9 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { return false; } else { - $array_params = array( + $array_params = [ 'updated' => 1, - ); + ]; if ($this->edit === false) { $array_params['id'] = $object->get_id(); @@ -870,7 +870,7 @@ abstract class Edit_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_delete() { + public function handle_delete(): void { $object = $this->get_object(); diff --git a/inc/admin-pages/class-email-edit-admin-page.php b/inc/admin-pages/class-email-edit-admin-page.php index 3c96967..142d51b 100644 --- a/inc/admin-pages/class-email-edit-admin-page.php +++ b/inc/admin-pages/class-email-edit-admin-page.php @@ -78,9 +78,9 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_edit_emails', - ); + ]; /** * Initializes the class @@ -88,14 +88,14 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page { * @since 1.8.2 * @return void */ - public function init() { + public function init(): void { /** * Runs the parent init functions */ parent::init(); - add_action('wu_page_edit_redirect_handlers', array($this, 'handle_page_redirect'), 10); + add_action('wu_page_edit_redirect_handlers', [$this, 'handle_page_redirect'], 10); } /** @@ -104,11 +104,11 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { parent::register_scripts(); - wp_enqueue_script('wu-email-edit-page', wu_get_asset('email-edit-page.js', 'js'), array('jquery', 'clipboard')); + wp_enqueue_script('wu-email-edit-page', wu_get_asset('email-edit-page.js', 'js'), ['jquery', 'clipboard']); } /** @@ -117,7 +117,7 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { parent::register_widgets(); @@ -138,224 +138,224 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page { $this->add_save_widget( 'save', - array( - 'html_attr' => array( + [ + 'html_attr' => [ 'data-wu-app' => 'email_edit_save', 'data-state' => wu_convert_to_state( - array( + [ 'slug' => $this->edit ? $object->get_slug() : '', 'target' => $this->edit ? $object->get_target() : 'admin', 'schedule' => $this->edit ? $object->has_schedule() : false, 'schedule_type' => $this->edit ? $object->get_schedule_type() : 'days', 'days' => $this->edit ? $object->get_send_days() : 1, 'hours' => $this->edit ? $object->get_send_hours() : '12:00', - ) + ] ), - ), - 'fields' => array( - 'slug' => array( + ], + 'fields' => [ + 'slug' => [ 'type' => 'text', 'title' => __('Slug', 'wp-ultimo'), 'desc' => __('An unique identifier for this system email.', 'wp-ultimo'), 'value' => $this->edit ? $object->get_slug() : '', - 'html_attr' => array( + 'html_attr' => [ 'required' => 'required', 'v-on:input' => 'slug = $event.target.value.toLowerCase().replace(/[^a-z0-9-_]+/g, "")', 'v-bind:value' => 'slug', - ), - ), - 'event' => array( + ], + ], + 'event' => [ 'type' => 'select', 'title' => __('Event', 'wp-ultimo'), 'desc' => __('The event that will trigger the sending of this email.', 'wp-ultimo'), 'placeholder' => __('Event', 'wp-ultimo'), 'options' => 'wu_get_event_types_as_options', 'value' => $this->edit ? $object->get_event() : 0, - 'html_attr' => array( + 'html_attr' => [ 'name' => '', - ), - ), - 'target' => array( + ], + ], + 'target' => [ 'type' => 'select', 'title' => __('Target', 'wp-ultimo'), 'desc' => __('To whom this email should be sent.', 'wp-ultimo'), 'placeholder' => __('Network Administrators', 'wp-ultimo'), 'value' => $this->edit ? $object->get_target() : 'admin', - 'options' => array( + 'options' => [ 'admin' => __('Network Administrators', 'wp-ultimo'), 'customer' => __('Customer', 'wp-ultimo'), - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'target', - ), - ), - 'send_copy_to_admin' => array( + ], + ], + 'send_copy_to_admin' => [ 'type' => 'toggle', 'title' => __('Send Copy to Admins?', 'wp-ultimo'), 'desc' => __('Checking this options will add the network admins as bcc every time this email is sent to a customer.', 'wp-ultimo'), 'value' => $this->edit ? $object->get_send_copy_to_admin() : false, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'target == "customer"', 'v-cloak' => 1, - ), - ), - 'schedule' => array( + ], + ], + 'schedule' => [ 'type' => 'toggle', 'title' => __('Schedule?', 'wp-ultimo'), 'desc' => __('You can define when the email is sent after the event triggers.', 'wp-ultimo'), 'value' => $this->edit ? $this->get_object()->has_schedule() : 0, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'schedule', - ), - ), - 'send_date' => array( + ], + ], + 'send_date' => [ 'type' => 'group', 'title' => __('Scheduling Options', 'wp-ultimo'), 'tooltip' => __('When this email will be sent after the event?', 'wp-ultimo'), 'desc' => $desc, 'desc_id' => 'send_date_desc', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'schedule', 'v-cloak' => 1, - ), - 'fields' => array( - 'schedule_type' => array( + ], + 'fields' => [ + 'schedule_type' => [ 'type' => 'select', 'default' => 'days', 'wrapper_classes' => 'wu-w-2/3', 'value' => $this->edit ? $object->get_schedule_type() : 'days', - 'options' => array( + 'options' => [ 'hours' => __('Delay for hours', 'wp-ultimo'), 'days' => __('Delay for days', 'wp-ultimo'), - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'schedule_type', - ), - ), - 'send_days' => array( + ], + ], + 'send_days' => [ 'type' => 'number', 'value' => $this->edit && $object->get_send_days() ? $object->get_send_days() : 1, 'placeholder' => 1, 'min' => 0, 'wrapper_classes' => 'wu-ml-2 wu-w-1/3', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "schedule_type == 'days'", 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'days', - ), - ), - 'send_hours' => array( + ], + ], + 'send_hours' => [ 'type' => 'text', 'date' => true, 'placeholder' => $this->edit ? $object->get_send_hours() : '12:00', 'value' => $this->edit ? $object->get_send_hours() : '', 'wrapper_classes' => 'wu-ml-2 wu-w-1/3', - 'html_attr' => array( + 'html_attr' => [ 'data-no-calendar' => 'true', 'wu-datepicker' => 'true', 'data-format' => 'H:i', 'data-allow-time' => 'true', 'v-model' => 'hours', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => "schedule_type == 'hours'", 'v-cloak' => '1', - ), - ), - ), - ), + ], + ], + ], + ], - ), - ) + ], + ] ); - add_meta_box('wp-ultimo-placeholders', __('Placeholders', 'wp-ultimo'), array($this, 'output_default_widget_placeholders'), get_current_screen()->id, 'normal', null, array()); + add_meta_box('wp-ultimo-placeholders', __('Placeholders', 'wp-ultimo'), [$this, 'output_default_widget_placeholders'], get_current_screen()->id, 'normal', null, []); $this->add_fields_widget( 'active', - array( + [ 'title' => __('Active', 'wp-ultimo'), - 'fields' => array( - 'active' => array( + 'fields' => [ + 'active' => [ 'type' => 'toggle', 'title' => __('Active', 'wp-ultimo'), 'desc' => __('Use this option to manually enable or disable this email.', 'wp-ultimo'), 'value' => $this->get_object()->is_active(), - ), - ), - ) + ], + ], + ] ); $this->add_tabs_widget( 'email_edit_options', - array( + [ 'title' => __('Advanced Options', 'wp-ultimo'), 'position' => 'normal', - 'sections' => array( - 'general' => array( + 'sections' => [ + 'general' => [ 'title' => __('General', 'wp-ultimo'), 'icon' => 'dashicons-wu-lock', 'desc' => __('Rules and limitations to the applicability of this discount code.', 'wp-ultimo'), - 'state' => array( + 'state' => [ 'sender' => $this->edit ? $object->get_custom_sender() : 0, - ), - 'fields' => array( - 'style' => array( + ], + 'fields' => [ + 'style' => [ 'type' => 'select', 'title' => __('Email Style', 'wp-ultimo'), 'desc' => __('Choose if email body will be sent using the HTML template or in plain text.', 'wp-ultimo'), 'placeholder' => __('Style', 'wp-ultimo'), - 'options' => array( + 'options' => [ 'default' => __('Use Default', 'wp-ultimo'), 'html' => __('HTML Emails', 'wp-ultimo'), 'plain' => __('Plain Emails', 'wp-ultimo'), - ), + ], 'value' => $this->edit ? $object->get_style() : 'html', - ), - ), - ), - 'sender' => array( + ], + ], + ], + 'sender' => [ 'title' => __('Custom Sender', 'wp-ultimo'), 'icon' => 'dashicons-wu-mail', 'desc' => __('You can define an email and a name that will only be used when this email is sent.', 'wp-ultimo'), - 'fields' => array( - 'custom_sender' => array( + 'fields' => [ + 'custom_sender' => [ 'type' => 'toggle', 'title' => __('Use a custom sender?', 'wp-ultimo'), 'desc' => __('You can define an email and a name that will only be used when this email is sent.', 'wp-ultimo'), 'value' => $this->edit ? $object->get_custom_sender() : 0, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'sender', - ), - ), - 'custom_sender_name' => array( + ], + ], + 'custom_sender_name' => [ 'type' => 'text', 'title' => __('From "Name"', 'wp-ultimo'), 'desc' => __('Override the global from name for this particular email.', 'wp-ultimo'), 'wrapper_classes' => 'wu-full', 'value' => $this->edit ? $object->get_custom_sender_name() : '', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'sender', 'v-cloak' => 1, - ), - ), - 'custom_sender_email' => array( + ], + ], + 'custom_sender_email' => [ 'type' => 'email', 'title' => __('From "Email"', 'wp-ultimo'), 'desc' => __('Override the global from email for this particular email.', 'wp-ultimo'), 'wrapper_classes' => 'wu-full', 'value' => $this->edit ? $object->get_custom_sender_email() : '', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'sender', 'v-cloak' => 1, - ), - ), - ), - ), - ), - ) + ], + ], + ], + ], + ], + ] ); } @@ -368,14 +368,14 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page { * @param array $data Arguments passed by add_meta_box. * @return void */ - public function output_default_widget_placeholders($unused, $data) { + public function output_default_widget_placeholders($unused, $data): void { wu_get_template( 'email/widget-placeholders', - array( + [ 'title' => __('Event Payload', 'wp-ultimo'), 'loading_text' => __('Loading Payload', 'wp-ultimo'), - ) + ] ); } @@ -409,27 +409,27 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page { */ public function action_links() { - $url_atts = array( + $url_atts = [ 'id' => $this->get_object()->get_id(), 'model' => 'email', 'page' => 'edit', - ); + ]; $send_test_link = wu_get_form_url('send_new_test', $url_atts); - return array( - array( + return [ + [ 'url' => wu_network_admin_url('wp-ultimo-emails'), 'label' => __('Go Back', 'wp-ultimo'), 'icon' => 'wu-reply', - ), - array( + ], + [ 'url' => $send_test_link, 'label' => __('Send Test Email', 'wp-ultimo'), 'icon' => 'wu-mail', 'classes' => 'wubox', - ), - ); + ], + ]; } /** @@ -440,7 +440,7 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page { */ public function get_labels() { - return array( + return [ 'edit_label' => __('Edit Email', 'wp-ultimo'), 'add_new_label' => __('Add new Email', 'wp-ultimo'), 'updated_message' => __('Email updated with success!', 'wp-ultimo'), @@ -450,7 +450,7 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page { 'save_description' => '', 'delete_button_label' => __('Delete Email', 'wp-ultimo'), 'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'), - ); + ]; } /** @@ -463,10 +463,10 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page { */ public function query_filter($args) { - $extra_args = array( + $extra_args = [ 'object_type' => 'system_email', 'object_id' => absint($this->get_object()->get_id()), - ); + ]; return array_merge($args, $extra_args); } @@ -477,7 +477,7 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_save() { + public function handle_save(): void { $_POST['schedule'] = wu_request('schedule'); @@ -491,10 +491,10 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page { /** * Handles the redirect notice from sent new test modal. * - * @param WP_Ultimo\Admin_Pages\Base_Admin_Page $page The page object. + * @param Base_Admin_Page $page The page object. * @return void */ - public function handle_page_redirect($page) { + public function handle_page_redirect($page): void { if ($page->get_id() === 'wp-ultimo-edit-email') { if (wu_request('test_notice')) { @@ -567,10 +567,10 @@ class Email_Edit_Admin_Page extends Edit_Admin_Page { */ public function events_query_filter($args) { - $extra_args = array( + $extra_args = [ 'object_type' => 'email', 'object_id' => absint($this->get_object()->get_id()), - ); + ]; return array_merge($args, $extra_args); } diff --git a/inc/admin-pages/class-email-list-admin-page.php b/inc/admin-pages/class-email-list-admin-page.php index 84b75a0..c4a5f8d 100644 --- a/inc/admin-pages/class-email-list-admin-page.php +++ b/inc/admin-pages/class-email-list-admin-page.php @@ -66,9 +66,9 @@ class Email_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_read_emails', - ); + ]; /** * Initializes the class @@ -76,14 +76,14 @@ class Email_List_Admin_Page extends List_Admin_Page { * @since 1.8.2 * @return void */ - public function init() { + public function init(): void { /** * Runs the parent init functions */ parent::init(); - add_action('wu_page_list_redirect_handlers', array($this, 'handle_page_redirect'), 10); + add_action('wu_page_list_redirect_handlers', [$this, 'handle_page_redirect'], 10); } /** @@ -133,17 +133,17 @@ class Email_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function register_forms() { + public function register_forms(): void { /* * Send a email test */ wu_register_form( 'send_new_test', - array( - 'render' => array($this, 'render_send_new_test_modal'), - 'handler' => array($this, 'handle_send_new_test_modal'), + [ + 'render' => [$this, 'render_send_new_test_modal'], + 'handler' => [$this, 'handle_send_new_test_modal'], 'capability' => 'wu_add_broadcast', - ) + ] ); /* @@ -151,11 +151,11 @@ class Email_List_Admin_Page extends List_Admin_Page { */ wu_register_form( 'reset_import', - array( - 'render' => array($this, 'render_reset_import_modal'), - 'handler' => array($this, 'handle_reset_import_modal'), + [ + 'render' => [$this, 'render_reset_import_modal'], + 'handler' => [$this, 'handle_reset_import_modal'], 'capability' => 'wu_add_broadcasts', - ) + ] ); /* @@ -163,11 +163,11 @@ class Email_List_Admin_Page extends List_Admin_Page { */ wu_register_form( 'reset_confirmation', - array( - 'render' => array($this, 'render_reset_confirmation_modal'), - 'handler' => array($this, 'handle_reset_confirmation_modal'), + [ + 'render' => [$this, 'render_reset_confirmation_modal'], + 'handler' => [$this, 'handle_reset_confirmation_modal'], 'capability' => 'wu_add_broadcasts', - ) + ] ); } @@ -177,47 +177,47 @@ class Email_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function render_send_new_test_modal() { + public function render_send_new_test_modal(): void { - $fields = array( - 'send_to' => array( + $fields = [ + 'send_to' => [ 'type' => 'email', 'title' => __('Send To', 'wp-ultimo'), 'placeholder' => __('E.g. network@email.com', 'wp-ultimo'), 'desc' => __('The test email will be sent to the above email address.', 'wp-ultimo'), 'value' => get_network_option(null, 'admin_email'), - 'html_attr' => array( + 'html_attr' => [ 'required' => 'required', - ), - ), - 'email_id' => array( + ], + ], + 'email_id' => [ 'type' => 'hidden', 'value' => wu_request('id'), - ), - 'page' => array( + ], + 'page' => [ 'type' => 'hidden', 'value' => wu_request('page'), - ), - 'submit_button' => array( + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Send Test Email', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end wu-text-right', - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'send_new_test', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'send_new_test', - ), - ) + ], + ] ); $form->render(); @@ -227,7 +227,7 @@ class Email_List_Admin_Page extends List_Admin_Page { * Handles the modal to send tests with system emails. * * @since 2.0.0 - * @return mixed + * @return void */ public function handle_send_new_test_modal() { @@ -238,20 +238,20 @@ class Email_List_Admin_Page extends List_Admin_Page { if ( ! $email_id || ! $send_to) { $error = new \WP_Error('error', __('Something wrong happened.', 'wp-ultimo')); - return wp_send_json_error($error); + wp_send_json_error($error); } - $from = array( + $from = [ 'name' => wu_get_setting('from_name'), 'email' => wu_get_setting('from_email'), - ); + ]; - $to = array( - array( + $to = [ + [ 'name' => wu_get_setting('from_name'), 'email' => $send_to, - ), - ); + ], + ]; $email = wu_get_email($email_id); @@ -259,54 +259,54 @@ class Email_List_Admin_Page extends List_Admin_Page { $event_type = wu_get_event_type($event_slug); - $payload = array(); + $payload = []; if ($event_type) { $payload = wu_maybe_lazy_load_payload($event_type['payload']); } - $args = array( + $args = [ 'style' => $email->get_style(), 'content' => $email->get_content(), 'subject' => get_network_option(null, 'site_name') . ' - ' . $email->get_title(), 'payload' => $payload, - ); + ]; $send_mail = wu_send_mail($from, $to, $args); if ( ! $send_mail) { $error = new \WP_Error('error', __('Something wrong happened with your test.', 'wp-ultimo')); - return wp_send_json_error($error); + wp_send_json_error($error); } $page = wu_request('page', 'list'); - if ($page === 'edit') { + if ('edit' === $page) { wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url( 'wp-ultimo-edit-email', - array( + [ 'id' => $email_id, 'test_notice' => __('Test sent successfully', 'wp-ultimo'), - ) + ] ), - ) + ] ); die(); } wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url( 'wp-ultimo-emails', - array( + [ 'notice' => __('Test sent successfully', 'wp-ultimo'), - ) + ] ), - ) + ] ); } @@ -317,36 +317,36 @@ class Email_List_Admin_Page extends List_Admin_Page { * * @return void */ - public function render_reset_import_modal() { + public function render_reset_import_modal(): void { $default_system_emails = wu_get_default_system_emails(); $created_emails = wu_get_all_system_emails(); - $fields = array( - 'reset_emails' => array( + $fields = [ + 'reset_emails' => [ 'type' => 'toggle', 'title' => __('Reset System Emails ', 'wp-ultimo'), - 'desc' => __('Restore the system emails to their original content.'), + 'desc' => __('Restore the system emails to their original content.', 'wp-ultimo'), 'tooltip' => '', 'value' => 0, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'reset_emails', - ), - ), - ); + ], + ], + ]; - $fields['reset_note'] = array( + $fields['reset_note'] = [ 'type' => 'note', 'title' => '', 'desc' => __('No emails to reset.', 'wp-ultimo'), 'tooltip' => '', 'value' => 0, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'reset_emails', 'v-cloak' => 1, - ), - ); + ], + ]; foreach ($created_emails as $system_email_key => $system_email_value) { $system_email_slug = $system_email_value->get_slug(); @@ -358,18 +358,18 @@ class Email_List_Admin_Page extends List_Admin_Page { $field_title = '
' . $system_email_value->get_title() . '
'; - $fields[ $field_name ] = array( + $fields[ $field_name ] = [ 'type' => 'toggle', 'title' => $field_title, 'desc' => $system_email_value->get_event() . ' ' . $system_email_target . '', 'tooltip' => '', 'value' => 0, 'wrapper_classes' => 'wu-bg-gray-100', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'reset_emails', 'v-cloak' => 1, - ), - ); + ], + ]; if (isset($fields['reset_note'])) { unset($fields['reset_note']); @@ -377,28 +377,28 @@ class Email_List_Admin_Page extends List_Admin_Page { } } - $fields['import_emails'] = array( + $fields['import_emails'] = [ 'type' => 'toggle', 'title' => __('Import System Emails', 'wp-ultimo'), - 'desc' => __('Add new system emails based on WP Multisite WaaS presets.'), + 'desc' => __('Add new system emails based on WP Multisite WaaS presets.', 'wp-ultimo'), 'tooltip' => '', 'value' => 0, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'import_emails', - ), - ); + ], + ]; - $fields['import_note'] = array( + $fields['import_note'] = [ 'type' => 'note', 'title' => '', 'desc' => __('All emails are already present.', 'wp-ultimo'), 'tooltip' => '', 'value' => 0, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'import_emails', 'v-cloak' => 1, - ), - ); + ], + ]; foreach ($default_system_emails as $default_email_key => $default_email_value) { $maybe_is_created = wu_get_email_by('slug', $default_email_key); @@ -408,18 +408,18 @@ class Email_List_Admin_Page extends List_Admin_Page { $field_title = '
' . $default_email_value['title'] . '
'; - $fields[ $field_name ] = array( + $fields[ $field_name ] = [ 'type' => 'toggle', 'title' => $field_title, 'desc' => $default_email_value['event'] . ' ' . $default_email_value['target'] . '', 'tooltip' => '', 'value' => 0, 'wrapper_classes' => 'wu-bg-gray-100', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'import_emails', 'v-cloak' => 1, - ), - ); + ], + ]; if (isset($fields['import_note'])) { unset($fields['import_note']); @@ -427,31 +427,31 @@ class Email_List_Admin_Page extends List_Admin_Page { } } - $fields['submit_button'] = array( + $fields['submit_button'] = [ 'type' => 'submit', 'title' => __('Reset and/or Import', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end wu-text-right', - ); + ]; $form = new \WP_Ultimo\UI\Form( 'reset_import', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'reset_import', - 'data-state' => json_encode( - array( + 'data-state' => wp_json_encode( + [ 'reset_emails' => false, 'import_emails' => false, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -464,7 +464,7 @@ class Email_List_Admin_Page extends List_Admin_Page { * * @return mixed */ - public function handle_reset_import_modal() { + public function handle_reset_import_modal(): void { $reset = wu_request('reset_emails'); @@ -501,19 +501,19 @@ class Email_List_Admin_Page extends List_Admin_Page { } wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url('wp-ultimo-emails'), - ) + ] ); } /** * Handles the redirect notice from sent new test modal. * - * @param WP_Ultimo\Admin_Pages\Base_Admin_Page $page The page object. + * @param Base_Admin_Page $page The page object. * @return void */ - public function handle_page_redirect($page) { + public function handle_page_redirect($page): void { if ($page->get_id() === 'wp-ultimo-emails') { if (wu_request('notice')) { @@ -528,7 +528,6 @@ class Email_List_Admin_Page extends List_Admin_Page {
array( + $fields = [ + 'single_reset' => [ 'type' => 'toggle', 'title' => __('Confirm Reset', 'wp-ultimo'), 'desc' => __('This action can not be undone.', 'wp-ultimo'), 'default' => 0, - 'html_attr' => array( + 'html_attr' => [ 'required' => 'required', - ), - ), - 'email_id' => array( + ], + ], + 'email_id' => [ 'type' => 'hidden', 'value' => wu_request('id'), - ), - 'submit_button' => array( + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Reset Email', 'wp-ultimo'), 'value' => 'reset', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end wu-text-right', - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'reset_confirmation', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'reset_confirmation', - ), - ) + ], + ] ); $form->render(); @@ -585,7 +584,7 @@ class Email_List_Admin_Page extends List_Admin_Page { * * @since 2.0.0 * - * @return mixed + * @return void */ public function handle_reset_confirmation_modal() { @@ -596,7 +595,7 @@ class Email_List_Admin_Page extends List_Admin_Page { if ( ! $single_reset || ! $email_id) { $error = new \WP_Error('error', __('Something wrong happened.', 'wp-ultimo')); - return wp_send_json_error($error); + wp_send_json_error($error); } $email = wu_get_email($email_id); @@ -615,18 +614,18 @@ class Email_List_Admin_Page extends List_Admin_Page { if ( ! $new_email) { $error = new \WP_Error('error', __('Something wrong happened.', 'wp-ultimo')); - return wp_send_json_error($error); + wp_send_json_error($error); } wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url( 'wp-ultimo-edit-email', - array( + [ 'id' => $new_email->get_id(), - ) + ] ), - ) + ] ); } } @@ -641,24 +640,24 @@ class Email_List_Admin_Page extends List_Admin_Page { $email_template_default = get_network_option(null, 'wu_default_email_template'); - return array( - array( + return [ + [ 'url' => wu_network_admin_url('wp-ultimo-edit-email'), - 'label' => __('Add System Email'), + 'label' => __('Add System Email', 'wp-ultimo'), 'icon' => 'wu-circle-with-plus', - ), - array( + ], + [ 'url' => wu_network_admin_url('wp-ultimo-customize-email-template&id=' . $email_template_default), - 'label' => __('Email Template'), + 'label' => __('Email Template', 'wp-ultimo'), 'icon' => 'wu-mail', - ), - array( + ], + [ 'url' => wu_get_form_url('reset_import'), 'classes' => 'wubox', - 'label' => __('Reset or Import'), + 'label' => __('Reset or Import', 'wp-ultimo'), 'icon' => 'wu-cycle', - ), - ); + ], + ]; } /** diff --git a/inc/admin-pages/class-email-template-customize-admin-page.php b/inc/admin-pages/class-email-template-customize-admin-page.php index 8445a49..c0b36ae 100644 --- a/inc/admin-pages/class-email-template-customize-admin-page.php +++ b/inc/admin-pages/class-email-template-customize-admin-page.php @@ -66,9 +66,9 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_customize_email_template', - ); + ]; /** * Overrides the init method to add additional hooks. @@ -76,11 +76,11 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { parent::init(); - add_action('wp_ajax_wu-email-template-preview', array($this, 'email_template_preview')); + add_action('wp_ajax_wu-email-template-preview', [$this, 'email_template_preview']); } /** @@ -101,7 +101,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page { * @since 2.0.0 * @return void */ - public function email_template_preview() { + public function email_template_preview(): void { $object = $this; @@ -151,14 +151,14 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page { wu_get_template( 'broadcast/emails/base', - array( + [ 'site_name' => get_network_option(null, 'site_name'), 'site_url' => get_site_url(), 'logo_url' => wu_get_network_logo(), 'content' => $content, 'subject' => __('Sample Subject', 'wp-ultimo'), 'is_editor' => true, - 'template_settings' => array( + 'template_settings' => [ 'use_custom_logo' => wu_string_to_bool(wu_request('use_custom_logo', $first_request ? $object->get_setting('use_custom_logo', false) : false)), 'custom_logo' => wu_request('custom_logo', $object->get_setting('custom_logo', false)), 'background_color' => wu_request('background_color', $object->get_setting('background_color', '#f9f9f9')), @@ -174,8 +174,8 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page { 'footer_color' => wu_request('footer_color', $object->get_setting('footer_color', '#000000')), 'footer_align' => wu_request('footer_align', $object->get_setting('footer_align', 'center')), 'display_company_address' => wu_string_to_bool(wu_request('display_company_address', $first_request ? $object->get_setting('display_company_address', true) : false)), - ), - ) + ], + ] ); die; @@ -192,10 +192,10 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page { $url = get_admin_url(wu_get_main_site_id(), 'admin-ajax.php'); return add_query_arg( - array( + [ 'action' => 'wu-email-template-preview', 'customizer' => 1, - ), + ], $url ); } @@ -206,22 +206,22 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { $this->add_save_widget( 'save', - array( - 'html_attr' => array( + [ + 'html_attr' => [ 'data-wu-app' => 'save', 'data-state' => wu_convert_to_state(), - ), - 'fields' => array( - 'note' => array( + ], + 'fields' => [ + 'note' => [ 'type' => 'note', 'desc' => __('System emails and broadcasts will be sent using this template.', 'wp-ultimo'), - ), - ), - ) + ], + ], + ] ); $settings = $this->get_attributes(); @@ -232,273 +232,273 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page { $custom_logo_url = $custom_logo_args ? $custom_logo_args[0] : ''; - $fields = array( - 'tab' => array( + $fields = [ + 'tab' => [ 'type' => 'tab-select', 'wrapper_classes' => '', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'tab', - ), - 'options' => array( + ], + 'options' => [ 'header' => __('Header', 'wp-ultimo'), 'content' => __('Content', 'wp-ultimo'), 'footer' => __('Footer', 'wp-ultimo'), - ), - ), - 'use_custom_logo' => array( + ], + ], + 'use_custom_logo' => [ 'type' => 'toggle', 'title' => __('Use Custom Logo', 'wp-ultimo'), 'desc' => __('You can set a different logo to be used on the system emails.', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "header")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'use_custom_logo', - ), - ), - 'custom_logo' => array( + ], + ], + 'custom_logo' => [ 'type' => 'image', 'stacked' => true, 'title' => __('Custom Logo', 'wp-ultimo'), 'desc' => __('The custom logo is used in the email header, if HTML emails are used.', 'wp-ultimo'), 'value' => $custom_logo, 'img' => $custom_logo_url, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "header") && require("use_custom_logo", true)', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ // 'v-model' => 'custom_logo', - ), - ), - 'background_color' => array( + ], + ], + 'background_color' => [ 'type' => 'color-picker', 'title' => __('Background Color', 'wp-ultimo'), 'tooltip' => __('The cover background color of the email.', 'wp-ultimo'), 'value' => '#00a1ff', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "header")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'background_color', - ), - ), - 'title_color' => array( + ], + ], + 'title_color' => [ 'type' => 'color-picker', 'title' => __('Title Color', 'wp-ultimo'), 'value' => '#00a1ff', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "header")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'title_color', - ), - ), - 'title_size' => array( + ], + ], + 'title_size' => [ 'type' => 'select', 'title' => __('Title Size', 'wp-ultimo'), 'value' => wu_get_isset($settings, 'title_size'), - 'options' => array( + 'options' => [ 'h1' => __('h1', 'wp-ultimo'), 'h2' => __('h2', 'wp-ultimo'), 'h3' => __('h3', 'wp-ultimo'), 'h4' => __('h4', 'wp-ultimo'), 'h5' => __('h5', 'wp-ultimo'), - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "header")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model.lazy' => 'title_size', - ), - ), - 'title_align' => array( + ], + ], + 'title_align' => [ 'type' => 'select', 'title' => __('Title Align', 'wp-ultimo'), 'tooltip' => __('Aligment of the font in the title.', 'wp-ultimo'), 'value' => wu_get_isset($settings, 'title_align', ''), - 'options' => array( + 'options' => [ 'left' => __('Left', 'wp-ultimo'), 'center' => __('Center', 'wp-ultimo'), 'right' => __('Right', 'wp-ultimo'), - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "header")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model.lazy' => 'title_align', - ), - ), - 'title_font' => array( + ], + ], + 'title_font' => [ 'type' => 'select', 'title' => __('Title Font-Family', 'wp-ultimo'), 'value' => wu_get_isset($settings, 'title_font', ''), - 'options' => array( + 'options' => [ 'Helvetica Neue, Helvetica, Helvetica, Arial, sans-serif' => __('Helvetica', 'wp-ultimo'), 'Arial, Helvetica, sans-serif' => __('Arial', 'wp-ultimo'), 'Times New Roman, Times, serif' => __('Times New Roman', 'wp-ultimo'), 'Lucida Console, Courier, monospace' => __('Lucida', 'wp-ultimo'), - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "header")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model.lazy' => 'title_font', - ), - ), - 'content_color' => array( + ], + ], + 'content_color' => [ 'type' => 'color-picker', 'title' => __('Content Color', 'wp-ultimo'), 'value' => '#000000', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "content")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'content_color', - ), - ), - 'content_align' => array( + ], + ], + 'content_align' => [ 'type' => 'select', 'title' => __('Content Alignment', 'wp-ultimo'), 'tooltip' => __('Alignment of the font in the main email content.', 'wp-ultimo'), 'value' => wu_get_isset($settings, 'content_align', ''), - 'options' => array( + 'options' => [ 'left' => __('Left', 'wp-ultimo'), 'center' => __('Center', 'wp-ultimo'), 'right' => __('Right', 'wp-ultimo'), - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "content")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model.lazy' => 'content_align', - ), - ), - 'content_font' => array( + ], + ], + 'content_font' => [ 'type' => 'select', 'title' => __('Content Font-Family', 'wp-ultimo'), 'value' => wu_get_isset($settings, 'content_font', ''), - 'options' => array( + 'options' => [ 'Helvetica Neue, Helvetica, Helvetica, Arial, sans-serif' => __('Helvetica', 'wp-ultimo'), 'Arial, Helvetica, sans-serif' => __('Arial', 'wp-ultimo'), 'Times New Roman, Times, serif' => __('Times New Roman', 'wp-ultimo'), 'Lucida Console, Courier, monospace' => __('Lucida', 'wp-ultimo'), - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "content")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model.lazy' => 'content_font', - ), - ), - 'display_company_address' => array( + ], + ], + 'display_company_address' => [ 'type' => 'toggle', 'title' => __('Display Company Address', 'wp-ultimo'), 'desc' => __('Toggle to show/hide your company address.', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "footer")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'display_company_address', - ), - ), - 'footer_text' => array( + ], + ], + 'footer_text' => [ 'type' => 'textarea', 'title' => __('Footer Content', 'wp-ultimo'), 'placeholder' => __('e.g. Extra info in the email footer.', 'wp-ultimo'), 'value' => wu_get_isset($settings, 'footer_text', ''), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "footer")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model.lazy' => 'footer_text', - ), - ), - 'footer_font' => array( + ], + ], + 'footer_font' => [ 'type' => 'select', 'title' => __('Footer Font-Family', 'wp-ultimo'), 'value' => wu_get_isset($settings, 'footer_font', ''), - 'options' => array( + 'options' => [ 'Helvetica Neue, Helvetica, Helvetica, Arial, sans-serif' => __('Helvetica', 'wp-ultimo'), 'Arial, Helvetica, sans-serif' => __('Arial', 'wp-ultimo'), 'Times New Roman, Times, serif' => __('Times New Roman', 'wp-ultimo'), 'Lucida Console, Courier, monospace' => __('Lucida', 'wp-ultimo'), - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "footer")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model.lazy' => 'footer_font', - ), - ), - 'footer_color' => array( + ], + ], + 'footer_color' => [ 'type' => 'color-picker', 'title' => __('Footer Color', 'wp-ultimo'), 'value' => '#000000', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "footer")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'footer_color', - ), - ), - 'footer_align' => array( + ], + ], + 'footer_align' => [ 'type' => 'select', 'title' => __('Footer Alignment', 'wp-ultimo'), 'tooltip' => __('Alignment of the font in the main email footer.', 'wp-ultimo'), 'value' => wu_get_isset($settings, 'footer_align', ''), - 'options' => array( + 'options' => [ 'left' => __('Left', 'wp-ultimo'), 'center' => __('Center', 'wp-ultimo'), 'right' => __('Right', 'wp-ultimo'), - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "footer")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model.lazy' => 'footer_align', - ), - ), - ); + ], + ], + ]; $state = array_merge( $settings, - array( + [ 'tab' => 'header', 'refresh' => true, - ) + ] ); $this->add_fields_widget( 'customizer', - array( + [ 'title' => __('Customizer', 'wp-ultimo'), 'position' => 'side', 'fields' => $fields, - 'html_attr' => array( + 'html_attr' => [ 'style' => 'margin-top: -6px;', 'data-wu-app' => 'email_template_customizer', 'data-wu-customizer-panel' => true, 'data-state' => json_encode($state), - ), - ) + ], + ] ); } @@ -532,7 +532,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page { */ public function action_links() { - return array(); + return []; } /** @@ -543,7 +543,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page { */ public function get_labels() { - return array( + return [ 'customize_label' => __('Customize Email Template', 'wp-ultimo'), 'add_new_label' => __('Customize Email Template', 'wp-ultimo'), 'edit_label' => __('Edit Email Template', 'wp-ultimo'), @@ -554,7 +554,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page { 'save_description' => '', 'delete_button_label' => __('Delete Email Template', 'wp-ultimo'), 'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'), - ); + ]; } /** @@ -563,7 +563,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_save() { + public function handle_save(): void { $_POST['footer_text'] = stripslashes((string) $_POST['footer_text']); @@ -590,9 +590,9 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page { */ public function get_attributes() { - $saved_atts = $this->get_settings(); + $saved_atts = static::get_settings(); - $attributes = wp_parse_args($saved_atts, $this->get_default_settings()); + $attributes = wp_parse_args($saved_atts, static::get_default_settings()); return $attributes; } @@ -605,7 +605,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page { */ public static function get_default_settings() { - return array( + return [ 'use_custom_logo' => false, 'custom_logo' => false, 'display_company_address' => true, @@ -621,7 +621,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page { 'footer_text' => '', 'footer_color' => '#000000', 'footer_align' => 'center', - ); + ]; } /** @@ -633,7 +633,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page { */ public static function get_settings() { - return wu_get_option('email_template', array()); + return wu_get_option('email_template', []); } /** @@ -648,7 +648,7 @@ class Email_Template_Customize_Admin_Page extends Customizer_Admin_Page { public function get_setting($setting, $default = false) { if ($setting) { - $return = wu_get_option('email_template', array()); + $return = wu_get_option('email_template', []); if ($return && isset($return[ $setting ])) { $return = $return[ $setting ]; diff --git a/inc/admin-pages/class-event-list-admin-page.php b/inc/admin-pages/class-event-list-admin-page.php index 57adf47..835a21c 100644 --- a/inc/admin-pages/class-event-list-admin-page.php +++ b/inc/admin-pages/class-event-list-admin-page.php @@ -52,9 +52,9 @@ class Event_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_read_events', - ); + ]; /** * Instantiate the necessary hooks. @@ -62,9 +62,9 @@ class Event_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - add_action('init', array($this, 'set_badge_count')); + add_action('init', [$this, 'set_badge_count']); } /** @@ -73,11 +73,11 @@ class Event_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function page_loaded() { + public function page_loaded(): void { parent::page_loaded(); - add_action('in_admin_header', array($this, 'count_seen_events')); + add_action('in_admin_header', [$this, 'count_seen_events']); } /** @@ -86,7 +86,7 @@ class Event_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function set_badge_count() { + public function set_badge_count(): void { global $wpdb; @@ -119,19 +119,19 @@ class Event_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function count_seen_events() { + public function count_seen_events(): void { $user_id = get_current_user_id(); delete_site_transient("wu_{$user_id}_unseen_events_count"); $last_event = wu_get_events( - array( + [ 'orderby' => 'id', 'fields' => 'ids', 'order' => 'DESC', 'number' => 1, - ) + ] ); if ( ! empty($last_event)) { @@ -159,10 +159,10 @@ class Event_List_Admin_Page extends List_Admin_Page { */ public function get_labels() { - return array( + return [ 'deleted_message' => __('Event removed successfully.', 'wp-ultimo'), 'search_label' => __('Search Event', 'wp-ultimo'), - ); + ]; } /** @@ -206,13 +206,13 @@ class Event_List_Admin_Page extends List_Admin_Page { */ public function action_links() { - return array( - array( + return [ + [ 'url' => wu_network_admin_url('wp-ultimo-view-logs'), 'label' => __('View Logs'), 'icon' => 'dashicons dashicons-editor-ol', - ), - ); + ], + ]; } /** diff --git a/inc/admin-pages/class-event-view-admin-page.php b/inc/admin-pages/class-event-view-admin-page.php index d431e9c..6eb1bef 100644 --- a/inc/admin-pages/class-event-view-admin-page.php +++ b/inc/admin-pages/class-event-view-admin-page.php @@ -76,9 +76,9 @@ class Event_View_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_read_events', - ); + ]; /** * Allow child classes to register scripts and styles that can be loaded on the output function, for example. @@ -86,11 +86,11 @@ class Event_View_Admin_Page extends Edit_Admin_Page { * @since 1.8.2 * @return void */ - public function register_scripts() { + public function register_scripts(): void { parent::register_scripts(); - \WP_Ultimo\Scripts::get_instance()->register_script('wu-event-view', wu_get_asset('event-view-page.js', 'js'), array('jquery')); + \WP_Ultimo\Scripts::get_instance()->register_script('wu-event-view', wu_get_asset('event-view-page.js', 'js'), ['jquery']); wp_enqueue_script('wu-event-view'); @@ -105,16 +105,16 @@ class Event_View_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function register_forms() { + public function register_forms(): void { /* * Delete Event - Confirmation modal */ add_filter( 'wu_data_json_success_delete_event_modal', - fn($data_json) => array( - 'redirect_url' => wu_network_admin_url('wp-ultimo-events', array('deleted' => 1)), - ) + fn($data_json) => [ + 'redirect_url' => wu_network_admin_url('wp-ultimo-events', ['deleted' => 1]), + ] ); } @@ -124,23 +124,23 @@ class Event_View_Admin_Page extends Edit_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { parent::register_widgets(); - add_meta_box('wp-ultimo-message', __('Event Message', 'wp-ultimo'), array($this, 'output_default_widget_message'), get_current_screen()->id, 'normal', 'default'); + add_meta_box('wp-ultimo-message', __('Event Message', 'wp-ultimo'), [$this, 'output_default_widget_message'], get_current_screen()->id, 'normal', 'default'); - add_meta_box('wp-ultimo-initiator', __('Event', 'wp-ultimo'), array($this, 'output_default_widget_initiator'), get_current_screen()->id, 'side', 'default'); + add_meta_box('wp-ultimo-initiator', __('Event', 'wp-ultimo'), [$this, 'output_default_widget_initiator'], get_current_screen()->id, 'side', 'default'); - add_meta_box('wp-ultimo-payload', __('Event Payload', 'wp-ultimo'), array($this, 'output_default_widget_payload'), get_current_screen()->id, 'normal', 'default'); + add_meta_box('wp-ultimo-payload', __('Event Payload', 'wp-ultimo'), [$this, 'output_default_widget_payload'], get_current_screen()->id, 'normal', 'default'); $this->add_info_widget( 'info', - array( + [ 'title' => __('Timestamps', 'wp-ultimo'), 'position' => 'side', 'modified' => false, - ) + ] ); } @@ -150,16 +150,16 @@ class Event_View_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function output_default_widget_message() { + public function output_default_widget_message(): void { wu_get_template( 'events/widget-message', - array( + [ 'screen' => get_current_screen(), 'page' => $this, 'labels' => $this->get_labels(), 'object' => $this->get_object(), - ) + ] ); } @@ -169,17 +169,17 @@ class Event_View_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function output_default_widget_payload() { + public function output_default_widget_payload(): void { $object = $this->get_object(); wu_get_template( 'events/widget-payload', - array( + [ 'title' => __('Event Payload', 'wp-ultimo'), 'loading_text' => __('Loading Payload', 'wp-ultimo'), 'payload' => json_encode($object->get_payload(), JSON_PRETTY_PRINT), - ) + ] ); } @@ -189,13 +189,13 @@ class Event_View_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function output_default_widget_initiator() { + public function output_default_widget_initiator(): void { $object = $this->get_object(); - $args = array( + $args = [ 'object' => $object, - ); + ]; wu_get_template('events/widget-initiator', $args); } @@ -230,7 +230,7 @@ class Event_View_Admin_Page extends Edit_Admin_Page { */ public function action_links() { - return array(); + return []; } /** @@ -241,7 +241,7 @@ class Event_View_Admin_Page extends Edit_Admin_Page { */ public function get_labels() { - return array( + return [ 'edit_label' => __('Edit Event', 'wp-ultimo'), 'add_new_label' => __('Add new Event', 'wp-ultimo'), 'updated_message' => __('Event updated with success!', 'wp-ultimo'), @@ -251,7 +251,7 @@ class Event_View_Admin_Page extends Edit_Admin_Page { 'save_description' => '', 'delete_button_label' => __('Delete Event', 'wp-ultimo'), 'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'), - ); + ]; } /** diff --git a/inc/admin-pages/class-hosting-integration-wizard-admin-page.php b/inc/admin-pages/class-hosting-integration-wizard-admin-page.php index d39534c..7d04e18 100644 --- a/inc/admin-pages/class-hosting-integration-wizard-admin-page.php +++ b/inc/admin-pages/class-hosting-integration-wizard-admin-page.php @@ -66,9 +66,9 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'manage_network', - ); + ]; /** * Current integration being setup. @@ -84,7 +84,7 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 1.8.2 * @return void */ - public function page_loaded() { + public function page_loaded(): void { if (isset($_GET['integration'])) { $domain_manager = \WP_Ultimo\Managers\Domain_Manager::get_instance(); @@ -131,30 +131,30 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page { */ public function get_sections() { - $sections = array( - 'activation' => array( + $sections = [ + 'activation' => [ 'title' => __('Activation', 'wp-ultimo'), - 'view' => array($this, 'section_activation'), - 'handler' => array($this, 'handle_activation'), - ), - 'instructions' => array( + 'view' => [$this, 'section_activation'], + 'handler' => [$this, 'handle_activation'], + ], + 'instructions' => [ 'title' => __('Instructions', 'wp-ultimo'), - 'view' => array($this, 'section_instructions'), - ), - 'config' => array( + 'view' => [$this, 'section_instructions'], + ], + 'config' => [ 'title' => __('Configuration', 'wp-ultimo'), - 'view' => array($this, 'section_configuration'), - 'handler' => array($this, 'handle_configuration'), - ), - 'testing' => array( + 'view' => [$this, 'section_configuration'], + 'handler' => [$this, 'handle_configuration'], + ], + 'testing' => [ 'title' => __('Testing Integration', 'wp-ultimo'), - 'view' => array($this, 'section_test'), - ), - 'done' => array( + 'view' => [$this, 'section_test'], + ], + 'done' => [ 'title' => __('Ready!', 'wp-ultimo'), - 'view' => array($this, 'section_ready'), - ), - ); + 'view' => [$this, 'section_ready'], + ], + ]; /* * Some host providers require no instructions. @@ -179,19 +179,19 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function section_activation() { + public function section_activation(): void { $explainer_lines = $this->integration->get_explainer_lines(); wu_get_template( 'wizards/host-integrations/activation', - array( + [ 'screen' => get_current_screen(), 'page' => $this, 'integration' => $this->integration, 'will' => $explainer_lines['will'], 'will_not' => $explainer_lines['will_not'], - ) + ] ); } @@ -201,9 +201,9 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function section_instructions() { + public function section_instructions(): void { - call_user_func(array($this->integration, 'get_instructions')); + call_user_func([$this->integration, 'get_instructions']); $this->render_submit_box(); } @@ -214,7 +214,7 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function section_configuration() { + public function section_configuration(): void { $fields = $this->integration->get_fields(); @@ -225,23 +225,23 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page { $form = new \WP_Ultimo\UI\Form( $this->get_current_section(), $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-widget-list wu-striped wu-m-0 wu--mt-2 wu--mb-3 wu--mx-3', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-px-6 wu-py-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - ) + ] ); if (wu_request('manual')) { wu_get_template( 'wizards/host-integrations/configuration-results', - array( + [ 'screen' => get_current_screen(), 'page' => $this, 'integration' => $this->integration, 'form' => $form, 'post' => $_GET['post'], - ) + ] ); return; @@ -249,12 +249,12 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page { wu_get_template( 'wizards/host-integrations/configuration', - array( + [ 'screen' => get_current_screen(), 'page' => $this, 'integration' => $this->integration, 'form' => $form, - ) + ] ); } @@ -264,15 +264,15 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function section_ready() { + public function section_ready(): void { wu_get_template( 'wizards/host-integrations/ready', - array( + [ 'screen' => get_current_screen(), 'page' => $this, 'integration' => $this->integration, - ) + ] ); } @@ -282,7 +282,7 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_activation() { + public function handle_activation(): void { $is_enabled = $this->integration->is_enabled(); @@ -305,15 +305,15 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_configuration() { + public function handle_configuration(): void { if (wu_request('submit') == '0') { // phpcs:ignore $redirect_url = add_query_arg( - array( + [ 'manual' => '1', 'post' => $_POST, - ) + ] ); wp_redirect($redirect_url); @@ -344,17 +344,17 @@ class Hosting_Integration_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function section_test() { + public function section_test(): void { wp_enqueue_script('wu-vue'); wu_get_template( 'wizards/host-integrations/test', - array( + [ 'screen' => get_current_screen(), 'page' => $this, 'integration' => $this->integration, - ) + ] ); } } diff --git a/inc/admin-pages/class-invoice-template-customize-admin-page.php b/inc/admin-pages/class-invoice-template-customize-admin-page.php index c5b1d53..58a7aad 100644 --- a/inc/admin-pages/class-invoice-template-customize-admin-page.php +++ b/inc/admin-pages/class-invoice-template-customize-admin-page.php @@ -68,9 +68,9 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_customize_invoice_template', - ); + ]; /** * Overrides the original init to add the required ajax endpoints. @@ -78,11 +78,11 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { parent::init(); - add_action('wp_ajax_wu-preview-invoice', array($this, 'generate_invoice_preview')); + add_action('wp_ajax_wu-preview-invoice', [$this, 'generate_invoice_preview']); } /** @@ -91,7 +91,7 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page { * @since 2.0.0 * @return void */ - public function generate_invoice_preview() { + public function generate_invoice_preview(): void { if ( ! current_user_can('wu_manage_invoice')) { return; @@ -119,11 +119,11 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page { $url = get_admin_url(wu_get_main_site_id(), 'admin-ajax.php'); return add_query_arg( - array( + [ 'action' => 'wu-preview-invoice', 'customizer' => 1, 'invoice-customize' => 1, - ), + ], $url ); } @@ -134,20 +134,20 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { $settings = Invoice::get_settings(); $this->add_save_widget( 'save', - array( - 'fields' => array( - 'note' => array( + [ + 'fields' => [ + 'note' => [ 'type' => 'note', 'desc' => __('Changes to this template will be applied to all PDF invoices generated after the change.

Existing PDF Invoices will not be affected unless explicitly re-generated', 'wp-ultimo'), - ), - ), - ) + ], + ], + ] ); $custom_logo = wu_get_isset($settings, 'custom_logo'); @@ -156,139 +156,139 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page { $custom_logo_url = $custom_logo_args ? $custom_logo_args[0] : ''; - $fields = array( - 'tab' => array( + $fields = [ + 'tab' => [ 'type' => 'tab-select', 'wrapper_classes' => '', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'tab', - ), - 'options' => array( + ], + 'options' => [ 'general' => __('General', 'wp-ultimo'), 'colors' => __('Colors', 'wp-ultimo'), 'images' => __('Images', 'wp-ultimo'), - ), - ), + ], + ], - 'paid_tag_text' => array( + 'paid_tag_text' => [ 'type' => 'text', 'title' => __('Paid Tag', 'wp-ultimo'), 'placeholder' => __('e.g. Paid.', 'wp-ultimo'), 'value' => wu_get_isset($settings, 'paid_tag_text', __('Paid', 'wp-ultimo')), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "general")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model.lazy' => 'paid_tag_text', - ), - ), - 'font' => array( + ], + ], + 'font' => [ 'type' => 'select', 'title' => __('Font-Family', 'wp-ultimo'), 'value' => wu_get_isset($settings, 'font', ''), - 'options' => array( - 'DejaVuSansCondensed' => __('Sans-Serif', 'wp-ultimo'), - 'FreeSerif' => __('Serif', 'wp-ultimo'), - 'FreeMono' => __('Mono', 'wp-ultimo'), - ), - 'wrapper_html_attr' => array( + 'options' => [ + 'DejaVuSansCondensed' => __('Sans-Serif', 'wp-ultimo'), + 'DejaVuSerifCondensed' => __('Serif', 'wp-ultimo'), + 'FreeMono' => __('Mono', 'wp-ultimo'), + ], + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "general")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model.lazy' => 'font', - ), - ), - 'footer_message' => array( + ], + ], + 'footer_message' => [ 'type' => 'textarea', 'title' => __('Footer Content', 'wp-ultimo'), 'placeholder' => __('e.g. Extra Info about the Invoice.', 'wp-ultimo'), 'value' => wu_get_isset($settings, 'footer_message', ''), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "general")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model.lazy' => 'footer_message', - ), - ), + ], + ], - 'primary_color' => array( + 'primary_color' => [ 'type' => 'color-picker', 'title' => __('Primary Color', 'wp-ultimo'), 'value' => '#00a1ff', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "colors")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'primary_color', - ), - ), + ], + ], - 'use_custom_logo' => array( + 'use_custom_logo' => [ 'type' => 'toggle', 'title' => __('Use Custom Logo', 'wp-ultimo'), 'desc' => __('You can set a different logo to be used on the invoice.', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "images")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'use_custom_logo', - ), - ), - 'custom_logo' => array( + ], + ], + 'custom_logo' => [ 'type' => 'image', 'title' => __('Custom Logo', 'wp-ultimo'), 'desc' => __('This will be added to the top of the generated PDF.', 'wp-ultimo'), 'value' => '', 'img' => $custom_logo_url, 'stacked' => true, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "images") && require("use_custom_logo", true)', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'custom_logo', - ), - ), - ); + ], + ], + ]; - $settings = array( + $settings = [ 'footer_message' => wu_get_isset($settings, 'footer_message', ''), 'paid_tag_text' => wu_get_isset($settings, 'paid_tag_text', __('Paid', 'wp-ultimo')), 'primary_color' => wu_get_isset($settings, 'primary_color', '00a1ff'), 'use_custom_logo' => wu_get_isset($settings, 'use_custom_logo'), 'custom_logo' => wu_get_isset($settings, 'custom_logo'), 'font' => wu_get_isset($settings, 'font', 'DejaVuSansCondensed'), - ); + ]; $state = array_merge( $settings, - array( + [ 'tab' => 'general', 'refresh' => true, - ) + ] ); $this->add_fields_widget( 'customizer', - array( + [ 'title' => __('Customizer', 'wp-ultimo'), 'position' => 'side', 'fields' => $fields, - 'html_attr' => array( + 'html_attr' => [ 'style' => 'margin-top: -6px;', 'data-wu-app' => 'invoice_customizer', 'data-wu-customizer-panel' => true, 'data-state' => json_encode($state), - ), - ) + ], + ] ); } @@ -322,7 +322,7 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page { */ public function action_links() { - return array(); + return []; } /** @@ -333,7 +333,7 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page { */ public function get_labels() { - return array( + return [ 'customize_label' => __('Customize Invoice Template', 'wp-ultimo'), 'add_new_label' => __('Customize Invoice Template', 'wp-ultimo'), 'edit_label' => __('Edit Invoice Template', 'wp-ultimo'), @@ -342,7 +342,7 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page { 'title_description' => __('This name is used for internal reference only.', 'wp-ultimo'), 'save_button_label' => __('Save Invoice Template', 'wp-ultimo'), 'save_description' => __('Save Invoice Template', 'wp-ultimo'), - ); + ]; } /** @@ -351,7 +351,7 @@ class Invoice_Template_Customize_Admin_Page extends Customizer_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_save() { + public function handle_save(): void { Invoice::save_settings($_POST); diff --git a/inc/admin-pages/class-jobs-list-admin-page.php b/inc/admin-pages/class-jobs-list-admin-page.php index 5f25672..f9bd3ce 100644 --- a/inc/admin-pages/class-jobs-list-admin-page.php +++ b/inc/admin-pages/class-jobs-list-admin-page.php @@ -66,9 +66,9 @@ class Jobs_List_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_read_jobs', - ); + ]; /** * Overrides the init method to add additional hooks. @@ -76,11 +76,11 @@ class Jobs_List_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { parent::init(); - add_filter('action_scheduler_admin_view_class', array($this, 'hide_as_admin_page'), 9999, 1); + add_filter('action_scheduler_admin_view_class', [$this, 'hide_as_admin_page'], 9999, 1); } /** @@ -97,7 +97,7 @@ class Jobs_List_Admin_Page extends Base_Admin_Page { return $admin_view_class; } - return '\WP_Ultimo\Compat\AS_Admin_View'; + return \WP_Ultimo\Compat\AS_Admin_View::class; } /** @@ -141,7 +141,7 @@ class Jobs_List_Admin_Page extends Base_Admin_Page { * @since 2.0.10 * @return void */ - public function page_loaded() { + public function page_loaded(): void { \ActionScheduler_AdminView::instance()->process_admin_ui(); } @@ -152,7 +152,7 @@ class Jobs_List_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function output() { + public function output(): void { \ActionScheduler_AdminView::instance()->render_admin_ui(); } diff --git a/inc/admin-pages/class-list-admin-page.php b/inc/admin-pages/class-list-admin-page.php index 837e08e..02821df 100644 --- a/inc/admin-pages/class-list-admin-page.php +++ b/inc/admin-pages/class-list-admin-page.php @@ -40,7 +40,7 @@ abstract class List_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @var array */ - protected $labels = array(); + protected $labels = []; /** * Holds the WP_List_Table instance to be used on the list @@ -56,7 +56,7 @@ abstract class List_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function page_loaded() { + public function page_loaded(): void { /** * Loads the list table @@ -90,14 +90,14 @@ abstract class List_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function init() { + public function init(): void { /** * Runs the parent init functions */ parent::init(); - add_filter('set-screen-option', array($this, 'save_screen_option'), 8, 3); + add_filter('set-screen-option', [$this, 'save_screen_option'], 8, 3); } /** @@ -106,7 +106,7 @@ abstract class List_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function process_single_action() { + public function process_single_action(): void { if ($this->table) { $this->table->process_single_action(); @@ -121,10 +121,10 @@ abstract class List_Admin_Page extends Base_Admin_Page { */ public function get_labels() { - return array( + return [ 'deleted_message' => __('Object removed successfully.', 'wp-ultimo'), 'search_label' => __('Search Object', 'wp-ultimo'), - ); + ]; } /** @@ -133,7 +133,7 @@ abstract class List_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function register_scripts() { + public function register_scripts(): void { parent::register_scripts(); @@ -152,18 +152,18 @@ abstract class List_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function output() { + public function output(): void { /** * Renders the base list page layout, with the columns and everything else =) */ wu_get_template( 'base/list', - array( + [ 'page' => $this, 'table' => $this->get_table(), 'classes' => $this->table->get_filters() ? 'wu-advanced-filters' : 'wu-no-advanced-filters', - ) + ] ); } @@ -184,14 +184,14 @@ abstract class List_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function screen_options() { + public function screen_options(): void { if ($this->table) { - $args = array( + $args = [ 'default' => 20, 'label' => $this->table->get_per_page_option_label(), 'option' => $this->table->get_per_page_option_name(), - ); + ]; add_screen_option('per_page', $args); } diff --git a/inc/admin-pages/class-membership-edit-admin-page.php b/inc/admin-pages/class-membership-edit-admin-page.php index b868fd1..481d01a 100644 --- a/inc/admin-pages/class-membership-edit-admin-page.php +++ b/inc/admin-pages/class-membership-edit-admin-page.php @@ -84,9 +84,9 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_edit_memberships', - ); + ]; /** * Override the page load. @@ -94,7 +94,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function page_loaded() { + public function page_loaded(): void { parent::page_loaded(); @@ -118,12 +118,12 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { return; } - $actions = array( - 'preview' => array( + $actions = [ + 'preview' => [ 'title' => __('Preview', 'wp-ultimo'), 'url' => add_query_arg('preview-swap', 1), - ), - ); + ], + ]; $date = new \DateTime($swap_order->scheduled_date); @@ -139,7 +139,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.4 * @return void */ - public function register_scripts() { + public function register_scripts(): void { parent::register_scripts(); @@ -152,17 +152,17 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function register_forms() { + public function register_forms(): void { /* * Transfer membership - Confirmation modal */ wu_register_form( 'transfer_membership', - array( - 'render' => array($this, 'render_transfer_membership_modal'), - 'handler' => array($this, 'handle_transfer_membership_modal'), + [ + 'render' => [$this, 'render_transfer_membership_modal'], + 'handler' => [$this, 'handle_transfer_membership_modal'], 'capability' => 'wu_transfer_memberships', - ) + ] ); /* @@ -170,10 +170,10 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { */ wu_register_form( 'edit_membership_product', - array( - 'render' => array($this, 'render_edit_membership_product_modal'), - 'handler' => array($this, 'handle_edit_membership_product_modal'), - ) + [ + 'render' => [$this, 'render_edit_membership_product_modal'], + 'handler' => [$this, 'handle_edit_membership_product_modal'], + ] ); /* @@ -181,10 +181,10 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { */ wu_register_form( 'change_membership_plan', - array( - 'render' => array($this, 'render_change_membership_plan_modal'), - 'handler' => array($this, 'handle_change_membership_plan_modal'), - ) + [ + 'render' => [$this, 'render_change_membership_plan_modal'], + 'handler' => [$this, 'handle_change_membership_plan_modal'], + ] ); /* @@ -192,17 +192,17 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { */ wu_register_form( 'remove_membership_product', - array( - 'render' => array($this, 'render_remove_membership_product'), - 'handler' => array($this, 'handle_remove_membership_product'), - ) + [ + 'render' => [$this, 'render_remove_membership_product'], + 'handler' => [$this, 'handle_remove_membership_product'], + ] ); add_filter( 'wu_data_json_success_delete_membership_modal', - fn($data_json) => array( - 'redirect_url' => wu_network_admin_url('wp-ultimo-memberships', array('deleted' => 1)), - ) + fn($data_json) => [ + 'redirect_url' => wu_network_admin_url('wp-ultimo-memberships', ['deleted' => 1]), + ] ); } @@ -212,7 +212,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - function render_transfer_membership_modal() { + function render_transfer_membership_modal(): void { $membership = wu_get_membership(wu_request('id')); @@ -220,52 +220,52 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { return; } - $fields = array( - 'confirm' => array( + $fields = [ + 'confirm' => [ 'type' => 'toggle', 'title' => __('Confirm Transfer', 'wp-ultimo'), 'desc' => __('This will start the transfer of assets from one customer to another.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'confirmed', - ), - ), - 'submit_button' => array( + ], + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Start Transfer', 'wp-ultimo'), 'placeholder' => __('Start Transfer', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:disabled' => '!confirmed', - ), - ), - 'id' => array( + ], + ], + 'id' => [ 'type' => 'hidden', 'value' => $membership->get_id(), - ), - 'target_customer_id' => array( + ], + 'target_customer_id' => [ 'type' => 'hidden', 'value' => wu_request('target_customer_id'), - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'total-actions', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'true', 'data-state' => json_encode( - array( + [ 'confirmed' => false, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -277,7 +277,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_transfer_membership_modal() { + public function handle_transfer_membership_modal(): void { $membership = wu_get_membership(wu_request('id')); @@ -305,23 +305,23 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { */ wu_enqueue_async_action( 'wu_async_transfer_membership', - array( + [ 'membership_id' => $membership->get_id(), 'target_customer_id' => $target_customer->get_id(), - ), + ], 'membership' ); wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url( 'wp-ultimo-edit-membership', - array( + [ 'id' => $membership->get_id(), 'transfer-started' => 1, - ) + ] ), - ) + ] ); } @@ -331,7 +331,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { parent::register_widgets(); @@ -353,102 +353,102 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { $this->add_fields_widget( 'at_a_glance', - array( + [ 'title' => __('At a Glance', 'wp-ultimo'), 'position' => 'normal', 'classes' => 'wu-overflow-hidden wu-widget-inset', 'field_wrapper_classes' => 'wu-w-1/3 wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t-0 wu-border-l-0 wu-border-r wu-border-b-0 wu-border-gray-300 wu-border-solid wu-float-left wu-relative', - 'fields' => array( - 'status' => array( + 'fields' => [ + 'status' => [ 'type' => 'text-display', 'title' => __('Membership Status', 'wp-ultimo'), 'display_value' => $tag, 'tooltip' => '', - ), - 'hash' => array( + ], + 'hash' => [ 'copy' => true, 'type' => 'text-display', 'title' => __('Reference ID', 'wp-ultimo'), 'display_value' => $this->get_object()->get_hash(), - ), - 'total_grossed' => array( + ], + 'total_grossed' => [ 'type' => 'text-display', 'title' => __('Total Grossed', 'wp-ultimo'), 'display_value' => wu_format_currency($this->get_object()->get_total_grossed(), $this->get_object()->get_currency()), 'wrapper_classes' => 'sm:wu-border-r-0', - ), - ), - ) + ], + ], + ] ); $this->add_list_table_widget( 'membership-products', - array( + [ 'position' => 'normal', 'title' => __('Products', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Membership_Line_Item_List_Table(), 'after' => $this->output_widget_products(), - ) + ] ); $this->add_list_table_widget( 'payments', - array( + [ 'title' => __('Payments', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Customers_Payment_List_Table(), - 'query_filter' => array($this, 'payments_query_filter'), - ) + 'query_filter' => [$this, 'payments_query_filter'], + ] ); $this->add_list_table_widget( 'sites', - array( + [ 'title' => __('Sites', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Memberships_Site_List_Table(), - 'query_filter' => array($this, 'sites_query_filter'), - ) + 'query_filter' => [$this, 'sites_query_filter'], + ] ); $this->add_list_table_widget( 'customer', - array( + [ 'title' => __('Linked Customer', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Site_Customer_List_Table(), - 'query_filter' => array($this, 'customer_query_filter'), - ) + 'query_filter' => [$this, 'customer_query_filter'], + ] ); $this->add_tabs_widget( 'options', - array( + [ 'title' => __('Membership Options', 'wp-ultimo'), 'position' => 'normal', 'sections' => apply_filters( 'wu_membership_options_sections', - array( - 'general' => array( + [ + 'general' => [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General membership options', 'wp-ultimo'), 'icon' => 'dashicons-wu-globe', - 'fields' => array( - 'blocking' => array( + 'fields' => [ + 'blocking' => [ 'type' => 'toggle', 'title' => __('Is Blocking?', 'wp-ultimo'), 'desc' => __('Should we block access to the site, plugins, themes, and services after the expiration date is reached?', 'wp-ultimo'), 'value' => true, - ), - ), - ), - 'billing_info' => array( + ], + ], + ], + 'billing_info' => [ 'title' => __('Billing Info', 'wp-ultimo'), 'desc' => __('Billing information for this particular membership.', 'wp-ultimo'), 'icon' => 'dashicons-wu-address', 'fields' => $this->get_object()->get_billing_address()->get_fields(), - ), - ), + ], + ], $this->get_object() ), - ) + ] ); /* @@ -457,62 +457,62 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { if ( ! $this->is_swap_preview) { $this->add_list_table_widget( 'events', - array( + [ 'title' => __('Events', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(), - 'query_filter' => array($this, 'events_query_filter'), - ) + 'query_filter' => [$this, 'events_query_filter'], + ] ); } - $regular_fields = array( - 'status' => array( + $regular_fields = [ + 'status' => [ 'type' => 'select', 'title' => __('Status', 'wp-ultimo'), 'desc' => __('The membership current status.', 'wp-ultimo'), 'value' => $this->get_object()->get_status(), 'options' => Membership_Status::to_array(), 'tooltip' => '', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'status', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - ), - 'cancellation_reason' => array( + ], + ], + 'cancellation_reason' => [ 'type' => 'textarea', 'title' => __('Cancellation Reason', 'wp-ultimo'), 'desc' => __('The reason why the customer cancelled this membership.', 'wp-ultimo'), 'value' => $this->get_object()->get_cancellation_reason(), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'status == \'cancelled\'', 'v-cloak' => '1', - ), - ), - 'cancel_gateway' => array( + ], + ], + 'cancel_gateway' => [ 'type' => 'toggle', 'title' => __('Cancel on gateway', 'wp-ultimo'), 'desc' => __('If enable we will cancel the subscription on payment method', 'wp-ultimo'), 'value' => false, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => ! empty($this->get_object()->get_gateway_customer_id()) ? 'status == \'cancelled\'' : 'false', 'v-cloak' => '1', - ), - ), - 'preview-swap' => array( + ], + ], + 'preview-swap' => [ 'type' => 'hidden', 'value' => wu_request('preview-swap', 0), - ), - 'customer_id' => array( + ], + 'customer_id' => [ 'type' => 'model', 'title' => __('Customer', 'wp-ultimo'), 'placeholder' => __('Search a Customer...', 'wp-ultimo'), 'desc' => __('The owner of this membership.', 'wp-ultimo'), 'value' => $this->get_object()->get_customer_id(), 'tooltip' => '', - 'html_attr' => array( - 'data-base-link' => wu_network_admin_url('wp-ultimo-edit-customer', array('id' => '')), + 'html_attr' => [ + 'data-base-link' => wu_network_admin_url('wp-ultimo-edit-customer', ['id' => '']), 'v-model' => 'customer_id', 'data-model' => 'customer', 'data-value-field' => 'id', @@ -520,53 +520,53 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { 'data-search-field' => 'display_name', 'data-max-items' => 1, 'data-selected' => $this->get_object()->get_customer() ? json_encode($this->get_object()->get_customer()->to_search_results()) : '', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - ), - 'transfer_note' => array( + ], + ], + 'transfer_note' => [ 'type' => 'note', 'desc' => __('Changing the customer will transfer this membership and all its assets, including sites, to the new customer.', 'wp-ultimo'), 'classes' => 'wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-w-full', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => '(original_customer_id != customer_id) && customer_id', 'v-cloak' => '1', - ), - ), - 'submit_save' => array( + ], + ], + 'submit_save' => [ 'type' => 'submit', 'title' => $labels['save_button_label'], 'placeholder' => $labels['save_button_label'], 'value' => 'save', 'classes' => 'button button-primary wu-w-full', - 'html_attr' => array(), - 'wrapper_html_attr' => array( + 'html_attr' => [], + 'wrapper_html_attr' => [ 'v-show' => 'original_customer_id == customer_id || !customer_id', 'v-cloak' => '1', - ), - ), - 'transfer' => array( + ], + ], + 'transfer' => [ 'type' => 'link', 'display_value' => __('Transfer Membership', 'wp-ultimo'), 'wrapper_classes' => 'wu-bg-gray-200', 'classes' => 'button wubox wu-w-full wu-text-center', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'original_customer_id != customer_id && customer_id', 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-bind:href' => "'" . wu_get_form_url( 'transfer_membership', - array( + [ 'id' => $this->get_object()->get_id(), 'target_customer_id' => '', - ) + ] ) . "=' + customer_id", 'title' => __('Transfer Membership', 'wp-ultimo'), - ), - ), - ); + ], + ], + ]; if ($this->get_object()->is_locked()) { unset($regular_fields['transfer_note']); @@ -580,30 +580,30 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { $this->add_fields_widget( 'save', - array( - 'html_attr' => array( + [ + 'html_attr' => [ 'data-wu-app' => 'membership_save', 'data-state' => json_encode( - array( + [ 'status' => $this->get_object()->get_status(), 'original_customer_id' => $this->get_object()->get_customer_id(), 'customer_id' => $this->get_object()->get_customer_id(), 'plan_id' => $this->get_object()->get_plan_id(), - ) + ] ), - ), + ], 'fields' => $regular_fields, - ) + ] ); $this->add_fields_widget( 'pricing', - array( + [ 'title' => __('Billing Amount', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'true', 'data-state' => json_encode( - array( + [ 'is_recurring' => $this->get_object()->is_recurring(), 'is_auto_renew' => $this->get_object()->should_auto_renew(), 'amount' => $this->get_object()->get_amount(), @@ -613,12 +613,12 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { 'gateway' => $this->get_object()->get_gateway(), 'gateway_subscription_id' => $this->get_object()->get_gateway_subscription_id(), 'gateway_customer_id' => $this->get_object()->get_gateway_customer_id(), - ) + ] ), - ), - 'fields' => array( + ], + 'fields' => [ // Fields for price - '_initial_amount' => array( + '_initial_amount' => [ 'type' => 'text', 'title' => __('Initial Amount', 'wp-ultimo'), // translators: %s is a price placeholder value. @@ -626,93 +626,93 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { 'desc' => __('The initial amount collected on the first payment.', 'wp-ultimo'), 'value' => $this->get_object()->get_initial_amount(), 'money' => true, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'initial_amount', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - ), - 'initial_amount' => array( + ], + ], + 'initial_amount' => [ 'type' => 'hidden', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'initial_amount', - ), - ), - 'recurring' => array( + ], + ], + 'recurring' => [ 'type' => 'toggle', 'title' => __('Is Recurring', 'wp-ultimo'), 'desc' => __('Use this option to manually enable or disable this membership.', 'wp-ultimo'), 'value' => $this->get_object()->is_recurring(), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'is_recurring', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - ), - 'amount' => array( + ], + ], + 'amount' => [ 'type' => 'hidden', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'amount', - ), - ), - 'recurring_amount_group' => array( + ], + ], + 'recurring_amount_group' => [ 'type' => 'group', 'title' => __('Recurring Amount', 'wp-ultimo'), // translators: placeholder %1$s is the amount, %2$s is the duration (such as 1, 2, 3), and %3$s is the unit (such as month, year, week) 'desc' => sprintf(__('The customer will be charged %1$s every %2$s %3$s(s).', 'wp-ultimo'), '{{ wu_format_money(amount) }}', '{{ duration }}', '{{ duration_unit }}'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'is_recurring', 'v-cloak' => '1', - ), - 'fields' => array( - '_amount' => array( + ], + 'fields' => [ + '_amount' => [ 'type' => 'text', 'value' => $this->get_object()->get_amount(), 'placeholder' => wu_format_currency('99'), 'wrapper_classes' => '', 'money' => true, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'amount', - ), - ), - 'duration' => array( + ], + ], + 'duration' => [ 'type' => 'number', 'value' => $this->get_object()->get_duration(), 'placeholder' => '', 'wrapper_classes' => 'wu-mx-2 wu-w-1/3', 'min' => 0, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'duration', 'steps' => 1, - ), - ), - 'duration_unit' => array( + ], + ], + 'duration_unit' => [ 'type' => 'select', 'value' => $this->get_object()->get_duration_unit(), 'placeholder' => '', 'wrapper_classes' => 'wu-w-2/3', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'duration_unit', - ), - 'options' => array( + ], + 'options' => [ 'day' => __('Days', 'wp-ultimo'), 'week' => __('Weeks', 'wp-ultimo'), 'month' => __('Months', 'wp-ultimo'), 'year' => __('Years', 'wp-ultimo'), - ), - ), - ), - ), - 'recurring_note' => array( + ], + ], + ], + ], + 'recurring_note' => [ 'type' => 'note', 'desc' => $gateway_message, 'classes' => 'wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-w-full', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => implode( ' && ', - array( + [ 'is_recurring', 'gateway', 'gateway === "' . $this->get_object()->get_gateway() . '"', @@ -720,55 +720,55 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { 'gateway_customer_id === "' . $this->get_object()->get_gateway_customer_id() . '"', '(' . implode( ' || ', - array( + [ $this->get_object()->get_amount() . ' !== amount', $this->get_object()->get_duration() . ' != duration', '"' . $this->get_object()->get_duration_unit() . '" !== duration_unit', - ) + ] ) . ')', - ) + ] ), 'v-cloak' => '1', - ), - ), - 'billing_cycles' => array( + ], + ], + 'billing_cycles' => [ 'type' => 'number', 'title' => __('Billing Cycles', 'wp-ultimo'), 'placeholder' => __('E.g. 0', 'wp-ultimo'), 'desc' => __('How many times should we bill this customer. Leave 0 to charge until cancelled.', 'wp-ultimo'), 'value' => $this->get_object()->get_billing_cycles(), 'min' => 0, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'is_recurring', 'v-cloak' => '1', - ), - ), - 'times_billed' => array( + ], + ], + 'times_billed' => [ 'type' => 'number', 'title' => __('Times Billed', 'wp-ultimo'), 'desc' => __('The number of times this membership was billed so far.', 'wp-ultimo'), 'value' => $this->get_object()->get_times_billed(), 'min' => 0, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'is_recurring', 'v-cloak' => '1', - ), - ), + ], + ], - 'auto_renew' => array( + 'auto_renew' => [ 'type' => 'toggle', 'title' => __('Auto-Renew?', 'wp-ultimo'), 'desc' => __('Activating this will tell the gateway to try to automatically charge for this membership.', 'wp-ultimo'), 'value' => $this->get_object()->should_auto_renew(), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'is_recurring', 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'is_auto_renew', - ), - ), - 'gateway' => array( + ], + ], + 'gateway' => [ 'type' => 'text', 'title' => __('Gateway', 'wp-ultimo'), 'placeholder' => __('e.g. stripe', 'wp-ultimo'), @@ -776,15 +776,15 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { 'desc' => __('Payment gateway used to process the payment.', 'wp-ultimo'), 'value' => $this->get_object()->get_gateway(), 'wrapper_classes' => 'wu-w-full', - 'html_attr' => array( + 'html_attr' => [ 'v-on:input' => 'gateway = $event.target.value.toLowerCase().replace(/[^a-z0-9-_]+/g, "")', 'v-bind:value' => 'gateway', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - ), - 'gateway_customer_id_group' => array( + ], + ], + 'gateway_customer_id_group' => [ 'type' => 'group', 'desc' => function (): string { @@ -802,27 +802,27 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { return ''; }, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'is_recurring && is_auto_renew', 'v-cloak' => '1', - ), - 'fields' => array( - 'gateway_customer_id' => array( + ], + 'fields' => [ + 'gateway_customer_id' => [ 'type' => 'text', 'title' => __('Gateway Customer ID', 'wp-ultimo'), 'placeholder' => __('Gateway Customer ID', 'wp-ultimo'), 'value' => $this->get_object()->get_gateway_customer_id(), 'tooltip' => '', 'wrapper_classes' => 'wu-w-full', - 'wrapper_html_attr' => array(), - 'html_attr' => array( + 'wrapper_html_attr' => [], + 'html_attr' => [ 'v-model' => 'gateway_customer_id', - ), - ), - ), - ), + ], + ], + ], + ], - 'gateway_subscription_id_group' => array( + 'gateway_subscription_id_group' => [ 'type' => 'group', 'desc' => function (): string { @@ -840,59 +840,59 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { return ''; }, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'is_recurring && is_auto_renew', 'v-cloak' => '1', - ), - 'fields' => array( - 'gateway_subscription_id' => array( + ], + 'fields' => [ + 'gateway_subscription_id' => [ 'type' => 'text', 'title' => __('Gateway Subscription ID', 'wp-ultimo'), 'placeholder' => __('Gateway Subscription ID', 'wp-ultimo'), 'value' => $this->get_object()->get_gateway_subscription_id(), 'tooltip' => '', 'wrapper_classes' => 'wu-w-full', - 'wrapper_html_attr' => array(), - 'html_attr' => array( + 'wrapper_html_attr' => [], + 'html_attr' => [ 'v-model' => 'gateway_subscription_id', - ), - ), - ), - ), + ], + ], + ], + ], - 'gateway_note' => array( + 'gateway_note' => [ 'type' => 'note', 'desc' => __('We will try to cancel the old subscription on the gateway.', 'wp-ultimo'), 'classes' => 'wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-w-full', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'is_recurring && (' . implode( ' || ', - array( + [ '"' . $this->get_object()->get_gateway() . '" !== "" && gateway !== "' . $this->get_object()->get_gateway() . '"', '"' . $this->get_object()->get_gateway_subscription_id() . '" !== "" && gateway_subscription_id !== "' . $this->get_object()->get_gateway_subscription_id() . '"', '"' . $this->get_object()->get_gateway_customer_id() . '" !== "" && gateway_customer_id !== "' . $this->get_object()->get_gateway_customer_id() . '"', - ) + ] ) . ')', 'v-cloak' => '1', - ), - ), - ), - ) + ], + ], + ], + ] ); - $timestamp_fields = array(); + $timestamp_fields = []; - $timestamps = array( + $timestamps = [ 'date_expiration' => __('Expires at', 'wp-ultimo'), 'date_renewed' => __('Last Renewed at', 'wp-ultimo'), 'date_trial_end' => __('Trial Ends at', 'wp-ultimo'), 'date_cancellation' => __('Cancelled at', 'wp-ultimo'), - ); + ]; foreach ($timestamps as $timestamp_name => $timestamp_label) { $value = $this->get_object()->{"get_$timestamp_name"}(); - $timestamp_fields[ $timestamp_name ] = array( + $timestamp_fields[ $timestamp_name ] = [ 'title' => $timestamp_label, 'type' => 'text-edit', 'date' => true, @@ -900,30 +900,30 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { 'display_value' => $this->edit ? $value : '', 'value' => $value, 'placeholder' => '2020-04-04 12:00:00', - 'html_attr' => array( + 'html_attr' => [ 'wu-datepicker' => 'true', 'data-format' => 'Y-m-d H:i:S', 'data-allow-time' => 'true', - ), - ); + ], + ]; } if ( ! $this->get_object()->is_lifetime()) { - $timestamp_fields['convert_to_lifetime'] = array( + $timestamp_fields['convert_to_lifetime'] = [ 'type' => 'submit', 'title' => __('Convert to Lifetime', 'wp-ultimo'), 'value' => 'convert_to_lifetime', 'classes' => 'button wu-w-full', - 'wrapper_html_attr' => array(), - ); + 'wrapper_html_attr' => [], + ]; } $this->add_fields_widget( 'membership-timestamps', - array( + [ 'title' => __('Important Timestamps', 'wp-ultimo'), 'fields' => $timestamp_fields, - ) + ] ); } @@ -937,9 +937,9 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { return wu_get_template_contents( 'memberships/product-list', - array( + [ 'membership' => $this->get_object(), - ) + ] ); } @@ -973,7 +973,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { */ public function action_links() { - return array(); + return []; } /** @@ -984,7 +984,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { */ public function get_labels() { - return array( + return [ 'edit_label' => __('Edit Membership', 'wp-ultimo'), 'add_new_label' => __('Add new Membership', 'wp-ultimo'), 'updated_message' => __('Membership updated with success!', 'wp-ultimo'), @@ -994,7 +994,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { 'save_description' => '', 'delete_button_label' => __('Delete Membership', 'wp-ultimo'), 'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'), - ); + ]; } /** @@ -1022,12 +1022,12 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { */ public function sites_query_filter($args) { - $args['meta_query'] = array( - 'membership_id' => array( + $args['meta_query'] = [ + 'membership_id' => [ 'key' => 'wu_membership_id', 'value' => $this->get_object()->get_id(), - ), - ); + ], + ]; return $args; } @@ -1057,10 +1057,10 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { */ public function events_query_filter($args) { - $extra_args = array( + $extra_args = [ 'object_type' => 'membership', 'object_id' => absint($this->get_object()->get_id()), - ); + ]; return array_merge($args, $extra_args); } @@ -1101,12 +1101,12 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { $this->is_swap_preview = true; - $actions = array( - 'preview' => array( + $actions = [ + 'preview' => [ 'title' => __('← Go back', 'wp-ultimo'), 'url' => remove_query_arg('preview-swap', wu_get_current_url()), - ), - ); + ], + ]; $date = new \DateTime($swap_order->scheduled_date); @@ -1150,9 +1150,9 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { return false; } - $array_params = array( + $array_params = [ 'updated' => 1, - ); + ]; if ($this->edit === false) { $array_params['id'] = $object->get_id(); @@ -1217,9 +1217,9 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { $object->delete_scheduled_swap(); - $array_params = array( + $array_params = [ 'updated' => 1, - ); + ]; $url = add_query_arg($array_params); @@ -1239,7 +1239,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function render_edit_membership_product_modal() { + public function render_edit_membership_product_modal(): void { $membership = wu_get_membership(wu_request('id')); @@ -1255,63 +1255,63 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { $gateway_message = $gateway ? $gateway->get_amount_update_message() : ''; } - $fields = array( - 'product_id' => array( + $fields = [ + 'product_id' => [ 'type' => 'model', 'title' => __('Product', 'wp-ultimo'), 'placeholder' => __('Search product...', 'wp-ultimo'), 'value' => '', 'tooltip' => '', - 'html_attr' => array( + 'html_attr' => [ 'data-model' => 'product', 'data-value-field' => 'id', 'data-label-field' => 'name', 'data-search-field' => 'name', 'data-max-items' => 1, 'data-selected' => '', - ), - ), - 'quantity' => array( + ], + ], + 'quantity' => [ 'type' => 'number', 'title' => __('Quantity', 'wp-ultimo'), 'value' => 1, 'placeholder' => 1, 'wrapper_classes' => 'wu-w-1/2', - 'html_attr' => array( + 'html_attr' => [ 'min' => 1, 'required' => 'required', - ), - ), - 'update_price' => array( + ], + ], + 'update_price' => [ 'type' => 'toggle', 'title' => __('Update Pricing', 'wp-ultimo'), 'desc' => __('Checking this box will update the membership pricing. Otherwise, the products will be added without changing the membership prices.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'update_pricing', - ), - ), - 'transfer_note' => array( + ], + ], + 'transfer_note' => [ 'type' => 'note', 'desc' => $gateway_message, 'classes' => 'sm:wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-w-full', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'update_pricing', 'v-cloak' => '1', - ), - ), - 'submit_button' => array( + ], + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Add Product', 'wp-ultimo'), 'placeholder' => __('Add Product', 'wp-ultimo'), 'value' => 'save', 'classes' => 'wu-w-full button button-primary', 'wrapper_classes' => 'wu-items-end', - ), - 'id' => array( + ], + 'id' => [ 'type' => 'hidden', 'value' => $membership->get_id(), - ), - ); + ], + ]; if ( ! $gateway_message) { unset($fields['transfer_note']); @@ -1320,19 +1320,19 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { $form = new \WP_Ultimo\UI\Form( 'edit_membership_product', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'edit_membership_product', 'data-state' => wu_convert_to_state( - array( + [ 'update_pricing' => 0, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -1344,7 +1344,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return mixed */ - public function handle_edit_membership_product_modal() { + public function handle_edit_membership_product_modal(): void { $membership = wu_get_membership(wu_request('id')); @@ -1382,9 +1382,9 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { } wp_send_json_success( - array( + [ 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']), - ) + ] ); } @@ -1394,7 +1394,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function render_remove_membership_product() { + public function render_remove_membership_product(): void { $membership = wu_get_membership(wu_request('id')); @@ -1410,52 +1410,52 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { $gateway_message = $gateway ? $gateway->get_amount_update_message() : ''; } - $fields = array( - 'quantity' => array( + $fields = [ + 'quantity' => [ 'type' => 'number', 'title' => __('Quantity', 'wp-ultimo'), 'value' => 1, 'placeholder' => 1, 'wrapper_classes' => 'wu-w-1/2', - 'html_attr' => array( + 'html_attr' => [ 'min' => 1, 'required' => 'required', - ), - ), - 'update_price' => array( + ], + ], + 'update_price' => [ 'type' => 'toggle', 'title' => __('Update Pricing?', 'wp-ultimo'), 'desc' => __('Checking this box will update the membership pricing. Otherwise, the products will be added without changing the membership prices.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'update_pricing', - ), - ), - 'transfer_note' => array( + ], + ], + 'transfer_note' => [ 'type' => 'note', 'desc' => $gateway_message, 'classes' => 'sm:wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-w-full', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'update_pricing', 'v-cloak' => '1', - ), - ), - 'submit_button' => array( + ], + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Remove Product', 'wp-ultimo'), 'placeholder' => __('Remove Product', 'wp-ultimo'), 'value' => 'save', 'classes' => 'wu-w-full button button-primary', 'wrapper_classes' => 'wu-items-end', - ), - 'id' => array( + ], + 'id' => [ 'type' => 'hidden', 'value' => $membership->get_id(), - ), - 'product_id' => array( + ], + 'product_id' => [ 'type' => 'hidden', 'value' => wu_request('product_id', 0), - ), - ); + ], + ]; if ( ! $gateway_message) { unset($fields['transfer_note']); @@ -1464,19 +1464,19 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { $form = new \WP_Ultimo\UI\Form( 'edit_membership_product', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'edit_membership_product', 'data-state' => wu_convert_to_state( - array( + [ 'update_pricing' => 0, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -1488,7 +1488,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_remove_membership_product() { + public function handle_remove_membership_product(): void { $membership = wu_get_membership(wu_request('id')); @@ -1532,9 +1532,9 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { } wp_send_json_success( - array( + [ 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']), - ) + ] ); } @@ -1544,7 +1544,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function render_change_membership_plan_modal() { + public function render_change_membership_plan_modal(): void { $membership = wu_get_membership(wu_request('id')); @@ -1566,15 +1566,15 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { $gateway_message = $gateway ? $gateway->get_amount_update_message() : ''; } - $fields = array( - 'plan_id' => array( + $fields = [ + 'plan_id' => [ 'type' => 'model', 'title' => __('Plan', 'wp-ultimo'), 'placeholder' => __('Search new Plan...', 'wp-ultimo'), 'desc' => __('Select a new plan for this membership.', 'wp-ultimo'), 'value' => $product->get_id(), 'tooltip' => '', - 'html_attr' => array( + 'html_attr' => [ 'data-model' => 'plan', 'v-model' => 'plan_id', 'data-value-field' => 'id', @@ -1582,42 +1582,42 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { 'data-search-field' => 'name', 'data-max-items' => 1, 'data-selected' => json_encode($product->to_search_results()), - ), - ), - 'update_price' => array( + ], + ], + 'update_price' => [ 'type' => 'toggle', 'title' => __('Update Pricing', 'wp-ultimo'), 'desc' => __('Checking this box will update the membership pricing. Otherwise, the products will be added without changing the membership prices.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'update_pricing', - ), - ), - 'transfer_note' => array( + ], + ], + 'transfer_note' => [ 'type' => 'note', 'desc' => $gateway_message, 'classes' => 'sm:wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-w-full', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'update_pricing', 'v-cloak' => '1', - ), - ), - 'submit_button' => array( + ], + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Change Product', 'wp-ultimo'), 'placeholder' => __('Change Product', 'wp-ultimo'), 'value' => 'save', 'classes' => 'wu-w-full button button-primary', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:class' => 'plan_id == original_plan_id ? "button-disabled" : ""', 'v-bind:disabled' => 'plan_id == original_plan_id', - ), - ), - 'id' => array( + ], + ], + 'id' => [ 'type' => 'hidden', 'value' => $membership->get_id(), - ), - ); + ], + ]; if ( ! $gateway_message) { unset($fields['transfer_note']); @@ -1626,21 +1626,21 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { $form = new \WP_Ultimo\UI\Form( 'change_membership_plan', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'change_membership_plan', 'data-state' => wu_convert_to_state( - array( + [ 'update_pricing' => 0, 'original_plan_id' => $product->get_id(), 'plan_id' => $product->get_id(), - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -1652,7 +1652,7 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return mixed */ - public function handle_change_membership_plan_modal() { + public function handle_change_membership_plan_modal(): void { $membership = wu_get_membership(wu_request('id')); @@ -1704,9 +1704,9 @@ class Membership_Edit_Admin_Page extends Edit_Admin_Page { } wp_send_json_success( - array( + [ 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']), - ) + ] ); } } diff --git a/inc/admin-pages/class-membership-list-admin-page.php b/inc/admin-pages/class-membership-list-admin-page.php index 94b0870..0f00401 100644 --- a/inc/admin-pages/class-membership-list-admin-page.php +++ b/inc/admin-pages/class-membership-list-admin-page.php @@ -53,9 +53,9 @@ class Membership_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_read_memberships', - ); + ]; /** * Register ajax forms to handle adding new memberships. @@ -63,17 +63,17 @@ class Membership_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function register_forms() { + public function register_forms(): void { /* * Add new Membership */ wu_register_form( 'add_new_membership', - array( - 'render' => array($this, 'render_add_new_membership_modal'), - 'handler' => array($this, 'handle_add_new_membership_modal'), + [ + 'render' => [$this, 'render_add_new_membership_modal'], + 'handler' => [$this, 'handle_add_new_membership_modal'], 'capability' => 'wu_edit_memberships', - ) + ] ); } @@ -83,37 +83,37 @@ class Membership_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function render_add_new_membership_modal() { + public function render_add_new_membership_modal(): void { - $fields = array( - 'customer_id' => array( + $fields = [ + 'customer_id' => [ 'type' => 'model', 'title' => __('Customer', 'wp-ultimo'), 'placeholder' => __('Search Customer...', 'wp-ultimo'), 'desc' => __('The customer to attach this membership to.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'data-model' => 'customer', 'data-value-field' => 'id', 'data-label-field' => 'display_name', 'data-search-field' => 'display_name', 'data-max-items' => 1, - ), - ), - 'product_ids' => array( + ], + ], + 'product_ids' => [ 'type' => 'model', 'title' => __('Products', 'wp-ultimo'), 'placeholder' => __('Search Products...', 'wp-ultimo'), 'desc' => __('You can add multiples products to this membership.', 'wp-ultimo'), 'tooltip' => '', - 'html_attr' => array( + 'html_attr' => [ 'data-model' => 'product', 'data-value-field' => 'id', 'data-label-field' => 'name', 'data-search-field' => 'name', 'data-max-items' => 99, - ), - ), - 'status' => array( + ], + ], + 'status' => [ 'type' => 'select', 'title' => __('Status', 'wp-ultimo'), 'placeholder' => __('Status', 'wp-ultimo'), @@ -121,59 +121,59 @@ class Membership_List_Admin_Page extends List_Admin_Page { 'tooltip' => '', 'value' => Membership_Status::PENDING, 'options' => Membership_Status::to_array(), - ), - 'lifetime' => array( + ], + 'lifetime' => [ 'type' => 'toggle', 'title' => __('Lifetime', 'wp-ultimo'), 'desc' => __('Activate this toggle to mark the newly created membership as lifetime.', 'wp-ultimo'), 'value' => 1, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'lifetime', - ), - ), - 'date_expiration' => array( + ], + ], + 'date_expiration' => [ 'title' => __('Expiration Date', 'wp-ultimo'), 'desc' => __('Set the expiration date of the membership to be created.', 'wp-ultimo'), 'type' => 'text', 'date' => true, 'value' => gmdate('Y-m-d', strtotime('+1 month')), 'placeholder' => '2020-04-04', - 'html_attr' => array( + 'html_attr' => [ 'wu-datepicker' => 'true', 'data-format' => 'Y-m-d', 'data-allow-time' => 'false', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => '!lifetime', 'v-cloak' => 1, - ), - ), - 'submit_button' => array( + ], + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Create Membership', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'add_new_membership', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'add_new_membership', 'data-on-load' => 'wu_initialize_datepickers', 'data-state' => wu_convert_to_state( - array( + [ 'lifetime' => 1, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -185,7 +185,7 @@ class Membership_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_add_new_membership_modal() { + public function handle_add_new_membership_modal(): void { global $wpdb; @@ -214,10 +214,10 @@ class Membership_List_Admin_Page extends List_Admin_Page { } $cart = new \WP_Ultimo\Checkout\Cart( - array( + [ 'products' => $products, 'country' => $customer->get_country(), - ) + ] ); $data = $cart->to_membership_data(); @@ -243,14 +243,14 @@ class Membership_List_Admin_Page extends List_Admin_Page { } wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url( 'wp-ultimo-edit-membership', - array( + [ 'id' => $membership->get_id(), - ) + ] ), - ) + ] ); } @@ -262,10 +262,10 @@ class Membership_List_Admin_Page extends List_Admin_Page { */ public function get_labels() { - return array( + return [ 'deleted_message' => __('Membership removed successfully.', 'wp-ultimo'), 'search_label' => __('Search Membership', 'wp-ultimo'), - ); + ]; } /** @@ -309,14 +309,14 @@ class Membership_List_Admin_Page extends List_Admin_Page { */ public function action_links() { - return array( - array( + return [ + [ 'label' => __('Add Membership'), 'icon' => 'wu-circle-with-plus', 'classes' => 'wubox', 'url' => wu_get_form_url('add_new_membership'), - ), - ); + ], + ]; } /** diff --git a/inc/admin-pages/class-migration-alert-admin-page.php b/inc/admin-pages/class-migration-alert-admin-page.php index 65e28c0..61370ec 100644 --- a/inc/admin-pages/class-migration-alert-admin-page.php +++ b/inc/admin-pages/class-migration-alert-admin-page.php @@ -66,9 +66,9 @@ class Migration_Alert_Admin_Page extends Wizard_Admin_Page { * @since 2.0.24 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'manage_network', - ); + ]; /** * Overrides original construct method. @@ -93,7 +93,7 @@ class Migration_Alert_Admin_Page extends Wizard_Admin_Page { */ public function get_logo() { - return wu_get_asset('logo.png', 'img'); + return wu_get_asset('logo.webp', 'img'); } /** @@ -126,13 +126,13 @@ class Migration_Alert_Admin_Page extends Wizard_Admin_Page { */ public function get_sections() { - return array( - 'alert' => array( + return [ + 'alert' => [ 'title' => __('Alert!', 'wp-ultimo'), - 'view' => array($this, 'section_alert'), - 'handler' => array($this, 'handle_proceed'), - ), - ); + 'view' => [$this, 'section_alert'], + 'handler' => [$this, 'handle_proceed'], + ], + ]; } /** @@ -141,14 +141,14 @@ class Migration_Alert_Admin_Page extends Wizard_Admin_Page { * @since 2.0.24 * @return void */ - public function section_alert() { + public function section_alert(): void { wu_get_template( 'wizards/setup/alert', - array( + [ 'screen' => get_current_screen(), 'page' => $this, - ) + ] ); } @@ -158,7 +158,7 @@ class Migration_Alert_Admin_Page extends Wizard_Admin_Page { * @since 2.0.24 * @return void */ - public function handle_proceed() { + public function handle_proceed(): void { delete_network_option(null, 'wu_setup_finished'); delete_network_option(null, 'wu_is_migration_done'); diff --git a/inc/admin-pages/class-payment-edit-admin-page.php b/inc/admin-pages/class-payment-edit-admin-page.php index 0fb0698..e5490ad 100644 --- a/inc/admin-pages/class-payment-edit-admin-page.php +++ b/inc/admin-pages/class-payment-edit-admin-page.php @@ -77,9 +77,9 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_edit_payments', - ); + ]; /** * Registers the necessary scripts and styles for this admin page. @@ -87,7 +87,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.4 * @return void */ - public function register_scripts() { + public function register_scripts(): void { parent::register_scripts(); @@ -100,17 +100,17 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function register_forms() { + public function register_forms(): void { /* * Edit/Add Line Item */ wu_register_form( 'edit_line_item', - array( - 'render' => array($this, 'render_edit_line_item_modal'), - 'handler' => array($this, 'handle_edit_line_item_modal'), + [ + 'render' => [$this, 'render_edit_line_item_modal'], + 'handler' => [$this, 'handle_edit_line_item_modal'], 'capability' => 'wu_edit_payments', - ) + ] ); /* @@ -118,11 +118,11 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { */ wu_register_form( 'delete_line_item', - array( - 'render' => array($this, 'render_delete_line_item_modal'), - 'handler' => array($this, 'handle_delete_line_item_modal'), + [ + 'render' => [$this, 'render_delete_line_item_modal'], + 'handler' => [$this, 'handle_delete_line_item_modal'], 'capability' => 'wu_delete_payments', - ) + ] ); /* @@ -130,11 +130,11 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { */ wu_register_form( 'refund_payment', - array( - 'render' => array($this, 'render_refund_payment_modal'), - 'handler' => array($this, 'handle_refund_payment_modal'), + [ + 'render' => [$this, 'render_refund_payment_modal'], + 'handler' => [$this, 'handle_refund_payment_modal'], 'capability' => 'wu_refund_payments', - ) + ] ); /* @@ -142,9 +142,9 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { */ add_filter( 'wu_data_json_success_delete_payment_modal', - fn($data_json) => array( - 'redirect_url' => wu_network_admin_url('wp-ultimo-payments', array('deleted' => 1)), - ) + fn($data_json) => [ + 'redirect_url' => wu_network_admin_url('wp-ultimo-payments', ['deleted' => 1]), + ] ); } @@ -154,7 +154,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function render_delete_line_item_modal() { + public function render_delete_line_item_modal(): void { $payment = wu_get_payment(wu_request('id')); @@ -164,51 +164,51 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { return; } - $fields = array( - 'confirm' => array( + $fields = [ + 'confirm' => [ 'type' => 'toggle', 'title' => __('Confirm Deletion', 'wp-ultimo'), 'desc' => __('This action can not be undone.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'confirmed', - ), - ), - 'submit_button' => array( + ], + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Delete', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:disabled' => '!confirmed', - ), - ), - 'id' => array( + ], + ], + 'id' => [ 'type' => 'hidden', 'value' => $payment->get_id(), - ), - 'line_item_id' => array( + ], + 'line_item_id' => [ 'type' => 'hidden', 'value' => $line_item->get_id(), - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'total-actions', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'true', 'data-state' => wu_convert_to_state( - array( + [ 'confirmed' => false, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -220,7 +220,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_delete_line_item_modal() { + public function handle_delete_line_item_modal(): void { $payment = wu_get_payment(wu_request('id')); @@ -243,9 +243,9 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { } wp_send_json_success( - array( + [ 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']), - ) + ] ); } @@ -255,7 +255,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - function render_refund_payment_modal() { + function render_refund_payment_modal(): void { $payment = wu_get_payment(wu_request('id')); @@ -263,110 +263,110 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { return; } - $fields = array( - '_amount' => array( + $fields = [ + '_amount' => [ 'type' => 'text', 'title' => __('Refund Amount', 'wp-ultimo'), 'placeholder' => __('Refund Amount', 'wp-ultimo'), 'money' => true, 'min' => 0, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'amount', 'step' => '0.01', 'v-bind:max' => 'total', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'step === 1', - ), - ), - 'amount' => array( + ], + ], + 'amount' => [ 'type' => 'hidden', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'amount', - ), - ), - 'cancel_membership' => array( + ], + ], + 'cancel_membership' => [ 'type' => 'toggle', 'title' => __('Cancel Related Membership?', 'wp-ultimo'), 'desc' => __('Checking this option will cancel the membership as well.', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'step === 1', - ), - ), - 'refund_not_immediate_note' => array( + ], + ], + 'refund_not_immediate_note' => [ 'type' => 'note', 'desc' => __('Confirming the refund might not immediately change the status of the payment, as each gateway handles refunds differently and WP Multisite WaaS relies on the gateway reporting a successful refund before changing the status.', 'wp-ultimo'), 'classes' => 'wu-p-2 wu-bg-yellow-200 wu-text-yellow-700 wu-rounded wu-w-full', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'step === 2', 'v-cloak' => '1', - ), - ), - 'confirm' => array( + ], + ], + 'confirm' => [ 'type' => 'toggle', 'title' => __('Confirm Refund', 'wp-ultimo'), 'desc' => __('This action can not be undone.', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'step === 2', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'confirmed', - ), - ), - 'submit_button' => array( + ], + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Next Step', 'wp-ultimo'), 'placeholder' => __('Next Step', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'step === 1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-bind:disabled' => 'amount <= 0 || amount > total', 'v-on:click.prevent' => 'step = 2', - ), - ), - 'submit_button_2' => array( + ], + ], + 'submit_button_2' => [ 'type' => 'submit', 'title' => __('Issue Refund', 'wp-ultimo'), 'placeholder' => __('Issue Refund', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:disabled' => '!confirmed', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'step === 2', - ), - ), - 'id' => array( + ], + ], + 'id' => [ 'type' => 'hidden', 'value' => $payment->get_id(), - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'total-actions', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'refund', 'data-state' => wu_convert_to_state( - array( + [ 'step' => 1, 'confirmed' => false, 'total' => round($payment->get_total(), 2), 'amount' => round($payment->get_total(), 2), - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -378,7 +378,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_refund_payment_modal() { + public function handle_refund_payment_modal(): void { $amount = wu_to_float(wu_request('amount')); @@ -438,15 +438,15 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { * Done! Redirect back. */ wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url( 'wp-ultimo-edit-payment', - array( + [ 'id' => $payment->get_id(), 'updated' => 1, - ) + ] ), - ) + ] ); } @@ -498,15 +498,15 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { * Done! Redirect back. */ wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url( 'wp-ultimo-edit-payment', - array( + [ 'id' => $payment->get_id(), 'updated' => 1, - ) + ] ), - ) + ] ); } @@ -516,14 +516,14 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return mixed */ - public function handle_edit_line_item_modal() { + public function handle_edit_line_item_modal(): void { $payment = wu_get_payment(wu_request('payment_id')); $line_item = wu_get_line_item(wu_request('line_item_id'), $payment->get_id()); if ( ! $line_item) { - $line_item = new \WP_Ultimo\Checkout\Line_Item(array()); + $line_item = new \WP_Ultimo\Checkout\Line_Item([]); } /* @@ -550,7 +550,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { * Constructs the arguments * for the product line item. */ - $atts = array( + $atts = [ 'product' => $product, 'quantity' => wu_request('quantity', 1), 'unit_price' => wu_to_float(wu_request('unit_price')), @@ -559,7 +559,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { 'tax_rate' => wu_request('tax_rate', 0), 'tax_type' => wu_request('tax_type', 'percentage'), 'tax_label' => wu_request('tax_label', ''), - ); + ]; } else { /** @@ -570,11 +570,11 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { */ $allowed_types = apply_filters( 'wu_allowed_line_item_types', - array( + [ 'fee', 'refund', 'credit', - ) + ] ); if ( ! in_array($type, $allowed_types, true)) { @@ -586,7 +586,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { /* * Set the new attributes */ - $atts = array( + $atts = [ 'quantity' => 1, 'title' => wu_request('title', ''), 'description' => wu_request('description', '--'), @@ -594,7 +594,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { 'tax_rate' => 0, 'tax_type' => 'percentage', 'tax_label' => '', - ); + ]; } $line_item->attributes($atts); @@ -618,9 +618,9 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { } wp_send_json_success( - array( + [ 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']), - ) + ] ); } @@ -630,7 +630,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function render_edit_line_item_modal() { + public function render_edit_line_item_modal(): void { /* * Get the payment line item. */ @@ -641,102 +641,102 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { * If that doesn't work, * we start a new line. */ - $line_item = new \WP_Ultimo\Checkout\Line_Item(array()); + $line_item = new \WP_Ultimo\Checkout\Line_Item([]); } - $fields = array( - 'tab' => array( + $fields = [ + 'tab' => [ 'type' => 'tab-select', - 'options' => array( + 'options' => [ 'type' => __('Type', 'wp-ultimo'), 'info' => __('Additional Info', 'wp-ultimo'), 'tax' => __('Tax Info', 'wp-ultimo'), - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'tab', - ), - ), - 'type' => array( + ], + ], + 'type' => [ 'type' => 'select', 'title' => __('Line Item Type', 'wp-ultimo'), 'desc' => __('Select the line item type.', 'wp-ultimo'), - 'options' => array( + 'options' => [ 'product' => __('Product', 'wp-ultimo'), 'refund' => __('Refund', 'wp-ultimo'), 'fee' => __('Fee', 'wp-ultimo'), 'credit' => __('Credit', 'wp-ultimo'), - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'tab === "type"', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'type', - ), - ), - 'product_id' => array( + ], + ], + 'product_id' => [ 'type' => 'model', 'title' => __('Product', 'wp-ultimo'), 'desc' => __('Product associated with this line item.', 'wp-ultimo'), 'placeholder' => __('Search Products', 'wp-ultimo'), 'value' => $line_item->get_product_id(), 'tooltip' => '', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'type === "product" && tab === "type"', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'data-model' => 'product', 'data-value-field' => 'id', 'data-label-field' => 'name', 'data-search-field' => 'name', 'data-max-items' => 1, 'data-selected' => $line_item->get_product() ? json_encode($line_item->get_product()->to_search_results()) : '', - ), - ), - 'title' => array( + ], + ], + 'title' => [ 'type' => 'text', 'title' => __('Line Item Title', 'wp-ultimo'), 'placeholder' => __('E.g. Extra Charge', 'wp-ultimo'), 'desc' => __('This is used when generating invoices.', 'wp-ultimo'), 'value' => $line_item->get_title(), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'tab === "info"', - ), - ), - 'description' => array( + ], + ], + 'description' => [ 'type' => 'textarea', 'title' => __('Line Item Description', 'wp-ultimo'), 'placeholder' => __('E.g. This service was done to improve performance.', 'wp-ultimo'), 'desc' => __('This is used when generating invoices.', 'wp-ultimo'), 'value' => $line_item->get_description(), - 'html_attr' => array( + 'html_attr' => [ 'rows' => 4, - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'tab === "info"', - ), - ), - 'quantity' => array( + ], + ], + 'quantity' => [ 'type' => 'number', 'title' => __('Quantity', 'wp-ultimo'), 'desc' => __('Item quantity.', 'wp-ultimo'), 'value' => $line_item->get_quantity(), 'placeholder' => __('E.g. 1', 'wp-ultimo'), 'wrapper_classes' => 'wu-w-1/2', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'type === "product" && tab === "type"', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'min' => 1, 'required' => 'required', - ), - ), - 'unit_price' => array( + ], + ], + 'unit_price' => [ 'type' => 'hidden', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'unit_price', - ), - ), - '_unit_price' => array( + ], + ], + '_unit_price' => [ 'type' => 'text', 'title' => __('Unit Price', 'wp-ultimo'), 'desc' => __('Item unit price. This is multiplied by the quantity to calculate the sub-total.', 'wp-ultimo'), @@ -745,16 +745,16 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { 'value' => $line_item->get_unit_price(), 'money' => true, 'wrapper_classes' => 'wu-w-1/2', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'type === "product" && tab === "type"', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'required' => 'required', 'step' => '0.01', 'v-model' => 'unit_price', - ), - ), - '_unit_price_amount' => array( + ], + ], + '_unit_price_amount' => [ 'type' => 'text', 'title' => __('Amount', 'wp-ultimo'), 'desc' => __('Refund, credit or fee amount.', 'wp-ultimo'), @@ -763,105 +763,105 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { 'value' => $line_item->get_unit_price(), 'money' => true, 'wrapper_classes' => 'wu-w-1/2', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'type !== "product" && tab === "type"', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'required' => 'required', 'step' => '0.01', 'v-model' => 'unit_price', - ), - ), - 'taxable' => array( + ], + ], + 'taxable' => [ 'type' => 'toggle', 'title' => __('Is Taxable?', 'wp-ultimo'), 'desc' => __('Checking this box will toggle the tax controls.', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-bind:class' => 'type !== "product" ? "wu-opacity-50" : ""', 'v-show' => 'tab === "tax"', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'taxable', 'v-bind:disabled' => 'type !== "product"', - ), - ), - 'tax_label' => array( + ], + ], + 'tax_label' => [ 'type' => 'text', 'title' => __('Tax Label', 'wp-ultimo'), 'placeholder' => __('E.g. ES VAT', 'wp-ultimo'), 'desc' => __('Tax description. This is shown on invoices to end customers.', 'wp-ultimo'), 'value' => $line_item->get_tax_label(), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'taxable && tab === "tax"', - ), - ), - 'tax_rate_group' => array( + ], + ], + 'tax_rate_group' => [ 'type' => 'group', 'title' => __('Tax Rate', 'wp-ultimo'), 'desc' => __('Tax rate and type to apply to this item.', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'taxable && tab === "tax"', - ), - 'fields' => array( - 'tax_rate' => array( + ], + 'fields' => [ + 'tax_rate' => [ 'type' => 'number', 'value' => $line_item->get_tax_rate(), 'placeholder' => '', 'wrapper_classes' => 'wu-mr-2 wu-w-1/3', - 'html_attr' => array( + 'html_attr' => [ 'required' => 'required', 'step' => '0.01', - ), - ), - 'tax_type' => array( + ], + ], + 'tax_type' => [ 'type' => 'select', 'value' => $line_item->get_tax_type(), 'placeholder' => '', 'wrapper_classes' => 'wu-w-2/3', - 'options' => array( + 'options' => [ 'percentage' => __('Percentage (%)', 'wp-ultimo'), 'absolute' => __('Flat Rate ($)', 'wp-ultimo'), - ), - ), - ), - ), - 'submit_button' => array( + ], + ], + ], + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Save', 'wp-ultimo'), 'placeholder' => __('Save', 'wp-ultimo'), 'value' => 'save', 'classes' => 'wu-w-full button button-primary', 'wrapper_classes' => 'wu-items-end', - ), - 'line_item_id' => array( + ], + 'line_item_id' => [ 'type' => 'hidden', 'value' => $line_item->get_id(), - ), - 'payment_id' => array( + ], + 'payment_id' => [ 'type' => 'hidden', 'value' => wu_request('id'), - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'edit_line_item', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'edit_line_item', 'data-state' => wu_convert_to_state( - array( + [ 'tab' => 'type', 'type' => $line_item->get_type(), 'taxable' => $line_item->get_tax_rate() > 0, 'unit_price' => $line_item->get_unit_price(), - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -875,42 +875,42 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { */ public function display_payment_actions() { - $actions = array(); + $actions = []; $is_refundable = in_array($this->get_object()->get_status(), wu_get_refundable_payment_types(), true); if ($is_refundable) { - $actions['refund_payment'] = array( + $actions['refund_payment'] = [ 'label' => __('Refund Payment', 'wp-ultimo'), 'icon_classes' => 'dashicons-wu-ccw wu-align-text-bottom', 'classes' => 'button wubox', 'href' => wu_get_form_url( 'refund_payment', - array( + [ 'id' => $this->get_object()->get_id(), - ) + ] ), - ); + ]; } - $actions['add_line_item'] = array( + $actions['add_line_item'] = [ 'label' => __('Add Line Item', 'wp-ultimo'), 'icon_classes' => 'dashicons-wu-circle-with-plus wu-align-text-bottom', 'classes' => 'button wubox', 'href' => wu_get_form_url( 'edit_line_item', - array( + [ 'id' => $this->get_object()->get_id(), - ) + ] ), - ); + ]; return wu_get_template_contents( 'payments/line-item-actions', - array( + [ 'payment' => $this->get_object(), 'actions' => $actions, - ) + ] ); } @@ -920,16 +920,16 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function display_tax_breakthrough() { + public function display_tax_breakthrough(): void { $tax_breakthrough = $this->get_object()->get_tax_breakthrough(); wu_get_template( 'payments/tax-details', - array( + [ 'tax_breakthrough' => $tax_breakthrough, 'payment' => $this->get_object(), - ) + ] ); } @@ -939,7 +939,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { parent::register_widgets(); @@ -951,91 +951,91 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { $this->add_fields_widget( 'at_a_glance', - array( + [ 'title' => __('At a Glance', 'wp-ultimo'), 'position' => 'normal', 'classes' => 'wu-overflow-hidden wu-widget-inset', 'field_wrapper_classes' => 'wu-w-1/3 wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t-0 wu-border-l-0 wu-border-r wu-border-b-0 wu-border-gray-300 wu-border-solid wu-float-left wu-relative', - 'fields' => array( - 'status' => array( + 'fields' => [ + 'status' => [ 'type' => 'text-display', 'title' => __('Payment Status', 'wp-ultimo'), 'display_value' => $tag, 'tooltip' => '', - ), - 'hash' => array( + ], + 'hash' => [ 'copy' => true, 'type' => 'text-display', 'title' => __('Reference ID', 'wp-ultimo'), 'display_value' => $this->get_object()->get_hash(), - ), - 'total' => array( + ], + 'total' => [ 'type' => 'text-display', 'title' => __('Total', 'wp-ultimo'), 'display_value' => wu_format_currency($this->get_object()->get_total(), $this->get_object()->get_currency()), 'wrapper_classes' => 'sm:wu-border-r-0', - ), - ), - ) + ], + ], + ] ); $this->add_list_table_widget( 'line-items', - array( + [ 'title' => __('Line Items', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Payment_Line_Item_List_Table(), 'position' => 'normal', - 'query_filter' => array($this, 'payments_query_filter'), + 'query_filter' => [$this, 'payments_query_filter'], 'after' => $this->display_payment_actions(), - ) + ] ); $this->add_widget( 'tax-rates', - array( + [ 'title' => __('Tax Rate Breakthrough', 'wp-ultimo'), 'position' => 'normal', - 'display' => array($this, 'display_tax_breakthrough'), - ) + 'display' => [$this, 'display_tax_breakthrough'], + ] ); $this->add_tabs_widget( 'options', - array( + [ 'title' => __('Payment Options', 'wp-ultimo'), 'position' => 'normal', - 'sections' => apply_filters('wu_payments_options_sections', array(), $this->get_object()), - ) + 'sections' => apply_filters('wu_payments_options_sections', [], $this->get_object()), + ] ); $this->add_list_table_widget( 'events', - array( + [ 'title' => __('Events', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(), - 'query_filter' => array($this, 'events_query_filter'), - ) + 'query_filter' => [$this, 'events_query_filter'], + ] ); $membership = $this->get_object()->get_membership(); $this->add_save_widget( 'save', - array( - 'html_attr' => array( + [ + 'html_attr' => [ 'data-wu-app' => 'payment_save', 'data-state' => wu_convert_to_state( - array( + [ 'status' => $this->get_object()->get_status(), 'original_status' => $this->get_object()->get_status(), 'membership_id' => $membership ? $this->get_object()->get_membership_id() : '', 'membership_status' => $membership ? $membership->get_status() : 'active', 'gateway' => $this->get_object()->get_gateway(), - ) + ] ), - ), - 'fields' => array( - 'status' => array( + ], + 'fields' => [ + 'status' => [ 'type' => 'select', 'title' => __('Status', 'wp-ultimo'), 'placeholder' => __('Status', 'wp-ultimo'), @@ -1043,43 +1043,43 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { 'value' => $this->get_object()->get_status(), 'options' => Payment_Status::to_array(), 'tooltip' => '', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'status', - ), - ), - 'confirm_membership' => array( + ], + ], + 'confirm_membership' => [ 'type' => 'toggle', 'title' => __('Activate Membership?', 'wp-ultimo'), 'desc' => __('This payment belongs to a pending membership. If you toggle this option, this change in status will also apply to the membership. If any sites are pending, they are also going to be published automatically.', 'wp-ultimo'), 'value' => 0, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'status !== original_status && status === "completed" && membership_status === "pending"', 'v-cloak' => '1', - ), - ), - 'membership_id' => array( + ], + ], + 'membership_id' => [ 'type' => 'model', 'title' => __('Membership', 'wp-ultimo'), 'desc' => __('The membership associated with this payment.', 'wp-ultimo'), 'value' => $this->get_object()->get_membership_id(), 'tooltip' => '', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'membership_id', - 'data-base-link' => wu_network_admin_url('wp-ultimo-edit-membership', array('id' => '')), + 'data-base-link' => wu_network_admin_url('wp-ultimo-edit-membership', ['id' => '']), 'data-model' => 'membership', 'data-value-field' => 'id', 'data-label-field' => 'reference_code', 'data-max-items' => 1, 'data-selected' => $this->get_object()->get_membership() ? json_encode($this->get_object()->get_membership()->to_search_results()) : '', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - ), - 'gateway' => array( + ], + ], + 'gateway' => [ 'type' => 'text', 'title' => __('Gateway', 'wp-ultimo'), 'placeholder' => __('e.g. stripe', 'wp-ultimo'), @@ -1087,15 +1087,15 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { 'desc' => __('Payment gateway used to process the payment.', 'wp-ultimo'), 'value' => $this->get_object()->get_gateway(), 'wrapper_classes' => 'wu-w-full', - 'html_attr' => array( + 'html_attr' => [ 'v-on:input' => 'gateway = $event.target.value.toLowerCase().replace(/[^a-z0-9-_]+/g, "")', 'v-bind:value' => 'gateway', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - ), - 'gateway_payment_id_group' => array( + ], + ], + 'gateway_payment_id_group' => [ 'type' => 'group', 'desc' => function (): string { @@ -1113,12 +1113,12 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { return ''; }, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => '1', 'v-show' => 'gateway', - ), - 'fields' => array( - 'gateway_payment_id' => array( + ], + 'fields' => [ + 'gateway_payment_id' => [ 'type' => 'text', 'title' => __('Gateway Payment ID', 'wp-ultimo'), 'placeholder' => __('e.g. EX897540987913', 'wp-ultimo'), @@ -1126,12 +1126,12 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { 'tooltip' => __('This will usually be set automatically by the payment gateway.', 'wp-ultimo'), 'value' => $this->get_object()->get_gateway_payment_id(), 'wrapper_classes' => 'wu-w-full', - 'html_attr' => array(), - 'wrapper_html_attr' => array(), - ), - ), - ), - 'invoice_number' => array( + 'html_attr' => [], + 'wrapper_html_attr' => [], + ], + ], + ], + 'invoice_number' => [ 'type' => 'number', 'min' => 0, 'title' => __('Invoice Number', 'wp-ultimo'), @@ -1140,13 +1140,13 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { 'desc' => __('The invoice number for this particular payment.', 'wp-ultimo'), 'value' => $this->get_object()->get_saved_invoice_number(), 'wrapper_classes' => 'wu-w-full', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => json_encode(wu_get_setting('invoice_numbering_scheme', 'reference_code') === 'sequential_number'), 'v-cloak' => '1', - ), - ), - ), - ) + ], + ], + ], + ] ); } @@ -1180,23 +1180,23 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { */ public function action_links() { - $actions = array(); + $actions = []; $payment = $this->get_object(); if ($payment) { - $actions[] = array( + $actions[] = [ 'url' => $payment->get_invoice_url(), 'label' => __('Generate Invoice', 'wp-ultimo'), 'icon' => 'wu-attachment', - ); + ]; if ($payment->is_payable()) { - $actions[] = array( + $actions[] = [ 'url' => $payment->get_payment_url(), 'label' => __('Payment URL', 'wp-ultimo'), 'icon' => 'wu-credit-card', - ); + ]; } } @@ -1211,7 +1211,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { */ public function get_labels() { - return array( + return [ 'edit_label' => __('Edit Payment', 'wp-ultimo'), 'add_new_label' => __('Add new Payment', 'wp-ultimo'), 'updated_message' => __('Payment updated with success!', 'wp-ultimo'), @@ -1221,7 +1221,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { 'save_description' => '', 'delete_button_label' => __('Delete Payment', 'wp-ultimo'), 'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'), - ); + ]; } /** @@ -1234,10 +1234,10 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { */ public function events_query_filter($args) { - $extra_args = array( + $extra_args = [ 'object_type' => 'payment', 'object_id' => absint($this->get_object()->get_id()), - ); + ]; return array_merge($args, $extra_args); } @@ -1252,10 +1252,10 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { */ public function payments_query_filter($args) { - $extra_args = array( + $extra_args = [ 'parent' => absint($this->get_object()->get_id()), 'parent__in' => false, - ); + ]; return array_merge($args, $extra_args); } @@ -1309,7 +1309,7 @@ class Payment_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_save() { + public function handle_save(): void { $this->get_object()->recalculate_totals()->save(); diff --git a/inc/admin-pages/class-payment-list-admin-page.php b/inc/admin-pages/class-payment-list-admin-page.php index b879956..fad858e 100644 --- a/inc/admin-pages/class-payment-list-admin-page.php +++ b/inc/admin-pages/class-payment-list-admin-page.php @@ -52,9 +52,9 @@ class Payment_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_read_payments', - ); + ]; /** * Register ajax forms that we use for payments. @@ -62,17 +62,17 @@ class Payment_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function register_forms() { + public function register_forms(): void { /* * Edit/Add Line Item */ wu_register_form( 'add_new_payment', - array( - 'render' => array($this, 'render_add_new_payment_modal'), - 'handler' => array($this, 'handle_add_new_payment_modal'), + [ + 'render' => [$this, 'render_add_new_payment_modal'], + 'handler' => [$this, 'handle_add_new_payment_modal'], 'capability' => 'wu_edit_payments', - ) + ] ); } @@ -82,25 +82,25 @@ class Payment_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function render_add_new_payment_modal() { + public function render_add_new_payment_modal(): void { - $fields = array( - 'products' => array( + $fields = [ + 'products' => [ 'type' => 'model', 'title' => __('Products', 'wp-ultimo'), 'placeholder' => __('Search Products...', 'wp-ultimo'), 'desc' => __('Each product will be added as a line item.', 'wp-ultimo'), 'value' => '', 'tooltip' => '', - 'html_attr' => array( + 'html_attr' => [ 'data-model' => 'product', 'data-value-field' => 'id', 'data-label-field' => 'name', 'data-search-field' => 'name', 'data-max-items' => 10, - ), - ), - 'status' => array( + ], + ], + 'status' => [ 'type' => 'select', 'title' => __('Status', 'wp-ultimo'), 'placeholder' => __('Status', 'wp-ultimo'), @@ -108,54 +108,54 @@ class Payment_List_Admin_Page extends List_Admin_Page { 'value' => Payment_Status::COMPLETED, 'options' => Payment_Status::to_array(), 'tooltip' => '', - ), - 'membership_id' => array( + ], + 'membership_id' => [ 'type' => 'model', 'title' => __('Membership', 'wp-ultimo'), 'placeholder' => __('Search Membership...', 'wp-ultimo'), 'desc' => __('The membership associated with this payment.', 'wp-ultimo'), 'value' => '', 'tooltip' => '', - 'html_attr' => array( + 'html_attr' => [ 'data-model' => 'membership', 'data-value-field' => 'id', 'data-label-field' => 'reference_code', 'data-max-items' => 1, 'data-selected' => '', - ), - ), - 'add_setup_fees' => array( + ], + ], + 'add_setup_fees' => [ 'type' => 'toggle', 'title' => __('Include Setup Fees', 'wp-ultimo'), 'desc' => __('Checking this box will include setup fees attached to the selected products as well.', 'wp-ultimo'), 'value' => 1, - ), - 'submit_button' => array( + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Add Payment', 'wp-ultimo'), 'value' => 'save', 'classes' => 'wu-w-full button button-primary', 'wrapper_classes' => 'wu-items-end', - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'add_payment', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'add_payment', 'data-state' => wu_convert_to_state( - array( + [ 'taxable' => 0, 'type' => 'product', - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -178,19 +178,19 @@ class Payment_List_Admin_Page extends List_Admin_Page { } $cart = new \WP_Ultimo\Checkout\Cart( - array( + [ 'products' => explode(',', (string) wu_request('products')), 'cart_type' => wu_request('add_setup_fees') ? 'new' : 'renewal', - ) + ] ); $payment_data = array_merge( $cart->to_payment_data(), - array( + [ 'status' => wu_request('status'), 'membership_id' => $membership->get_id(), 'customer_id' => $membership->get_customer_id(), - ) + ] ); $payment = wu_create_payment($payment_data); @@ -200,14 +200,14 @@ class Payment_List_Admin_Page extends List_Admin_Page { } wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url( 'wp-ultimo-edit-payment', - array( + [ 'id' => $payment->get_id(), - ) + ] ), - ) + ] ); } @@ -227,10 +227,10 @@ class Payment_List_Admin_Page extends List_Admin_Page { */ public function get_labels() { - return array( + return [ 'deleted_message' => __('Payment removed successfully.', 'wp-ultimo'), 'search_label' => __('Search Payment', 'wp-ultimo'), - ); + ]; } /** @@ -274,14 +274,14 @@ class Payment_List_Admin_Page extends List_Admin_Page { */ public function action_links() { - return array( - array( + return [ + [ 'label' => __('Add Payment', 'wp-ultimo'), 'icon' => 'wu-circle-with-plus', 'classes' => 'wubox', 'url' => wu_get_form_url('add_new_payment'), - ), - ); + ], + ]; } /** diff --git a/inc/admin-pages/class-placeholders-admin-page.php b/inc/admin-pages/class-placeholders-admin-page.php index 68c78ef..0162e8e 100644 --- a/inc/admin-pages/class-placeholders-admin-page.php +++ b/inc/admin-pages/class-placeholders-admin-page.php @@ -58,9 +58,9 @@ class Placeholders_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'manage_network', - ); + ]; /** * Returns the title of the page. @@ -101,24 +101,24 @@ class Placeholders_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function output() { + public function output(): void { do_action('wu_load_edit_placeholders_list_page'); $columns = apply_filters( 'wu_edit_placeholders_columns', - array( + [ 'placeholder' => __('Placeholder', 'wp-ultimo'), 'content' => __('Content', 'wp-ultimo'), - ) + ] ); wu_get_template( 'sites/edit-placeholders', - array( + [ 'columns' => $columns, - 'types' => array(), - ) + 'types' => [], + ] ); } @@ -128,20 +128,20 @@ class Placeholders_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { parent::register_scripts(); - wp_register_script('wu-edit-placeholders', wu_get_asset('edit-placeholders.js', 'js'), array('wu-admin', 'wu-vue', 'underscore'), wu_get_version(), false); + wp_register_script('wu-edit-placeholders', wu_get_asset('edit-placeholders.js', 'js'), ['wu-admin', 'wu-vue', 'underscore'], wu_get_version(), false); wp_localize_script( 'wu-edit-placeholders', 'wu_placeholdersl10n', - array( + [ 'name' => __('Tax', 'wp-ultimo'), 'confirm_message' => __('Are you sure you want to delete this rows?', 'wp-ultimo'), 'confirm_delete_tax_category_message' => __('Are you sure you want to delete this tax category?', 'wp-ultimo'), - ) + ] ); wp_enqueue_script('wu-edit-placeholders'); diff --git a/inc/admin-pages/class-product-edit-admin-page.php b/inc/admin-pages/class-product-edit-admin-page.php index 2d81934..514da3f 100644 --- a/inc/admin-pages/class-product-edit-admin-page.php +++ b/inc/admin-pages/class-product-edit-admin-page.php @@ -77,9 +77,9 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_edit_products', - ); + ]; /** * Register ajax forms. @@ -87,15 +87,15 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function register_forms() { + public function register_forms(): void { /* * Adds the hooks to handle deletion. */ - add_filter('wu_form_fields_delete_product_modal', array($this, 'product_extra_delete_fields'), 10, 2); + add_filter('wu_form_fields_delete_product_modal', [$this, 'product_extra_delete_fields'], 10, 2); - add_action('wu_after_delete_product_modal', array($this, 'product_after_delete_actions')); + add_action('wu_after_delete_product_modal', [$this, 'product_after_delete_actions']); - add_filter("wu_page_{$this->id}_load", array($this, 'add_new_product_warning_message')); + add_filter("wu_page_{$this->id}_load", [$this, 'add_new_product_warning_message']); } /** @@ -104,7 +104,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function add_new_product_warning_message() { + public function add_new_product_warning_message(): void { if (wu_request('wu-new-model')) { if ( ! $this->get_object() || $this->get_object()->get_type() !== Product_Type::PLAN) { @@ -113,28 +113,28 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { \WP_Ultimo\UI\Tours::get_instance()->create_tour( 'new_product_warning', - array( - array( + [ + [ 'id' => 'new-product-warning', 'title' => __('On adding a new product...', 'wp-ultimo'), - 'text' => array( + 'text' => [ __("You just successfully added a new product to your WP Multisite WaaS network and that's awesome!", 'wp-ultimo'), __('Keep in mind that newly created products do not appear automatically in your checkout forms.', 'wp-ultimo'), __('To make a product available on registration, you will need to manually add it to the pricing table field of your checkout forms.', 'wp-ultimo'), - ), - 'buttons' => array( - array( + ], + 'buttons' => [ + [ 'classes' => 'button wu-text-xs sm:wu-normal-case wu-float-left', 'text' => __('Go to Checkout Forms', 'wp-ultimo'), 'url' => wu_network_admin_url('wp-ultimo-checkout-forms'), - ), - ), - 'attachTo' => array( + ], + ], + 'attachTo' => [ 'element' => '#message.updated', 'on' => 'top', - ), - ), - ) + ], + ], + ] ); } } @@ -150,22 +150,22 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { */ public function product_extra_delete_fields($fields, $product) { - $custom_fields = array( - 're_assignment_product_id' => array( + $custom_fields = [ + 're_assignment_product_id' => [ 'type' => 'model', 'title' => __('Re-assign Memberships to', 'wp-ultimo'), 'placeholder' => __('Select Product...', 'wp-ultimo'), 'tooltip' => __('The product you select here will be assigned to all the memberships attached to the product you are deleting.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'data-model' => 'product', 'data-value-field' => 'id', 'data-label-field' => 'name', 'data-search-field' => 'name', 'data-max-items' => 1, - 'data-exclude' => json_encode(array($product->get_id())), - ), - ), - ); + 'data-exclude' => json_encode([$product->get_id()]), + ], + ], + ]; return array_merge($custom_fields, $fields); } @@ -178,7 +178,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { * @param object $product The product object. * @return void */ - public function product_after_delete_actions($product) { + public function product_after_delete_actions($product): void { global $wpdb; @@ -205,7 +205,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { parent::register_scripts(); @@ -218,37 +218,37 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { parent::register_widgets(); $this->add_fields_widget( 'description', - array( + [ 'title' => __('Description', 'wp-ultimo'), 'position' => 'normal', - 'fields' => array( - 'description' => array( + 'fields' => [ + 'description' => [ 'type' => 'textarea', 'title' => __('Product Description', 'wp-ultimo'), 'placeholder' => __('Tell your customers what this product is about.', 'wp-ultimo'), 'tooltip' => __('This description is made available for layouts and can be shown to end customers.', 'wp-ultimo'), 'value' => $this->get_object()->get_description(), - 'html_attr' => array( + 'html_attr' => [ 'rows' => 3, - ), - ), - ), - ) + ], + ], + ], + ] ); $this->add_tabs_widget( 'product_options', - array( + [ 'title' => __('Product Options', 'wp-ultimo'), 'position' => 'normal', 'sections' => $this->get_product_option_sections(), - ) + ] ); /* @@ -258,20 +258,20 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { $this->add_list_table_widget( 'events', - array( + [ 'title' => __('Events', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(), - 'query_filter' => array($this, 'query_filter'), - ) + 'query_filter' => [$this, 'query_filter'], + ] ); $save_widget_args = apply_filters( 'wu_product_edit_save_widget', - array( - 'html_attr' => array( + [ + 'html_attr' => [ 'data-wu-app' => 'product_pricing', 'data-state' => json_encode( - array( + [ 'is_recurring' => $this->get_object()->is_recurring(), 'pricing_type' => $this->get_object()->get_pricing_type(), 'has_trial' => $this->get_object()->get_trial_duration() > 0, @@ -280,211 +280,211 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { 'amount' => $this->get_object()->get_formatted_amount(), 'duration' => $this->get_object()->get_duration(), 'duration_unit' => $this->get_object()->get_duration_unit(), - ) + ] ), - ), - 'fields' => array( + ], + 'fields' => [ // Fields for price - 'pricing_type' => array( + 'pricing_type' => [ 'type' => 'select', 'title' => __('Pricing Type', 'wp-ultimo'), 'placeholder' => __('Select Pricing Type', 'wp-ultimo'), 'desc' => __('Products can be free, paid, or require further contact for pricing.', 'wp-ultimo'), 'value' => $this->get_object()->get_pricing_type(), 'tooltip' => '', - 'options' => array( + 'options' => [ 'paid' => __('Paid', 'wp-ultimo'), 'free' => __('Free', 'wp-ultimo'), 'contact_us' => __('Contact Us', 'wp-ultimo'), - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'pricing_type', - ), - ), - 'contact_us_label' => array( + ], + ], + 'contact_us_label' => [ 'type' => 'text', 'title' => __('Button Label', 'wp-ultimo'), 'placeholder' => __('E.g. Contact us', 'wp-ultimo'), 'desc' => __('This will be used on the pricing table CTA button, as the label.', 'wp-ultimo'), 'value' => $this->get_object()->get_contact_us_label(), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "pricing_type == 'contact_us'", 'v-cloak' => '1', - ), - ), - 'contact_us_link' => array( + ], + ], + 'contact_us_link' => [ 'type' => 'url', 'title' => __('Button Link', 'wp-ultimo'), 'placeholder' => __('E.g. https://contactus.page.com', 'wp-ultimo'), 'desc' => __('This will be used on the pricing table CTA button.', 'wp-ultimo'), 'value' => $this->get_object()->get_contact_us_link(), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "pricing_type == 'contact_us'", 'v-cloak' => '1', - ), - ), - 'recurring' => array( + ], + ], + 'recurring' => [ 'type' => 'toggle', 'title' => __('Is Recurring?', 'wp-ultimo'), 'desc' => __('Check this if this product has a recurring charge.', 'wp-ultimo'), 'value' => $this->get_object()->is_recurring(), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "pricing_type == 'paid'", 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'is_recurring', - ), - ), - 'amount' => array( + ], + ], + 'amount' => [ 'type' => 'hidden', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'amount', - ), - ), - '_amount' => array( + ], + ], + '_amount' => [ 'type' => 'text', 'title' => __('Price', 'wp-ultimo'), 'placeholder' => __('Price', 'wp-ultimo'), 'value' => $this->get_object()->get_formatted_amount(), 'tooltip' => '', 'money' => true, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "pricing_type == 'paid' && !is_recurring ", 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-bind:name' => '""', 'v-model' => 'amount', - ), - ), - 'amount_group' => array( + ], + ], + 'amount_group' => [ 'type' => 'group', 'title' => __('Price', 'wp-ultimo'), // translators: placeholder %1$s is the amount, %2$s is the duration (such as 1, 2, 3), and %3$s is the unit (such as month, year, week) 'desc' => sprintf(__('The customer will be charged %1$s every %2$s %3$s(s).', 'wp-ultimo'), '{{ wu_format_money(amount) }}', '{{ duration }}', '{{ duration_unit }}'), 'tooltip' => '', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "is_recurring && pricing_type == 'paid'", 'v-cloak' => '1', - ), - 'fields' => array( - '_amount' => array( + ], + 'fields' => [ + '_amount' => [ 'type' => 'text', 'value' => $this->get_object()->get_formatted_amount(), 'placeholder' => wu_format_currency('99'), 'wrapper_classes' => '', 'money' => true, - 'html_attr' => array( + 'html_attr' => [ 'v-bind:name' => '""', 'v-model' => 'amount', - ), - ), - 'duration' => array( + ], + ], + 'duration' => [ 'type' => 'number', 'value' => $this->get_object()->get_duration(), 'placeholder' => '', 'wrapper_classes' => 'wu-mx-2 wu-w-1/3', 'min' => 0, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'duration', 'steps' => 1, - ), - ), - 'duration_unit' => array( + ], + ], + 'duration_unit' => [ 'type' => 'select', 'value' => $this->get_object()->get_duration_unit(), 'placeholder' => '', 'wrapper_classes' => 'wu-w-2/3', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'duration_unit', - ), - 'options' => array( + ], + 'options' => [ 'day' => __('Days', 'wp-ultimo'), 'week' => __('Weeks', 'wp-ultimo'), 'month' => __('Months', 'wp-ultimo'), 'year' => __('Years', 'wp-ultimo'), - ), - ), - ), - ), - 'billing_cycles' => array( + ], + ], + ], + ], + 'billing_cycles' => [ 'type' => 'number', 'title' => __('Billing Cycles', 'wp-ultimo'), 'placeholder' => __('E.g. 1', 'wp-ultimo'), 'desc' => __('How many times should we bill this customer. Leave 0 to charge until cancelled.', 'wp-ultimo'), 'value' => $this->get_object()->get_billing_cycles(), 'tooltip' => '', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "is_recurring && pricing_type == 'paid'", 'v-cloak' => '1', - ), - ), - 'has_trial' => array( + ], + ], + 'has_trial' => [ 'type' => 'toggle', 'title' => __('Offer Trial', 'wp-ultimo'), 'desc' => __('Check if you want to add a trial period to this product.', 'wp-ultimo'), 'value' => $this->get_object()->has_trial(), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "pricing_type == 'paid'", 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'has_trial', - ), - ), - 'trial_group' => array( + ], + ], + 'trial_group' => [ 'type' => 'group', 'title' => __('Trial', 'wp-ultimo'), 'tooltip' => '', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "has_trial && pricing_type == 'paid'", 'v-cloak' => '1', - ), - 'fields' => array( - 'trial_duration' => array( + ], + 'fields' => [ + 'trial_duration' => [ 'type' => 'number', 'value' => $this->get_object()->get_trial_duration(), 'placeholder' => '', 'wrapper_classes' => 'wu-mr-2 wu-w-1/3', - ), - 'trial_duration_unit' => array( + ], + 'trial_duration_unit' => [ 'type' => 'select', 'value' => $this->get_object()->get_trial_duration_unit(), 'placeholder' => '', 'wrapper_classes' => 'wu-w-2/3', - 'options' => array( + 'options' => [ 'day' => __('Days', 'wp-ultimo'), 'week' => __('Weeks', 'wp-ultimo'), 'month' => __('Months', 'wp-ultimo'), 'year' => __('Years', 'wp-ultimo'), - ), - ), - ), - ), - 'has_setup_fee' => array( + ], + ], + ], + ], + 'has_setup_fee' => [ 'type' => 'toggle', 'title' => __('Add Setup Fee?', 'wp-ultimo'), 'desc' => __('Check if you want to add a setup fee.', 'wp-ultimo'), 'value' => $this->get_object()->has_setup_fee(), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "pricing_type == 'paid'", 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'has_setup_fee', - ), - ), - 'setup_fee' => array( + ], + ], + 'setup_fee' => [ 'type' => 'hidden', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'setup_fee', - ), - ), - '_setup_fee' => array( + ], + ], + '_setup_fee' => [ 'type' => 'text', 'money' => true, 'title' => __('Setup Fee', 'wp-ultimo'), @@ -492,16 +492,16 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { // translators: %s is a price placeholder value. 'placeholder' => sprintf(__('E.g. %s', 'wp-ultimo'), wu_format_currency(199)), 'value' => $this->get_object()->get_formatted_amount('setup_fee'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "has_setup_fee && pricing_type == 'paid'", 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'setup_fee', - ), - ), - ), - ), + ], + ], + ], + ], $this->get_object() ); @@ -509,34 +509,34 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { $this->add_fields_widget( 'active', - array( + [ 'title' => __('Active', 'wp-ultimo'), - 'fields' => array( - 'active' => array( + 'fields' => [ + 'active' => [ 'type' => 'toggle', 'title' => __('Active', 'wp-ultimo'), 'desc' => __('Use this option to manually enable or disable this product for new sign-ups.', 'wp-ultimo'), 'value' => $this->get_object()->is_active(), - ), - ), - ) + ], + ], + ] ); $this->add_fields_widget( 'image', - array( + [ 'title' => __('Product Image', 'wp-ultimo'), - 'fields' => array( - 'featured_image_id' => array( + 'fields' => [ + 'featured_image_id' => [ 'type' => 'image', 'stacked' => true, 'title' => __('Product Image', 'wp-ultimo'), 'desc' => __('This image is used on product list tables and other places.', 'wp-ultimo'), 'value' => $this->get_object()->get_featured_image_id(), 'img' => $this->get_object()->get_featured_image(), - ), - ), - ) + ], + ], + ] ); } @@ -546,15 +546,15 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_legacy_options() { + public function handle_legacy_options(): void { global $wp_filter; $tabs = apply_filters_deprecated( 'wu_plans_advanced_options_tabs', - array( - array(), - ), + [ + [], + ], '2.0.0', 'wu_product_options_sections' ); @@ -567,40 +567,40 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { $priorities = $wp_filter['wu_plans_advanced_options_after_panels']->callbacks; - $fields = array( - 'heading' => array( + $fields = [ + 'heading' => [ 'type' => 'header', 'title' => __('Legacy Options', 'wp-ultimo'), // translators: %s is the name of legacy add-ons. 'desc' => sprintf(__('Options for %s, and others.', 'wp-ultimo'), implode(', ', $tabs)), - ), - ); + ], + ]; foreach ($priorities as $priority => $callbacks) { foreach ($callbacks as $id => $callable) { - $fields[ $id ] = array( + $fields[ $id ] = [ 'type' => 'html', 'classes' => 'wu--mt-2', 'content' => function () use ($callable) { call_user_func($callable['function'], new \WU_Plan($this->get_object())); }, - ); + ]; } } $this->add_fields_widget( 'legacy-options', - array( + [ 'title' => __('Legacy Options', 'wp-ultimo'), 'position' => 'normal', 'fields' => $fields, 'classes' => 'wu-legacy-options-panel', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'style' => 'margin-top: -5px;', - ), - ) + ], + ] ); } @@ -616,30 +616,30 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { */ protected function get_product_option_sections() { - $sections = array( - 'general' => array( + $sections = [ + 'general' => [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General product options such as product slug, type, etc.', 'wp-ultimo'), 'icon' => 'dashicons-wu-globe', - 'state' => array( + 'state' => [ 'slug' => $this->get_object()->get_slug(), 'product_type' => $this->get_object()->get_type(), - ), - 'fields' => array( - 'slug' => array( + ], + 'fields' => [ + 'slug' => [ 'type' => 'text', 'title' => __('Product Slug', 'wp-ultimo'), 'placeholder' => __('e.g. premium', 'wp-ultimo'), 'desc' => __('This serves as a id to the product in a number of different contexts.', 'wp-ultimo'), 'value' => $this->get_object()->get_slug(), 'tooltip' => __('Lowercase alpha-numeric characters with dashes or underlines. No spaces allowed.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-on:input' => 'slug = $event.target.value.toLowerCase().replace(/[^a-z0-9-_]+/g, "")', 'v-bind:value' => 'slug', - ), - ), + ], + ], // Fields for price - 'type' => array( + 'type' => [ 'type' => 'select', 'title' => __('Product Type', 'wp-ultimo'), 'placeholder' => __('Product Type', 'wp-ultimo'), @@ -647,58 +647,58 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { 'value' => $this->get_object()->get_type(), 'tooltip' => '', 'options' => Product_Type::to_array(), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'product_type', - ), - ), - 'modules[customer_user_role][limit]' => array( + ], + ], + 'modules[customer_user_role][limit]' => [ 'title' => __('Customer Role', 'wp-ultimo'), 'desc' => __('Select the role WP Multisite WaaS should use when adding the user to their newly created site.', 'wp-ultimo'), 'type' => 'select', 'value' => $this->get_object()->get_customer_role(), 'default' => 'administrator', 'options' => fn() => wu_get_roles_as_options(true), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'product_type === "plan"', 'v-cloak' => 1, - ), - ), - ), - ), - ); + ], + ], + ], + ], + ]; - $sections['ups-and-downs'] = array( + $sections['ups-and-downs'] = [ 'title' => __('Up & Downgrades', 'wp-ultimo'), 'desc' => __('Settings related to upgrade and downgrade flows.', 'wp-ultimo'), 'icon' => 'dashicons-wu-shop', 'v-show' => 'product_type === "plan"', - 'state' => array(), - 'fields' => array( - 'group' => array( + 'state' => [], + 'fields' => [ + 'group' => [ 'title' => __('Plan Group', 'wp-ultimo'), 'desc' => __('Add related plans to the same group to have them show up as upgrade/downgrade paths.', 'wp-ultimo'), 'placeholder' => __('Type and press enter to search and/or add.', 'wp-ultimo'), 'type' => 'select', 'value' => $this->get_object()->get_group(), - 'options' => array_merge(array('' => __('Select Group', 'wp-ultimo')), wu_get_product_groups()), - 'html_attr' => array( + 'options' => array_merge(['' => __('Select Group', 'wp-ultimo')], wu_get_product_groups()), + 'html_attr' => [ 'data-selectize-categories' => 999, 'data-max-items' => 1, - ), - ), - 'list_order' => array( + ], + ], + 'list_order' => [ 'title' => __('Product Order', 'wp-ultimo'), 'desc' => __('Plans are shown in the order determined by this parameter, from the lowest to the highest.', 'wp-ultimo'), 'placeholder' => __('Type and press enter to search and/or add.', 'wp-ultimo'), 'type' => 'number', 'value' => $this->get_object()->get_list_order(), - ), - 'available_addons' => array( + ], + 'available_addons' => [ 'type' => 'model', 'title' => __('Offer Add-ons', 'wp-ultimo'), 'placeholder' => __('Search for a package or service', 'wp-ultimo'), 'desc' => __('This products will be offered inside upgrade/downgrade forms as order bumps.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'data-exclude' => implode(',', array_keys(wu_get_plans_as_options())), 'data-model' => 'product', 'data-value-field' => 'id', @@ -707,206 +707,206 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { 'data-max-items' => 99, 'data-selected' => json_encode( wu_get_products( - array( + [ 'id__in' => $this->get_object()->get_available_addons(), 'id__not_in' => array_keys(wu_get_plans_as_options()), - ) + ] ) ), - ), - ), - ), - ); + ], + ], + ], + ]; - $sections['price-variations'] = array( + $sections['price-variations'] = [ 'title' => __('Price Variations', 'wp-ultimo'), 'desc' => __('Discounts for longer membership commitments.', 'wp-ultimo'), 'icon' => 'dashicons-wu-price-tag', - 'state' => array( + 'state' => [ 'enable_price_variations' => ! empty($this->get_object()->get_price_variations()), 'price_variations' => $this->get_object()->get_price_variations(), - ), - 'fields' => array( - 'enable_price_variations' => array( + ], + 'fields' => [ + 'enable_price_variations' => [ 'type' => 'toggle', 'title' => __('Enable Price Variations', 'wp-ultimo'), 'desc' => __('Price Variations are an easy way to offer discounted prices for longer subscription commitments.', 'wp-ultimo'), 'value' => false, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'enable_price_variations', - ), - ), - 'price_variations' => array( + ], + ], + 'price_variations' => [ 'type' => 'group', // translators: 1 is the price, 2 is the duration and 3 the duration unit 'desc' => sprintf(__('A discounted price of %1$s will be used when memberships are created with the recurrence of %2$s %3$s(s) instead of the regular period.', 'wp-ultimo'), '{{ wu_format_money(price_variation.amount) }}', '{{ price_variation.duration }}', '{{ price_variation.duration_unit }}'), 'tooltip' => '', 'wrapper_classes' => 'wu-relative', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-for' => '(price_variation, index) in price_variations', 'v-show' => 'enable_price_variations', 'v-cloak' => '1', - ), - 'fields' => array( - 'price_variations_remove' => array( + ], + 'fields' => [ + 'price_variations_remove' => [ 'type' => 'note', 'desc' => sprintf('', __('Remove', 'wp-ultimo')), 'wrapper_classes' => 'wu-absolute wu-top-0 wu-right-0', - ), - 'price_variations_duration' => array( + ], + 'price_variations_duration' => [ 'type' => 'number', 'title' => __('Duration', 'wp-ultimo'), 'placeholder' => '', 'wrapper_classes' => 'wu-w-1/3', 'min' => 1, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'price_variation.duration', 'steps' => 1, 'v-bind:name' => '"price_variations[" + index + "][duration]"', - ), - ), - 'price_variations_duration_unit' => array( + ], + ], + 'price_variations_duration_unit' => [ 'type' => 'select', 'title' => __('Period', 'wp-ultimo'), 'placeholder' => '', 'wrapper_classes' => 'wu-w-1/3 wu-mx-2', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'price_variation.duration_unit', 'v-bind:name' => '"price_variations[" + index + "][duration_unit]"', - ), - 'options' => array( + ], + 'options' => [ 'day' => __('Days', 'wp-ultimo'), 'week' => __('Weeks', 'wp-ultimo'), 'month' => __('Months', 'wp-ultimo'), 'year' => __('Years', 'wp-ultimo'), - ), - ), + ], + ], // Bind the amount of the price variation to another field so we don't send the formatted value to the server. - 'price_variations_amount' => array( + 'price_variations_amount' => [ 'type' => 'hidden', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:value' => 'price_variation.amount', 'v-bind:name' => '"price_variations[" + index + "][amount]"', - ), - ), - '_price_variations_amount' => array( + ], + ], + '_price_variations_amount' => [ 'type' => 'text', 'title' => __('New Price', 'wp-ultimo'), 'placeholder' => wu_format_currency('99'), 'wrapper_classes' => 'wu-w-1/3', 'money' => true, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'price_variation.amount', 'v-bind:name' => '""', - ), - ), - ), - ), - 'repeat' => array( + ], + ], + ], + ], + 'repeat' => [ 'type' => 'submit', 'title' => __('Add new Price Variation', 'wp-ultimo'), 'classes' => 'button wu-self-end', 'wrapper_classes' => 'wu-bg-whiten wu-items-end', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'enable_price_variations', 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-on:click.prevent' => '() => price_variations.push({ duration: 1, duration_unit: "month", amount: get_value("wu_product_pricing").amount, })', - ), - ), - ), - ); + ], + ], + ], + ]; - $sections['taxes'] = array( + $sections['taxes'] = [ 'title' => __('Taxes', 'wp-ultimo'), 'desc' => __('Tax settings for your products.', 'wp-ultimo'), 'icon' => 'dashicons-wu-credit', - 'state' => array( + 'state' => [ 'taxable' => $this->get_object()->is_taxable(), - ), - 'fields' => array( - 'taxable' => array( + ], + 'fields' => [ + 'taxable' => [ 'type' => 'toggle', 'title' => __('Is Taxable?', 'wp-ultimo'), 'desc' => __('Enable this if you plan to collect taxes for this product.', 'wp-ultimo'), 'value' => $this->get_object()->is_taxable(), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'taxable', - ), - ), - 'tax_category' => array( + ], + ], + 'tax_category' => [ 'type' => 'select', 'title' => __('Tax Category', 'wp-ultimo'), 'desc' => __('Select the product tax category.', 'wp-ultimo'), 'value' => $this->get_object()->get_tax_category(), 'options' => 'wu_get_tax_categories_as_options', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => '1', 'v-show' => 'require("taxable", true)', - ), - ), - ), - ); + ], + ], + ], + ]; - $sections['allowed_templates'] = array( + $sections['allowed_templates'] = [ 'title' => __('Site Templates', 'wp-ultimo'), 'desc' => __('Limit which site templates are available for this particular template.', 'wp-ultimo'), 'icon' => 'dashicons-wu-grid1 wu-align-text-bottom', 'v-show' => "get_state_value('product_type', 'none') !== 'service'", - 'state' => array( + 'state' => [ 'allow_site_templates' => $this->get_object()->get_limitations()->site_templates->is_enabled(), 'site_template_selection_mode' => $this->get_object()->get_limitations()->site_templates->get_mode(), 'pre_selected_template' => $this->get_object()->get_limitations()->site_templates->get_pre_selected_site_template(), - ), - 'fields' => array( - 'modules[site_templates][enabled]' => array( + ], + 'fields' => [ + 'modules[site_templates][enabled]' => [ 'type' => 'toggle', 'title' => __('Allow Site Templates', 'wp-ultimo'), 'desc' => __('Toggle this option on to allow this plan to use Site Templates. If this option is disabled, sign-ups on this plan will get a default WordPress site.', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'allow_site_templates', - ), - ), - 'modules[site_templates][mode]' => array( + ], + ], + 'modules[site_templates][mode]' => [ 'type' => 'select', 'title' => __('Site Template Selection Mode', 'wp-ultimo'), 'placeholder' => __('Site Template Selection Mode', 'wp-ultimo'), 'desc' => __('Select the type of limitation you want to apply.', 'wp-ultimo'), 'tooltip' => __('"Default" will follow the settings of the checkout form: if you have a template selection field in there, all the templates selected will show up. If no field is present, then a default WordPress site will be created.

"Assign Site Template" forces new accounts with this plan to use a particular template site (this option removes the template selection field from the signup, if one exists).

Finally, "Choose Available Site Templates", overrides the templates selected on the checkout form with the templates selected here, while also giving you the chance of pre-select a template to be used as default.', 'wp-ultimo'), 'value' => 'default', - 'options' => array( + 'options' => [ 'default' => __('Default', 'wp-ultimo'), 'assign_template' => __('Assign Site Template', 'wp-ultimo'), 'choose_available_templates' => __('Choose Available Site Templates', 'wp-ultimo'), - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'site_template_selection_mode', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-cloak' => '1', 'v-show' => 'allow_site_templates', - ), - ), - 'templates' => array( + ], + ], + 'templates' => [ 'type' => 'html', 'title' => __('Site Templates', 'wp-ultimo'), 'desc' => esc_attr(sprintf('{{ site_template_selection_mode === "assign_template" ? "%s" : "%s" }}', __('Select the Site Template to assign.', 'wp-ultimo'), __('Customize the access level of each Site Template below.', 'wp-ultimo'))), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => '1', 'v-show' => "allow_site_templates && site_template_selection_mode !== 'default'", - ), + ], 'content' => fn() => $this->get_site_template_selection_list($this->get_object()), - ), - ), - ); + ], + ], + ]; return apply_filters('wu_product_options_sections', $sections, $this->get_object()); } @@ -925,10 +925,10 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { return wu_get_template_contents( 'limitations/site-template-selector', - array( + [ 'templates' => $all_templates, 'product' => $product, - ) + ] ); } @@ -962,18 +962,18 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { */ public function action_links() { - $actions = array(); + $actions = []; if ($this->get_object()->get_type() === 'plan' && $this->edit) { $shareable_link = $this->get_object()->get_shareable_link(); - $actions[] = array( + $actions[] = [ 'url' => '#', 'label' => __('Click to copy Shareable Link', 'wp-ultimo'), 'icon' => 'wu-attachment', 'classes' => 'wu-copy', 'attrs' => 'data-clipboard-text="' . esc_attr($shareable_link) . '"', - ); + ]; } return $actions; @@ -987,7 +987,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { */ public function get_labels() { - return array( + return [ 'edit_label' => __('Edit Product', 'wp-ultimo'), 'add_new_label' => __('Add new Product', 'wp-ultimo'), 'updated_message' => __('Product updated with success!', 'wp-ultimo'), @@ -997,7 +997,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { 'save_description' => '', 'delete_button_label' => __('Delete Product', 'wp-ultimo'), 'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'), - ); + ]; } /** @@ -1010,10 +1010,10 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { */ public function query_filter($args) { - $extra_args = array( + $extra_args = [ 'object_type' => 'product', 'object_id' => absint($this->get_object()->get_id()), - ); + ]; return array_merge($args, $extra_args); } @@ -1066,7 +1066,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_save() { + public function handle_save(): void { /* * Set the recurring value to zero if the toggle is disabled. */ @@ -1100,7 +1100,7 @@ class Product_Edit_Admin_Page extends Edit_Admin_Page { * Set the setup fee value to zero if the toggle is disabled. */ if ( ! wu_request('price_variations')) { - $_POST['price_variations'] = array(); + $_POST['price_variations'] = []; } /* diff --git a/inc/admin-pages/class-product-list-admin-page.php b/inc/admin-pages/class-product-list-admin-page.php index 9683304..72d1ef3 100644 --- a/inc/admin-pages/class-product-list-admin-page.php +++ b/inc/admin-pages/class-product-list-admin-page.php @@ -50,9 +50,9 @@ class Product_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_read_products', - ); + ]; /** * Allow child classes to register widgets, if they need them. @@ -70,10 +70,10 @@ class Product_List_Admin_Page extends List_Admin_Page { */ public function get_labels() { - return array( + return [ 'deleted_message' => __('Product removed successfully.', 'wp-ultimo'), 'search_label' => __('Search Product', 'wp-ultimo'), - ); + ]; } /** @@ -117,13 +117,13 @@ class Product_List_Admin_Page extends List_Admin_Page { */ public function action_links() { - return array( - array( + return [ + [ 'url' => wu_network_admin_url('wp-ultimo-edit-product'), 'label' => __('Add Product'), 'icon' => 'wu-circle-with-plus', - ), - ); + ], + ]; } /** diff --git a/inc/admin-pages/class-settings-admin-page.php b/inc/admin-pages/class-settings-admin-page.php index fb98554..36864f1 100644 --- a/inc/admin-pages/class-settings-admin-page.php +++ b/inc/admin-pages/class-settings-admin-page.php @@ -62,9 +62,9 @@ class Settings_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_read_settings', - ); + ]; /** * Should we hide admin notices on this page? @@ -104,7 +104,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page { * @since 1.8.2 * @return void */ - public function register_scripts() { + public function register_scripts(): void { wp_enqueue_editor(); @@ -130,56 +130,56 @@ class Settings_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function register_widgets() { + public function register_widgets(): void { parent::register_widgets(); wu_register_settings_side_panel( 'login-and-registration', - array( + [ 'title' => __('Checkout Forms', 'wp-ultimo'), - 'render' => array($this, 'render_checkout_forms_side_panel'), - ) + 'render' => [$this, 'render_checkout_forms_side_panel'], + ] ); wu_register_settings_side_panel( 'sites', - array( + [ 'title' => __('Template Previewer', 'wp-ultimo'), - 'render' => array($this, 'render_site_template_side_panel'), - ) + 'render' => [$this, 'render_site_template_side_panel'], + ] ); wu_register_settings_side_panel( 'sites', - array( + [ 'title' => __('Placeholder Editor', 'wp-ultimo'), - 'render' => array($this, 'render_site_placeholders_side_panel'), - ) + 'render' => [$this, 'render_site_placeholders_side_panel'], + ] ); wu_register_settings_side_panel( 'payment-gateways', - array( + [ 'title' => __('Invoices', 'wp-ultimo'), - 'render' => array($this, 'render_invoice_side_panel'), - ) + 'render' => [$this, 'render_invoice_side_panel'], + ] ); wu_register_settings_side_panel( 'emails', - array( + [ 'title' => __('System Emails', 'wp-ultimo'), - 'render' => array($this, 'render_system_emails_side_panel'), - ) + 'render' => [$this, 'render_system_emails_side_panel'], + ] ); wu_register_settings_side_panel( 'emails', - array( + [ 'title' => __('Email Template', 'wp-ultimo'), - 'render' => array($this, 'render_email_template_side_panel'), - ) + 'render' => [$this, 'render_email_template_side_panel'], + ] ); } @@ -189,7 +189,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function render_checkout_forms_side_panel() { + public function render_checkout_forms_side_panel(): void { ?>
@@ -201,7 +201,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {
- <?php esc_attr_e('Checkout Forms', 'wp-ultimo'); ?> + <?php esc_attr_e('Checkout Forms', 'wp-ultimo'); ?>

@@ -231,7 +231,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function render_site_template_side_panel() { + public function render_site_template_side_panel(): void { ?> @@ -244,7 +244,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {

- <?php esc_attr_e('Customize the Template Previewer', 'wp-ultimo'); ?> + <?php esc_attr_e('Customize the Template Previewer', 'wp-ultimo'); ?>

@@ -274,7 +274,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function render_site_placeholders_side_panel() { + public function render_site_placeholders_side_panel(): void { ?> @@ -287,7 +287,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {

- <?php esc_attr_e('Customize the Template Placeholders', 'wp-ultimo'); ?> + <?php esc_attr_e('Customize the Template Placeholders', 'wp-ultimo'); ?>

@@ -317,7 +317,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function render_invoice_side_panel() { + public function render_invoice_side_panel(): void { ?> @@ -330,7 +330,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {

- <?php esc_attr_e('Customize the Invoice Template', 'wp-ultimo'); ?> + <?php esc_attr_e('Customize the Invoice Template', 'wp-ultimo'); ?>

@@ -360,7 +360,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function render_system_emails_side_panel() { + public function render_system_emails_side_panel(): void { ?> @@ -373,7 +373,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {

- <?php esc_attr_e('Customize System Emails', 'wp-ultimo'); ?> + <?php esc_attr_e('Customize System Emails', 'wp-ultimo'); ?>

@@ -403,7 +403,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function render_email_template_side_panel() { + public function render_email_template_side_panel(): void { ?> @@ -416,7 +416,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page {

- <?php esc_attr_e('Customize Email Template', 'wp-ultimo'); ?> + <?php esc_attr_e('Customize Email Template', 'wp-ultimo'); ?>

@@ -470,7 +470,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page { * @since 1.8.2 * @return void */ - public function output() { + public function output(): void { /* * Enqueue the base Dashboard Scripts */ @@ -486,14 +486,14 @@ class Settings_Admin_Page extends Wizard_Admin_Page { wu_get_template( 'base/settings', - array( + [ 'screen' => get_current_screen(), 'page' => $this, 'classes' => '', 'sections' => $this->get_sections(), 'current_section' => $this->get_current_section(), 'clickable_navigation' => $this->clickable_navigation, - ) + ] ); } @@ -514,14 +514,14 @@ class Settings_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function default_handler() { + public function default_handler(): void { if ( ! current_user_can('wu_edit_settings')) { wp_die(__('You do not have the permissions required to change settings.', 'wp-ultimo')); } if ( ! isset($_POST['active_gateways']) && wu_request('tab') === 'payment-gateways') { - $_POST['active_gateways'] = array(); + $_POST['active_gateways'] = []; } WP_Ultimo()->settings->save_settings($_POST); @@ -537,7 +537,7 @@ class Settings_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function default_view() { + public function default_view(): void { $sections = $this->get_sections(); @@ -552,15 +552,15 @@ class Settings_Admin_Page extends Wizard_Admin_Page { /* * Get Field to save */ - $fields['save'] = array( + $fields['save'] = [ 'type' => 'submit', 'title' => __('Save Settings', 'wp-ultimo'), 'classes' => 'button button-primary button-large wu-ml-auto wu-w-full md:wu-w-auto', 'wrapper_classes' => 'wu-sticky wu-bottom-0 wu-save-button wu-mr-px wu-w-full md:wu-w-auto', - 'html_attr' => array( + 'html_attr' => [ 'v-on:click' => 'send("window", "wu_block_ui", "#wpcontent")', - ), - ); + ], + ]; if ( ! current_user_can('wu_edit_settings')) { $fields['save']['html_attr']['disabled'] = 'disabled'; @@ -569,17 +569,17 @@ class Settings_Admin_Page extends Wizard_Admin_Page { $form = new Form( $section_slug, $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu--mt-5 wu--mx-in wu--mb-in', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-py-5 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'style' => '', 'data-on-load' => 'remove_block_ui', 'data-wu-app' => str_replace('-', '_', $section_slug), 'data-state' => json_encode(wu_array_map_keys('wu_replace_dashes', Settings::get_instance()->get_all(true))), - ), - ) + ], + ] ); $form->render(); diff --git a/inc/admin-pages/class-setup-wizard-admin-page.php b/inc/admin-pages/class-setup-wizard-admin-page.php index f3007af..cfc4984 100644 --- a/inc/admin-pages/class-setup-wizard-admin-page.php +++ b/inc/admin-pages/class-setup-wizard-admin-page.php @@ -71,9 +71,9 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'manage_network', - ); + ]; /** * Is this an old install migrating. @@ -119,29 +119,29 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { $this->menu_icon = 'dashicons-wu-wp-ultimo'; - add_action('admin_enqueue_scripts', array($this, 'register_scripts')); + add_action('admin_enqueue_scripts', [$this, 'register_scripts']); } parent::__construct(); - add_action('admin_action_download_migration_logs', array($this, 'download_migration_logs')); + add_action('admin_action_download_migration_logs', [$this, 'download_migration_logs']); /* * Serve the installers */ - add_action('wp_ajax_wu_setup_install', array($this, 'setup_install')); + add_action('wp_ajax_wu_setup_install', [$this, 'setup_install']); /* * Load installers */ - add_action('wu_handle_ajax_installers', array(Core_Installer::get_instance(), 'handle'), 10, 3); - add_action('wu_handle_ajax_installers', array(Default_Content_Installer::get_instance(), 'handle'), 10, 3); - add_action('wu_handle_ajax_installers', array(Migrator::get_instance(), 'handle'), 10, 3); + add_action('wu_handle_ajax_installers', [Core_Installer::get_instance(), 'handle'], 10, 3); + add_action('wu_handle_ajax_installers', [Default_Content_Installer::get_instance(), 'handle'], 10, 3); + add_action('wu_handle_ajax_installers', [Migrator::get_instance(), 'handle'], 10, 3); /* * Redirect on activation */ - add_action('wu_activation', array($this, 'redirect_to_wizard')); + add_action('wu_activation', [$this, 'redirect_to_wizard']); } /** @@ -150,7 +150,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.7 * @return void */ - public function download_migration_logs() { + public function download_migration_logs(): void { check_admin_referer('download_migration_logs', 'nonce'); @@ -177,7 +177,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 1.8.2 * @return void */ - public function page_loaded() { + public function page_loaded(): void { parent::page_loaded(); @@ -205,7 +205,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function set_settings() { + public function set_settings(): void { WP_Ultimo()->settings->default_sections(); } @@ -216,7 +216,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function redirect_to_wizard() { + public function redirect_to_wizard(): void { if ( ! \WP_Ultimo\Requirements::run_setup() && wu_request('page') !== 'wp-ultimo-setup') { wp_redirect(wu_network_admin_url('wp-ultimo-setup')); @@ -231,7 +231,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function setup_install() { + public function setup_install(): void { global $wpdb; @@ -279,7 +279,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { */ public function get_logo() { - return wu_get_asset('logo.png', 'img'); + return wu_get_asset('logo.webp', 'img'); } /** @@ -312,45 +312,45 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { */ public function get_sections() { - $sections = array( - 'welcome' => array( + $sections = [ + 'welcome' => [ 'title' => __('Welcome', 'wp-ultimo'), 'description' => implode( '

', - array( + [ __('...and thanks for choosing WP Multisite WaaS!', 'wp-ultimo'), __('This quick setup wizard will make sure your server is correctly setup, help you configure your new network, and migrate data from previous WP Multisite WaaS versions if necessary.', 'wp-ultimo'), __('You will also have the option of importing default content. It should take 10 minutes or less!', 'wp-ultimo'), - ) + ] ), 'next_label' => __('Get Started →', 'wp-ultimo'), 'back' => false, - ), - 'checks' => array( + ], + 'checks' => [ 'title' => __('Pre-install Checks', 'wp-ultimo'), 'description' => __('Now it is time to see if this machine has what it takes to run WP Multisite WaaS well!', 'wp-ultimo'), 'next_label' => \WP_Ultimo\Requirements::met() ? __('Go to the Next Step →', 'wp-ultimo') : __('Check Again', 'wp-ultimo'), - 'handler' => array($this, 'handle_checks'), + 'handler' => [$this, 'handle_checks'], 'back' => false, - 'fields' => array( - 'requirements' => array( + 'fields' => [ + 'requirements' => [ 'type' => 'note', - 'desc' => array($this, 'renders_requirements_table'), - ), - ), - ), - 'installation' => array( + 'desc' => [$this, 'renders_requirements_table'], + ], + ], + ], + 'installation' => [ 'title' => __('Installation', 'wp-ultimo'), 'description' => __('Now, let\'s update your database and install the Sunrise.php file, which are necessary for the correct functioning of WP Multisite WaaS.', 'wp-ultimo'), 'next_label' => Core_Installer::get_instance()->all_done() ? __('Go to the Next Step →', 'wp-ultimo') : __('Install', 'wp-ultimo'), - 'fields' => array( - 'terms' => array( + 'fields' => [ + 'terms' => [ 'type' => 'note', 'desc' => fn() => $this->render_installation_steps(Core_Installer::get_instance()->get_steps(), false), - ), - ), - ), - ); + ], + ], + ], + ]; /* * In case of migrations, add different sections. @@ -374,19 +374,19 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { $description = __('It seems that you were running WP Multisite WaaS 1.X on this network. This migrator will convert the data from the old version to the new one.', 'wp-ultimo') . '

' . __('First, let\'s run a test migration to see if we can spot any potential errors.', 'wp-ultimo'); } - $fields = array( - 'migration' => array( + $fields = [ + 'migration' => [ 'type' => 'note', 'desc' => fn() => $this->render_installation_steps(Migrator::get_instance()->get_steps(), false), - ), - ); + ], + ]; if ($errors) { $subject = 'Errors on migrating my network'; $user = wp_get_current_user(); - $message_lines = array( + $message_lines = [ 'Hi there,', sprintf('My name is %s.', $user->display_name), 'I tried to migrate my network from version 1 to version 2, but was not able to do it successfully...', @@ -394,7 +394,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { sprintf('```%s%s%s```', PHP_EOL, implode(PHP_EOL, $errors), PHP_EOL), sprintf('```%s%s%s```', PHP_EOL, $back_traces ? implode(PHP_EOL, $back_traces) : 'No backtraces found.', PHP_EOL), 'Kind regards.', - ); + ]; $message = implode(PHP_EOL . PHP_EOL, $message_lines); @@ -410,10 +410,10 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { '
%1$s', __('Download migration error log', 'wp-ultimo'), add_query_arg( - array( + [ 'action' => 'download_migration_logs', 'nonce' => wp_create_nonce('download_migration_logs'), - ), + ], network_admin_url('admin.php') ) ); @@ -422,11 +422,11 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { '
%1$s', __('Rollback to version 1.10.13', 'wp-ultimo'), add_query_arg( - array( + [ 'page' => 'wp-ultimo-rollback', 'version' => '1.10.13', 'type' => 'select-version', - ), + ], network_admin_url('admin.php') ) ); @@ -434,57 +434,57 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { $error_list .= implode('
', $errors); $fields = array_merge( - array( - 'errors' => array( + [ + 'errors' => [ 'type' => 'note', 'classes' => 'wu-flex-grow', 'desc' => function () use ($error_list) { /** Reset errors */ - Migrator::get_instance()->session->set('errors', array()); + Migrator::get_instance()->session->set('errors', []); return sprintf('

%s
', $error_list); }, - ), - ), + ], + ], $fields ); } - $sections['migration'] = array( + $sections['migration'] = [ 'title' => __('Migration', 'wp-ultimo'), 'description' => $description, 'next_label' => $next_label, 'skip' => false, 'next' => $next, - 'handler' => array($this, 'handle_migration'), + 'handler' => [$this, 'handle_migration'], 'fields' => $fields, - ); + ]; } else { - $sections['your-company'] = array( + $sections['your-company'] = [ 'title' => __('Your Company', 'wp-ultimo'), 'description' => __('Before we move on, let\'s configure the basic settings of your network, shall we?', 'wp-ultimo'), - 'handler' => array($this, 'handle_save_settings'), - 'fields' => array($this, 'get_general_settings'), - ); + 'handler' => [$this, 'handle_save_settings'], + 'fields' => [$this, 'get_general_settings'], + ]; - $sections['defaults'] = array( + $sections['defaults'] = [ 'title' => __('Default Content', 'wp-ultimo'), 'description' => __('Starting from scratch can be scarry, specially when first starting out. In this step, you can create default content to have a starting point for your network. Everything can be customized later.', 'wp-ultimo'), 'next_label' => Default_Content_Installer::get_instance()->all_done() ? __('Go to the Next Step →', 'wp-ultimo') : __('Install', 'wp-ultimo'), - 'fields' => array( - 'terms' => array( + 'fields' => [ + 'terms' => [ 'type' => 'note', 'desc' => fn() => $this->render_installation_steps(Default_Content_Installer::get_instance()->get_steps()), - ), - ), - ); + ], + ], + ]; } - $sections['done'] = array( + $sections['done'] = [ 'title' => __('Ready!', 'wp-ultimo'), - 'view' => array($this, 'section_ready'), - ); + 'view' => [$this, 'section_ready'], + ]; /** * Allow developers to add additional setup wizard steps. @@ -514,23 +514,23 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { /* * Unset a couple of undesired settings */ - $fields_to_unset = array( + $fields_to_unset = [ 'error_reporting_header', 'enable_error_reporting', 'advanced_header', 'uninstall_wipe_tables', - ); + ]; foreach ($fields_to_unset as $field_to_unset) { unset($general_fields[ $field_to_unset ]); } // Adds a fake first field to bypass some styling issues with the top-border - $fake_field = array( - array( + $fake_field = [ + [ 'type' => 'hidden', - ), - ); + ], + ]; $fields = array_merge($fake_field, $general_fields); @@ -549,9 +549,9 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { */ $payment_fields = \WP_Ultimo\Settings::get_instance()->get_section('payment-gateways')['fields']; - $fields_to_unset = array( + $fields_to_unset = [ 'main_header', - ); + ]; foreach ($fields_to_unset as $field_to_unset) { unset($payment_fields[ $field_to_unset ]); @@ -578,21 +578,21 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { wp_localize_script( 'wu-setup-wizard', 'wu_setup_settings', - array( + [ 'dry_run' => wu_request('dry-run', true), 'generic_error_message' => __('A server error happened while processing this item.', 'wp-ultimo'), - ) + ] ); wp_enqueue_script('wu-setup-wizard'); return wu_get_template_contents( 'wizards/setup/installation_steps', - array( + [ 'page' => $this, 'steps' => $steps, 'checks' => $checks, - ) + ] ); } @@ -617,8 +617,8 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { global $wp_version; - $requirements = array( - 'php' => array( + $requirements = [ + 'php' => [ 'name' => __('PHP', 'wp-ultimo'), 'help' => wu_get_documentation_url('wp-ultimo-requirements'), 'required_version' => \WP_Ultimo\Requirements::$php_version, @@ -626,8 +626,8 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { 'installed_version' => phpversion(), 'pass_requirements' => version_compare(phpversion(), \WP_Ultimo\Requirements::$php_version, '>='), 'pass_recommendation' => version_compare(phpversion(), \WP_Ultimo\Requirements::$php_recommended_version, '>='), - ), - 'wordpress' => array( + ], + 'wordpress' => [ 'name' => __('WordPress', 'wp-ultimo'), 'help' => wu_get_documentation_url('wp-ultimo-requirements'), 'required_version' => \WP_Ultimo\Requirements::$wp_version, @@ -635,36 +635,36 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { 'installed_version' => $wp_version, 'pass_requirements' => version_compare(phpversion(), \WP_Ultimo\Requirements::$wp_version, '>='), 'pass_recommendation' => version_compare(phpversion(), \WP_Ultimo\Requirements::$wp_recommended_version, '>='), - ), - ); + ], + ]; - $plugin_requirements = array( - 'multisite' => array( + $plugin_requirements = [ + 'multisite' => [ 'name' => __('WordPress Multisite', 'wp-ultimo'), 'help' => wu_get_documentation_url('wp-ultimo-requirements'), 'condition' => __('Installed & Activated', 'wp-ultimo'), 'pass_requirements' => is_multisite(), - ), - 'wp-ultimo' => array( + ], + 'wp-ultimo' => [ 'name' => __('WP Multisite WaaS', 'wp-ultimo'), 'help' => wu_get_documentation_url('wp-ultimo-requirements'), 'condition' => apply_filters('wp_ultimo_skip_network_active_check', false) ? __('Bypassed via filter', 'wp-ultimo') : __('Network Activated', 'wp-ultimo'), 'pass_requirements' => \WP_Ultimo\Requirements::is_network_active(), - ), - 'wp-cron' => array( + ], + 'wp-cron' => [ 'name' => __('WordPress Cron', 'wp-ultimo'), 'help' => wu_get_documentation_url('wp-ultimo-requirements'), 'condition' => __('Activated', 'wp-ultimo'), 'pass_requirements' => \WP_Ultimo\Requirements::check_wp_cron(), - ), - ); + ], + ]; return wu_get_template_contents( 'wizards/setup/requirements_table', - array( + [ 'requirements' => $requirements, 'plugin_requirements' => $plugin_requirements, - ) + ] ); } @@ -674,7 +674,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function section_ready() { + public function section_ready(): void { update_network_option(null, 'wu_setup_finished', true); @@ -689,18 +689,18 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { wu_enqueue_async_action( 'wu_async_take_screenshot', - array( + [ 'site_id' => wu_get_main_site_id(), - ), + ], 'site' ); wu_get_template( 'wizards/setup/ready', - array( + [ 'screen' => get_current_screen(), 'page' => $this, - ) + ] ); } @@ -710,7 +710,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_checks() { + public function handle_checks(): void { if (\WP_Ultimo\Requirements::met() === false) { wp_redirect(add_query_arg()); @@ -729,7 +729,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_save_settings() { + public function handle_save_settings(): void { $this->set_settings(); @@ -758,7 +758,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_migration() { + public function handle_migration(): void { $dry_run = wu_request('dry-run', true); @@ -783,7 +783,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_configuration() { + public function handle_configuration(): void { if ($_POST['submit'] === '1') { $this->integration->setup_constants($_POST); @@ -803,17 +803,17 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function section_test() { + public function section_test(): void { wp_enqueue_script('wu-vue'); wu_get_template( 'wizards/host-integrations/test', - array( + [ 'screen' => get_current_screen(), 'page' => $this, 'integration' => $this->integration, - ) + ] ); } @@ -823,12 +823,12 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { if (WP_Ultimo()->is_loaded() === false) { wp_enqueue_style('wu-styling', wu_get_asset('framework.css', 'css'), false, wu_get_version()); - wp_enqueue_style('wu-admin', wu_get_asset('admin.css', 'css'), array('wu-styling'), wu_get_version()); + wp_enqueue_style('wu-admin', wu_get_asset('admin.css', 'css'), ['wu-styling'], wu_get_version()); /* * Adds tipTip @@ -838,9 +838,9 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { /* * Adds jQueryBlockUI */ - wp_enqueue_script('wu-block-ui', wu_get_asset('lib/jquery.blockUI.js', 'js'), array('jquery')); + wp_enqueue_script('wu-block-ui', wu_get_asset('lib/jquery.blockUI.js', 'js'), ['jquery']); - wp_register_script('wu-fields', wu_get_asset('fields.js', 'js'), array('jquery')); + wp_register_script('wu-fields', wu_get_asset('fields.js', 'js'), ['jquery']); /* * Localize components @@ -848,22 +848,22 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { wp_localize_script( 'wu-fields', 'wu_fields', - array( - 'l10n' => array( + [ + 'l10n' => [ 'image_picker_title' => __('Select an Image.', 'wp-ultimo'), 'image_picker_button_text' => __('Use this image', 'wp-ultimo'), - ), - ) + ], + ] ); - wp_register_script('wu-functions', wu_get_asset('functions.js', 'js'), array('jquery')); + wp_register_script('wu-functions', wu_get_asset('functions.js', 'js'), ['jquery']); - wp_register_script('wubox', wu_get_asset('wubox.js', 'js'), array('wu-functions')); + wp_register_script('wubox', wu_get_asset('wubox.js', 'js'), ['wu-functions']); wp_localize_script( 'wubox', 'wuboxL10n', - array( + [ 'next' => __('Next >'), 'prev' => __('< Prev'), 'image' => __('Image'), @@ -871,17 +871,17 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { 'close' => __('Close'), 'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'), 'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'), - ) + ] ); wp_add_inline_script('wu-setup-wizard-polyfill', 'document.addEventListener("DOMContentLoaded", () => wu_initialize_imagepicker());', 'after'); } - wp_enqueue_script('wu-setup-wizard-polyfill', wu_get_asset('setup-wizard-polyfill.js', 'js'), array('jquery', 'wu-fields', 'wu-functions', 'wubox'), wu_get_version()); + wp_enqueue_script('wu-setup-wizard-polyfill', wu_get_asset('setup-wizard-polyfill.js', 'js'), ['jquery', 'wu-fields', 'wu-functions', 'wubox'], wu_get_version()); wp_enqueue_media(); - wp_register_script('wu-setup-wizard', wu_get_asset('setup-wizard.js', 'js'), array('jquery'), wu_get_version()); + wp_register_script('wu-setup-wizard', wu_get_asset('setup-wizard.js', 'js'), ['jquery'], wu_get_version()); wp_add_inline_style( 'wu-admin', @@ -891,7 +891,7 @@ class Setup_Wizard_Admin_Page extends Wizard_Admin_Page { background: url("%s") right bottom no-repeat; background-size: 90%%; }', - wu_get_asset('bg-setup.png', 'img') + wu_get_asset('bg-setup.webp', 'img') ) ); } diff --git a/inc/admin-pages/class-shortcodes-admin-page.php b/inc/admin-pages/class-shortcodes-admin-page.php index 36d82c7..8094843 100644 --- a/inc/admin-pages/class-shortcodes-admin-page.php +++ b/inc/admin-pages/class-shortcodes-admin-page.php @@ -68,9 +68,9 @@ class Shortcodes_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'manage_network', - ); + ]; /** * Allow child classes to add further initializations. @@ -78,7 +78,7 @@ class Shortcodes_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function init() { + public function init(): void { parent::init(); } @@ -122,16 +122,16 @@ class Shortcodes_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function output() { + public function output(): void { $screen = get_current_screen(); wu_get_template( 'shortcodes/shortcodes', - array( + [ 'screen' => $screen, 'data' => $this->get_data(), - ) + ] ); } @@ -145,7 +145,7 @@ class Shortcodes_Admin_Page extends Base_Admin_Page { $elements = Base_Element::get_public_elements(); - $data = array(); + $data = []; foreach ($elements as $element) { $defaults = $element->defaults(); @@ -162,7 +162,7 @@ class Shortcodes_Admin_Page extends Base_Admin_Page { $params[ $key ]['options'] = '0 | 1'; break; case 'select': - $params[ $key ]['options'] = implode(' | ', array_keys(wu_get_isset($value, 'options', array()))); + $params[ $key ]['options'] = implode(' | ', array_keys(wu_get_isset($value, 'options', []))); break; case 'int': $params[ $key ]['options'] = __('integer', 'wp-ultimo'); @@ -184,17 +184,17 @@ class Shortcodes_Admin_Page extends Base_Admin_Page { $id = $element->get_id(); - if (strncmp((string) $id, 'wp-ultimo/', strlen('wp-ultimo/')) === 0) { + if (str_starts_with((string) $id, 'wp-ultimo/')) { $id = substr((string) $element->get_id(), strlen('wp-ultimo/')); } - $data[] = array( + $data[] = [ 'generator_form_url' => wu_get_form_url("shortcode_{$id}"), 'title' => $element->get_title(), 'shortcode' => $element->get_shortcode_id(), 'description' => $element->get_description(), 'params' => $params, - ); + ]; } return $data; diff --git a/inc/admin-pages/class-site-edit-admin-page.php b/inc/admin-pages/class-site-edit-admin-page.php index 3aa34b3..9af44f3 100644 --- a/inc/admin-pages/class-site-edit-admin-page.php +++ b/inc/admin-pages/class-site-edit-admin-page.php @@ -77,9 +77,9 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_edit_sites', - ); + ]; /** * Registers the necessary scripts and styles for this admin page. @@ -87,11 +87,11 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { parent::register_scripts(); - WP_Ultimo()->scripts->register_script('wu-screenshot-scraper', wu_get_asset('screenshot-scraper.js', 'js'), array('jquery')); + WP_Ultimo()->scripts->register_script('wu-screenshot-scraper', wu_get_asset('screenshot-scraper.js', 'js'), ['jquery']); wp_enqueue_script('wu-screenshot-scraper'); @@ -106,17 +106,17 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function register_forms() { + public function register_forms(): void { /* * Transfer site - Confirmation modal */ wu_register_form( 'transfer_site', - array( - 'render' => array($this, 'render_transfer_site_modal'), - 'handler' => array($this, 'handle_transfer_site_modal'), + [ + 'render' => [$this, 'render_transfer_site_modal'], + 'handler' => [$this, 'handle_transfer_site_modal'], 'capability' => 'wu_transfer_sites', - ) + ] ); /* @@ -125,12 +125,12 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { add_filter( 'wu_data_json_success_delete_site_modal', - fn($data_json) => array( - 'redirect_url' => wu_network_admin_url('wp-ultimo-sites', array('deleted' => 1)), - ) + fn($data_json) => [ + 'redirect_url' => wu_network_admin_url('wp-ultimo-sites', ['deleted' => 1]), + ] ); - add_filter("wu_page_{$this->id}_load", array($this, 'add_new_site_template_warning_message')); + add_filter("wu_page_{$this->id}_load", [$this, 'add_new_site_template_warning_message']); } /** @@ -139,7 +139,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function add_new_site_template_warning_message() { + public function add_new_site_template_warning_message(): void { if (wu_request('wu-new-model')) { if ( ! $this->get_object() || $this->get_object()->get_type() !== Site_Type::SITE_TEMPLATE) { @@ -148,28 +148,28 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { \WP_Ultimo\UI\Tours::get_instance()->create_tour( 'new_site_template_warning', - array( - array( + [ + [ 'id' => 'new-site-template-warning', 'title' => __('On adding a new Site Template...', 'wp-ultimo'), - 'text' => array( + 'text' => [ __("You just successfully added a new site template to your WP Multisite WaaS network and that's awesome!", 'wp-ultimo'), __('Keep in mind that newly created site templates do not appear automatically in your checkout forms.', 'wp-ultimo'), __('To make a site template available on registration, you will need to manually add it to the template selection field of your checkout forms.', 'wp-ultimo'), - ), - 'buttons' => array( - array( + ], + 'buttons' => [ + [ 'classes' => 'button wu-text-xs sm:wu-normal-case wu-float-left', 'text' => __('Go to Checkout Forms', 'wp-ultimo'), 'url' => wu_network_admin_url('wp-ultimo-checkout-forms'), - ), - ), - 'attachTo' => array( + ], + ], + 'attachTo' => [ 'element' => '#message.updated', 'on' => 'top', - ), - ), - ) + ], + ], + ] ); } } @@ -180,7 +180,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - function render_transfer_site_modal() { + function render_transfer_site_modal(): void { $site = wu_get_site(wu_request('id')); @@ -188,52 +188,52 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { return; } - $fields = array( - 'confirm' => array( + $fields = [ + 'confirm' => [ 'type' => 'toggle', 'title' => __('Confirm Transfer', 'wp-ultimo'), 'desc' => __('This will start the transfer of assets from one membership to another.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'confirmed', - ), - ), - 'submit_button' => array( + ], + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Start Transfer', 'wp-ultimo'), 'placeholder' => __('Start Transfer', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:disabled' => '!confirmed', - ), - ), - 'id' => array( + ], + ], + 'id' => [ 'type' => 'hidden', 'value' => $site->get_id(), - ), - 'target_membership_id' => array( + ], + 'target_membership_id' => [ 'type' => 'hidden', 'value' => wu_request('target_membership_id'), - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'total-actions', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'transfer_site', 'data-state' => json_encode( - array( + [ 'confirmed' => false, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -245,7 +245,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_transfer_site_modal() { + public function handle_transfer_site_modal(): void { global $wpdb; @@ -274,15 +274,15 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { } wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url( 'wp-ultimo-edit-site', - array( + [ 'id' => $site->get_id(), 'updated' => 1, - ) + ] ), - ) + ] ); } @@ -292,7 +292,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { parent::register_widgets(); @@ -304,73 +304,73 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { $this->add_fields_widget( 'at_a_glance', - array( + [ 'title' => __('At a Glance', 'wp-ultimo'), 'position' => 'normal', 'classes' => 'wu-overflow-hidden wu-m-0 wu--mt-1 wu--mx-3 wu--mb-3', 'field_wrapper_classes' => 'wu-w-1/4 wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t-0 wu-border-l-0 wu-border-r wu-border-b-0 wu-border-gray-300 wu-border-solid wu-float-left wu-relative', - 'html_attr' => array( + 'html_attr' => [ 'style' => 'margin-top: -6px;', - ), - 'fields' => array( - 'type' => array( + ], + 'fields' => [ + 'type' => [ 'type' => 'text-display', 'title' => __('Site Type', 'wp-ultimo'), 'display_value' => $tag, 'tooltip' => '', - ), - 'id' => array( + ], + 'id' => [ 'type' => 'text-display', 'copy' => true, 'title' => __('Site ID', 'wp-ultimo'), 'display_value' => $this->get_object()->get_id(), 'tooltip' => '', - ), - ), - ) + ], + ], + ] ); $this->add_fields_widget( 'description', - array( + [ 'title' => __('Description', 'wp-ultimo'), 'position' => 'normal', - 'fields' => array( - 'description' => array( + 'fields' => [ + 'description' => [ 'type' => 'textarea', 'title' => __('Site Description', 'wp-ultimo'), 'placeholder' => __('Tell your customers what this site is about.', 'wp-ultimo'), 'value' => $this->get_object()->get_option_blogdescription(), - 'html_attr' => array( + 'html_attr' => [ 'rows' => 3, - ), - ), - ), - ) + ], + ], + ], + ] ); $this->add_tabs_widget( 'options', - array( + [ 'title' => __('Site Options', 'wp-ultimo'), 'position' => 'normal', 'sections' => $this->get_site_option_sections(), - ) + ] ); $this->add_list_table_widget( 'domains', - array( + [ 'title' => __('Mapped Domains', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Sites_Domain_List_Table(), - 'query_filter' => array($this, 'domain_query_filter'), - ) + 'query_filter' => [$this, 'domain_query_filter'], + ] ); if ($this->get_object()->get_type() === 'customer_owned') { $this->add_list_table_widget( 'membership', - array( + [ 'title' => __('Linked Membership', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Customers_Membership_List_Table(), 'query_filter' => function ($query) { @@ -379,12 +379,12 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { return $query; }, - ) + ] ); $this->add_list_table_widget( 'customer', - array( + [ 'title' => __('Linked Customer', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Site_Customer_List_Table(), 'query_filter' => function ($query) { @@ -393,17 +393,17 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { return $query; }, - ) + ] ); } $this->add_list_table_widget( 'events', - array( + [ 'title' => __('Events', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(), - 'query_filter' => array($this, 'query_filter'), - ) + 'query_filter' => [$this, 'query_filter'], + ] ); $membership_selected = $this->get_object()->get_membership() ? $this->get_object()->get_membership()->to_search_results() : ''; @@ -411,180 +411,180 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { $this->add_fields_widget( 'save', - array( - 'html_attr' => array( + [ + 'html_attr' => [ 'data-wu-app' => 'site_type', 'data-state' => json_encode( - array( + [ 'type' => $this->get_object()->get_type(), 'original_membership_id' => $this->get_object()->get_membership_id(), 'membership_id' => $this->get_object()->get_membership_id(), - ) + ] ), - ), - 'fields' => array( + ], + 'fields' => [ // Fields for price - 'type_main' => array( + 'type_main' => [ 'type' => 'text-display', 'title' => __('Site Type', 'wp-ultimo'), 'display_value' => __('Main Site', 'wp-ultimo'), 'tooltip' => __('You can\'t change the main site type.', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => '1', 'v-show' => 'type === "main"', - ), - ), - 'type' => array( + ], + ], + 'type' => [ 'type' => 'select', 'title' => __('Site Type', 'wp-ultimo'), 'placeholder' => __('Select Site Type', 'wp-ultimo'), 'desc' => __('Different site types have different options and settings.', 'wp-ultimo'), 'value' => $this->get_object()->get_type(), 'tooltip' => '', - 'options' => array( + 'options' => [ 'default' => __('Regular WordPress', 'wp-ultimo'), 'site_template' => __('Site Template', 'wp-ultimo'), 'customer_owned' => __('Customer-owned', 'wp-ultimo'), - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'type', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-cloak' => '1', 'v-show' => 'type !== "main"', - ), - ), - 'categories' => array( + ], + ], + 'categories' => [ 'type' => 'select', 'title' => __('Template Categories', 'wp-ultimo'), 'placeholder' => __('e.g.: Landing Page, Health...', 'wp-ultimo'), 'desc' => __('Customers will be able to filter by categories during signup.', 'wp-ultimo'), 'value' => $this->get_object()->get_categories(), 'options' => Site::get_all_categories(), - 'html_attr' => array( + 'html_attr' => [ 'data-selectize-categories' => 1, 'multiple' => 1, - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => "type === 'site_template'", 'v-cloak' => '1', - ), - ), - 'membership_id' => array( + ], + ], + 'membership_id' => [ 'type' => 'model', 'title' => __('Associated Membership', 'wp-ultimo'), 'placeholder' => __('Search Membership...', 'wp-ultimo'), 'desc' => __('The membership that owns this site.', 'wp-ultimo'), 'value' => $this->get_object()->get_membership_id(), 'tooltip' => '', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "type === 'customer_owned'", 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'data-model' => 'membership', 'data-value-field' => 'id', 'data-label-field' => 'reference_code', 'data-search-field' => 'reference_code', 'data-max-items' => 1, 'data-selected' => json_encode($membership_selected), - ), - ), - 'transfer_note' => array( + ], + ], + 'transfer_note' => [ 'type' => 'note', 'desc' => __('Changing the membership will transfer the site and all its assets to the new membership.', 'wp-ultimo'), 'classes' => 'wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-w-full', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => '(original_membership_id != membership_id) && membership_id', 'v-cloak' => '1', - ), - ), - 'submit_save' => array( + ], + ], + 'submit_save' => [ 'type' => 'submit', 'title' => __('Save Site', 'wp-ultimo'), 'placeholder' => __('Save Site', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'original_membership_id == membership_id || !membership_id', 'v-cloak' => 1, - ), - ), - 'transfer' => array( + ], + ], + 'transfer' => [ 'type' => 'link', 'display_value' => __('Transfer Site', 'wp-ultimo'), 'wrapper_classes' => 'wu-bg-gray-200', 'classes' => 'button wubox wu-w-full wu-text-center', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'original_membership_id != membership_id && membership_id', 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-bind:href' => "'" . wu_get_form_url( 'transfer_site', - array( + [ 'id' => $this->get_object()->get_id(), 'target_membership_id' => '', - ) + ] ) . "=' + membership_id", 'title' => __('Transfer Site', 'wp-ultimo'), - ), - ), - ), - ) + ], + ], + ], + ] ); $this->add_fields_widget( 'active', - array( + [ 'title' => __('Active', 'wp-ultimo'), - 'fields' => array( - 'active' => array( + 'fields' => [ + 'active' => [ 'type' => 'toggle', 'title' => __('Active', 'wp-ultimo'), 'desc' => __('Use this option to manually enable or disable this site.', 'wp-ultimo'), 'value' => $this->get_object()->is_active(), - ), - ), - ) + ], + ], + ] ); $this->add_fields_widget( 'image', - array( + [ 'title' => __('Site Image', 'wp-ultimo'), - 'fields' => array( - 'featured_image_id' => array( + 'fields' => [ + 'featured_image_id' => [ 'type' => 'image', 'stacked' => true, 'title' => __('Site Image', 'wp-ultimo'), 'desc' => __('This image is used on lists of sites and other places. It can be automatically generated by the screenshot scraper.', 'wp-ultimo'), 'value' => $this->get_object()->get_featured_image_id(), 'img' => $this->get_object()->get_featured_image(), - ), - 'scraper_note' => array( + ], + 'scraper_note' => [ 'type' => 'note', 'desc' => __('You need to save the site for the change to take effect.', 'wp-ultimo'), 'wrapper_classes' => 'wu-hidden wu-scraper-note', - ), - 'scraper_error' => array( + ], + 'scraper_error' => [ 'type' => 'note', 'desc' => '', 'wrapper_classes' => 'wu-hidden wu-scraper-error', - ), - 'scraper_message' => array( + ], + 'scraper_message' => [ 'type' => 'note', 'desc' => sprintf('%s', __('We detected that this network might be running locally. If that\'s the case, WP Multisite WaaS will not be able to take a screenshot of the site. A site needs to be publicly available to the outside world in order for this feature to work.', 'wp-ultimo')), 'wrapper_classes' => \WP_Ultimo\Domain_Mapping\Helper::is_development_mode() ? '' : 'wu-hidden', - ), - 'scraper' => array( + ], + 'scraper' => [ 'type' => 'submit', 'title' => __('Take Screenshot', 'wp-ultimo'), 'title' => __('Take Screenshot', 'wp-ultimo'), 'classes' => 'button wu-w-full', - ), - ), - ) + ], + ], + ] ); } @@ -600,7 +600,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { */ protected function get_site_option_sections() { - $sections = array(); + $sections = []; $sections = apply_filters('wu_site_options_sections', $sections, $this->get_object()); @@ -637,23 +637,23 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { */ public function action_links() { - return array( - array( + return [ + [ 'url' => network_admin_url('site-settings.php?id=' . $this->get_object()->get_id()), 'label' => __('Go to the Default Edit Screen', 'wp-ultimo'), 'icon' => 'wu-cog', - ), - array( + ], + [ 'url' => get_site_url($this->get_object()->get_id()), 'label' => __('Visit Site', 'wp-ultimo'), 'icon' => 'wu-link', - ), - array( + ], + [ 'url' => get_admin_url($this->get_object()->get_id()), 'label' => __('Dashboard', 'wp-ultimo'), 'icon' => 'dashboard', - ), - ); + ], + ]; } /** @@ -664,7 +664,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { */ public function get_labels() { - return array( + return [ 'edit_label' => __('Edit Site', 'wp-ultimo'), 'add_new_label' => __('Add new Site', 'wp-ultimo'), 'updated_message' => __('Site updated with success!', 'wp-ultimo'), @@ -674,7 +674,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { 'save_description' => '', 'delete_button_label' => __('Delete Site', 'wp-ultimo'), 'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'), - ); + ]; } /** @@ -687,9 +687,9 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { */ public function domain_query_filter($args) { - $extra_args = array( + $extra_args = [ 'blog_id' => absint($this->get_object()->get_id()), - ); + ]; return array_merge($args, $extra_args); } @@ -704,10 +704,10 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { */ public function query_filter($args) { - $extra_args = array( + $extra_args = [ 'object_type' => 'site', 'object_id' => absint($this->get_object()->get_id()), - ); + ]; return array_merge($args, $extra_args); } @@ -756,7 +756,7 @@ class Site_Edit_Admin_Page extends Edit_Admin_Page { */ public function handle_save() { - $_POST['categories'] = wu_get_isset($_POST, 'categories', array()); + $_POST['categories'] = wu_get_isset($_POST, 'categories', []); if ($_POST['type'] !== Site_Type::CUSTOMER_OWNED) { $_POST['membership_id'] = false; diff --git a/inc/admin-pages/class-site-list-admin-page.php b/inc/admin-pages/class-site-list-admin-page.php index 6b331f1..15d4e82 100644 --- a/inc/admin-pages/class-site-list-admin-page.php +++ b/inc/admin-pages/class-site-list-admin-page.php @@ -50,9 +50,9 @@ class Site_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_read_sites', - ); + ]; /** * Register ajax forms that we use for sites. @@ -60,17 +60,17 @@ class Site_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function register_forms() { + public function register_forms(): void { /* * Edit/Add New Site */ wu_register_form( 'add_new_site', - array( - 'render' => array($this, 'render_add_new_site_modal'), - 'handler' => array($this, 'handle_add_new_site_modal'), + [ + 'render' => [$this, 'render_add_new_site_modal'], + 'handler' => [$this, 'handle_add_new_site_modal'], 'capability' => 'wu_add_sites', - ) + ] ); /* @@ -78,14 +78,14 @@ class Site_List_Admin_Page extends List_Admin_Page { */ wu_register_form( 'publish_pending_site', - array( - 'render' => array($this, 'render_publish_pending_site_modal'), - 'handler' => array($this, 'handle_publish_pending_site_modal'), + [ + 'render' => [$this, 'render_publish_pending_site_modal'], + 'handler' => [$this, 'handle_publish_pending_site_modal'], 'capability' => 'wu_publish_sites', - ) + ] ); - add_action('wu_handle_bulk_action_form_site_screenshot', array($this, 'handle_bulk_screenshots'), 10, 3); + add_action('wu_handle_bulk_action_form_site_screenshot', [$this, 'handle_bulk_screenshots'], 10, 3); } /** @@ -98,16 +98,16 @@ class Site_List_Admin_Page extends List_Admin_Page { * @param array $ids The ids list. * @return void */ - public function handle_bulk_screenshots($action, $model, $ids) { + public function handle_bulk_screenshots($action, $model, $ids): void { $item_ids = array_filter($ids); foreach ($item_ids as $item_id) { wu_enqueue_async_action( 'wu_async_take_screenshot', - array( + [ 'site_id' => $item_id, - ), + ], 'site' ); } @@ -119,7 +119,7 @@ class Site_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function render_publish_pending_site_modal() { + public function render_publish_pending_site_modal(): void { $membership = wu_get_membership(wu_request('membership_id')); @@ -127,52 +127,52 @@ class Site_List_Admin_Page extends List_Admin_Page { return; } - $fields = array( - 'confirm' => array( + $fields = [ + 'confirm' => [ 'type' => 'toggle', 'title' => __('Confirm Publication', 'wp-ultimo'), 'desc' => __('This action can not be undone.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'confirmed', - ), - ), - 'submit_button' => array( + ], + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Publish', 'wp-ultimo'), 'placeholder' => __('Publish', 'wp-ultimo'), 'value' => 'publish', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:disabled' => '!confirmed', - ), - ), - 'wu-when' => array( + ], + ], + 'wu-when' => [ 'type' => 'hidden', 'value' => base64_encode('init'), - ), - 'membership_id' => array( + ], + 'membership_id' => [ 'type' => 'hidden', 'value' => $membership->get_id(), - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'total-actions', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'true', 'data-state' => json_encode( - array( + [ 'confirmed' => false, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -184,7 +184,7 @@ class Site_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_publish_pending_site_modal() { + public function handle_publish_pending_site_modal(): void { $membership = wu_get_membership(wu_request('membership_id')); @@ -216,14 +216,14 @@ class Site_List_Admin_Page extends List_Admin_Page { $redirect = current_user_can('wu_edit_sites') ? 'wp-ultimo-edit-site' : 'wp-ultimo-sites'; wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url( $redirect, - array( + [ 'id' => $pending_site->get_id(), - ) + ] ), - ) + ] ); } @@ -248,17 +248,17 @@ class Site_List_Admin_Page extends List_Admin_Page { $path = $d->path; } - $atts = array( + $atts = [ 'domain' => $domain, 'path' => $path, 'title' => wu_request('title'), 'type' => wu_request('type'), 'template_id' => wu_request('template_site', 0), 'membership_id' => wu_request('membership_id', false), - 'duplication_arguments' => array( + 'duplication_arguments' => [ 'copy_media' => wu_request('copy_media'), - ), - ); + ], + ]; $site = wu_create_site($atts); @@ -275,16 +275,16 @@ class Site_List_Admin_Page extends List_Admin_Page { $redirect = current_user_can('wu_edit_sites') ? 'wp-ultimo-edit-site' : 'wp-ultimo-sites'; wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url( $redirect, - array( + [ 'id' => $site->get_id(), 'wu-new-model' => 1, 'updated' => 1, - ) + ] ), - ) + ] ); } @@ -294,7 +294,7 @@ class Site_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function render_add_new_site_modal() { + public function render_add_new_site_modal(): void { global $current_site; @@ -323,11 +323,11 @@ class Site_List_Admin_Page extends List_Admin_Page { $save_label = $duplicate_id ? __('Duplicate Site', 'wp-ultimo') : __('Add new Site', 'wp-ultimo'); - $options = array( + $options = [ 'sub-domain' => __('Subdomain', 'wp-ultimo'), 'sub-directory' => __('Subdirectory', 'wp-ultimo'), 'domain' => __('Domain', 'wp-ultimo'), - ); + ]; /* * Only keep the tab that correspond to the install type. @@ -338,137 +338,137 @@ class Site_List_Admin_Page extends List_Admin_Page { unset($options['sub-domain']); } - $fields = array( - 'tab' => array( + $fields = [ + 'tab' => [ 'type' => 'tab-select', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'tab', - ), + ], 'options' => $options, - ), - 'title' => array( + ], + 'title' => [ 'type' => 'text', 'title' => __('Site Title', 'wp-ultimo'), 'placeholder' => __('New Network Site', 'wp-ultimo'), 'value' => $title, - ), - 'domain_group' => array( + ], + 'domain_group' => [ 'type' => 'group', // translators: the %s is the site preview url. 'desc' => sprintf(__('The site URL will be: %s', 'wp-ultimo'), '{{ tab === "domain" ? domain : ( tab === "sub-directory" ? scheme + base_url + domain : scheme + domain + "." + base_url ) }}'), - 'fields' => array( - 'domain' => array( + 'fields' => [ + 'domain' => [ 'type' => 'text', 'title' => __('Site Domain/Path', 'wp-ultimo'), 'tooltip' => __('Enter the complete domain for the site', 'wp-ultimo'), 'wrapper_classes' => 'wu-w-full', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:placeholder' => 'tab === "domain" ? "mysite.com" : "mysite"', 'v-on:input' => 'domain = tab === "domain" ? $event.target.value.toLowerCase().replace(/[^a-z0-9-.-]+/g, "") : $event.target.value.toLowerCase().replace(/[^a-z0-9-]+/g, "")', 'v-bind:value' => 'domain', - ), - ), - ), - ), - 'type' => array( + ], + ], + ], + ], + 'type' => [ 'type' => 'select', 'title' => __('Site Type', 'wp-ultimo'), 'value' => $type, 'placeholder' => '', - 'options' => array( + 'options' => [ 'default' => __('Regular WP Site', 'wp-ultimo'), 'site_template' => __('Site Template', 'wp-ultimo'), 'customer_owned' => __('Customer-Owned', 'wp-ultimo'), - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'type', - ), - ), - 'membership_id' => array( + ], + ], + 'membership_id' => [ 'type' => 'model', 'title' => __('Associated Membership', 'wp-ultimo'), 'placeholder' => __('Search Membership...', 'wp-ultimo'), 'value' => '', 'tooltip' => '', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => "type === 'customer_owned'", - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'data-model' => 'membership', 'data-value-field' => 'id', 'data-label-field' => 'reference_code', 'data-search-field' => 'reference_code', 'data-max-items' => 1, - ), - ), - 'copy' => array( + ], + ], + 'copy' => [ 'type' => 'toggle', 'title' => __('Copy Site', 'wp-ultimo'), 'desc' => __('Select an existing site to use as a starting point.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'copy', - ), - ), - 'template_site' => array( + ], + ], + 'template_site' => [ 'type' => 'model', 'title' => __('Template Site', 'wp-ultimo'), 'placeholder' => __('Search Sites...', 'wp-ultimo'), 'desc' => __('The site selected will be copied and used as a starting point.', 'wp-ultimo'), 'value' => $template_id, - 'html_attr' => array( + 'html_attr' => [ 'data-model' => 'site', 'data-selected' => $site ? json_encode($site->to_search_results()) : '', 'data-value-field' => 'blog_id', 'data-label-field' => 'title', 'data-search-field' => 'title', 'data-max-items' => 1, - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'copy', - ), - ), - 'copy_media' => array( + ], + ], + 'copy_media' => [ 'type' => 'toggle', 'title' => __('Copy Media on Duplication', 'wp-ultimo'), 'desc' => __('Copy media files from the template site on duplication. Disabling this can lead to broken images on the new site.', 'wp-ultimo'), 'value' => true, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'copy', - ), - ), - 'wu-when' => array( + ], + ], + 'wu-when' => [ 'type' => 'hidden', 'value' => base64_encode('init'), - ), - 'submit_button' => array( + ], + 'submit_button' => [ 'type' => 'submit', 'title' => $save_label, 'placeholder' => $save_label, 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end wu-text-right', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:disabled' => 'install_type !== tab && tab !== "domain"', - ), - ), - ); + ], + ], + ]; $d = wu_get_site_domain_and_path('replace'); $form = new \WP_Ultimo\UI\Form( 'add_new_site', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'add_new_site', 'data-state' => wu_convert_to_state( - array( + [ 'tab' => is_subdomain_install() ? 'sub-domain' : 'sub-directory', 'install_type' => is_subdomain_install() ? 'sub-domain' : 'sub-directory', 'membership' => $membership_id, @@ -477,10 +477,10 @@ class Site_List_Admin_Page extends List_Admin_Page { 'base_url' => str_replace('replace.', '', (string) $d->domain) . '/', 'scheme' => is_ssl() ? 'https://' : 'http://', 'domain' => $path, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -502,10 +502,10 @@ class Site_List_Admin_Page extends List_Admin_Page { */ public function get_labels() { - return array( + return [ 'deleted_message' => __('Site removed successfully.', 'wp-ultimo'), 'search_label' => __('Search Site', 'wp-ultimo'), - ); + ]; } /** @@ -549,14 +549,14 @@ class Site_List_Admin_Page extends List_Admin_Page { */ public function action_links() { - return array( - array( + return [ + [ 'label' => __('Add Site'), 'icon' => 'wu-circle-with-plus', 'classes' => 'wubox', 'url' => wu_get_form_url('add_new_site'), - ), - ); + ], + ]; } /** diff --git a/inc/admin-pages/class-system-info-admin-page.php b/inc/admin-pages/class-system-info-admin-page.php index 39a7ca0..fff4973 100644 --- a/inc/admin-pages/class-system-info-admin-page.php +++ b/inc/admin-pages/class-system-info-admin-page.php @@ -68,9 +68,9 @@ class System_Info_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'manage_network', - ); + ]; /** * Allow child classes to add further initializations. @@ -78,9 +78,9 @@ class System_Info_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function init() { + public function init(): void { - add_action('wp_ajax_wu_generate_text_file_system_info', array($this, 'generate_text_file_system_info')); + add_action('wp_ajax_wu_generate_text_file_system_info', [$this, 'generate_text_file_system_info']); } /** @@ -89,7 +89,7 @@ class System_Info_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function register_scripts() { + public function register_scripts(): void { wp_enqueue_script('dashboard'); @@ -102,7 +102,7 @@ class System_Info_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { $screen = get_current_screen(); @@ -129,16 +129,16 @@ class System_Info_Admin_Page extends Base_Admin_Page { * @param array $data Data. * @return void */ - public function output_table_system_info($data) { + public function output_table_system_info($data): void { $screen = get_current_screen(); wu_get_template( 'system-info/system-info-table', - array( + [ 'data' => $data, 'screen' => $screen, - ) + ] ); } @@ -181,16 +181,16 @@ class System_Info_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function output() { + public function output(): void { $screen = get_current_screen(); wu_get_template( 'system-info/system-info', - array( + [ 'data' => $this->get_data(), 'screen' => $screen, - ) + ] ); } @@ -224,9 +224,9 @@ class System_Info_Admin_Page extends Base_Admin_Page { $all_options_bytes = round(mb_strlen($all_options_serialized, '8bit') / 1024, 2); $all_options_transients = $this->get_transients_in_options($all_options); - $array_active_plugins = array(); + $array_active_plugins = []; - $array_constants_options = array( + $array_constants_options = [ 'SAVEQUERIES', 'WP_DEBUG', 'WP_DEBUG_DISPLAY', @@ -235,16 +235,16 @@ class System_Info_Admin_Page extends Base_Admin_Page { 'SCRIPT_DEBUG', 'WP_ENV', 'NOBLOGREDIRECT', - ); + ]; - $array_constants = array(); + $array_constants = []; foreach ($array_constants_options as $constant) { - $array_constants[] = array( + $array_constants[] = [ 'tooltip' => '', 'title' => $constant, 'value' => defined($constant) ? (is_bool(constant($constant)) ? __('Enabled', 'wp-ultimo') : constant($constant)) : __('Disabled', 'wp-ultimo'), - ); + ]; } foreach ($plugins as $plugin_path => $plugin) { @@ -255,15 +255,15 @@ class System_Info_Admin_Page extends Base_Admin_Page { $plugin_uri = ' (' . $plugin['PluginURI'] . ')'; } - $array_active_plugins[] = array( + $array_active_plugins[] = [ 'tooltip' => '', 'title' => $plugin['Name'], 'value' => $plugin['Version'] . $plugin_uri, - ); + ]; } } - $array_active_plugins_main_site = array(); + $array_active_plugins_main_site = []; foreach ($plugins as $plugin_path => $plugin) { if (in_array($plugin_path, $active_plugins_main_site, true)) { @@ -273,263 +273,263 @@ class System_Info_Admin_Page extends Base_Admin_Page { $plugin_uri = ' (' . $plugin['PluginURI'] . ')'; } - $array_active_plugins_main_site[] = array( + $array_active_plugins_main_site[] = [ 'tooltip' => '', 'title' => $plugin['Name'], 'value' => $plugin['Version'] . $plugin_uri, - ); + ]; } } - $wpultimo_settings = array(); + $wpultimo_settings = []; foreach ($this->get_all_wp_ultimo_settings() as $setting => $value) { if (is_array($value)) { continue; } - $wpultimo_settings[ $setting ] = array( + $wpultimo_settings[ $setting ] = [ 'tooltip' => '', 'title' => $setting, 'value' => $value, - ); + ]; } - $array_wu_tables = array(); + $array_wu_tables = []; foreach ($wpdb->ms_global_tables as $key => $value) { - if (strncmp((string) $value, 'wu_', strlen('wu_')) === 0 && ! array_key_exists($value, $array_wu_tables)) { - $array_wu_tables[ $value ] = array( + if (str_starts_with((string) $value, 'wu_') && ! array_key_exists($value, $array_wu_tables)) { + $array_wu_tables[ $value ] = [ 'tooltip' => '', 'title' => $value, 'value' => get_network_option(null, "wpdb_{$value}_version"), - ); + ]; } } return apply_filters( 'wu_system_info_data', - array( - 'WordPress and System Settings' => array( - 'wp-ultimo-version' => array( + [ + 'WordPress and System Settings' => [ + 'wp-ultimo-version' => [ 'tooltip' => 'WP Multisite WaaS current version installed locally', 'title' => 'WP Multisite WaaS Version', 'value' => wu_get_version(), - ), - 'wordpress-version' => array( + ], + 'wordpress-version' => [ 'tooltip' => '', 'title' => 'WordPress Version', 'value' => get_bloginfo('version'), - ), - 'php-version' => array( + ], + 'php-version' => [ 'tooltip' => '', 'title' => 'PHP Version', 'value' => PHP_VERSION, - ), - 'mysql-version' => array( + ], + 'mysql-version' => [ 'tooltip' => '', 'title' => 'MySQL Version ', 'value' => $wpdb->db_version(), - ), - 'web-server' => array( + ], + 'web-server' => [ 'tooltip' => '', 'title' => 'Web Server', 'value' => $_SERVER['SERVER_SOFTWARE'], - ), - 'wordpress-url' => array( + ], + 'wordpress-url' => [ 'tooltip' => '', 'title' => 'WordPress URL', 'value' => get_bloginfo('wpurl'), - ), - 'home-url' => array( + ], + 'home-url' => [ 'tooltip' => '', 'title' => 'Home URL', 'value' => get_bloginfo('url'), - ), - 'content-directory' => array( + ], + 'content-directory' => [ 'tooltip' => '', 'title' => 'Content Directory', 'value' => WP_CONTENT_DIR, - ), - 'content-url' => array( + ], + 'content-url' => [ 'tooltip' => '', 'title' => 'Content URL', 'value' => WP_CONTENT_URL, - ), - 'plugins-directory' => array( + ], + 'plugins-directory' => [ 'tooltip' => '', 'title' => 'Plugins Directory', 'value' => WP_PLUGIN_DIR, - ), - 'pluguins-url' => array( + ], + 'pluguins-url' => [ 'tooltip' => '', 'title' => 'Plugins URL', 'value' => WP_PLUGIN_URL, - ), - 'uploads-directory' => array( + ], + 'uploads-directory' => [ 'tooltip' => '', 'title' => 'Uploads Directory', 'value' => (defined('UPLOADS') ? UPLOADS : WP_CONTENT_DIR . '/uploads'), - ), - 'pluguins-url' => array( + ], + 'pluguins-url' => [ 'tooltip' => '', 'title' => 'Cookie Domain', - 'value' => defined('COOKIE_DOMAIN') ? COOKIE_DOMAIN ? COOKIE_DOMAIN : __('Disabled', 'wp-ultimo') : __('Not set', 'wp-ultimo'), - ), - 'multisite-active' => array( + 'value' => defined('COOKIE_DOMAIN') ? COOKIE_DOMAIN ?: __('Disabled', 'wp-ultimo') : __('Not set', 'wp-ultimo'), + ], + 'multisite-active' => [ 'tooltip' => '', 'title' => 'Multi-Site Active', 'value' => is_multisite() ? __('Yes', 'wp-ultimo') : __('No', 'wp-ultimo'), - ), - 'php-current-time-gmt' => array( + ], + 'php-current-time-gmt' => [ 'tooltip' => '', 'title' => 'PHP Current Time - GMT', 'value' => wu_get_current_time('mysql', true), - ), - 'timezone' => array( + ], + 'timezone' => [ 'tooltip' => '', 'title' => 'Timezone', 'value' => wp_timezone_string(), - ), - 'php-current-time' => array( + ], + 'php-current-time' => [ 'tooltip' => '', 'title' => 'PHP Current Time - with Timezone', 'value' => wu_get_current_time(), - ), - 'database-current-time' => array( + ], + 'database-current-time' => [ 'tooltip' => '', 'title' => 'Database Current Time', 'value' => gmdate('Y-m-d H:i:s', strtotime((string) $wpdb->get_row('SELECT NOW() as time;')->time)), - ), - 'php-curl-support' => array( + ], + 'php-curl-support' => [ 'tooltip' => '', 'title' => 'PHP cURL Support', 'value' => function_exists('curl_init') ? __('Yes', 'wp-ultimo') : __('No', 'wp-ultimo'), - ), - 'php-gd-time' => array( + ], + 'php-gd-time' => [ 'tooltip' => '', 'title' => 'PHP GD Support', 'value' => function_exists('gd_info') ? __('Yes', 'wp-ultimo') : __('No', 'wp-ultimo'), - ), - 'php-memory-limit' => array( + ], + 'php-memory-limit' => [ 'tooltip' => '', 'title' => 'PHP Memory Limit', 'value' => $memory_limit . 'M', - ), - 'php-memory-usage' => array( + ], + 'php-memory-usage' => [ 'tooltip' => '', 'title' => 'PHP Memory Usage', 'value' => $memory_usage . 'M (' . round($memory_usage / $memory_limit * $pad_spaces, 0) . '%)', - ), - 'php-post-max-size' => array( + ], + 'php-post-max-size' => [ 'tooltip' => '', 'title' => 'PHP Post Max Size', 'value' => ini_get('post_max_size'), - ), - 'php-upload-max-size' => array( + ], + 'php-upload-max-size' => [ 'tooltip' => '', 'title' => 'PHP Upload Max Size', 'value' => ini_get('upload_max_filesize'), - ), - 'php-max-execution-time' => array( + ], + 'php-max-execution-time' => [ 'tooltip' => '', 'title' => 'PHP Max Execution Time', 'value' => $max_execution_time, - ), - 'php-allow-url-fopen' => array( + ], + 'php-allow-url-fopen' => [ 'tooltip' => '', 'title' => 'PHP Allow URL Fopen', 'value' => ini_get('allow_url_fopen'), - ), - 'php-max-file-uploads' => array( + ], + 'php-max-file-uploads' => [ 'tooltip' => '', 'title' => 'PHP Max File Uploads', 'value' => ini_get('max_file_uploads'), - ), - 'wp-options-count' => array( + ], + 'wp-options-count' => [ 'tooltip' => '', 'title' => 'WP Options Count', 'value' => count($all_options), - ), - 'wp-options-size' => array( + ], + 'wp-options-size' => [ 'tooltip' => '', 'title' => 'WP Options Size', 'value' => $all_options_bytes . 'kb', - ), - 'wp-options-transients' => array( + ], + 'wp-options-transients' => [ 'tooltip' => '', 'title' => 'WP Options Transients', 'value' => count($all_options_transients), - ), - 'wp-debug' => array( + ], + 'wp-debug' => [ 'tooltip' => '', 'title' => 'WP Options Transients', 'value' => defined('WP_DEBUG') ? WP_DEBUG ? __('Enabled', 'wp-ultimo') : __('Disabled', 'wp-ultimo') : __('Not set', 'wp-ultimo'), - ), - 'script-debug' => array( + ], + 'script-debug' => [ 'tooltip' => '', 'title' => 'WP Options Transients', 'value' => defined('SCRIPT_DEBUG') ? SCRIPT_DEBUG ? __('Enabled', 'wp-ultimo') : __('Disabled', 'wp-ultimo') : __('Not set', 'wp-ultimo'), - ), - 'save-queries' => array( + ], + 'save-queries' => [ 'tooltip' => '', 'title' => 'WP Options Transients', 'value' => defined('SAVEQUERIES') ? SAVEQUERIES ? __('Enabled', 'wp-ultimo') : __('Disabled', 'wp-ultimo') : __('Not set', 'wp-ultimo'), - ), - 'autosave-interval' => array( + ], + 'autosave-interval' => [ 'tooltip' => '', 'title' => 'WP Options Transients', - 'value' => defined('AUTOSAVE_INTERVAL') ? AUTOSAVE_INTERVAL ? AUTOSAVE_INTERVAL : __('Disabled', 'wp-ultimo') : __('Not set', 'wp-ultimo'), - ), - 'wp_post_revisions' => array( + 'value' => defined('AUTOSAVE_INTERVAL') ? AUTOSAVE_INTERVAL ?: __('Disabled', 'wp-ultimo') : __('Not set', 'wp-ultimo'), + ], + 'wp_post_revisions' => [ 'tooltip' => '', 'title' => 'WP Options Transients', - 'value' => defined('WP_POST_REVISIONS') ? WP_POST_REVISIONS ? WP_POST_REVISIONS : __('Disabled', 'wp-ultimo') : __('Not set', 'wp-ultimo'), - ), - 'disable_wp_cron' => array( + 'value' => defined('WP_POST_REVISIONS') ? WP_POST_REVISIONS ?: __('Disabled', 'wp-ultimo') : __('Not set', 'wp-ultimo'), + ], + 'disable_wp_cron' => [ 'tooltip' => '', 'title' => 'DISABLE_WP_CRON', - 'value' => defined('DISABLE_WP_CRON') ? DISABLE_WP_CRON ? DISABLE_WP_CRON : __('Yes', 'wp-ultimo') : __('No', 'wp-ultimo'), - ), - 'wp_lang' => array( + 'value' => defined('DISABLE_WP_CRON') ? DISABLE_WP_CRON ?: __('Yes', 'wp-ultimo') : __('No', 'wp-ultimo'), + ], + 'wp_lang' => [ 'tooltip' => '', 'title' => 'WPLANG', - 'value' => defined('WPLANG') ? WPLANG ? WPLANG : __('Yes', 'wp-ultimo') : __('No', 'wp-ultimo'), - ), - 'wp_memory_limit' => array( + 'value' => defined('WPLANG') ? WPLANG ?: __('Yes', 'wp-ultimo') : __('No', 'wp-ultimo'), + ], + 'wp_memory_limit' => [ 'tooltip' => '', 'title' => 'WP_MEMORY_LIMIT', 'value' => (defined('WP_MEMORY_LIMIT') && WP_MEMORY_LIMIT) ? WP_MEMORY_LIMIT : __('Not set', 'wp-ultimo'), - ), - 'wp_max_memory_limit' => array( + ], + 'wp_max_memory_limit' => [ 'tooltip' => '', 'title' => 'WP_MAX_MEMORY_LIMIT', 'value' => (defined('WP_MAX_MEMORY_LIMIT') && WP_MAX_MEMORY_LIMIT) ? WP_MAX_MEMORY_LIMIT : __('Not set', 'wp-ultimo'), - ), - 'operating-system' => array( + ], + 'operating-system' => [ 'tooltip' => '', 'title' => 'Operating System', 'value' => $browser['platform'], - ), - 'browser' => array( + ], + 'browser' => [ 'tooltip' => '', 'title' => 'Browser', 'value' => $browser['name'] . ' ' . $browser['version'], - ), - 'user-agent' => array( + ], + 'user-agent' => [ 'tooltip' => '', 'title' => 'User Agent', 'value' => $browser['user_agent'], - ), - ), + ], + ], - 'Active Theme' => array( - 'active-theme' => array( + 'Active Theme' => [ + 'active-theme' => [ 'tooltip' => '', 'title' => 'Active Theme', 'value' => $theme->get('Name') . ' - ' . $theme->get('Version') . '(' . $theme->get('ThemeURI') . ')', - ), - ), + ], + ], 'Active Plugins' => $array_active_plugins, 'Active Plugins on Main Site' => $array_active_plugins_main_site, @@ -537,17 +537,17 @@ class System_Info_Admin_Page extends Base_Admin_Page { 'WP Multisite WaaS Database Status' => $array_wu_tables, 'WP Multisite WaaS Core Settings' => array_merge( - array( - 'logs-directory' => array( + [ + 'logs-directory' => [ 'tooltip' => '', 'title' => 'Logs Directory', 'value' => is_writable(Logger::get_logs_folder()) ? __('Writable', 'wp-ultimo') : __('Not Writable', 'wp-ultimo'), - ), - ), + ], + ], $wpultimo_settings ), 'Defined Constants' => $array_constants, - ) + ] ); } @@ -557,7 +557,7 @@ class System_Info_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function generate_text_file_system_info() { + public function generate_text_file_system_info(): void { $file_name = sprintf("$this->id-%s.txt", gmdate('Y-m-d')); $txt = fopen($file_name, 'w') or die('Unable to open file!'); @@ -629,7 +629,7 @@ class System_Info_Admin_Page extends Base_Admin_Page { } // Finally get the correct version number - $known = array('Version', $browser_name_short, 'other'); + $known = ['Version', $browser_name_short, 'other']; $pattern = '#(?' . join('|', $known) . ')[/ ]+(?[0-9.|a-zA-Z.]*)#'; if ( ! preg_match_all($pattern, (string) $user_agent, $matches)) { @@ -657,13 +657,13 @@ class System_Info_Admin_Page extends Base_Admin_Page { $version = '?'; } - return array( + return [ 'user_agent' => $user_agent, 'name' => $browser_name, 'version' => $version, 'platform' => $platform, 'pattern' => $pattern, - ); + ]; } /** @@ -683,7 +683,7 @@ class System_Info_Admin_Page extends Base_Admin_Page { */ public function get_active_plugins() { - return (array) get_site_option('active_sitewide_plugins', array()); + return (array) get_site_option('active_sitewide_plugins', []); } /** @@ -693,7 +693,7 @@ class System_Info_Admin_Page extends Base_Admin_Page { */ public function get_active_plugins_on_main_site() { - return (array) get_option('active_plugins', array()); + return (array) get_option('active_plugins', []); } /** * Get memory usage @@ -722,7 +722,7 @@ class System_Info_Admin_Page extends Base_Admin_Page { */ public function get_all_wp_ultimo_settings() { - $exclude = array( + $exclude = [ 'email', 'logo', 'color', @@ -734,11 +734,11 @@ class System_Info_Admin_Page extends Base_Admin_Page { 'license_key', 'api-', 'manual_payment_instructions', - ); + ]; - $include = array('enable'); + $include = ['enable']; - $return_settings = array(); + $return_settings = []; $settings = new \WP_Ultimo\Settings(); @@ -769,7 +769,7 @@ class System_Info_Admin_Page extends Base_Admin_Page { */ public function get_transients_in_options($options) { - $transients = array(); + $transients = []; foreach ($options as $name => $value) { if (stristr($name, 'transient')) { diff --git a/inc/admin-pages/class-tax-rates-admin-page.php b/inc/admin-pages/class-tax-rates-admin-page.php index 3a651f7..dc569bb 100644 --- a/inc/admin-pages/class-tax-rates-admin-page.php +++ b/inc/admin-pages/class-tax-rates-admin-page.php @@ -60,9 +60,9 @@ class Tax_Rates_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'manage_network', - ); + ]; /** * Returns the title of the page. @@ -103,29 +103,29 @@ class Tax_Rates_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function output() { + public function output(): void { do_action('wu_load_tax_rates_list_page'); $columns = apply_filters( 'wu_tax_rates_columns', - array( + [ 'title' => __('Label', 'wp-ultimo'), 'country' => __('Country', 'wp-ultimo'), 'state' => __('State / Province', 'wp-ultimo'), 'city' => __('City', 'wp-ultimo'), 'tax_rate' => __('Tax Rate (%)', 'wp-ultimo'), 'move' => '', - ) + ] ); wu_get_template( 'taxes/list', - array( + [ 'columns' => $columns, 'screen' => get_current_screen(), 'types' => Tax::get_instance()->get_tax_rate_types(), - ) + ] ); } @@ -135,25 +135,25 @@ class Tax_Rates_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { parent::register_scripts(); - wp_register_script('wu-tax-rates', wu_get_asset('tax-rates.js', 'js'), array('wu-admin', 'wu-vue', 'underscore', 'wu-selectizer'), wu_get_version(), false); + wp_register_script('wu-tax-rates', wu_get_asset('tax-rates.js', 'js'), ['wu-admin', 'wu-vue', 'underscore', 'wu-selectizer'], wu_get_version(), false); wp_localize_script( 'wu-tax-rates', 'wu_tax_ratesl10n', - array( + [ 'name' => __('Tax', 'wp-ultimo'), 'confirm_message' => __('Are you sure you want to delete this rows?', 'wp-ultimo'), 'confirm_delete_tax_category_message' => __('Are you sure you want to delete this tax category?', 'wp-ultimo'), - ) + ] ); - wp_enqueue_script('wu-vue-sortable', '//cdn.jsdelivr.net/npm/sortablejs@1.8.4/Sortable.min.js', array(), wu_get_version()); + wp_enqueue_script('wu-vue-sortable', '//cdn.jsdelivr.net/npm/sortablejs@1.8.4/Sortable.min.js', [], wu_get_version()); - wp_enqueue_script('wu-vue-draggable', '//cdnjs.cloudflare.com/ajax/libs/Vue.Draggable/2.20.0/vuedraggable.umd.min.js', array(), wu_get_version()); + wp_enqueue_script('wu-vue-draggable', '//cdnjs.cloudflare.com/ajax/libs/Vue.Draggable/2.20.0/vuedraggable.umd.min.js', [], wu_get_version()); wp_enqueue_script('wu-tax-rates'); } @@ -168,22 +168,22 @@ class Tax_Rates_Admin_Page extends Base_Admin_Page { * @param array $atts Array of attributes to pass to the form. * @return void */ - protected function add_fields_widget($id, $atts = array()) { + protected function add_fields_widget($id, $atts = []) { $atts = wp_parse_args( $atts, - array( + [ 'widget_id' => $id, 'before' => '', 'after' => '', 'title' => __('Fields', 'wp-ultimo'), 'position' => 'side', 'screen' => get_current_screen(), - 'fields' => array(), - 'html_attr' => array(), + 'fields' => [], + 'html_attr' => [], 'classes' => '', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - ) + ] ); add_meta_box( @@ -192,13 +192,13 @@ class Tax_Rates_Admin_Page extends Base_Admin_Page { function () use ($atts) { if (wu_get_isset($atts['html_attr'], 'data-wu-app')) { - $atts['fields']['loading'] = array( + $atts['fields']['loading'] = [ 'type' => 'note', 'desc' => sprintf('
%s
', __('Loading...', 'wp-ultimo')), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 0, - ), - ); + ], + ]; } /** @@ -209,14 +209,14 @@ class Tax_Rates_Admin_Page extends Base_Admin_Page { $form = new \WP_Ultimo\UI\Form( $atts['widget_id'], $atts['fields'], - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-widget-list wu-striped wu-m-0 wu--mt-2 wu--mb-3 wu--mx-3 ' . $atts['classes'], 'field_wrapper_classes' => $atts['field_wrapper_classes'], 'html_attr' => $atts['html_attr'], 'before' => $atts['before'], 'after' => $atts['after'], - ) + ] ); $form->render(); diff --git a/inc/admin-pages/class-template-previewer-customize-admin-page.php b/inc/admin-pages/class-template-previewer-customize-admin-page.php index 294a545..bcb6ca4 100644 --- a/inc/admin-pages/class-template-previewer-customize-admin-page.php +++ b/inc/admin-pages/class-template-previewer-customize-admin-page.php @@ -60,9 +60,9 @@ class Template_Previewer_Customize_Admin_Page extends Customizer_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_customize_invoice_template', - ); + ]; /** * Returns the preview URL. This is then added to the iframe. @@ -75,10 +75,10 @@ class Template_Previewer_Customize_Admin_Page extends Customizer_Admin_Page { $url = get_site_url(null); return add_query_arg( - array( + [ 'customizer' => 1, Template_Previewer::get_instance()->get_preview_parameter() => 1, - ), + ], $url ); } @@ -89,27 +89,27 @@ class Template_Previewer_Customize_Admin_Page extends Customizer_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { $this->add_save_widget( 'save', - array( - 'fields' => array( - 'preview_url_parameter' => array( + [ + 'fields' => [ + 'preview_url_parameter' => [ 'type' => 'text', 'title' => __('URL Parameter', 'wp-ultimo'), 'desc' => __('This is the URL parameter WP Multisite WaaS will use to generate the template preview URLs.', 'wp-ultimo'), 'value' => Template_Previewer::get_instance()->get_setting('preview_url_parameter', 'template-preview'), - ), - 'enabled' => array( + ], + 'enabled' => [ 'type' => 'toggle', 'title' => __('Active', 'wp-ultimo'), 'desc' => __('If your site templates are not loading, you can disable the top-bar using this setting.', 'wp-ultimo'), 'value' => Template_Previewer::get_instance()->get_setting('enabled', true), - 'html_attr' => array(), - ), - ), - ) + 'html_attr' => [], + ], + ], + ] ); $custom_logo_id = Template_Previewer::get_instance()->get_setting('custom_logo'); @@ -118,124 +118,124 @@ class Template_Previewer_Customize_Admin_Page extends Customizer_Admin_Page { $custom_logo = $custom_logo ? $custom_logo[0] : false; - $fields = array( - 'tab' => array( + $fields = [ + 'tab' => [ 'type' => 'tab-select', 'wrapper_classes' => '', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'tab', - ), - 'options' => array( + ], + 'options' => [ 'general' => __('General', 'wp-ultimo'), 'colors' => __('Colors', 'wp-ultimo'), 'images' => __('Images', 'wp-ultimo'), - ), - ), + ], + ], - 'display_responsive_controls' => array( + 'display_responsive_controls' => [ 'type' => 'toggle', 'title' => __('Show Responsive Controls', 'wp-ultimo'), 'desc' => __('Toggle to show or hide the responsive controls.', 'wp-ultimo'), 'value' => true, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "general")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'display_responsive_controls', - ), - ), - 'button_text' => array( + ], + ], + 'button_text' => [ 'type' => 'text', 'title' => __('Button Text', 'wp-ultimo'), 'value' => __('Use this Template', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "general")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model.lazy' => 'button_text', - ), - ), + ], + ], - 'bg_color' => array( + 'bg_color' => [ 'type' => 'color-picker', 'title' => __('Background Color', 'wp-ultimo'), 'desc' => __('Choose the background color for the top-bar.', 'wp-ultimo'), 'value' => '#f9f9f9', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "colors")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'bg_color', - ), - ), - 'button_bg_color' => array( + ], + ], + 'button_bg_color' => [ 'type' => 'color-picker', 'title' => __('Button BG Color', 'wp-ultimo'), 'desc' => __('Pick the background color for the button.', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "colors")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'button_bg_color', - ), - ), + ], + ], - 'use_custom_logo' => array( + 'use_custom_logo' => [ 'type' => 'toggle', 'title' => __('Use Custom Logo', 'wp-ultimo'), 'desc' => __('You can set a different logo to be used on the top-bar.', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "images")', 'v-cloak' => 1, - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'use_custom_logo', - ), - ), - 'custom_logo' => array( + ], + ], + 'custom_logo' => [ 'type' => 'image', 'stacked' => true, 'title' => __('Custom Logo', 'wp-ultimo'), 'desc' => __('The logo is displayed on the preview page top-bar.', 'wp-ultimo'), 'value' => $custom_logo_id, 'img' => $custom_logo, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'require("tab", "images") && require("use_custom_logo", true)', 'v-cloak' => 1, - ), - ), - ); + ], + ], + ]; $settings = Template_Previewer::get_instance()->get_settings(); $state = array_merge( $settings, - array( + [ 'tab' => 'general', 'refresh' => true, - ) + ] ); $this->add_fields_widget( 'customizer', - array( + [ 'title' => __('Customizer', 'wp-ultimo'), 'position' => 'side', 'fields' => $fields, - 'html_attr' => array( + 'html_attr' => [ 'style' => 'margin-top: -6px;', 'data-wu-app' => 'site_template_customizer', 'data-wu-customizer-panel' => true, 'data-state' => json_encode($state), - ), - ) + ], + ] ); } @@ -269,7 +269,7 @@ class Template_Previewer_Customize_Admin_Page extends Customizer_Admin_Page { */ public function action_links() { - return array(); + return []; } /** @@ -280,7 +280,7 @@ class Template_Previewer_Customize_Admin_Page extends Customizer_Admin_Page { */ public function get_labels() { - return array( + return [ 'customize_label' => __('Customize Template Previewer', 'wp-ultimo'), 'add_new_label' => __('Customize Template Previewer', 'wp-ultimo'), 'edit_label' => __('Edit Template Previewer', 'wp-ultimo'), @@ -289,7 +289,7 @@ class Template_Previewer_Customize_Admin_Page extends Customizer_Admin_Page { 'title_description' => __('This name is used for internal reference only.', 'wp-ultimo'), 'save_button_label' => __('Save Changes', 'wp-ultimo'), 'save_description' => '', - ); + ]; } /** @@ -298,13 +298,13 @@ class Template_Previewer_Customize_Admin_Page extends Customizer_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_save() { + public function handle_save(): void { $settings = Template_Previewer::get_instance()->save_settings($_POST); - $array_params = array( + $array_params = [ 'updated' => 1, - ); + ]; $url = add_query_arg($array_params); diff --git a/inc/admin-pages/class-top-admin-nav-menu.php b/inc/admin-pages/class-top-admin-nav-menu.php index 7dfb5c4..a0f6901 100644 --- a/inc/admin-pages/class-top-admin-nav-menu.php +++ b/inc/admin-pages/class-top-admin-nav-menu.php @@ -32,7 +32,7 @@ class Top_Admin_Nav_Menu { */ public function __construct() { - add_action('admin_bar_menu', array($this, 'add_top_bar_menus'), 50); + add_action('admin_bar_menu', [$this, 'add_top_bar_menus'], 50); } /** @@ -42,7 +42,7 @@ class Top_Admin_Nav_Menu { * @param \WP_Admin_Bar $wp_admin_bar The admin bar identifier. * @return void */ - public function add_top_bar_menus($wp_admin_bar) { + public function add_top_bar_menus($wp_admin_bar): void { // Only for super admins if ( ! current_user_can('manage_network')) { @@ -50,111 +50,111 @@ class Top_Admin_Nav_Menu { } // Add Parent element - $parent = array( + $parent = [ 'id' => 'wp-ultimo', 'title' => __('Multisite Waas', 'wp-ultimo'), 'href' => current_user_can('wu_read_dashboard') ? network_admin_url('admin.php?page=wp-ultimo') : '#', - 'meta' => array( + 'meta' => [ 'class' => 'wp-ultimo-top-menu', 'title' => __('Go to the dashboard', 'wp-ultimo'), - ), - ); + ], + ]; // Site - $sites = array( + $sites = [ 'id' => 'wp-ultimo-sites', 'parent' => 'wp-ultimo', 'title' => __('Manage Sites', 'wp-ultimo'), 'href' => network_admin_url('admin.php?page=wp-ultimo-sites'), - 'meta' => array( + 'meta' => [ 'class' => 'wp-ultimo-top-menu', 'title' => __('Go to the sites page', 'wp-ultimo'), - ), - ); + ], + ]; // Memberships - $memberships = array( + $memberships = [ 'id' => 'wp-ultimo-memberships', 'parent' => 'wp-ultimo', 'title' => __('Manage Memberships', 'wp-ultimo'), 'href' => network_admin_url('admin.php?page=wp-ultimo-memberships'), - 'meta' => array( + 'meta' => [ 'class' => 'wp-ultimo-top-menu', 'title' => __('Go to the memberships page', 'wp-ultimo'), - ), - ); + ], + ]; // Customers - $customers = array( + $customers = [ 'id' => 'wp-ultimo-customers', 'parent' => 'wp-ultimo', 'title' => __('Customers', 'wp-ultimo'), 'href' => network_admin_url('admin.php?page=wp-ultimo-customers'), - 'meta' => array( + 'meta' => [ 'class' => 'wp-ultimo-top-menu', 'title' => __('Go to the customers page', 'wp-ultimo'), - ), - ); + ], + ]; // Products - $products = array( + $products = [ 'id' => 'wp-ultimo-products', 'parent' => 'wp-ultimo', 'title' => __('Products', 'wp-ultimo'), 'href' => network_admin_url('admin.php?page=wp-ultimo-products'), - 'meta' => array( + 'meta' => [ 'class' => 'wp-ultimo-top-menu', 'title' => __('Go to the products page', 'wp-ultimo'), - ), - ); + ], + ]; // Payments - $payments = array( + $payments = [ 'id' => 'wp-ultimo-payments', 'parent' => 'wp-ultimo', 'title' => __('Payments', 'wp-ultimo'), 'href' => network_admin_url('admin.php?page=wp-ultimo-payments'), - 'meta' => array( + 'meta' => [ 'class' => 'wp-ultimo-top-menu', 'title' => __('Go to the payments page', 'wp-ultimo'), - ), - ); + ], + ]; // Discount Codes - $discount_codes = array( + $discount_codes = [ 'id' => 'wp-ultimo-discount-codes', 'parent' => 'wp-ultimo', 'title' => __('Discount Codes', 'wp-ultimo'), 'href' => network_admin_url('admin.php?page=wp-ultimo-discount-codes'), - 'meta' => array( + 'meta' => [ 'class' => 'wp-ultimo-top-menu', 'title' => __('Go to the discount codes page', 'wp-ultimo'), - ), - ); + ], + ]; - $container = array( + $container = [ 'id' => 'wp-ultimo-settings-group', 'parent' => 'wp-ultimo', 'group' => true, 'title' => __('Settings Container', 'wp-ultimo'), 'href' => '#', - 'meta' => array( + 'meta' => [ 'class' => 'wp-ultimo-top-menu ab-sub-secondary', 'title' => __('Go to the settings page', 'wp-ultimo'), - ), - ); + ], + ]; // Settings - $settings = array( + $settings = [ 'id' => 'wp-ultimo-settings', 'parent' => 'wp-ultimo-settings-group', 'title' => __('Settings', 'wp-ultimo'), 'href' => network_admin_url('admin.php?page=wp-ultimo-settings'), - 'meta' => array( + 'meta' => [ 'class' => 'wp-ultimo-top-menu ab-sub-secondary', 'title' => __('Go to the settings page', 'wp-ultimo'), - ), - ); + ], + ]; /** * Add items to the top bar. @@ -208,16 +208,16 @@ class Top_Admin_Nav_Menu { $parent = 'wp-ultimo-settings-addons'; } - $settings_tab = array( + $settings_tab = [ 'id' => 'wp-ultimo-settings-' . $tab, 'parent' => $parent, 'title' => $tab_info['title'], 'href' => network_admin_url('admin.php?page=wp-ultimo-settings&tab=') . $tab, - 'meta' => array( + 'meta' => [ 'class' => 'wp-ultimo-top-menu', 'title' => __('Go to the settings page', 'wp-ultimo'), - ), - ); + ], + ]; $wp_admin_bar->add_node($settings_tab); } diff --git a/inc/admin-pages/class-view-logs-admin-page.php b/inc/admin-pages/class-view-logs-admin-page.php index 9b796f3..bd21af3 100644 --- a/inc/admin-pages/class-view-logs-admin-page.php +++ b/inc/admin-pages/class-view-logs-admin-page.php @@ -68,9 +68,9 @@ class View_Logs_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'manage_network', - ); + ]; /** * Allow child classes to add further initializations. @@ -78,9 +78,9 @@ class View_Logs_Admin_Page extends Edit_Admin_Page { * @since 1.8.2 * @return void */ - public function init() { + public function init(): void { - add_action('wp_ajax_wu_handle_view_logs', array($this, 'handle_view_logs')); + add_action('wp_ajax_wu_handle_view_logs', [$this, 'handle_view_logs']); } /** @@ -89,20 +89,20 @@ class View_Logs_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { parent::register_scripts(); - \WP_Ultimo\Scripts::get_instance()->register_script('wu-view-log', wu_get_asset('view-logs.js', 'js'), array('jquery')); + \WP_Ultimo\Scripts::get_instance()->register_script('wu-view-log', wu_get_asset('view-logs.js', 'js'), ['jquery']); wp_localize_script( 'wu-view-log', 'wu_view_logs', - array( - 'i18n' => array( + [ + 'i18n' => [ 'copied' => __('Copied!', 'wp-ultimo'), - ), - ) + ], + ] ); wp_enqueue_script('wu-view-log'); @@ -144,9 +144,9 @@ class View_Logs_Admin_Page extends Edit_Admin_Page { $logs_list = list_files( Logger::get_logs_folder(), 2, - array( + [ 'index.html', - ) + ] ); $logs_list = array_combine(array_values($logs_list), array_map(fn($file) => str_replace(Logger::get_logs_folder(), '', (string) $file), $logs_list)); @@ -176,12 +176,12 @@ class View_Logs_Admin_Page extends Edit_Admin_Page { $contents = $file && file_exists($file) ? file_get_contents($file) : $default_content; - $response = array( + $response = [ 'file' => $file, 'file_name' => $file_name, 'contents' => $contents, 'logs_list' => $logs_list, - ); + ]; if (wp_doing_ajax()) { wp_send_json_success($response); @@ -196,50 +196,50 @@ class View_Logs_Admin_Page extends Edit_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { $info = $this->handle_view_logs(); - add_meta_box('wp-ultimo-log-contents', __('Log Contents', 'wp-ultimo'), array($this, 'output_default_widget_payload'), get_current_screen()->id, 'normal', null, $info); + add_meta_box('wp-ultimo-log-contents', __('Log Contents', 'wp-ultimo'), [$this, 'output_default_widget_payload'], get_current_screen()->id, 'normal', null, $info); $this->add_fields_widget( 'file-selector', - array( + [ 'title' => __('Log Files', 'wp-ultimo'), - 'fields' => array( - 'log_file' => array( + 'fields' => [ + 'log_file' => [ 'type' => 'select', 'title' => __('Select Log File', 'wp-ultimo'), 'placeholder' => __('Select Log File', 'wp-ultimo'), 'value' => wu_request('file'), 'tooltip' => '', 'options' => $info['logs_list'], - ), - 'download' => array( + ], + 'download' => [ 'type' => 'submit', 'title' => __('Download Log', 'wp-ultimo'), 'value' => 'download', 'classes' => 'button button-primary wu-w-full', - ), - ), - ) + ], + ], + ] ); $this->add_fields_widget( 'info', - array( + [ 'title' => __('Timestamps', 'wp-ultimo'), 'position' => 'side', - 'fields' => array( - 'date_modified' => array( + 'fields' => [ + 'date_modified' => [ 'title' => __('Last Modified at', 'wp-ultimo'), 'type' => 'text-edit', 'date' => true, 'value' => date_i18n('Y-m-d H:i:s', filemtime($info['file'])), 'display_value' => date_i18n('Y-m-d H:i:s', filemtime($info['file'])), - ), - ), - ) + ], + ], + ] ); } @@ -252,15 +252,15 @@ class View_Logs_Admin_Page extends Edit_Admin_Page { * @param array $data Arguments passed by add_meta_box. * @return void */ - public function output_default_widget_payload($unused, $data) { + public function output_default_widget_payload($unused, $data): void { wu_get_template( 'events/widget-payload', - array( + [ 'title' => __('Event Payload', 'wp-ultimo'), 'loading_text' => __('Loading Payload', 'wp-ultimo'), 'payload' => $data['args']['contents'], - ) + ] ); } @@ -272,14 +272,14 @@ class View_Logs_Admin_Page extends Edit_Admin_Page { */ public function get_labels() { - return array( + return [ 'edit_label' => __('View Log', 'wp-ultimo'), 'add_new_label' => __('View Log', 'wp-ultimo'), 'title_placeholder' => __('Enter Customer', 'wp-ultimo'), 'title_description' => __('Viewing file: ', 'wp-ultimo'), 'delete_button_label' => __('Delete Log File', 'wp-ultimo'), 'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'), - ); + ]; } /** @@ -290,7 +290,7 @@ class View_Logs_Admin_Page extends Edit_Admin_Page { */ public function get_object() { - return array(); + return []; } /** @@ -299,7 +299,7 @@ class View_Logs_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function page_loaded() { + public function page_loaded(): void { /** * Get the action links @@ -318,7 +318,7 @@ class View_Logs_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_save() { + public function handle_save(): void { $action = wu_request('submit_button', 'none'); diff --git a/inc/admin-pages/class-webhook-edit-admin-page.php b/inc/admin-pages/class-webhook-edit-admin-page.php index 25833cb..281d4cf 100644 --- a/inc/admin-pages/class-webhook-edit-admin-page.php +++ b/inc/admin-pages/class-webhook-edit-admin-page.php @@ -76,9 +76,9 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_edit_webhooks', - ); + ]; /** * Registers the necessary scripts and styles for this admin page. @@ -86,22 +86,22 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { parent::register_scripts(); - wp_register_script('wu-webhook-page', wu_get_asset('webhook-page.js', 'js'), array('jquery', 'wu-sweet-alert')); + wp_register_script('wu-webhook-page', wu_get_asset('webhook-page.js', 'js'), ['jquery', 'wu-sweet-alert']); wp_localize_script( 'wu-webhook-page', 'wu_webhook_page', - array( - 'i18n' => array( + [ + 'i18n' => [ 'error_title' => __('Webhook Test', 'wp-ultimo'), 'error_message' => __('An error occurred when sending the test webhook, please try again.', 'wp-ultimo'), 'copied' => __('Copied!', 'wp-ultimo'), - ), - ) + ], + ] ); wp_enqueue_script('wu-webhook-page'); @@ -113,15 +113,15 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function register_forms() { + public function register_forms(): void { /* * Delete Webhook - Confirmation modal */ add_filter( 'wu_data_json_success_delete_webhook_modal', - fn($data_json) => array( - 'redirect_url' => wu_network_admin_url('wp-ultimo-webhooks', array('deleted' => 1)), - ) + fn($data_json) => [ + 'redirect_url' => wu_network_admin_url('wp-ultimo-webhooks', ['deleted' => 1]), + ] ); } @@ -131,55 +131,55 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { parent::register_widgets(); $this->add_fields_widget( 'domain-url', - array( + [ 'title' => __('Webhook URL', 'wp-ultimo'), 'position' => 'normal', - 'fields' => array( - 'webhook_url' => array( + 'fields' => [ + 'webhook_url' => [ 'type' => 'url', 'title' => __('Webhook URL', 'wp-ultimo'), 'desc' => __('The URL where we will send the payload when the event triggers.', 'wp-ultimo'), 'placeholder' => __('https://example.com', 'wp-ultimo'), 'value' => $this->get_object()->get_webhook_url(), - ), - 'actions' => array( + ], + 'actions' => [ 'type' => 'actions', 'tooltip' => __('The event .', 'wp-ultimo'), - 'actions' => array( - 'send_test_event' => array( + 'actions' => [ + 'send_test_event' => [ 'title' => __('Send Test Event', 'wp-ultimo'), 'action' => 'wu_send_test_event', 'object_id' => $this->get_object()->get_id(), 'loading_text' => 'Sending Test...', - ), - ), - 'html_attr' => array( + ], + ], + 'html_attr' => [ 'data-page' => 'edit', - ), + ], 'wrapper_classes' => 'wu-items-left wu-justify-start', - ), - ), - ) + ], + ], + ] ); - add_meta_box('wp-ultimo-payload', __('Event Payload', 'wp-ultimo'), array($this, 'output_default_widget_payload'), get_current_screen()->id, 'normal'); + add_meta_box('wp-ultimo-payload', __('Event Payload', 'wp-ultimo'), [$this, 'output_default_widget_payload'], get_current_screen()->id, 'normal'); $this->add_list_table_widget( 'events', - array( + [ 'title' => __('Events', 'wp-ultimo'), 'table' => new \WP_Ultimo\List_Tables\Inside_Events_List_Table(), - 'query_filter' => array($this, 'query_filter'), - ) + 'query_filter' => [$this, 'query_filter'], + ] ); - $event_list = array(); + $event_list = []; foreach (wu_get_event_types() as $key => $value) { $event_list[ $key ] = $value['name']; @@ -187,42 +187,42 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page { $this->add_save_widget( 'save', - array( - 'fields' => array( - 'event' => array( + [ + 'fields' => [ + 'event' => [ 'type' => 'select', 'title' => __('Event', 'wp-ultimo'), 'desc' => __('The event that triggers this webhook.', 'wp-ultimo'), 'placeholder' => __('Select Event', 'wp-ultimo'), 'options' => $event_list, 'value' => $this->get_object()->get_event(), - ), - ), - ) + ], + ], + ] ); $this->add_fields_widget( 'active', - array( + [ 'title' => __('Active', 'wp-ultimo'), - 'fields' => array( - 'active' => array( + 'fields' => [ + 'active' => [ 'type' => 'toggle', 'title' => __('Active', 'wp-ultimo'), 'tooltip' => __('Deactivate will end the event trigger for this webhook.', 'wp-ultimo'), 'desc' => __('Use this option to manually enable or disable this webhook.', 'wp-ultimo'), 'value' => $this->get_object()->is_active(), - ), - ), - ) + ], + ], + ] ); $this->add_fields_widget( 'options', - array( + [ 'title' => __('Options', 'wp-ultimo'), - 'fields' => array( - 'integration' => array( + 'fields' => [ + 'integration' => [ 'edit' => true, 'title' => __('Integration', 'wp-ultimo'), 'type' => 'text-edit', @@ -230,8 +230,8 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page { 'value' => $this->get_object()->get_integration(), 'display_value' => ucwords((string) $this->get_object()->get_integration()), 'tooltip' => __('Name of the service responsible for creating this webhook. If you are manually creating this webhook, use the value "manual".', 'wp-ultimo'), - ), - 'event_count' => array( + ], + 'event_count' => [ 'title' => __('Run Count', 'wp-ultimo'), 'type' => 'text-edit', 'min' => 0, @@ -241,9 +241,9 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page { // translators: %d is the number of times that this webhook was triggered. 'display_value' => sprintf(__('This webhook was triggered %d time(s).', 'wp-ultimo'), $this->get_object()->get_event_count()), 'tooltip' => __('The number of times that this webhook was triggered so far. It includes test runs.', 'wp-ultimo'), - ), - ), - ) + ], + ], + ] ); } @@ -253,7 +253,7 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function output_default_widget_payload() { + public function output_default_widget_payload(): void { $object_event_slug = $this->get_object()->get_event(); @@ -263,11 +263,11 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page { wu_get_template( 'events/widget-payload', - array( + [ 'title' => __('Event Payload', 'wp-ultimo'), 'loading_text' => __('Loading Payload', 'wp-ultimo'), 'payload' => $payload, - ) + ] ); } @@ -281,10 +281,10 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page { */ public function query_filter($args) { - $extra_args = array( + $extra_args = [ 'object_type' => 'webhook', 'object_id' => absint($this->get_object()->get_id()), - ); + ]; return array_merge($args, $extra_args); } @@ -319,7 +319,7 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page { */ public function action_links() { - return array(); + return []; } /** @@ -330,7 +330,7 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page { */ public function get_labels() { - return array( + return [ 'edit_label' => __('Edit Webhook', 'wp-ultimo'), 'add_new_label' => __('Add new Webhook', 'wp-ultimo'), 'updated_message' => __('Webhook updated successfully!', 'wp-ultimo'), @@ -340,7 +340,7 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page { 'save_description' => '', 'delete_button_label' => __('Delete Webhook', 'wp-ultimo'), 'delete_description' => __('Be careful. This action is irreversible.', 'wp-ultimo'), - ); + ]; } /** @@ -383,7 +383,7 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_save() { + public function handle_save(): void { $object = $this->get_object(); @@ -396,9 +396,9 @@ class Webhook_Edit_Admin_Page extends Edit_Admin_Page { return; } else { - $array_params = array( + $array_params = [ 'updated' => 1, - ); + ]; if ($this->edit === false) { $array_params['id'] = $object->get_id(); diff --git a/inc/admin-pages/class-webhook-list-admin-page.php b/inc/admin-pages/class-webhook-list-admin-page.php index 3f2463e..5b0ac80 100644 --- a/inc/admin-pages/class-webhook-list-admin-page.php +++ b/inc/admin-pages/class-webhook-list-admin-page.php @@ -50,9 +50,9 @@ class Webhook_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'wu_read_webhooks', - ); + ]; /** * Registers the necessary scripts and styles for this admin page. @@ -60,22 +60,22 @@ class Webhook_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { parent::register_scripts(); - wp_register_script('wu-webhook-page', wu_get_asset('webhook-page.js', 'js'), array('jquery', 'wu-sweet-alert')); + wp_register_script('wu-webhook-page', wu_get_asset('webhook-page.js', 'js'), ['jquery', 'wu-sweet-alert']); wp_localize_script( 'wu-webhook-page', 'wu_webhook_page', - array( - 'i18n' => array( + [ + 'i18n' => [ 'error_title' => __('Webhook Test', 'wp-ultimo'), 'error_message' => __('An error occurred when sending the test webhook, please try again.', 'wp-ultimo'), 'copied' => __('Copied!', 'wp-ultimo'), - ), - ) + ], + ] ); wp_enqueue_script('wu-webhook-page'); @@ -87,17 +87,17 @@ class Webhook_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function register_forms() { + public function register_forms(): void { /* * Add new webhook. */ wu_register_form( 'add_new_webhook_modal', - array( - 'render' => array($this, 'render_add_new_webhook_modal'), - 'handler' => array($this, 'handle_add_new_webhook_modal'), + [ + 'render' => [$this, 'render_add_new_webhook_modal'], + 'handler' => [$this, 'handle_add_new_webhook_modal'], 'capability' => 'wu_edit_webhooks', - ) + ] ); } @@ -107,63 +107,63 @@ class Webhook_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - function render_add_new_webhook_modal() { + function render_add_new_webhook_modal(): void { $events = wu_get_event_types(); - $event_options = array(); + $event_options = []; foreach ($events as $slug => $event) { $event_options[ $slug ] = $event['name']; } - $fields = array( - 'name' => array( + $fields = [ + 'name' => [ 'type' => 'text', 'title' => __('Webhook Name', 'wp-ultimo'), 'desc' => __('A name to easily identify your webhook.', 'wp-ultimo'), 'placeholder' => __('E.g. Zapier Integration', 'wp-ultimo'), - ), - 'event' => array( + ], + 'event' => [ 'title' => __('Event', 'wp-ultimo'), 'type' => 'select', 'desc' => __('The event that will trigger the webhook.', 'wp-ultimo'), 'options' => $event_options, - ), - 'webhook_url' => array( + ], + 'webhook_url' => [ 'type' => 'url', 'title' => __('Webhook Url', 'wp-ultimo'), 'desc' => __('The url of your webhook.', 'wp-ultimo'), 'placeholder' => __('E.g. https://example.com/', 'wp-ultimo'), - ), - 'submit_button' => array( + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Add New Webhook', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ // 'v-bind:disabled' => '!confirmed', - ), - ), - ); + ], + ], + ]; $form = new \WP_Ultimo\UI\Form( 'edit_line_item', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'edit_line_item', 'data-state' => json_encode( - array( + [ 'event' => '', - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -175,7 +175,7 @@ class Webhook_List_Admin_Page extends List_Admin_Page { * @since 2.0.0 * @return void */ - public function handle_add_new_webhook_modal() { + public function handle_add_new_webhook_modal(): void { $status = wu_create_webhook($_POST); @@ -183,14 +183,14 @@ class Webhook_List_Admin_Page extends List_Admin_Page { wp_send_json_error($status); } else { wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url( 'wp-ultimo-edit-webhook', - array( + [ 'id' => $status->get_id(), - ) + ] ), - ) + ] ); } } @@ -211,10 +211,10 @@ class Webhook_List_Admin_Page extends List_Admin_Page { */ public function get_labels() { - return array( + return [ 'deleted_message' => __('Webhook removed successfully.', 'wp-ultimo'), 'search_label' => __('Search Webhook', 'wp-ultimo'), - ); + ]; } /** @@ -258,14 +258,14 @@ class Webhook_List_Admin_Page extends List_Admin_Page { */ public function action_links() { - return array( - array( + return [ + [ 'label' => __('Add New Webhook', 'wp-ultimo'), 'icon' => 'wu-circle-with-plus', 'classes' => 'wubox', 'url' => wu_get_form_url('add_new_webhook_modal'), - ), - ); + ], + ]; } diff --git a/inc/admin-pages/class-wizard-admin-page.php b/inc/admin-pages/class-wizard-admin-page.php index ec468ef..3eaec49 100644 --- a/inc/admin-pages/class-wizard-admin-page.php +++ b/inc/admin-pages/class-wizard-admin-page.php @@ -76,7 +76,7 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function page_loaded() { + public function page_loaded(): void { /* * Load sections to memory. */ @@ -99,14 +99,14 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - final public function process_save() { + final public function process_save(): void { $saving_tag = sprintf('saving_%s', $this->get_current_section()); if (isset($_REQUEST[ $saving_tag ])) { check_admin_referer($saving_tag, '_wpultimo_nonce'); - $handler = isset($this->current_section['handler']) ? $this->current_section['handler'] : array($this, 'default_handler'); + $handler = $this->current_section['handler'] ?? [$this, 'default_handler']; /* * Calls the saving function @@ -123,7 +123,7 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page { */ public function get_labels() { - return array( + return [ 'edit_label' => __('Edit Object', 'wp-ultimo'), 'add_new_label' => __('Add New Object', 'wp-ultimo'), 'updated_message' => __('Object updated with success!', 'wp-ultimo'), @@ -131,7 +131,7 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page { 'title_description' => '', 'save_button_label' => __('Save', 'wp-ultimo'), 'save_description' => '', - ); + ]; } /** @@ -144,7 +144,7 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function register_widgets() { + public function register_widgets(): void { $screen = get_current_screen(); @@ -152,7 +152,7 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page { return; } - add_meta_box('wp-ultimo-wizard-body', wu_get_isset($this->current_section, 'title', __('Section', 'wp-ultimo')), array($this, 'output_default_widget_body'), $screen->id, 'normal', null); + add_meta_box('wp-ultimo-wizard-body', wu_get_isset($this->current_section, 'title', __('Section', 'wp-ultimo')), [$this, 'output_default_widget_body'], $screen->id, 'normal', null); } /** @@ -161,11 +161,11 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function output_default_widget_body() { + public function output_default_widget_body(): void { echo '
'; - $view = isset($this->current_section['view']) ? $this->current_section['view'] : array($this, 'default_view'); + $view = $this->current_section['view'] ?? [$this, 'default_view']; /* * Calls the view function. @@ -192,13 +192,13 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function output() { + public function output(): void { /* * Renders the base edit page layout, with the columns and everything else =) */ wu_get_template( 'base/wizard', - array( + [ 'screen' => get_current_screen(), 'page' => $this, 'logo' => $this->get_logo(), @@ -208,7 +208,7 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page { 'classes' => 'wu-w-full wu-mx-auto sm:wu-w-11/12 xl:wu-w-8/12 wu-mt-8 sm:wu-max-w-screen-lg', 'clickable_navigation' => $this->clickable_navigation, 'form_id' => $this->form_id, - ) + ] ); } @@ -297,7 +297,7 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function default_handler() { + public function default_handler(): void { wp_redirect($this->get_next_section_link()); @@ -310,22 +310,22 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function default_view() { + public function default_view(): void { $section = wp_parse_args( $this->current_section, - array( + [ 'title' => '', 'description' => '', 'content' => '', - 'fields' => array(), + 'fields' => [], 'next_label' => __('Continue →', 'wp-ultimo'), 'back_label' => __('← Go Back', 'wp-ultimo'), 'skip_label' => __('Skip this Step', 'wp-ultimo'), 'back' => false, 'skip' => false, 'next' => true, - ) + ] ); /* @@ -339,11 +339,11 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page { $form = new \WP_Ultimo\UI\Form( $this->get_current_section(), $section['fields'], - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-widget-list wu-striped wu-m-0 wu-mt-2 wu--mb-6 wu--mx-6', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-px-6 wu-py-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - ) + ] ); ob_start(); @@ -357,9 +357,9 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page { 'wizards/setup/default', array_merge( $section, - array( + [ 'page' => $this, - ) + ] ) ); } @@ -370,15 +370,15 @@ abstract class Wizard_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function render_submit_box() { + public function render_submit_box(): void { wu_get_template( 'base/wizard/submit-box', - array( + [ 'screen' => get_current_screen(), 'page' => $this, 'labels' => $this->get_labels(), - ) + ] ); } diff --git a/inc/admin-pages/customer-panel/class-account-admin-page.php b/inc/admin-pages/customer-panel/class-account-admin-page.php index d2bb1f2..12ae960 100644 --- a/inc/admin-pages/customer-panel/class-account-admin-page.php +++ b/inc/admin-pages/customer-panel/class-account-admin-page.php @@ -68,10 +68,10 @@ class Account_Admin_Page extends Base_Customer_Facing_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'admin_menu' => 'exist', 'user_admin_menu' => 'exist', - ); + ]; /** * The current site instance. @@ -113,7 +113,7 @@ class Account_Admin_Page extends Base_Customer_Facing_Admin_Page { * @since 1.8.2 * @return void */ - public function page_loaded() { + public function page_loaded(): void { $this->current_site = wu_get_current_site(); @@ -166,7 +166,7 @@ class Account_Admin_Page extends Base_Customer_Facing_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { \WP_Ultimo\UI\Current_Membership_Element::get_instance()->as_metabox(get_current_screen()->id); @@ -186,7 +186,7 @@ class Account_Admin_Page extends Base_Customer_Facing_Admin_Page { \WP_Ultimo\UI\Simple_Text_Element::get_instance()->as_inline_content(get_current_screen()->id, 'wu_dash_before_metaboxes'); - \WP_Ultimo\UI\Current_Site_Element::get_instance()->as_inline_content(get_current_screen()->id, 'wu_dash_before_metaboxes', array('show_admin_link' => false)); + \WP_Ultimo\UI\Current_Site_Element::get_instance()->as_inline_content(get_current_screen()->id, 'wu_dash_before_metaboxes', ['show_admin_link' => false]); } /** @@ -228,17 +228,17 @@ class Account_Admin_Page extends Base_Customer_Facing_Admin_Page { * @since 1.8.2 * @return void */ - public function output() { + public function output(): void { /* * Renders the base edit page layout, with the columns and everything else =) */ wu_get_template( 'base/dash', - array( + [ 'screen' => get_current_screen(), 'page' => $this, 'has_full_position' => false, - ) + ] ); } } diff --git a/inc/admin-pages/customer-panel/class-add-new-site-admin-page.php b/inc/admin-pages/customer-panel/class-add-new-site-admin-page.php index 171d9c7..a33d664 100644 --- a/inc/admin-pages/customer-panel/class-add-new-site-admin-page.php +++ b/inc/admin-pages/customer-panel/class-add-new-site-admin-page.php @@ -84,10 +84,10 @@ class Add_New_Site_Admin_Page extends Base_Customer_Facing_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'admin_menu' => 'exist', 'user_admin_menu' => 'exist', - ); + ]; /** * The current customer instance. @@ -137,7 +137,7 @@ class Add_New_Site_Admin_Page extends Base_Customer_Facing_Admin_Page { * @since 1.8.2 * @return void */ - public function page_loaded() { + public function page_loaded(): void { $this->customer = wu_get_current_customer(); } @@ -157,7 +157,7 @@ class Add_New_Site_Admin_Page extends Base_Customer_Facing_Admin_Page { * @since 2.0.0 * @return void */ - public function force_screen_options() { + public function force_screen_options(): void { if (get_current_screen()->id !== 'toplevel_page_sites') { return; @@ -166,10 +166,10 @@ class Add_New_Site_Admin_Page extends Base_Customer_Facing_Admin_Page { // Forces Screen options so we can add our links. add_screen_option( 'wu_fix', - array( + [ 'option' => 'test', 'value' => true, - ) + ] ); } @@ -187,17 +187,17 @@ class Add_New_Site_Admin_Page extends Base_Customer_Facing_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { \WP_Ultimo\UI\Simple_Text_Element::get_instance()->as_inline_content(get_current_screen()->id, 'wu_dash_before_metaboxes'); \WP_Ultimo\UI\Checkout_Element::get_instance()->as_inline_content( get_current_screen()->id, 'wu_dash_before_metaboxes', - array( + [ 'slug' => 'wu-add-new-site', - 'membership_limitations' => array('sites'), - ) + 'membership_limitations' => ['sites'], + ] ); } @@ -240,17 +240,17 @@ class Add_New_Site_Admin_Page extends Base_Customer_Facing_Admin_Page { * @since 1.8.2 * @return void */ - public function output() { + public function output(): void { /* * Renders the base edit page layout, with the columns and everything else =) */ wu_get_template( 'base/dash', - array( + [ 'screen' => get_current_screen(), 'page' => $this, 'has_full_position' => false, - ) + ] ); } } diff --git a/inc/admin-pages/customer-panel/class-checkout-admin-page.php b/inc/admin-pages/customer-panel/class-checkout-admin-page.php index a34f5ec..3b6af34 100644 --- a/inc/admin-pages/customer-panel/class-checkout-admin-page.php +++ b/inc/admin-pages/customer-panel/class-checkout-admin-page.php @@ -66,10 +66,10 @@ class Checkout_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer_Facing_Ad * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'user_admin_menu' => 'read', 'admin_menu' => 'read', - ); + ]; /** * Should we hide admin notices on this page? @@ -115,7 +115,7 @@ class Checkout_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer_Facing_Ad * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { do_action('wu_checkout_scripts', null, null); } @@ -126,7 +126,7 @@ class Checkout_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer_Facing_Ad * @since 2.0.0 * @return void */ - public function page_loaded() { + public function page_loaded(): void { do_action('wu_setup_checkout', null); @@ -141,12 +141,12 @@ class Checkout_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer_Facing_Ad */ public function get_sections() { - $sections = array( - 'plan' => array( + $sections = [ + 'plan' => [ 'title' => __('Change Membership', 'wp-ultimo'), - 'view' => array($this, 'display_checkout_form'), - ), - ); + 'view' => [$this, 'display_checkout_form'], + ], + ]; return $sections; } @@ -157,17 +157,17 @@ class Checkout_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer_Facing_Ad * @since 2.0.0 * @return void */ - public function output() { + public function output(): void { /* * Renders the base edit page layout, with the columns and everything else =) */ wu_get_template( 'base/centered', - array( + [ 'screen' => get_current_screen(), 'page' => $this, 'content' => do_shortcode('[wu_checkout slug="wu-checkout"]'), - ) + ] ); } @@ -177,7 +177,7 @@ class Checkout_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer_Facing_Ad * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { \WP_Ultimo\UI\Current_Membership_Element::get_instance()->as_metabox(get_current_screen()->id); diff --git a/inc/admin-pages/customer-panel/class-my-sites-admin-page.php b/inc/admin-pages/customer-panel/class-my-sites-admin-page.php index ff4c9c4..80fdeef 100644 --- a/inc/admin-pages/customer-panel/class-my-sites-admin-page.php +++ b/inc/admin-pages/customer-panel/class-my-sites-admin-page.php @@ -68,10 +68,10 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'admin_menu' => 'exist', 'user_admin_menu' => 'exist', - ); + ]; /** * The current customer instance. @@ -113,11 +113,11 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page { if ($this->current_site->get_type() === 'customer_owned') { parent::__construct(); - add_action('admin_menu', array($this, 'unset_default_my_sites_menu')); + add_action('admin_menu', [$this, 'unset_default_my_sites_menu']); - add_action('admin_bar_menu', array($this, 'change_my_sites_link'), 90); + add_action('admin_bar_menu', [$this, 'change_my_sites_link'], 90); - add_action('current_screen', array($this, 'force_screen_options')); + add_action('current_screen', [$this, 'force_screen_options']); } } @@ -127,7 +127,7 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page { * @since 1.8.2 * @return void */ - public function page_loaded() { + public function page_loaded(): void { $this->customer = wu_get_current_customer(); } @@ -147,7 +147,7 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page { * @since 2.0.0 * @return void */ - public function unset_default_my_sites_menu() { + public function unset_default_my_sites_menu(): void { global $submenu; @@ -162,7 +162,7 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page { * @param object $wp_admin_bar The admin bar object. * @return void */ - public function change_my_sites_link($wp_admin_bar) { + public function change_my_sites_link($wp_admin_bar): void { $my_sites = $wp_admin_bar->get_node('my-sites'); @@ -170,9 +170,9 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page { return; } - $args = array( + $args = [ 'page' => 'sites', - ); + ]; $my_sites->href = add_query_arg($args, admin_url('admin.php')); @@ -185,7 +185,7 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page { * @since 2.0.0 * @return void */ - public function force_screen_options() { + public function force_screen_options(): void { if (get_current_screen()->id !== 'toplevel_page_sites') { return; @@ -194,10 +194,10 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page { // Forces Screen options so we can add our links. add_screen_option( 'wu_fix', - array( + [ 'option' => 'test', 'value' => true, - ) + ] ); } @@ -215,7 +215,7 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { \WP_Ultimo\UI\Login_Form_Element::get_instance()->as_inline_content(get_current_screen()->id, 'wu_dash_before_metaboxes'); @@ -263,17 +263,17 @@ class My_Sites_Admin_Page extends Base_Customer_Facing_Admin_Page { * @since 1.8.2 * @return void */ - public function output() { + public function output(): void { /* * Renders the base edit page layout, with the columns and everything else =) */ wu_get_template( 'base/dash', - array( + [ 'screen' => get_current_screen(), 'page' => $this, 'has_full_position' => false, - ) + ] ); } } diff --git a/inc/admin-pages/customer-panel/class-template-switching-admin-page.php b/inc/admin-pages/customer-panel/class-template-switching-admin-page.php index be5935c..a52ce91 100644 --- a/inc/admin-pages/customer-panel/class-template-switching-admin-page.php +++ b/inc/admin-pages/customer-panel/class-template-switching-admin-page.php @@ -66,10 +66,10 @@ class Template_Switching_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'user_admin_menu' => 'read', 'admin_menu' => 'read', - ); + ]; /** * Should we hide admin notices on this page? @@ -123,7 +123,7 @@ class Template_Switching_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { do_action('wu_template_switching_admin_page_scripts', null, null); } @@ -134,7 +134,7 @@ class Template_Switching_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer * @since 2.0.0 * @return void */ - public function page_loaded() { + public function page_loaded(): void { do_action('wu_template_switching_admin_page', null); @@ -147,20 +147,20 @@ class Template_Switching_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer * @since 2.0.0 * @return void */ - public function output() { + public function output(): void { /* * Renders the base edit page layout, with the columns and everything else =) */ wu_get_template( 'base/centered', - array( + [ 'screen' => get_current_screen(), 'page' => $this, 'content' => '', - 'labels' => array( + 'labels' => [ 'updated_message' => __('Template switched successfully!', 'wp-ultimo'), - ), - ) + ], + ] ); } @@ -170,7 +170,7 @@ class Template_Switching_Admin_Page extends \WP_Ultimo\Admin_Pages\Base_Customer * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { \WP_Ultimo\UI\Template_Switching_Element::get_instance()->as_metabox(get_current_screen()->id); } diff --git a/inc/admin-pages/debug/class-debug-admin-page.php b/inc/admin-pages/debug/class-debug-admin-page.php index 1a08492..ebfa24a 100644 --- a/inc/admin-pages/debug/class-debug-admin-page.php +++ b/inc/admin-pages/debug/class-debug-admin-page.php @@ -69,9 +69,9 @@ class Debug_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @var array */ - protected $supported_panels = array( + protected $supported_panels = [ 'network_admin_menu' => 'capability_here', - ); + ]; /** * Allow child classes to register widgets, if they need them. @@ -79,12 +79,12 @@ class Debug_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function register_widgets() { + public function register_widgets(): void { add_meta_box( 'wp-ultimo-debug-pages', __('All Registered Pages', 'wp-ultimo'), - array($this, 'render_debug_pages'), + [$this, 'render_debug_pages'], get_current_screen()->id, 'normal', null @@ -97,7 +97,7 @@ class Debug_Admin_Page extends Base_Admin_Page { * @since 2.0.0 * @return void */ - public function render_debug_pages() { + public function render_debug_pages(): void { $pages = Debug::get_instance()->get_pages(); @@ -157,15 +157,15 @@ class Debug_Admin_Page extends Base_Admin_Page { * @since 1.8.2 * @return void */ - public function output() { + public function output(): void { wu_get_template( 'base/dash', - array( + [ 'page' => $this, 'screen' => get_current_screen(), 'has_full_position' => false, - ) + ] ); } } diff --git a/inc/api/class-register-endpoint.php b/inc/api/class-register-endpoint.php index d7e7626..c168e91 100644 --- a/inc/api/class-register-endpoint.php +++ b/inc/api/class-register-endpoint.php @@ -33,9 +33,9 @@ class Register_Endpoint { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - add_action('wu_register_rest_routes', array($this, 'register_route')); + add_action('wu_register_rest_routes', [$this, 'register_route']); } /** @@ -46,29 +46,29 @@ class Register_Endpoint { * @param \WP_Ultimo\API $api The API main singleton. * @return void */ - public function register_route($api) { + public function register_route($api): void { $namespace = $api->get_namespace(); register_rest_route( $namespace, '/register', - array( + [ 'methods' => \WP_REST_Server::READABLE, - 'callback' => array($this, 'handle_get'), - 'permission_callback' => \Closure::fromCallable(array($api, 'check_authorization')), - ) + 'callback' => [$this, 'handle_get'], + 'permission_callback' => \Closure::fromCallable([$api, 'check_authorization']), + ] ); register_rest_route( $namespace, '/register', - array( + [ 'methods' => \WP_REST_Server::CREATABLE, - 'callback' => array($this, 'handle_endpoint'), - 'permission_callback' => \Closure::fromCallable(array($api, 'check_authorization')), + 'callback' => [$this, 'handle_endpoint'], + 'permission_callback' => \Closure::fromCallable([$api, 'check_authorization']), 'args' => $this->get_rest_args(), - ) + ] ); } @@ -82,9 +82,9 @@ class Register_Endpoint { */ public function handle_get($request) { - return array( + return [ 'registration_status' => wu_get_setting('enable_registration', true) ? 'open' : 'closed', - ); + ]; } /** @@ -109,9 +109,9 @@ class Register_Endpoint { if (is_wp_error($validation_errors)) { $validation_errors->add_data( - array( + [ 'status' => 400, - ) + ] ); return $validation_errors; @@ -129,10 +129,10 @@ class Register_Endpoint { $customer->update_last_login(true, true); $customer->add_note( - array( + [ 'text' => __('Created via REST API', 'wp-ultimo'), 'author_id' => $customer->get_user_id(), - ) + ] ); /* @@ -140,12 +140,12 @@ class Register_Endpoint { */ $payment_method = wp_parse_args( wu_get_isset($params, 'payment_method'), - array( + [ 'gateway' => '', 'gateway_customer_id' => '', 'gateway_subscription_id' => '', 'gateway_payment_id' => '', - ) + ] ); /* @@ -155,9 +155,9 @@ class Register_Endpoint { $cart_params = wp_parse_args( $cart_params, - array( + [ 'type' => 'new', - ) + ] ); $cart = new Cart($cart_params); @@ -171,9 +171,9 @@ class Register_Endpoint { __('Products are required.', 'wp-ultimo'), array_merge( (array) $cart->done(), - array( + [ 'status' => 400, - ) + ] ) ); } @@ -188,9 +188,9 @@ class Register_Endpoint { wu_get_isset( $params, 'membership', - array( + [ 'status' => Membership_Status::PENDING, - ) + ] ) ); @@ -214,10 +214,10 @@ class Register_Endpoint { } $membership->add_note( - array( + [ 'text' => __('Created via REST API', 'wp-ultimo'), 'author_id' => $customer->get_user_id(), - ) + ] ); $payment_data = $cart->to_payment_data(); @@ -227,9 +227,9 @@ class Register_Endpoint { wu_get_isset( $params, 'payment', - array( + [ 'status' => Payment_Status::PENDING, - ) + ] ) ); @@ -252,10 +252,10 @@ class Register_Endpoint { } $payment->add_note( - array( + [ 'text' => __('Created via REST API', 'wp-ultimo'), 'author_id' => $customer->get_user_id(), - ) + ] ); $site = false; @@ -301,7 +301,7 @@ class Register_Endpoint { } catch (\Throwable $e) { $wpdb->query('ROLLBACK'); - return new \WP_Error('registration_error', $e->getMessage(), array('status' => 500)); + return new \WP_Error('registration_error', $e->getMessage(), ['status' => 500]); } $wpdb->query('COMMIT'); @@ -309,12 +309,12 @@ class Register_Endpoint { /* * We have everything we need now. */ - return array( + return [ 'membership' => $membership->to_array(), 'customer' => $customer->to_array(), 'payment' => $payment->to_array(), - 'site' => $site ? $site : array('id' => 0), - ); + 'site' => $site ?: ['id' => 0], + ]; } /** @@ -331,203 +331,203 @@ class Register_Endpoint { */ $billing_address_fields = Billing_Address::fields_for_rest(false); - $customer_args = array( - 'customer_id' => array( + $customer_args = [ + 'customer_id' => [ 'description' => __('The customer ID, if the customer already exists. If you also need to create a customer/wp user, use the "customer" property.', 'wp-ultimo'), 'type' => 'integer', - ), - 'customer' => array( + ], + 'customer' => [ 'description' => __('Customer data. Needs to be present when customer id is not.', 'wp-ultimo'), 'type' => 'object', - 'properties' => array( - 'user_id' => array( + 'properties' => [ + 'user_id' => [ 'description' => __('Existing WordPress user id to attach this customer to. If you also need to create a WordPress user, pass the properties "username", "password", and "email".', 'wp-ultimo'), 'type' => 'integer', - ), - 'username' => array( + ], + 'username' => [ 'description' => __('The customer username. This is used to create the WordPress user.', 'wp-ultimo'), 'type' => 'string', 'minLength' => 4, - ), - 'password' => array( + ], + 'password' => [ 'description' => __('The customer password. This is used to create the WordPress user. Note that no validation is performed here to enforce strength.', 'wp-ultimo'), 'type' => 'string', 'minLength' => 6, - ), - 'email' => array( + ], + 'email' => [ 'description' => __('The customer email address. This is used to create the WordPress user.', 'wp-ultimo'), 'type' => 'string', 'format' => 'email', - ), - 'billing_address' => array( + ], + 'billing_address' => [ 'type' => 'object', 'properties' => $billing_address_fields, - ), - ), - ), - ); + ], + ], + ], + ]; - $membership_args = array( - 'membership' => array( + $membership_args = [ + 'membership' => [ 'description' => __('The membership data is automatically generated based on the cart info passed (e.g. products) but can be overridden with this property.', 'wp-ultimo'), 'type' => 'object', - 'properties' => array( - 'status' => array( + 'properties' => [ + 'status' => [ 'description' => __('The membership status.', 'wp-ultimo'), 'type' => 'string', 'enum' => array_values(Membership_Status::get_allowed_list()), 'default' => Membership_Status::PENDING, - ), - 'date_expiration' => array( + ], + 'date_expiration' => [ 'description' => __('The membership expiration date. Must be a valid PHP date format.', 'wp-ultimo'), 'type' => 'string', 'format' => 'date-time', - ), - 'date_trial_end' => array( + ], + 'date_trial_end' => [ 'description' => __('The membership trial end date. Must be a valid PHP date format.', 'wp-ultimo'), 'type' => 'string', 'format' => 'date-time', - ), - 'date_activated' => array( + ], + 'date_activated' => [ 'description' => __('The membership activation date. Must be a valid PHP date format.', 'wp-ultimo'), 'type' => 'string', 'format' => 'date-time', - ), - 'date_renewed' => array( + ], + 'date_renewed' => [ 'description' => __('The membership last renewed date. Must be a valid PHP date format.', 'wp-ultimo'), 'type' => 'string', 'format' => 'date-time', - ), - 'date_cancellation' => array( + ], + 'date_cancellation' => [ 'description' => __('The membership cancellation date. Must be a valid PHP date format.', 'wp-ultimo'), 'type' => 'string', 'format' => 'date-time', - ), - 'date_payment_plan_completed' => array( + ], + 'date_payment_plan_completed' => [ 'description' => __('The membership completion date. Used when the membership is limited to a limited number of billing cycles. Must be a valid PHP date format.', 'wp-ultimo'), 'type' => 'string', 'format' => 'date-time', - ), - ), - ), - ); + ], + ], + ], + ]; - $payment_args = array( - 'payment' => array( + $payment_args = [ + 'payment' => [ 'description' => __('The payment data is automatically generated based on the cart info passed (e.g. products) but can be overridden with this property.', 'wp-ultimo'), 'type' => 'object', - 'properties' => array( - 'status' => array( + 'properties' => [ + 'status' => [ 'description' => __('The payment status.', 'wp-ultimo'), 'type' => 'string', 'enum' => array_values(Payment_Status::get_allowed_list()), 'default' => Payment_Status::PENDING, - ), - ), - ), - 'payment_method' => array( + ], + ], + ], + 'payment_method' => [ 'description' => __('Payment method information. Useful when using the REST API to integrate other payment methods.', 'wp-ultimo'), 'type' => 'object', - 'properties' => array( - 'gateway' => array( + 'properties' => [ + 'gateway' => [ 'description' => __('The gateway name. E.g. stripe.', 'wp-ultimo'), 'type' => 'string', - ), - 'gateway_customer_id' => array( + ], + 'gateway_customer_id' => [ 'description' => __('The customer ID on the gateway system.', 'wp-ultimo'), 'type' => 'string', - ), - 'gateway_subscription_id' => array( + ], + 'gateway_subscription_id' => [ 'description' => __('The subscription ID on the gateway system.', 'wp-ultimo'), 'type' => 'string', - ), - 'gateway_payment_id' => array( + ], + 'gateway_payment_id' => [ 'description' => __('The payment ID on the gateway system.', 'wp-ultimo'), 'type' => 'string', - ), - ), - ), - ); + ], + ], + ], + ]; - $site_args = array( - 'site' => array( + $site_args = [ + 'site' => [ 'type' => 'object', - 'properties' => array( - 'site_url' => array( + 'properties' => [ + 'site_url' => [ 'type' => 'string', 'description' => __('The site subdomain or subdirectory (depending on your Multisite install). This would be "test" in "test.your-network.com".', 'wp-ultimo'), 'minLength' => 4, 'required' => true, - ), - 'site_title' => array( + ], + 'site_title' => [ 'type' => 'string', 'description' => __('The site title. E.g. My Amazing Site', 'wp-ultimo'), 'minLength' => 4, 'required' => true, - ), - 'publish' => array( + ], + 'publish' => [ 'description' => __('If we should publish this site regardless of membership/payment status. Sites are created as pending by default, and are only published when a payment is received or the status of the membership changes to "active". This flag allows you to bypass the pending state.', 'wp-ultimo'), 'type' => 'boolean', 'default' => false, - ), - 'template_id' => array( + ], + 'template_id' => [ 'description' => __('The template ID we should copy when creating this site. If left empty, the value dictated by the products will be used.', 'wp-ultimo'), 'type' => 'integer', - ), - 'site_meta' => array( + ], + 'site_meta' => [ 'description' => __('An associative array of key values to be saved as site_meta.', 'wp-ultimo'), 'type' => 'object', - ), - 'site_option' => array( + ], + 'site_option' => [ 'description' => __('An associative array of key values to be saved as site_options. Useful for changing plugin settings and other site configurations.', 'wp-ultimo'), 'type' => 'object', - ), - ), - ), - ); + ], + ], + ], + ]; - $cart_args = array( - 'products' => array( + $cart_args = [ + 'products' => [ 'description' => __('The products to be added to this membership. Takes an array of product ids or slugs.', 'wp-ultimo'), 'uniqueItems' => true, 'type' => 'array', - ), - 'duration' => array( + ], + 'duration' => [ 'description' => __('The membership duration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'duration_unit' => array( + ], + 'duration_unit' => [ 'description' => __('The membership duration unit.', 'wp-ultimo'), 'type' => 'string', 'default' => 'month', - 'enum' => array( + 'enum' => [ 'day', 'week', 'month', 'year', - ), - ), - 'discount_code' => array( + ], + ], + 'discount_code' => [ 'description' => __('A discount code. E.g. PROMO10.', 'wp-ultimo'), 'type' => 'string', - ), - 'auto_renew' => array( + ], + 'auto_renew' => [ 'description' => __('The membership auto-renew status. Useful when integrating with other payment options via this REST API.', 'wp-ultimo'), 'type' => 'boolean', 'default' => false, 'required' => true, - ), - 'country' => array( + ], + 'country' => [ 'description' => __('The customer country. Used to calculate taxes and check if registration is allowed for that country.', 'wp-ultimo'), 'type' => 'string', 'default' => '', - ), - 'currency' => array( + ], + 'currency' => [ 'description' => __('The currency to be used.', 'wp-ultimo'), 'type' => 'string', - ), - ); + ], + ]; $args = array_merge($customer_args, $membership_args, $cart_args, $payment_args, $site_args); @@ -616,13 +616,13 @@ class Register_Endpoint { * the site on WordPress. */ $transient = array_merge( - wu_get_isset($site_data, 'site_meta', array()), - wu_get_isset($site_data, 'site_option', array()) + wu_get_isset($site_data, 'site_meta', []), + wu_get_isset($site_data, 'site_option', []) ); $template_id = apply_filters('wu_checkout_template_id', (int) wu_get_isset($site_data, 'template_id'), $membership, $this); - $site_data = array( + $site_data = [ 'domain' => $d->domain, 'path' => $d->path, 'title' => wu_get_isset($site_data, 'site_title'), @@ -630,10 +630,10 @@ class Register_Endpoint { 'customer_id' => $membership->get_customer()->get_id(), 'membership_id' => $membership->get_id(), 'transient' => $transient, - 'signup_meta' => wu_get_isset($site_data, 'site_meta', array()), - 'signup_options' => wu_get_isset($site_data, 'site_option', array()), + 'signup_meta' => wu_get_isset($site_data, 'site_meta', []), + 'signup_options' => wu_get_isset($site_data, 'site_option', []), 'type' => Site_Type::CUSTOMER_OWNED, - ); + ]; $membership->create_pending_site($site_data); @@ -664,7 +664,7 @@ class Register_Endpoint { */ public function validation_rules() { - return array( + return [ 'customer_id' => 'required_without:customer', 'customer' => 'required_without:customer_id', 'customer.username' => 'required_without_all:customer_id,customer.user_id', @@ -673,7 +673,7 @@ class Register_Endpoint { 'customer.user_id' => 'required_without_all:customer_id,customer.username,customer.password,customer.email', 'site.site_url' => 'required_with:site|alpha_num|min:4|lowercase|unique_site', 'site.site_title' => 'required_with:site|min:4', - ); + ]; } /** * Validates the rules and make sure we only save models when necessary. diff --git a/inc/api/schemas/broadcast-create.php b/inc/api/schemas/broadcast-create.php index 441e779..1f23764 100644 --- a/inc/api/schemas/broadcast-create.php +++ b/inc/api/schemas/broadcast-create.php @@ -18,76 +18,76 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'migrated_from_id' => array( +return [ + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'notice_type' => array( + ], + 'notice_type' => [ 'description' => __('Can be info, success, warning or error.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'info', 'success', 'warning', 'error', - ), - ), - 'name' => array( + ], + ], + 'name' => [ 'description' => __('This broadcast name, which is used as broadcast title as well.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'type' => array( + ], + 'type' => [ 'description' => __('The type being set.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'status' => array( + ], + 'status' => [ 'description' => __('The status being set.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'author_id' => array( + ], + 'author_id' => [ 'description' => __('The author ID.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'title' => array( + ], + 'title' => [ 'description' => __('Post title.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'content' => array( + ], + 'content' => [ 'description' => __('Post content.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'excerpt' => array( + ], + 'excerpt' => [ 'description' => __('Post excerpt.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Post creation date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Post last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'slug' => array( + ], + 'slug' => [ 'description' => __('The slug.', 'wp-ultimo'), 'type' => 'mixed', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/broadcast-update.php b/inc/api/schemas/broadcast-update.php index f4623f2..bf2abcf 100644 --- a/inc/api/schemas/broadcast-update.php +++ b/inc/api/schemas/broadcast-update.php @@ -18,76 +18,76 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'migrated_from_id' => array( +return [ + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'notice_type' => array( + ], + 'notice_type' => [ 'description' => __('Can be info, success, warning or error.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'info', 'success', 'warning', 'error', - ), - ), - 'name' => array( + ], + ], + 'name' => [ 'description' => __('This broadcast name, which is used as broadcast title as well.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'type' => array( + ], + 'type' => [ 'description' => __('The type being set.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'status' => array( + ], + 'status' => [ 'description' => __('The status being set.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'author_id' => array( + ], + 'author_id' => [ 'description' => __('The author ID.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'title' => array( + ], + 'title' => [ 'description' => __('Post title.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'content' => array( + ], + 'content' => [ 'description' => __('Post content.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'excerpt' => array( + ], + 'excerpt' => [ 'description' => __('Post excerpt.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Post creation date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Post last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'slug' => array( + ], + 'slug' => [ 'description' => __('The slug.', 'wp-ultimo'), 'type' => 'mixed', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/checkout-form-create.php b/inc/api/schemas/checkout-form-create.php index b2ff915..afb13ad 100644 --- a/inc/api/schemas/checkout-form-create.php +++ b/inc/api/schemas/checkout-form-create.php @@ -18,75 +18,75 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'slug' => array( +return [ + 'slug' => [ 'description' => __('The checkout form slug. It needs to be unique and preferably make it clear what it is about. E.g. my_checkout_form.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'name' => array( + ], + 'name' => [ 'description' => __('Your checkout form name, which is used as checkout form title as well.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'active' => array( + ], + 'active' => [ 'description' => __('Set this checkout form as active (true), which means available to be used, or inactive (false).', 'wp-ultimo'), 'type' => 'boolean', 'required' => true, - ), - 'custom_css' => array( + ], + 'custom_css' => [ 'description' => __('Custom CSS code for the checkout form.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'settings' => array( + ], + 'settings' => [ 'description' => __('The checkout form settings and configurations.', 'wp-ultimo'), 'type' => 'object', 'required' => false, - ), - 'allowed_countries' => array( + ], + 'allowed_countries' => [ 'description' => __('The allowed countries that can access this checkout.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'thank_you_page_id' => array( + ], + 'thank_you_page_id' => [ 'description' => __('The thank you page ID. This page is shown after a successful purchase.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'conversion_snippets' => array( + ], + 'conversion_snippets' => [ 'description' => __('Snippets to run on thank you page.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'template' => array( + ], + 'template' => [ 'description' => __("Template mode. Can be either 'blank', 'single-step' or 'multi-step'.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'blank', 'single-step', 'multi-step', - ), - ), - 'date_created' => array( + ], + ], + 'date_created' => [ 'description' => __('Model creation date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Model last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/checkout-form-update.php b/inc/api/schemas/checkout-form-update.php index bbdbe4c..04cf99b 100644 --- a/inc/api/schemas/checkout-form-update.php +++ b/inc/api/schemas/checkout-form-update.php @@ -18,75 +18,75 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'slug' => array( +return [ + 'slug' => [ 'description' => __('The checkout form slug. It needs to be unique and preferably make it clear what it is about. E.g. my_checkout_form.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'name' => array( + ], + 'name' => [ 'description' => __('Your checkout form name, which is used as checkout form title as well.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'active' => array( + ], + 'active' => [ 'description' => __('Set this checkout form as active (true), which means available to be used, or inactive (false).', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'custom_css' => array( + ], + 'custom_css' => [ 'description' => __('Custom CSS code for the checkout form.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'settings' => array( + ], + 'settings' => [ 'description' => __('The checkout form settings and configurations.', 'wp-ultimo'), 'type' => 'array', 'required' => false, - ), - 'allowed_countries' => array( + ], + 'allowed_countries' => [ 'description' => __('The allowed countries that can access this checkout.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'thank_you_page_id' => array( + ], + 'thank_you_page_id' => [ 'description' => __('The thank you page ID. This page is shown after a successful purchase.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'conversion_snippets' => array( + ], + 'conversion_snippets' => [ 'description' => __('Snippets to run on thank you page.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'template' => array( + ], + 'template' => [ 'description' => __("Template mode. Can be either 'blank', 'single-step' or 'multi-step'.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'blank', 'single-step', 'multi-step', - ), - ), - 'date_created' => array( + ], + ], + 'date_created' => [ 'description' => __('Model creation date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Model last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/customer-create.php b/inc/api/schemas/customer-create.php index a19585b..3204a0f 100644 --- a/inc/api/schemas/customer-create.php +++ b/inc/api/schemas/customer-create.php @@ -18,83 +18,83 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'user_id' => array( +return [ + 'user_id' => [ 'description' => __('The WordPress user ID attached to this customer.', 'wp-ultimo'), 'type' => 'integer', 'required' => true, - ), - 'date_registered' => array( + ], + 'date_registered' => [ 'description' => __('Date when the customer was created.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'email_verification' => array( + ], + 'email_verification' => [ 'description' => __('Email verification status - either `none`, `pending`, or `verified`.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - 'enum' => array( + 'enum' => [ 'verified', 'pending', 'none', - ), - ), - 'last_login' => array( + ], + ], + 'last_login' => [ 'description' => __('Date this customer last logged in.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'has_trialed' => array( + ], + 'has_trialed' => [ 'description' => __('Whether or not the customer has trialed before.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'vip' => array( + ], + 'vip' => [ 'description' => __('If this customer is a VIP customer or not.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'ips' => array( + ], + 'ips' => [ 'description' => __('List of IP addresses used by this customer.', 'wp-ultimo'), 'type' => 'array', 'required' => false, - ), - 'extra_information' => array( + ], + 'extra_information' => [ 'description' => __('Any extra information related to this customer.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'type' => array( + ], + 'type' => [ 'description' => __("The customer type. Can be 'customer'.", 'wp-ultimo'), 'type' => 'string', 'required' => true, - 'enum' => array( + 'enum' => [ 'customer', - ), - ), - 'signup_form' => array( + ], + ], + 'signup_form' => [ 'description' => __('The form used to signup.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Model creation date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Model last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/customer-update.php b/inc/api/schemas/customer-update.php index ad04cf0..7a31b9c 100644 --- a/inc/api/schemas/customer-update.php +++ b/inc/api/schemas/customer-update.php @@ -18,83 +18,83 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'user_id' => array( +return [ + 'user_id' => [ 'description' => __('The WordPress user ID attached to this customer.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'date_registered' => array( + ], + 'date_registered' => [ 'description' => __('Date when the customer was created.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'email_verification' => array( + ], + 'email_verification' => [ 'description' => __('Email verification status - either `none`, `pending`, or `verified`.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'verified', 'pending', 'none', - ), - ), - 'last_login' => array( + ], + ], + 'last_login' => [ 'description' => __('Date this customer last logged in.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'has_trialed' => array( + ], + 'has_trialed' => [ 'description' => __('Whether or not the customer has trialed before.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'vip' => array( + ], + 'vip' => [ 'description' => __('If this customer is a VIP customer or not.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'ips' => array( + ], + 'ips' => [ 'description' => __('List of IP addresses used by this customer.', 'wp-ultimo'), 'type' => 'array', 'required' => false, - ), - 'extra_information' => array( + ], + 'extra_information' => [ 'description' => __('Any extra information related to this customer.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'type' => array( + ], + 'type' => [ 'description' => __("The customer type. Can be 'customer'.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'customer', - ), - ), - 'signup_form' => array( + ], + ], + 'signup_form' => [ 'description' => __('The form used to signup.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Model creation date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Model last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/discount-code-create.php b/inc/api/schemas/discount-code-create.php index d247f66..1dbeccf 100644 --- a/inc/api/schemas/discount-code-create.php +++ b/inc/api/schemas/discount-code-create.php @@ -18,108 +18,108 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'name' => array( +return [ + 'name' => [ 'description' => __('Your discount code name, which is used as discount code title as well.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'code' => array( + ], + 'code' => [ 'description' => __('A unique identification to redeem the discount code. E.g. PROMO10.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'description' => array( + ], + 'description' => [ 'description' => __('A description for the discount code, usually a short text.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'uses' => array( + ], + 'uses' => [ 'description' => __('Number of times this discount was applied.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'max_uses' => array( + ], + 'max_uses' => [ 'description' => __('The number of times this discount can be used before becoming inactive.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'apply_to_renewals' => array( + ], + 'apply_to_renewals' => [ 'description' => __('Wether or not we should apply the discount to membership renewals.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'type' => array( + ], + 'type' => [ 'description' => __("The type of the discount code. Can be 'percentage' (e.g. 10%% OFF), 'absolute' (e.g. $10 OFF).", 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'percentage', 'absolute', - ), - ), - 'value' => array( + ], + ], + 'value' => [ 'description' => __('Amount discounted in cents.', 'wp-ultimo'), 'type' => 'integer', 'required' => true, - ), - 'setup_fee_type' => array( + ], + 'setup_fee_type' => [ 'description' => __('Type of the discount for the setup fee value. Can be a percentage or absolute.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'percentage', 'absolute', - ), - ), - 'setup_fee_value' => array( + ], + ], + 'setup_fee_value' => [ 'description' => __('Amount discounted for setup fees in cents.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'active' => array( + ], + 'active' => [ 'description' => __('Set this discount code as active (true), which means available to be used, or inactive (false).', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'date_start' => array( + ], + 'date_start' => [ 'description' => __('Start date for the coupon code to be considered valid.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_expiration' => array( + ], + 'date_expiration' => [ 'description' => __('Expiration date for the coupon code.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Date when this discount code was created.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'allowed_products' => array( + ], + 'allowed_products' => [ 'description' => __('The list of products that allows this discount code to be used. If empty, all products will accept this code.', 'wp-ultimo'), 'type' => 'array', 'required' => false, - ), - 'limit_products' => array( + ], + 'limit_products' => [ 'description' => __('This discount code will be limited to be used in certain products? If set to true, you must define a list of allowed products.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Model last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/discount-code-update.php b/inc/api/schemas/discount-code-update.php index 98a6664..f7e5874 100644 --- a/inc/api/schemas/discount-code-update.php +++ b/inc/api/schemas/discount-code-update.php @@ -18,108 +18,108 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'name' => array( +return [ + 'name' => [ 'description' => __('Your discount code name, which is used as discount code title as well.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'code' => array( + ], + 'code' => [ 'description' => __('A unique identification to redeem the discount code. E.g. PROMO10.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'description' => array( + ], + 'description' => [ 'description' => __('A description for the discount code, usually a short text.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'uses' => array( + ], + 'uses' => [ 'description' => __('Number of times this discount was applied.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'max_uses' => array( + ], + 'max_uses' => [ 'description' => __('The number of times this discount can be used before becoming inactive.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'apply_to_renewals' => array( + ], + 'apply_to_renewals' => [ 'description' => __('Wether or not we should apply the discount to membership renewals.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'type' => array( + ], + 'type' => [ 'description' => __("The type of the discount code. Can be 'percentage' (e.g. 10%% OFF), 'absolute' (e.g. $10 OFF).", 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'percentage', 'absolute', - ), - ), - 'value' => array( + ], + ], + 'value' => [ 'description' => __('Amount discounted in cents.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'setup_fee_type' => array( + ], + 'setup_fee_type' => [ 'description' => __('Type of the discount for the setup fee value. Can be a percentage or absolute.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'percentage', 'absolute', - ), - ), - 'setup_fee_value' => array( + ], + ], + 'setup_fee_value' => [ 'description' => __('Amount discounted for setup fees in cents.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'active' => array( + ], + 'active' => [ 'description' => __('Set this discount code as active (true), which means available to be used, or inactive (false).', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'date_start' => array( + ], + 'date_start' => [ 'description' => __('Start date for the coupon code to be considered valid.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_expiration' => array( + ], + 'date_expiration' => [ 'description' => __('Expiration date for the coupon code.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Date when this discount code was created.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'allowed_products' => array( + ], + 'allowed_products' => [ 'description' => __('The list of products that allows this discount code to be used. If empty, all products will accept this code.', 'wp-ultimo'), 'type' => 'array', 'required' => false, - ), - 'limit_products' => array( + ], + 'limit_products' => [ 'description' => __('This discount code will be limited to be used in certain products? If set to true, you must define a list of allowed products.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Model last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/domain-create.php b/inc/api/schemas/domain-create.php index af42fa5..a851236 100644 --- a/inc/api/schemas/domain-create.php +++ b/inc/api/schemas/domain-create.php @@ -18,62 +18,62 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'domain' => array( +return [ + 'domain' => [ 'description' => __("Your Domain name. You don't need to put http or https in front of your domain in this field. e.g: example.com.", 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'blog_id' => array( + ], + 'blog_id' => [ 'description' => __('The blog ID attached to this domain.', 'wp-ultimo'), 'type' => 'integer', 'required' => true, - ), - 'active' => array( + ], + 'active' => [ 'description' => __('Set this domain as active (true), which means available to be used, or inactive (false).', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'primary_domain' => array( + ], + 'primary_domain' => [ 'description' => __("Define true to set this as primary domain of a site, meaning it's the main url, or set false.", 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'secure' => array( + ], + 'secure' => [ 'description' => __('If this domain has some SSL security or not.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'stage' => array( + ], + 'stage' => [ 'description' => __('The state of the domain model object. Can be one of this options: checking-dns, checking-ssl-cert, done-without-ssl, done and failed.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - 'enum' => array( + 'enum' => [ 'checking-dns', 'checking-ssl-cert', 'done-without-ssl', 'done', 'failed', - ), - ), - 'date_created' => array( + ], + ], + 'date_created' => [ 'description' => __('Date when the domain was created. If no date is set, the current date and time will be used.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Model last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/domain-update.php b/inc/api/schemas/domain-update.php index af38fe9..37a35a0 100644 --- a/inc/api/schemas/domain-update.php +++ b/inc/api/schemas/domain-update.php @@ -18,62 +18,62 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'domain' => array( +return [ + 'domain' => [ 'description' => __("Your Domain name. You don't need to put http or https in front of your domain in this field. e.g: example.com.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'blog_id' => array( + ], + 'blog_id' => [ 'description' => __('The blog ID attached to this domain.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'active' => array( + ], + 'active' => [ 'description' => __('Set this domain as active (true), which means available to be used, or inactive (false).', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'primary_domain' => array( + ], + 'primary_domain' => [ 'description' => __("Define true to set this as primary domain of a site, meaning it's the main url, or set false.", 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'secure' => array( + ], + 'secure' => [ 'description' => __('If this domain has some SSL security or not.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'stage' => array( + ], + 'stage' => [ 'description' => __('The state of the domain model object. Can be one of this options: checking-dns, checking-ssl-cert, done-without-ssl, done and failed.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'checking-dns', 'checking-ssl-cert', 'done-without-ssl', 'done', 'failed', - ), - ), - 'date_created' => array( + ], + ], + 'date_created' => [ 'description' => __('Date when the domain was created. If no date is set, the current date and time will be used.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Model last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/email-create.php b/inc/api/schemas/email-create.php index bc5d02b..504ec28 100644 --- a/inc/api/schemas/email-create.php +++ b/inc/api/schemas/email-create.php @@ -18,127 +18,127 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'style' => array( +return [ + 'style' => [ 'description' => __("The email style. Can be 'html' or 'plain-text'.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'html', 'plain-text', - ), - ), - 'schedule' => array( + ], + ], + 'schedule' => [ 'description' => __('Whether or not this is a scheduled email.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'type' => array( + ], + 'type' => [ 'description' => __('The type being set.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'event' => array( + ], + 'event' => [ 'description' => __('The event that needs to be fired for this email to be sent.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'send_hours' => array( + ], + 'send_hours' => [ 'description' => __('The amount of hours that the email will wait before is sent.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'send_days' => array( + ], + 'send_days' => [ 'description' => __('The amount of days that the email will wait before is sent.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'schedule_type' => array( + ], + 'schedule_type' => [ 'description' => __("The type of schedule. Can be 'days' or 'hours'.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'days', 'hours', - ), - ), - 'name' => array( + ], + ], + 'name' => [ 'description' => __('The name being set as title.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'custom_sender' => array( + ], + 'custom_sender' => [ 'description' => __('If has a custom sender.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'custom_sender_name' => array( + ], + 'custom_sender_name' => [ 'description' => __('The name of the custom sender. E.g. From: John Doe.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'custom_sender_email' => array( + ], + 'custom_sender_email' => [ 'description' => __('The email of the custom sender. E.g. From: johndoe@gmail.com.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'target' => array( + ], + 'target' => [ 'description' => __("If we should send this to a customer or to the network admin. Can be 'customer' or 'admin'.", 'wp-ultimo'), 'type' => 'string', 'required' => true, - 'enum' => array( + 'enum' => [ 'customer', 'admin', - ), - ), - 'send_copy_to_admin' => array( + ], + ], + 'send_copy_to_admin' => [ 'description' => __('Checks if we should send a copy of the email to the admin.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'active' => array( + ], + 'active' => [ 'description' => __('Set this email as active (true), which means available will fire when the event occur, or inactive (false).', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'legacy' => array( + ], + 'legacy' => [ 'description' => __('Whether or not this is a legacy email.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'title' => array( + ], + 'title' => [ 'description' => __('Post title.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'content' => array( + ], + 'content' => [ 'description' => __('Post content.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'excerpt' => array( + ], + 'excerpt' => [ 'description' => __('Post excerpt.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Post creation date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Post last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/email-update.php b/inc/api/schemas/email-update.php index b948d31..a604767 100644 --- a/inc/api/schemas/email-update.php +++ b/inc/api/schemas/email-update.php @@ -18,127 +18,127 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'style' => array( +return [ + 'style' => [ 'description' => __("The email style. Can be 'html' or 'plain-text'.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'html', 'plain-text', - ), - ), - 'schedule' => array( + ], + ], + 'schedule' => [ 'description' => __('Whether or not this is a scheduled email.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'type' => array( + ], + 'type' => [ 'description' => __('The type being set.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'event' => array( + ], + 'event' => [ 'description' => __('The event that needs to be fired for this email to be sent.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'send_hours' => array( + ], + 'send_hours' => [ 'description' => __('The amount of hours that the email will wait before is sent.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'send_days' => array( + ], + 'send_days' => [ 'description' => __('The amount of days that the email will wait before is sent.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'schedule_type' => array( + ], + 'schedule_type' => [ 'description' => __("The type of schedule. Can be 'days' or 'hours'.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'days', 'hours', - ), - ), - 'name' => array( + ], + ], + 'name' => [ 'description' => __('The name being set as title.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'custom_sender' => array( + ], + 'custom_sender' => [ 'description' => __('If has a custom sender.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'custom_sender_name' => array( + ], + 'custom_sender_name' => [ 'description' => __('The name of the custom sender. E.g. From: John Doe.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'custom_sender_email' => array( + ], + 'custom_sender_email' => [ 'description' => __('The email of the custom sender. E.g. From: johndoe@gmail.com.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'target' => array( + ], + 'target' => [ 'description' => __("If we should send this to a customer or to the network admin. Can be 'customer' or 'admin'.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'customer', 'admin', - ), - ), - 'send_copy_to_admin' => array( + ], + ], + 'send_copy_to_admin' => [ 'description' => __('Checks if we should send a copy of the email to the admin.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'active' => array( + ], + 'active' => [ 'description' => __('Set this email as active (true), which means available will fire when the event occur, or inactive (false).', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'legacy' => array( + ], + 'legacy' => [ 'description' => __('Whether or not this is a legacy email.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'title' => array( + ], + 'title' => [ 'description' => __('Post title.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'content' => array( + ], + 'content' => [ 'description' => __('Post content.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'excerpt' => array( + ], + 'excerpt' => [ 'description' => __('Post excerpt.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Post creation date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Post last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/event-create.php b/inc/api/schemas/event-create.php index b8c463c..9f82b38 100644 --- a/inc/api/schemas/event-create.php +++ b/inc/api/schemas/event-create.php @@ -18,59 +18,59 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'severity' => array( +return [ + 'severity' => [ 'description' => __('Severity of the problem.', 'wp-ultimo'), 'type' => 'integer', 'required' => true, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Date when the event was created.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'payload' => array( + ], + 'payload' => [ 'description' => __('Payload of the event.', 'wp-ultimo'), 'type' => 'object', 'required' => true, - ), - 'initiator' => array( + ], + 'initiator' => [ 'description' => __('The type of user responsible for initiating the event. There are two options: Manual and System. By default, the event is saved as manual.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - 'enum' => array( + 'enum' => [ 'system', 'manual', - ), - ), - 'object_type' => array( + ], + ], + 'object_type' => [ 'description' => __("The type of object related to this event. It's usually the model name.", 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'slug' => array( + ], + 'slug' => [ 'description' => __('The event slug. It needs to be unique and preferably make it clear what it is about. Example: account_created is about creating an account.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'object_id' => array( + ], + 'object_id' => [ 'description' => __('The ID of the related objects.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Model last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/event-update.php b/inc/api/schemas/event-update.php index 3b79553..e8abcf8 100644 --- a/inc/api/schemas/event-update.php +++ b/inc/api/schemas/event-update.php @@ -18,59 +18,59 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'severity' => array( +return [ + 'severity' => [ 'description' => __('Severity of the problem.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Date when the event was created.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'payload' => array( + ], + 'payload' => [ 'description' => __('Payload of the event.', 'wp-ultimo'), 'type' => 'object', 'required' => false, - ), - 'initiator' => array( + ], + 'initiator' => [ 'description' => __('The type of user responsible for initiating the event. There are two options: Manual and System. By default, the event is saved as manual.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'system', 'manual', - ), - ), - 'object_type' => array( + ], + ], + 'object_type' => [ 'description' => __("The type of object related to this event. It's usually the model name.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'slug' => array( + ], + 'slug' => [ 'description' => __('The event slug. It needs to be unique and preferably make it clear what it is about. Example: account_created is about creating an account.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'object_id' => array( + ], + 'object_id' => [ 'description' => __('The ID of the related objects.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Model last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/membership-create.php b/inc/api/schemas/membership-create.php index 6b2a558..c5cbf4d 100644 --- a/inc/api/schemas/membership-create.php +++ b/inc/api/schemas/membership-create.php @@ -20,162 +20,162 @@ use WP_Ultimo\Database\Memberships\Membership_Status; * * @since 2.0.11 */ -return array( - 'customer_id' => array( +return [ + 'customer_id' => [ 'description' => __('The ID of the customer attached to this membership.', 'wp-ultimo'), 'type' => 'integer', 'required' => true, - ), - 'user_id' => array( + ], + 'user_id' => [ 'description' => __('The user ID attached to this membership.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'plan_id' => array( + ], + 'plan_id' => [ 'description' => __('The plan ID associated with the membership.', 'wp-ultimo'), 'type' => 'integer', 'required' => true, - ), - 'addon_products' => array( + ], + 'addon_products' => [ 'description' => __('Additional products related to this membership. Services, Packages or other types of products.', 'wp-ultimo'), 'type' => 'mixed', 'required' => false, - ), - 'currency' => array( + ], + 'currency' => [ 'description' => __("The currency that this membership. It's a 3-letter code. E.g. 'USD'.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'duration' => array( + ], + 'duration' => [ 'description' => __('The interval period between a charge. Only the interval amount, the unit will be defined in another property.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'duration_unit' => array( + ], + 'duration_unit' => [ 'description' => __("The duration amount type. Can be 'day', 'week', 'month' or 'year'.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'day', 'month', 'week', 'year', - ), - ), - 'amount' => array( + ], + ], + 'amount' => [ 'description' => __('The product amount.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'initial_amount' => array( + ], + 'initial_amount' => [ 'description' => __('The initial amount charged for this membership, including the setup fee.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Date of creation of this membership.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_activated' => array( + ], + 'date_activated' => [ 'description' => __('Date when this membership was activated.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_trial_end' => array( + ], + 'date_trial_end' => [ 'description' => __('Date when the trial period ends, if this membership has or had a trial period.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_renewed' => array( + ], + 'date_renewed' => [ 'description' => __('Date when the membership was cancelled.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_cancellation' => array( + ], + 'date_cancellation' => [ 'description' => __('Date when the membership was cancelled.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_expiration' => array( + ], + 'date_expiration' => [ 'description' => __('Date when the membership will expiry.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_payment_plan_completed' => array( + ], + 'date_payment_plan_completed' => [ 'description' => __('Change of the payment completion for the plan value.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'auto_renew' => array( + ], + 'auto_renew' => [ 'description' => __('If this membership should auto-renewal.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'times_billed' => array( + ], + 'times_billed' => [ 'description' => __('Amount of times this membership got billed.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'billing_cycles' => array( + ], + 'billing_cycles' => [ 'description' => __('Maximum times we should charge this membership.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'status' => array( + ], + 'status' => [ 'description' => __("The membership status. Can be 'pending', 'active', 'on-hold', 'expired', 'cancelled' or other values added by third-party add-ons.", 'wp-ultimo'), 'type' => 'string', 'required' => false, 'enum' => Membership_Status::get_allowed_list(), - ), - 'gateway_customer_id' => array( + ], + 'gateway_customer_id' => [ 'description' => __('The ID of the customer on the payment gateway database.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'gateway_subscription_id' => array( + ], + 'gateway_subscription_id' => [ 'description' => __('The ID of the subscription on the payment gateway database.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'gateway' => array( + ], + 'gateway' => [ 'description' => __('ID of the gateway being used on this subscription.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'signup_method' => array( + ], + 'signup_method' => [ 'description' => __('Signup method used to create this membership.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'upgraded_from' => array( + ], + 'upgraded_from' => [ 'description' => __('Plan that this membership upgraded from.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Date this membership was last modified.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'disabled' => array( + ], + 'disabled' => [ 'description' => __('If this membership is a disabled one.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'recurring' => array( + ], + 'recurring' => [ 'description' => __('If this membership is recurring (true), which means the customer paid a defined amount each period of time, or not recurring (false).', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/membership-update.php b/inc/api/schemas/membership-update.php index c34fb61..2db88fa 100644 --- a/inc/api/schemas/membership-update.php +++ b/inc/api/schemas/membership-update.php @@ -20,162 +20,162 @@ use WP_Ultimo\Database\Memberships\Membership_Status; * * @since 2.0.11 */ -return array( - 'customer_id' => array( +return [ + 'customer_id' => [ 'description' => __('The ID of the customer attached to this membership.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'user_id' => array( + ], + 'user_id' => [ 'description' => __('The user ID attached to this membership.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'plan_id' => array( + ], + 'plan_id' => [ 'description' => __('The plan ID associated with the membership.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'addon_products' => array( + ], + 'addon_products' => [ 'description' => __('Additional products related to this membership. Services, Packages or other types of products.', 'wp-ultimo'), 'type' => 'mixed', 'required' => false, - ), - 'currency' => array( + ], + 'currency' => [ 'description' => __("The currency that this membership. It's a 3-letter code. E.g. 'USD'.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'duration' => array( + ], + 'duration' => [ 'description' => __('The interval period between a charge. Only the interval amount, the unit will be defined in another property.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'duration_unit' => array( + ], + 'duration_unit' => [ 'description' => __("The duration amount type. Can be 'day', 'week', 'month' or 'year'.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'day', 'month', 'week', 'year', - ), - ), - 'amount' => array( + ], + ], + 'amount' => [ 'description' => __('The product amount.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'initial_amount' => array( + ], + 'initial_amount' => [ 'description' => __('The initial amount charged for this membership, including the setup fee.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Date of creation of this membership.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_activated' => array( + ], + 'date_activated' => [ 'description' => __('Date when this membership was activated.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_trial_end' => array( + ], + 'date_trial_end' => [ 'description' => __('Date when the trial period ends, if this membership has or had a trial period.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_renewed' => array( + ], + 'date_renewed' => [ 'description' => __('Date when the membership was cancelled.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_cancellation' => array( + ], + 'date_cancellation' => [ 'description' => __('Date when the membership was cancelled.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_expiration' => array( + ], + 'date_expiration' => [ 'description' => __('Date when the membership will expiry.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_payment_plan_completed' => array( + ], + 'date_payment_plan_completed' => [ 'description' => __('Change of the payment completion for the plan value.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'auto_renew' => array( + ], + 'auto_renew' => [ 'description' => __('If this membership should auto-renewal.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'times_billed' => array( + ], + 'times_billed' => [ 'description' => __('Amount of times this membership got billed.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'billing_cycles' => array( + ], + 'billing_cycles' => [ 'description' => __('Maximum times we should charge this membership.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'status' => array( + ], + 'status' => [ 'description' => __("The membership status. Can be 'pending', 'active', 'on-hold', 'expired', 'cancelled' or other values added by third-party add-ons.", 'wp-ultimo'), 'type' => 'string', 'required' => false, 'enum' => Membership_Status::get_allowed_list(), - ), - 'gateway_customer_id' => array( + ], + 'gateway_customer_id' => [ 'description' => __('The ID of the customer on the payment gateway database.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'gateway_subscription_id' => array( + ], + 'gateway_subscription_id' => [ 'description' => __('The ID of the subscription on the payment gateway database.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'gateway' => array( + ], + 'gateway' => [ 'description' => __('ID of the gateway being used on this subscription.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'signup_method' => array( + ], + 'signup_method' => [ 'description' => __('Signup method used to create this membership.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'upgraded_from' => array( + ], + 'upgraded_from' => [ 'description' => __('Plan that this membership upgraded from.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Date this membership was last modified.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'disabled' => array( + ], + 'disabled' => [ 'description' => __('If this membership is a disabled one.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'recurring' => array( + ], + 'recurring' => [ 'description' => __('If this membership is recurring (true), which means the customer paid a defined amount each period of time, or not recurring (false).', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/payment-create.php b/inc/api/schemas/payment-create.php index 5ec3e2a..1975ec0 100644 --- a/inc/api/schemas/payment-create.php +++ b/inc/api/schemas/payment-create.php @@ -20,106 +20,106 @@ use WP_Ultimo\Database\Payments\Payment_Status; * * @since 2.0.11 */ -return array( - 'customer_id' => array( +return [ + 'customer_id' => [ 'description' => __('The ID of the customer attached to this payment.', 'wp-ultimo'), 'type' => 'integer', 'required' => true, - ), - 'membership_id' => array( + ], + 'membership_id' => [ 'description' => __('The ID of the membership attached to this payment.', 'wp-ultimo'), 'type' => 'integer', 'required' => true, - ), - 'parent_id' => array( + ], + 'parent_id' => [ 'description' => __('The ID from another payment that this payment is related to.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'currency' => array( + ], + 'currency' => [ 'description' => __("The currency of this payment. It's a 3-letter code. E.g. 'USD'.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'subtotal' => array( + ], + 'subtotal' => [ 'description' => __('Value before taxes, discounts, fees and other changes.', 'wp-ultimo'), 'type' => 'number', 'required' => true, - ), - 'refund_total' => array( + ], + 'refund_total' => [ 'description' => __('Total amount refunded.', 'wp-ultimo'), 'type' => 'number', 'required' => false, - ), - 'tax_total' => array( + ], + 'tax_total' => [ 'description' => __('The amount, in currency, of the tax.', 'wp-ultimo'), 'type' => 'number', 'required' => false, - ), - 'discount_code' => array( + ], + 'discount_code' => [ 'description' => __('Discount code used.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'total' => array( + ], + 'total' => [ 'description' => __('This takes into account fees, discounts and credits.', 'wp-ultimo'), 'type' => 'number', 'required' => true, - ), - 'status' => array( + ], + 'status' => [ 'description' => __("The payment status: Can be 'pending', 'completed', 'refunded', 'partially-refunded', 'partially-paid', 'failed', 'cancelled' or other values added by third-party add-ons.", 'wp-ultimo'), 'type' => 'string', 'required' => true, 'enum' => Payment_Status::get_allowed_list(), - ), - 'gateway' => array( + ], + 'gateway' => [ 'description' => __('ID of the gateway being used on this payment.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'product_id' => array( + ], + 'product_id' => [ 'description' => __('The ID of the product of this payment.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'gateway_payment_id' => array( + ], + 'gateway_payment_id' => [ 'description' => __('The ID of the payment on the gateway, if it exists.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'discount_total' => array( + ], + 'discount_total' => [ 'description' => __('The total value of the discounts applied to this payment.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'invoice_number' => array( + ], + 'invoice_number' => [ 'description' => __('Sequential invoice number assigned to this payment.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'cancel_membership_on_refund' => array( + ], + 'cancel_membership_on_refund' => [ 'description' => __('Holds if we need to cancel the membership on refund.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Model creation date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Model last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/payment-update.php b/inc/api/schemas/payment-update.php index 68574cc..51aa85c 100644 --- a/inc/api/schemas/payment-update.php +++ b/inc/api/schemas/payment-update.php @@ -20,106 +20,106 @@ use WP_Ultimo\Database\Payments\Payment_Status; * * @since 2.0.11 */ -return array( - 'customer_id' => array( +return [ + 'customer_id' => [ 'description' => __('The ID of the customer attached to this payment.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'membership_id' => array( + ], + 'membership_id' => [ 'description' => __('The ID of the membership attached to this payment.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'parent_id' => array( + ], + 'parent_id' => [ 'description' => __('The ID from another payment that this payment is related to.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'currency' => array( + ], + 'currency' => [ 'description' => __("The currency of this payment. It's a 3-letter code. E.g. 'USD'.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'subtotal' => array( + ], + 'subtotal' => [ 'description' => __('Value before taxes, discounts, fees and other changes.', 'wp-ultimo'), 'type' => 'number', 'required' => false, - ), - 'refund_total' => array( + ], + 'refund_total' => [ 'description' => __('Total amount refunded.', 'wp-ultimo'), 'type' => 'number', 'required' => false, - ), - 'tax_total' => array( + ], + 'tax_total' => [ 'description' => __('The amount, in currency, of the tax.', 'wp-ultimo'), 'type' => 'number', 'required' => false, - ), - 'discount_code' => array( + ], + 'discount_code' => [ 'description' => __('Discount code used.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'total' => array( + ], + 'total' => [ 'description' => __('This takes into account fees, discounts and credits.', 'wp-ultimo'), 'type' => 'number', 'required' => false, - ), - 'status' => array( + ], + 'status' => [ 'description' => __("The payment status: Can be 'pending', 'completed', 'refunded', 'partially-refunded', 'partially-paid', 'failed', 'cancelled' or other values added by third-party add-ons.", 'wp-ultimo'), 'type' => 'string', 'required' => false, 'enum' => Payment_Status::get_allowed_list(), - ), - 'gateway' => array( + ], + 'gateway' => [ 'description' => __('ID of the gateway being used on this payment.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'product_id' => array( + ], + 'product_id' => [ 'description' => __('The ID of the product of this payment.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'gateway_payment_id' => array( + ], + 'gateway_payment_id' => [ 'description' => __('The ID of the payment on the gateway, if it exists.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'discount_total' => array( + ], + 'discount_total' => [ 'description' => __('The total value of the discounts applied to this payment.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'invoice_number' => array( + ], + 'invoice_number' => [ 'description' => __('Sequential invoice number assigned to this payment.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'cancel_membership_on_refund' => array( + ], + 'cancel_membership_on_refund' => [ 'description' => __('Holds if we need to cancel the membership on refund.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Model creation date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Model last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/product-create.php b/inc/api/schemas/product-create.php index 3cdfa9f..b0904e2 100644 --- a/inc/api/schemas/product-create.php +++ b/inc/api/schemas/product-create.php @@ -18,182 +18,182 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'featured_image_id' => array( +return [ + 'featured_image_id' => [ 'description' => __('The ID of the feature image of the product.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'slug' => array( + ], + 'slug' => [ 'description' => __('The product slug. It needs to be unique and preferably make it clear what it is about. Example: my_new_product.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'name' => array( + ], + 'name' => [ 'description' => __('Your product name, which is used as product title as well.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'description' => array( + ], + 'description' => [ 'description' => __('A description for the product, usually a short text.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'currency' => array( + ], + 'currency' => [ 'description' => __("The currency that this product accepts. It's a 3-letter code. E.g. 'USD'.", 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'pricing_type' => array( + ], + 'pricing_type' => [ 'description' => __("The pricing type can be 'free', 'paid' or 'contact_us'.", 'wp-ultimo'), 'type' => 'string', 'required' => true, - 'enum' => array( + 'enum' => [ 'free', 'paid', 'contact_us', - ), - ), - 'trial_duration' => array( + ], + ], + 'trial_duration' => [ 'description' => __('The duration of the trial period of this product, if the product has one.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'trial_duration_unit' => array( + ], + 'trial_duration_unit' => [ 'description' => __('The unit of the trial duration amount. Can be day, week, month or year.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'day', 'week', 'month', 'year', - ), - ), - 'duration' => array( + ], + ], + 'duration' => [ 'description' => __('Time interval between charges.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'duration_unit' => array( + ], + 'duration_unit' => [ 'description' => __('Time interval unit between charges.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'day', 'month', 'week', 'year', - ), - ), - 'amount' => array( + ], + ], + 'amount' => [ 'description' => __('The value of this product. E.g. 19.99.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'setup_fee' => array( + ], + 'setup_fee' => [ 'description' => __('The setup fee value, if the product has one. E.g. 159.99.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'active' => array( + ], + 'active' => [ 'description' => __('Set this product as active (true), which means available to be used, or inactive (false).', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'type' => array( + ], + 'type' => [ 'description' => __("The default product types are 'product', 'service' and 'package'. More types can be add using the product type filter.", 'wp-ultimo'), 'type' => 'string', 'required' => true, - 'enum' => array( + 'enum' => [ 'plan', 'service', 'package', - ), - ), - 'parent_id' => array( + ], + ], + 'parent_id' => [ 'description' => __('The ID from another Product that this product is related to.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'recurring' => array( + ], + 'recurring' => [ 'description' => __('Set this product as a recurring one (true), which means the customer paid a defined amount each period of time, or not recurring (false).', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'billing_cycles' => array( + ], + 'billing_cycles' => [ 'description' => __('The number of times we should charge this product.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Date when this was created.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Date when this was last modified.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'taxable' => array( + ], + 'taxable' => [ 'description' => __('Set this product as a taxable one (true), which means tax rules are applied to, or not taxable (false).', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'tax_category' => array( + ], + 'tax_category' => [ 'description' => __('Category of taxes applied to this product. You need to set this if taxable is set to true.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'contact_us_label' => array( + ], + 'contact_us_label' => [ 'description' => __("If the product is the 'contact_us' type, it will need a label for the contact us button.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'contact_us_link' => array( + ], + 'contact_us_link' => [ 'description' => __('The url where the contact us button will lead to.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'feature_list' => array( + ], + 'feature_list' => [ 'description' => __('A list (array) of features of the product.', 'wp-ultimo'), 'type' => 'array', 'required' => false, - ), - 'customer_role' => array( + ], + 'customer_role' => [ 'description' => __('The customer role of this product.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'available_addons' => array( + ], + 'available_addons' => [ 'description' => __('The available addons of this product.', 'wp-ultimo'), 'type' => 'array', 'required' => false, - ), - 'group' => array( + ], + 'group' => [ 'description' => __('The group of this product, if has any.', 'wp-ultimo'), 'type' => 'array', 'required' => false, - ), - 'legacy_options' => array( + ], + 'legacy_options' => [ 'description' => __('If the legacy options are enabled.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'featured_plan' => array( + ], + 'featured_plan' => [ 'description' => __('Feature list for pricing tables.', 'wp-ultimo'), 'type' => 'array', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/product-update.php b/inc/api/schemas/product-update.php index e335a15..46a175f 100644 --- a/inc/api/schemas/product-update.php +++ b/inc/api/schemas/product-update.php @@ -18,182 +18,182 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'featured_image_id' => array( +return [ + 'featured_image_id' => [ 'description' => __('The ID of the feature image of the product.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'slug' => array( + ], + 'slug' => [ 'description' => __('The product slug. It needs to be unique and preferably make it clear what it is about. Example: my_new_product.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'name' => array( + ], + 'name' => [ 'description' => __('Your product name, which is used as product title as well.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'description' => array( + ], + 'description' => [ 'description' => __('A description for the product, usually a short text.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'currency' => array( + ], + 'currency' => [ 'description' => __("The currency that this product accepts. It's a 3-letter code. E.g. 'USD'.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'pricing_type' => array( + ], + 'pricing_type' => [ 'description' => __("The pricing type can be 'free', 'paid' or 'contact_us'.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'free', 'paid', 'contact_us', - ), - ), - 'trial_duration' => array( + ], + ], + 'trial_duration' => [ 'description' => __('The duration of the trial period of this product, if the product has one.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'trial_duration_unit' => array( + ], + 'trial_duration_unit' => [ 'description' => __('The unit of the trial duration amount. Can be day, week, month or year.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'day', 'week', 'month', 'year', - ), - ), - 'duration' => array( + ], + ], + 'duration' => [ 'description' => __('Time interval between charges.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'duration_unit' => array( + ], + 'duration_unit' => [ 'description' => __('Time interval unit between charges.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'day', 'month', 'week', 'year', - ), - ), - 'amount' => array( + ], + ], + 'amount' => [ 'description' => __('The value of this product. E.g. 19.99.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'setup_fee' => array( + ], + 'setup_fee' => [ 'description' => __('The setup fee value, if the product has one. E.g. 159.99.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'active' => array( + ], + 'active' => [ 'description' => __('Set this product as active (true), which means available to be used, or inactive (false).', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'type' => array( + ], + 'type' => [ 'description' => __("The default product types are 'product', 'service' and 'package'. More types can be add using the product type filter.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'plan', 'service', 'package', - ), - ), - 'parent_id' => array( + ], + ], + 'parent_id' => [ 'description' => __('The ID from another Product that this product is related to.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'recurring' => array( + ], + 'recurring' => [ 'description' => __('Set this product as a recurring one (true), which means the customer paid a defined amount each period of time, or not recurring (false).', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'billing_cycles' => array( + ], + 'billing_cycles' => [ 'description' => __('The number of times we should charge this product.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Date when this was created.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Date when this was last modified.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'taxable' => array( + ], + 'taxable' => [ 'description' => __('Set this product as a taxable one (true), which means tax rules are applied to, or not taxable (false).', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'tax_category' => array( + ], + 'tax_category' => [ 'description' => __('Category of taxes applied to this product. You need to set this if taxable is set to true.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'contact_us_label' => array( + ], + 'contact_us_label' => [ 'description' => __("If the product is the 'contact_us' type, it will need a label for the contact us button.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'contact_us_link' => array( + ], + 'contact_us_link' => [ 'description' => __('The url where the contact us button will lead to.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'feature_list' => array( + ], + 'feature_list' => [ 'description' => __('A list (array) of features of the product.', 'wp-ultimo'), 'type' => 'array', 'required' => false, - ), - 'customer_role' => array( + ], + 'customer_role' => [ 'description' => __('The customer role of this product.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'available_addons' => array( + ], + 'available_addons' => [ 'description' => __('The available addons of this product.', 'wp-ultimo'), 'type' => 'array', 'required' => false, - ), - 'group' => array( + ], + 'group' => [ 'description' => __('The group of this product, if has any.', 'wp-ultimo'), 'type' => 'array', 'required' => false, - ), - 'legacy_options' => array( + ], + 'legacy_options' => [ 'description' => __('If the legacy options are enabled.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'featured_plan' => array( + ], + 'featured_plan' => [ 'description' => __('Feature list for pricing tables.', 'wp-ultimo'), 'type' => 'array', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/site-create.php b/inc/api/schemas/site-create.php index 5347ae5..fdfd14e 100644 --- a/inc/api/schemas/site-create.php +++ b/inc/api/schemas/site-create.php @@ -18,148 +18,148 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'categories' => array( +return [ + 'categories' => [ 'description' => __('The categories this site belongs to.', 'wp-ultimo'), 'type' => 'array', 'required' => false, - ), - 'featured_image_id' => array( + ], + 'featured_image_id' => [ 'description' => __('The ID of the feature image of the site.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'site_id' => array( + ], + 'site_id' => [ 'description' => __('The network ID for this site.', 'wp-ultimo'), 'type' => 'integer', 'required' => true, - ), - 'title' => array( + ], + 'title' => [ 'description' => __('The site title.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'name' => array( + ], + 'name' => [ 'description' => __('The site name.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'description' => array( + ], + 'description' => [ 'description' => __('A description for the site, usually a short text.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'domain' => array( + ], + 'domain' => [ 'description' => __("The site domain. You don't need to put http or https in front of your domain in this field. e.g: example.com.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'path' => array( + ], + 'path' => [ 'description' => __('Path of the site. Used when in sub-directory mode.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'registered' => array( + ], + 'registered' => [ 'description' => __('Date when the site was registered.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'last_updated' => array( + ], + 'last_updated' => [ 'description' => __('Date of the last update on this site.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'active' => array( + ], + 'active' => [ 'description' => __('Holds the ID of the customer that owns this site.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'public' => array( + ], + 'public' => [ 'description' => __('Set true if this site is a public one, false if not.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'archived' => array( + ], + 'archived' => [ 'description' => __('Is this an archived site.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'mature' => array( + ], + 'mature' => [ 'description' => __('Is this a site with mature content.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'spam' => array( + ], + 'spam' => [ 'description' => __('Is this an spam site.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'deleted' => array( + ], + 'deleted' => [ 'description' => __('Is this site deleted.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'lang_id' => array( + ], + 'lang_id' => [ 'description' => __('The ID of the language being used on this site.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'customer_id' => array( + ], + 'customer_id' => [ 'description' => __('The ID of the customer that owns this site.', 'wp-ultimo'), 'type' => 'integer', 'required' => true, - ), - 'membership_id' => array( + ], + 'membership_id' => [ 'description' => __('The ID of the membership associated with this site, if any.', 'wp-ultimo'), 'type' => 'integer', 'required' => true, - ), - 'template_id' => array( + ], + 'template_id' => [ 'description' => __('The ID of the templated used to create this site.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'type' => array( + ], + 'type' => [ 'description' => __('The type of this particular site. Can be default, site_template, customer_owned, pending, external, main or other values added by third-party add-ons.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - 'enum' => array( + 'enum' => [ 'default', 'site_template', 'customer_owned', 'pending', 'external', 'main', - ), - ), - 'signup_options' => array( + ], + ], + 'signup_options' => [ 'description' => __('Keeps signup options for the site.', 'wp-ultimo'), 'type' => 'array', 'required' => false, - ), - 'signup_meta' => array( + ], + 'signup_meta' => [ 'description' => __('Keeps signup meta for the site.', 'wp-ultimo'), 'type' => 'array', 'required' => false, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Model creation date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Model last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/site-update.php b/inc/api/schemas/site-update.php index 92d6bc2..643306f 100644 --- a/inc/api/schemas/site-update.php +++ b/inc/api/schemas/site-update.php @@ -18,148 +18,148 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'categories' => array( +return [ + 'categories' => [ 'description' => __('The categories this site belongs to.', 'wp-ultimo'), 'type' => 'array', 'required' => false, - ), - 'featured_image_id' => array( + ], + 'featured_image_id' => [ 'description' => __('The ID of the feature image of the site.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'site_id' => array( + ], + 'site_id' => [ 'description' => __('The network ID for this site.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'title' => array( + ], + 'title' => [ 'description' => __('The site title.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'name' => array( + ], + 'name' => [ 'description' => __('The site name.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'description' => array( + ], + 'description' => [ 'description' => __('A description for the site, usually a short text.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'domain' => array( + ], + 'domain' => [ 'description' => __("The site domain. You don't need to put http or https in front of your domain in this field. e.g: example.com.", 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'path' => array( + ], + 'path' => [ 'description' => __('Path of the site. Used when in sub-directory mode.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'registered' => array( + ], + 'registered' => [ 'description' => __('Date when the site was registered.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'last_updated' => array( + ], + 'last_updated' => [ 'description' => __('Date of the last update on this site.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'active' => array( + ], + 'active' => [ 'description' => __('Holds the ID of the customer that owns this site.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'public' => array( + ], + 'public' => [ 'description' => __('Set true if this site is a public one, false if not.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'archived' => array( + ], + 'archived' => [ 'description' => __('Is this an archived site.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'mature' => array( + ], + 'mature' => [ 'description' => __('Is this a site with mature content.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'spam' => array( + ], + 'spam' => [ 'description' => __('Is this an spam site.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'deleted' => array( + ], + 'deleted' => [ 'description' => __('Is this site deleted.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'lang_id' => array( + ], + 'lang_id' => [ 'description' => __('The ID of the language being used on this site.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'customer_id' => array( + ], + 'customer_id' => [ 'description' => __('The ID of the customer that owns this site.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'membership_id' => array( + ], + 'membership_id' => [ 'description' => __('The ID of the membership associated with this site, if any.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'template_id' => array( + ], + 'template_id' => [ 'description' => __('The ID of the templated used to create this site.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'type' => array( + ], + 'type' => [ 'description' => __('The type of this particular site. Can be default, site_template, customer_owned, pending, external, main or other values added by third-party add-ons.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - 'enum' => array( + 'enum' => [ 'default', 'site_template', 'customer_owned', 'pending', 'external', 'main', - ), - ), - 'signup_options' => array( + ], + ], + 'signup_options' => [ 'description' => __('Keeps signup options for the site.', 'wp-ultimo'), 'type' => 'array', 'required' => false, - ), - 'signup_meta' => array( + ], + 'signup_meta' => [ 'description' => __('Keeps signup meta for the site.', 'wp-ultimo'), 'type' => 'array', 'required' => false, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Model creation date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Model last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/webhook-create.php b/inc/api/schemas/webhook-create.php index 77172b3..7a6160b 100644 --- a/inc/api/schemas/webhook-create.php +++ b/inc/api/schemas/webhook-create.php @@ -18,65 +18,65 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'name' => array( +return [ + 'name' => [ 'description' => __('Webhook name, which is used as product title as well.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'webhook_url' => array( + ], + 'webhook_url' => [ 'description' => __('The URL used for the webhook call.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'event' => array( + ], + 'event' => [ 'description' => __('The event that needs to be fired for this webhook to be sent.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'event_count' => array( + ], + 'event_count' => [ 'description' => __('How many times this webhook was sent.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'active' => array( + ], + 'active' => [ 'description' => __('Set this webhook as active (true), which means available will fire when the event occur, or inactive (false).', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'hidden' => array( + ], + 'hidden' => [ 'description' => __('Is this webhook hidden.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Date when this was created.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'integration' => array( + ], + 'integration' => [ 'description' => __('The integration that created this webhook.', 'wp-ultimo'), 'type' => 'string', 'required' => true, - ), - 'date_last_failed' => array( + ], + 'date_last_failed' => [ 'description' => __('The date when this webhook last fail.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Model last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/schemas/webhook-update.php b/inc/api/schemas/webhook-update.php index e2d43d8..6ca7575 100644 --- a/inc/api/schemas/webhook-update.php +++ b/inc/api/schemas/webhook-update.php @@ -18,65 +18,65 @@ defined('ABSPATH') || exit; * * @since 2.0.11 */ -return array( - 'name' => array( +return [ + 'name' => [ 'description' => __('Webhook name, which is used as product title as well.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'webhook_url' => array( + ], + 'webhook_url' => [ 'description' => __('The URL used for the webhook call.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'event' => array( + ], + 'event' => [ 'description' => __('The event that needs to be fired for this webhook to be sent.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'event_count' => array( + ], + 'event_count' => [ 'description' => __('How many times this webhook was sent.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'active' => array( + ], + 'active' => [ 'description' => __('Set this webhook as active (true), which means available will fire when the event occur, or inactive (false).', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'hidden' => array( + ], + 'hidden' => [ 'description' => __('Is this webhook hidden.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), - 'date_created' => array( + ], + 'date_created' => [ 'description' => __('Date when this was created.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'integration' => array( + ], + 'integration' => [ 'description' => __('The integration that created this webhook.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_last_failed' => array( + ], + 'date_last_failed' => [ 'description' => __('The date when this webhook last fail.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'date_modified' => array( + ], + 'date_modified' => [ 'description' => __('Model last modification date.', 'wp-ultimo'), 'type' => 'string', 'required' => false, - ), - 'migrated_from_id' => array( + ], + 'migrated_from_id' => [ 'description' => __('The ID of the original 1.X model that was used to generate this item on migration.', 'wp-ultimo'), 'type' => 'integer', 'required' => false, - ), - 'skip_validation' => array( + ], + 'skip_validation' => [ 'description' => __('Set true to have field information validation bypassed when saving this event.', 'wp-ultimo'), 'type' => 'boolean', 'required' => false, - ), -); + ], +]; diff --git a/inc/api/trait-rest-api.php b/inc/api/trait-rest-api.php index f024b7c..c73c7ff 100644 --- a/inc/api/trait-rest-api.php +++ b/inc/api/trait-rest-api.php @@ -28,13 +28,13 @@ trait Rest_Api { * @since 2.0.0 * @var array */ - protected $enabled_rest_endpoints = array( + protected $enabled_rest_endpoints = [ 'get_item', 'get_items', 'create_item', 'update_item', 'delete_item', - ); + ]; /** * Returns the base used right after the namespace. @@ -54,14 +54,14 @@ trait Rest_Api { * * @since 2.0.0 */ - public function enable_rest_api() { + public function enable_rest_api(): void { $is_enabled = \WP_Ultimo\API::get_instance()->is_api_enabled(); if ($is_enabled) { - add_action('rest_api_init', array($this, 'register_routes_general')); + add_action('rest_api_init', [$this, 'register_routes_general']); - add_action('rest_api_init', array($this, 'register_routes_with_id')); + add_action('rest_api_init', [$this, 'register_routes_with_id']); } } @@ -71,27 +71,27 @@ trait Rest_Api { * * @since 2.0.0 */ - public function register_routes_general() { + public function register_routes_general(): void { - $routes = array(); + $routes = []; if (in_array('get_items', $this->enabled_rest_endpoints, true)) { - $routes = array( - array( + $routes = [ + [ 'methods' => \WP_REST_Server::READABLE, - 'callback' => array($this, 'get_items_rest'), - 'permission_callback' => array($this, 'get_items_permissions_check'), - ), - ); + 'callback' => [$this, 'get_items_rest'], + 'permission_callback' => [$this, 'get_items_permissions_check'], + ], + ]; } if (in_array('create_item', $this->enabled_rest_endpoints, true)) { - $routes[] = array( + $routes[] = [ 'methods' => \WP_REST_Server::CREATABLE, - 'callback' => array($this, 'create_item_rest'), - 'permission_callback' => array($this, 'create_item_permissions_check'), + 'callback' => [$this, 'create_item_rest'], + 'permission_callback' => [$this, 'create_item_permissions_check'], 'args' => $this->get_arguments_schema(), - ); + ]; } if ( ! empty($routes)) { @@ -112,33 +112,33 @@ trait Rest_Api { * * @since 2.0.0 */ - public function register_routes_with_id() { + public function register_routes_with_id(): void { - $routes = array(); + $routes = []; if (in_array('get_item', $this->enabled_rest_endpoints, true)) { - $routes[] = array( + $routes[] = [ 'methods' => \WP_REST_Server::READABLE, - 'callback' => array($this, 'get_item_rest'), - 'permission_callback' => array($this, 'get_item_permissions_check'), - ); + 'callback' => [$this, 'get_item_rest'], + 'permission_callback' => [$this, 'get_item_permissions_check'], + ]; } if (in_array('update_item', $this->enabled_rest_endpoints, true)) { - $routes[] = array( + $routes[] = [ 'methods' => \WP_REST_Server::EDITABLE, - 'callback' => array($this, 'update_item_rest'), - 'permission_callback' => array($this, 'update_item_permissions_check'), + 'callback' => [$this, 'update_item_rest'], + 'permission_callback' => [$this, 'update_item_permissions_check'], 'args' => $this->get_arguments_schema(true), - ); + ]; } if (in_array('delete_item', $this->enabled_rest_endpoints, true)) { - $routes[] = array( + $routes[] = [ 'methods' => \WP_REST_Server::DELETABLE, - 'callback' => array($this, 'delete_item_rest'), - 'permission_callback' => array($this, 'delete_item_permissions_check'), - ); + 'callback' => [$this, 'delete_item_rest'], + 'permission_callback' => [$this, 'delete_item_permissions_check'], + ]; } if ( ! empty($routes)) { @@ -165,7 +165,7 @@ trait Rest_Api { $item = $this->model_class::get_by_id($request['id']); if (empty($item)) { - return new \WP_Error("wu_rest_{$this->slug}_invalid_id", __('Item not found.', 'wp-ultimo'), array('status' => 404)); + return new \WP_Error("wu_rest_{$this->slug}_invalid_id", __('Item not found.', 'wp-ultimo'), ['status' => 404]); } return rest_ensure_response($item); @@ -196,7 +196,7 @@ trait Rest_Api { $body = json_decode($request->get_body(), true); - $model_name = (new $this->model_class(array()))->model; + $model_name = (new $this->model_class([]))->model; $saver_function = "wu_create_{$model_name}"; @@ -215,7 +215,7 @@ trait Rest_Api { } if ( ! $saved) { - return new \WP_Error("wu_rest_{$this->slug}", __('Something went wrong (Code 1).', 'wp-ultimo'), array('status' => 400)); + return new \WP_Error("wu_rest_{$this->slug}", __('Something went wrong (Code 1).', 'wp-ultimo'), ['status' => 400]); } return rest_ensure_response($item); @@ -235,12 +235,12 @@ trait Rest_Api { $item = $this->model_class::get_by_id($id); if (empty($item)) { - return new \WP_Error("wu_rest_{$this->slug}_invalid_id", __('Item not found.', 'wp-ultimo'), array('status' => 404)); + return new \WP_Error("wu_rest_{$this->slug}_invalid_id", __('Item not found.', 'wp-ultimo'), ['status' => 404]); } $params = array_filter( json_decode($request->get_body(), true), - array($this, 'is_not_credential_key'), + [$this, 'is_not_credential_key'], ARRAY_FILTER_USE_KEY ); @@ -250,7 +250,7 @@ trait Rest_Api { if ($param === 'meta') { $item->update_meta_batch($value); } elseif (method_exists($item, $set_method)) { - call_user_func(array($item, $set_method), $value); + call_user_func([$item, $set_method], $value); } else { $error_message = sprintf( /* translators: 1. Object class name; 2. Set method name */ @@ -262,7 +262,7 @@ trait Rest_Api { return new \WP_Error( "wu_rest_{$this->slug}_invalid_set_method", $error_message, - array('status' => 400) + ['status' => 400] ); } } @@ -292,7 +292,7 @@ trait Rest_Api { $item = $this->model_class::get_by_id($request['id']); if (empty($item)) { - return new \WP_Error("wu_rest_{$this->slug}_invalid_id", __('Item not found.', 'wp-ultimo'), array('status' => 404)); + return new \WP_Error("wu_rest_{$this->slug}_invalid_id", __('Item not found.', 'wp-ultimo'), ['status' => 404]); } $result = $item->delete(); @@ -440,12 +440,12 @@ trait Rest_Api { */ private function is_not_credential_key($value) { - $credentials_keys = array( + $credentials_keys = [ 'api_key', 'api_secret', 'api-key', 'api-secret', - ); + ]; return ! in_array($value, $credentials_keys, true); } @@ -460,15 +460,15 @@ trait Rest_Api { */ private function is_not_id_key($value) { - $arr = array( + $arr = [ 'id', - ); + ]; if ($this->slug === 'site') { - $arr = array( + $arr = [ 'id', 'blog_id', - ); + ]; } return ! in_array($value, $arr, true); @@ -486,7 +486,7 @@ trait Rest_Api { $schema = wu_rest_get_endpoint_schema($this->model_class, $edit ? 'update' : 'create', true); - $args = array_filter($schema, array($this, 'is_not_id_key'), ARRAY_FILTER_USE_KEY); + $args = array_filter($schema, [$this, 'is_not_id_key'], ARRAY_FILTER_USE_KEY); return $this->filter_schema_arguments($args); } @@ -521,12 +521,12 @@ trait Rest_Api { $remove_status = apply_filters( "wu_api_{$this->slug}_remove_status", - array( + [ 'broadcast', 'membership', 'product', 'payment', - ) + ] ); if ( ! in_array($this->slug, $remove_status, true) && isset($args['status'])) { @@ -535,12 +535,12 @@ trait Rest_Api { $remove_slug = apply_filters( "wu_api_{$this->slug}_remove_slug", - array( + [ 'broadcast', 'product', 'checkout_form', 'event', - ) + ] ); if ( ! in_array($this->slug, $remove_slug, true) && isset($args['slug'])) { diff --git a/inc/api/trait-wp-cli.php b/inc/api/trait-wp-cli.php index ef59231..d7209f7 100644 --- a/inc/api/trait-wp-cli.php +++ b/inc/api/trait-wp-cli.php @@ -28,7 +28,7 @@ trait WP_CLI { * @since 2.0.0 * @var array */ - protected $wp_cli_enabled_sub_commands = array(); + protected $wp_cli_enabled_sub_commands = []; /** * Returns the base used right after the root. @@ -48,7 +48,7 @@ trait WP_CLI { * * @since 2.0.0 */ - public function enable_wp_cli() { + public function enable_wp_cli(): void { if ( ! defined('WP_CLI')) { return; @@ -62,9 +62,9 @@ trait WP_CLI { \WP_CLI::add_command( "{$wp_cli_root} {$this->get_wp_cli_command_base()} {$sub_command}", $sub_command_data['callback'], - array( + [ 'synopsis' => $sub_command_data['synopsis'], - ) + ] ); } } @@ -72,25 +72,25 @@ trait WP_CLI { /** * Set wP-CLI Sub-command enabled for this entity. */ - public function set_wp_cli_enabled_sub_commands() { + public function set_wp_cli_enabled_sub_commands(): void { - $sub_commands = array( - 'get' => array( - 'callback' => array($this, 'wp_cli_get_item'), - ), - 'list' => array( - 'callback' => array($this, 'wp_cli_get_items'), - ), - 'create' => array( - 'callback' => array($this, 'wp_cli_create_item'), - ), - 'update' => array( - 'callback' => array($this, 'wp_cli_update_item'), - ), - 'delete' => array( - 'callback' => array($this, 'wp_cli_delete_item'), - ), - ); + $sub_commands = [ + 'get' => [ + 'callback' => [$this, 'wp_cli_get_item'], + ], + 'list' => [ + 'callback' => [$this, 'wp_cli_get_items'], + ], + 'create' => [ + 'callback' => [$this, 'wp_cli_create_item'], + ], + 'update' => [ + 'callback' => [$this, 'wp_cli_update_item'], + ], + 'delete' => [ + 'callback' => [$this, 'wp_cli_delete_item'], + ], + ]; $params = array_merge($this->wp_cli_get_fields(), $this->wp_cli_extra_parameters()); @@ -101,42 +101,42 @@ trait WP_CLI { */ $params_to_remove = apply_filters( 'wu_cli_params_to_remove', - array( + [ 'id', 'model', - ) + ] ); $params = array_filter($params, fn($param) => ! in_array($param, $params_to_remove, true)); foreach ($sub_commands as $sub_command => &$sub_command_data) { - $sub_command_data['synopsis'] = array(); + $sub_command_data['synopsis'] = []; - if (in_array($sub_command, array('get', 'update', 'delete'), true)) { - $sub_command_data['synopsis'][] = array( + if (in_array($sub_command, ['get', 'update', 'delete'], true)) { + $sub_command_data['synopsis'][] = [ 'name' => 'id', 'type' => 'positional', 'description' => __('The id for the resource.', 'wp-ultimo'), 'optional' => false, - ); + ]; } - if (in_array($sub_command, array('list', 'update', 'create'), true)) { + if (in_array($sub_command, ['list', 'update', 'create'], true)) { $explanation_list = wu_rest_get_endpoint_schema($this->model_class, 'update'); foreach ($params as $name) { - $explanation = wu_get_isset($explanation_list, $name, array()); + $explanation = wu_get_isset($explanation_list, $name, []); $type = wu_get_isset($explanation, 'type', 'assoc'); - $field = array( + $field = [ 'name' => $name, 'description' => wu_get_isset($explanation, 'description', __('No description found.', 'wp-ultimo')), 'optional' => ! wu_get_isset($explanation, 'required'), 'type' => 'assoc', - ); + ]; - $options = wu_get_isset($explanation, 'options', array()); + $options = wu_get_isset($explanation, 'options', []); if ($options) { $field['options'] = $options; @@ -146,39 +146,39 @@ trait WP_CLI { } } - if (in_array($sub_command, array('create', 'update'), true)) { - $sub_command_data['synopsis'][] = array( + if (in_array($sub_command, ['create', 'update'], true)) { + $sub_command_data['synopsis'][] = [ 'name' => 'porcelain', 'type' => 'flag', 'description' => __('Output just the id when the operation is successful.', 'wp-ultimo'), 'optional' => true, - ); + ]; } - if (in_array($sub_command, array('list', 'get'), true)) { - $sub_command_data['synopsis'][] = array( + if (in_array($sub_command, ['list', 'get'], true)) { + $sub_command_data['synopsis'][] = [ 'name' => 'format', 'type' => 'assoc', 'description' => __('Render response in a particular format.', 'wp-ultimo'), 'optional' => true, 'default' => 'table', - 'options' => array( + 'options' => [ 'table', 'json', 'csv', 'ids', 'yaml', 'count', - ), - ); + ], + ]; - $sub_command_data['synopsis'][] = array( + $sub_command_data['synopsis'][] = [ 'name' => 'fields', 'type' => 'assoc', 'description' => __('Limit response to specific fields. Defaults to id, name', 'wp-ultimo'), 'optional' => true, - 'options' => array_merge(array('id'), $params), - ); + 'options' => array_merge(['id'], $params), + ]; } } @@ -233,7 +233,7 @@ trait WP_CLI { * @param array $args Positional arguments passed. ID expected. * @param array $array_assoc Assoc arguments passed. */ - public function wp_cli_get_item($args, $array_assoc) { + public function wp_cli_get_item($args, $array_assoc): void { $item = $this->model_class::get_by_id($args[0]); @@ -256,7 +256,7 @@ trait WP_CLI { * @param array $args Positional arguments passed. ID expected. * @param array $array_assoc Assoc arguments passed. */ - public function wp_cli_get_items($args, $array_assoc) { + public function wp_cli_get_items($args, $array_assoc): void { $fields = (! empty($array_assoc['fields'])) ? $array_assoc['fields'] : $this->wp_cli_get_fields(); @@ -277,7 +277,7 @@ trait WP_CLI { * @param array $args Positional arguments passed. ID expected. * @param array $array_assoc Assoc arguments passed. */ - public function wp_cli_create_item($args, $array_assoc) { + public function wp_cli_create_item($args, $array_assoc): void { $item = new $this->model_class($array_assoc); @@ -306,7 +306,7 @@ trait WP_CLI { * @param array $args Positional arguments passed. ID expected. * @param array $array_assoc Assoc arguments passed. */ - public function wp_cli_update_item($args, $array_assoc) { + public function wp_cli_update_item($args, $array_assoc): void { $item = $this->model_class::get_by_id($args[0]); @@ -330,7 +330,7 @@ trait WP_CLI { if ($param === 'meta') { $item->update_meta_batch($value); } elseif (method_exists($item, $set_method)) { - call_user_func(array($item, $set_method), $value); + call_user_func([$item, $set_method], $value); } else { $error_message = sprintf( /* translators: 1. Object class name; 2. Set method name */ @@ -367,7 +367,7 @@ trait WP_CLI { * * @param array $args Positional arguments passed. ID expected. */ - public function wp_cli_delete_item($args) { + public function wp_cli_delete_item($args): void { $item = $this->model_class::get_by_id($args[0]); diff --git a/inc/builders/block-editor/class-block-editor-widget-manager.php b/inc/builders/block-editor/class-block-editor-widget-manager.php index 656f59b..2e0a96d 100644 --- a/inc/builders/block-editor/class-block-editor-widget-manager.php +++ b/inc/builders/block-editor/class-block-editor-widget-manager.php @@ -29,14 +29,14 @@ class Block_Editor_Widget_Manager { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { if (\WP_Ultimo\Compat\Gutenberg_Support::get_instance()->should_load()) { - add_action('wu_element_loaded', array($this, 'handle_element')); + add_action('wu_element_loaded', [$this, 'handle_element']); - add_action('init', array($this, 'register_scripts')); + add_action('init', [$this, 'register_scripts']); - add_action('wu_element_is_preview', array($this, 'is_block_preview')); + add_action('wu_element_is_preview', [$this, 'is_block_preview']); } } @@ -46,11 +46,11 @@ class Block_Editor_Widget_Manager { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { - \WP_Ultimo\Scripts::get_instance()->register_script('wu-blocks', wu_get_asset('blocks.js', 'js', 'inc/builders/block-editor/assets'), array('underscore', 'wp-blocks', 'wp-element', 'wp-components', 'wp-editor', 'wu-functions', 'wp-i18n', 'wp-polyfill')); + \WP_Ultimo\Scripts::get_instance()->register_script('wu-blocks', wu_get_asset('blocks.js', 'js', 'inc/builders/block-editor/assets'), ['underscore', 'wp-blocks', 'wp-element', 'wp-components', 'wp-editor', 'wu-functions', 'wp-i18n', 'wp-polyfill']); - $blocks = apply_filters('wu_blocks', array()); + $blocks = apply_filters('wu_blocks', []); wp_localize_script('wu-blocks', 'wu_blocks', $blocks); } @@ -79,7 +79,7 @@ class Block_Editor_Widget_Manager { * @param \WP_Ultimo\UI\Base_Element $element The element being registered. * @return void */ - public function handle_element($element) { + public function handle_element($element): void { if (wu_get_current_site()->get_type() === Site_Type::CUSTOMER_OWNED) { return; @@ -98,7 +98,7 @@ class Block_Editor_Widget_Manager { * @param \WP_Ultimo\UI\Base_Element $element The element being registered. * @return void */ - public function register_block($element) { + public function register_block($element): void { if (\WP_Block_Type_Registry::get_instance()->is_registered($element->get_id())) { return; @@ -108,11 +108,11 @@ class Block_Editor_Widget_Manager { register_block_type( $element->get_id(), - array( + [ 'attributes' => $attributes, 'editor_script' => 'wu-blocks', - 'render_callback' => \Closure::fromCallable(array($element, 'display')), - ) + 'render_callback' => \Closure::fromCallable([$element, 'display']), + ] ); } @@ -126,20 +126,20 @@ class Block_Editor_Widget_Manager { */ protected function consolidate_callables($fields) { - $callable_keys = array( + $callable_keys = [ 'options', 'value', - ); + ]; - $fields_to_ignore = array( + $fields_to_ignore = [ 'note', - ); + ]; foreach ($fields as $field_slug => &$field) { /* * Discard fields that are notes and start with _ */ - if (in_array($field['type'], $fields_to_ignore, true) && strncmp($field_slug, '_', strlen('_')) === 0) { + if (in_array($field['type'], $fields_to_ignore, true) && str_starts_with($field_slug, '_')) { unset($fields[ $field_slug ]); } @@ -184,13 +184,13 @@ class Block_Editor_Widget_Manager { $fields = $this->consolidate_callables($element->fields()); - $blocks[] = array( + $blocks[] = [ 'id' => $element->get_id(), 'title' => $element->get_title(), 'description' => $element->get_description(), 'fields' => $fields, 'keywords' => $element->keywords(), - ); + ]; return $blocks; } @@ -208,7 +208,7 @@ class Block_Editor_Widget_Manager { $defaults = $element->defaults(); - $_fields = array(); + $_fields = []; foreach ($fields as $field_id => $field) { $type = 'string'; @@ -223,10 +223,10 @@ class Block_Editor_Widget_Manager { $default_value = wu_get_isset($defaults, $field_id, ''); - $_fields[ $field_id ] = array( + $_fields[ $field_id ] = [ 'default' => wu_get_isset($field, 'value', $default_value), 'type' => $type, - ); + ]; } return $_fields; diff --git a/inc/checkout/class-cart.php b/inc/checkout/class-cart.php index 3ffd4c4..445c02b 100644 --- a/inc/checkout/class-cart.php +++ b/inc/checkout/class-cart.php @@ -179,7 +179,7 @@ class Cart implements \JsonSerializable { * @since 2.0.0 * @var \WP_Ultimo\Models\Product[] */ - protected $products = array(); + protected $products = []; /** * The cart recurring products. @@ -187,7 +187,7 @@ class Cart implements \JsonSerializable { * @since 2.0.0 * @var \WP_Ultimo\Models\Product[] */ - protected $recurring_products = array(); + protected $recurring_products = []; /** * The cart additional products. @@ -195,7 +195,7 @@ class Cart implements \JsonSerializable { * @since 2.0.0 * @var \WP_Ultimo\Models\Product[] */ - protected $additional_products = array(); + protected $additional_products = []; /** * Line item representation of the products. @@ -203,7 +203,7 @@ class Cart implements \JsonSerializable { * @since 2.0.0 * @var \WP_Ultimo\Checkout\Line_Item[] */ - protected $line_items = array(); + protected $line_items = []; /** * If this cart should auto-renew. @@ -227,7 +227,7 @@ class Cart implements \JsonSerializable { * @since 2.0.0 * @var array */ - protected $extra = array(); + protected $extra = []; /** * The cart description. @@ -255,7 +255,7 @@ class Cart implements \JsonSerializable { * this helps us to keep things cleaner and secure. */ $args = shortcode_atts( - array( + [ /* * Cart Type. @@ -265,7 +265,7 @@ class Cart implements \JsonSerializable { /* * The list of products being bought. */ - 'products' => array(), + 'products' => [], /* * The duration parameters @@ -309,7 +309,7 @@ class Cart implements \JsonSerializable { */ 'currency' => '', - ), + ], $args ); @@ -411,7 +411,7 @@ class Cart implements \JsonSerializable { * @param mixed $value The value to set. * @return void */ - public function set_param($key, $value) { + public function set_param($key, $value): void { $this->extra[] = $key; @@ -504,7 +504,7 @@ class Cart implements \JsonSerializable { $desc = wu_get_setting('company_name', __('Subscription', 'wp-ultimo')); - $products = array(); + $products = []; foreach ($this->get_line_items() as $line_item) { $product = $line_item->get_product(); @@ -529,7 +529,7 @@ class Cart implements \JsonSerializable { * @param string $descriptor The cart description. * @return void */ - public function set_cart_descriptor($descriptor) { + public function set_cart_descriptor($descriptor): void { $this->cart_descriptor = $descriptor; } @@ -568,7 +568,7 @@ class Cart implements \JsonSerializable { /* * Adds the country to calculate taxes. */ - $this->country = $this->country ? $this->country : ($this->customer ? $this->customer->get_country() : ''); + $this->country = ($this->country ?: $this->customer) ? $this->customer->get_country() : ''; /* * Set the currency in cart @@ -676,9 +676,9 @@ class Cart implements \JsonSerializable { */ $allowed_status = apply_filters( 'wu_cart_set_payment_allowed_status', - array( + [ 'pending', - ) + ] ); if ( ! in_array($payment->get_status(), $allowed_status, true)) { @@ -768,7 +768,7 @@ class Cart implements \JsonSerializable { /* * Adds the country to calculate taxes. */ - $this->country = $this->country ? $this->country : $this->customer->get_country(); + $this->country = $this->country ?: $this->customer->get_country(); /* * Set the currency in cart @@ -933,8 +933,8 @@ class Cart implements \JsonSerializable { * hev it here to prevent bugs. */ if ( ! $is_plan_change || ($this->get_plan_id() === $membership->get_plan_id() && $this->duration_unit === $membership->get_duration_unit() && $this->duration === $membership->get_duration())) { - $this->products = array(); - $this->line_items = array(); + $this->products = []; + $this->line_items = []; $this->errors->add('no_changes', __('This cart proposes no changes to the current membership.', 'wp-ultimo')); @@ -993,8 +993,8 @@ class Cart implements \JsonSerializable { } if ( ! $membership->is_free() && $old_price_per_day < $new_price_per_day && $days_in_old_cycle > $days_in_new_cycle && $membership->get_status() === Membership_Status::ACTIVE) { - $this->products = array(); - $this->line_items = array(); + $this->products = []; + $this->line_items = []; $description = sprintf( // translators: %1$s the duration, and %2$s the duration unit (day, week, month, etc) @@ -1023,7 +1023,7 @@ class Cart implements \JsonSerializable { if ($membership->is_active() || $membership->get_status() === Membership_Status::TRIALING) { $line_item_params = apply_filters( 'wu_checkout_credit_line_item_params', - array( + [ 'type' => 'credit', 'title' => __('Scheduled Swap Credit', 'wp-ultimo'), 'description' => __('Swap scheduled to next billing cycle.', 'wp-ultimo'), @@ -1031,7 +1031,7 @@ class Cart implements \JsonSerializable { 'taxable' => false, 'quantity' => 1, 'unit_price' => - $this->get_total(), - ) + ] ); $credit_line_item = new Line_Item($line_item_params); @@ -1061,28 +1061,28 @@ class Cart implements \JsonSerializable { protected function search_for_same_period_plans($plan_a, $plan_b) { if ($plan_a->get_duration_unit() === $plan_b->get_duration_unit() && $plan_a->get_duration() === $plan_b->get_duration()) { - return array( + return [ $plan_a, $plan_b, - ); + ]; } $plan_a_variation = $plan_a->get_as_variation($plan_b->get_duration(), $plan_b->get_duration_unit()); if ($plan_a_variation) { - return array( + return [ $plan_a_variation, $plan_b, - ); + ]; } $plan_b_variation = $plan_b->get_as_variation($plan_a->get_duration(), $plan_a->get_duration_unit()); if ($plan_b_variation) { - return array( + return [ $plan_a, $plan_b_variation, - ); + ]; } if ($this->duration_unit && $this->duration && ($this->duration_unit !== $plan_b->get_duration_unit() || $this->duration !== $plan_b->get_duration())) { @@ -1093,19 +1093,19 @@ class Cart implements \JsonSerializable { } if ($plan_b->get_duration_unit() === $plan_a_variation->get_duration_unit() && $plan_b->get_duration() === $plan_a_variation->get_duration()) { - return array( + return [ $plan_a_variation, $plan_b, - ); + ]; } $plan_b_variation = $plan_b->get_as_variation($this->duration, $this->duration_unit); if ($plan_b_variation) { - return array( + return [ $plan_a_variation, $plan_b_variation, - ); + ]; } } @@ -1175,7 +1175,7 @@ class Cart implements \JsonSerializable { if ($fee_credit > 0) { $new_line_item = new Line_Item( - array( + [ 'product' => $old_plan, 'type' => 'fee', 'description' => '--', @@ -1184,7 +1184,7 @@ class Cart implements \JsonSerializable { 'recurring' => false, 'unit_price' => $fee_credit, 'quantity' => 1, - ) + ] ); $new_line_item = $this->apply_taxes_to_item($new_line_item); @@ -1217,7 +1217,7 @@ class Cart implements \JsonSerializable { $line_item_params = apply_filters( 'wu_checkout_credit_line_item_params', - array( + [ 'type' => 'credit', 'title' => __('Credit', 'wp-ultimo'), 'description' => __('Prorated amount based on the previous membership.', 'wp-ultimo'), @@ -1225,7 +1225,7 @@ class Cart implements \JsonSerializable { 'taxable' => false, 'quantity' => 1, 'unit_price' => - $credit, - ) + ] ); /* @@ -1467,7 +1467,7 @@ class Cart implements \JsonSerializable { * @param \WP_Ultimo\Checkout\Line_Item $line_item The line item. * @return void */ - public function add_line_item($line_item) { + public function add_line_item($line_item): void { if ( ! is_a($line_item, '\WP_Ultimo\Checkout\Line_Item')) { return; @@ -1597,13 +1597,13 @@ class Cart implements \JsonSerializable { $line_item_data = apply_filters( 'wu_add_product_line_item', - array( + [ 'product' => $product, 'quantity' => $quantity, 'unit_price' => $amount, 'duration' => $duration, 'duration_unit' => $duration_unit, - ), + ], $product, $duration, $duration_unit, @@ -1666,7 +1666,7 @@ class Cart implements \JsonSerializable { */ $setup_fee_line_item = apply_filters( 'wu_add_product_setup_fee_line_item', - array( + [ 'product' => $product, 'type' => 'fee', 'description' => '--', @@ -1675,7 +1675,7 @@ class Cart implements \JsonSerializable { 'recurring' => false, 'unit_price' => $product->get_setup_fee(), 'quantity' => $quantity, - ), + ], $product, $this ); @@ -1697,7 +1697,7 @@ class Cart implements \JsonSerializable { $line_items = $this->line_items; - $tax_brackets = array(); + $tax_brackets = []; foreach ($line_items as $line_item) { $tax_bracket = $line_item->get_tax_rate(); @@ -1818,18 +1818,18 @@ class Cart implements \JsonSerializable { * @param array $where_clauses Additional where clauses for search. * @return \WP_Ultimo\Checkout\Line_Item[] */ - public function get_line_items_by_type($type = 'product', $where_clauses = array()): array { + public function get_line_items_by_type($type = 'product', $where_clauses = []): array { - $where_clauses[] = array('type', $type); + $where_clauses[] = ['type', $type]; // Cast to array recursively $line_items = json_decode(json_encode($this->line_items), true); $line_items = Array_Search::find( $line_items, - array( + [ 'where' => $where_clauses, - ) + ] ); $ids = array_keys($line_items); @@ -1958,10 +1958,10 @@ class Cart implements \JsonSerializable { $subtotal = 0; - $exclude_types = array( + $exclude_types = [ 'discount', 'credit', - ); + ]; foreach ($this->line_items as $line_item) { if (in_array($line_item->get_type(), $exclude_types, true)) { @@ -2037,9 +2037,9 @@ class Cart implements \JsonSerializable { $new_line_item = clone $line_item; $new_line_item->attributes( - array( + [ 'discount_rate' => 0, - ) + ] ); $new_line_item->recalculate_totals(); @@ -2230,21 +2230,21 @@ class Cart implements \JsonSerializable { } $line_item->attributes( - array( + [ 'discount_rate' => $this->discount_code->get_setup_fee_value(), 'discount_type' => $this->discount_code->get_setup_fee_type(), 'apply_discount_to_renewals' => false, 'discount_label' => strtoupper($this->discount_code->get_code()), - ) + ] ); } else { $line_item->attributes( - array( + [ 'discount_rate' => $this->discount_code->get_value(), 'discount_type' => $this->discount_code->get_type(), 'apply_discount_to_renewals' => $this->discount_code->should_apply_to_renewals(), 'discount_label' => strtoupper($this->discount_code->get_code()), - ) + ] ); } @@ -2301,13 +2301,13 @@ class Cart implements \JsonSerializable { } $line_item->attributes( - array( + [ 'tax_rate' => $tax_rate ?? 0, 'tax_type' => $tax_type ?? 'percentage', 'tax_label' => $tax_label ?? '', 'tax_inclusive' => wu_get_setting('inclusive_tax', false), 'tax_exempt' => $this->is_tax_exempt(), - ) + ] ); $line_item->recalculate_totals(); @@ -2323,17 +2323,17 @@ class Cart implements \JsonSerializable { */ public function calculate_totals() { - return (object) array( - 'recurring' => (object) array( + return (object) [ + 'recurring' => (object) [ 'subtotal' => $this->get_recurring_subtotal(), 'total' => $this->get_recurring_total(), - ), + ], 'subtotal' => $this->get_subtotal(), 'total_taxes' => $this->get_total_taxes(), 'total_fees' => $this->get_total_fees(), 'total_discounts' => $this->get_total_discounts(), 'total' => $this->get_total(), - ); + ]; } /** @@ -2355,7 +2355,7 @@ class Cart implements \JsonSerializable { */ public function get_extra_params() { - $extra_params = array(); + $extra_params = []; foreach ($this->extra as $key) { $extra_params[ $key ] = $this->get_param($key); @@ -2374,20 +2374,20 @@ class Cart implements \JsonSerializable { $totals = $this->calculate_totals(); - $errors = array(); + $errors = []; if ($this->errors->has_errors()) { foreach ($this->errors as $code => $messages) { foreach ($messages as $message) { - $errors[] = array( + $errors[] = [ 'code' => $code, 'message' => $message, - ); + ]; } } } - return (object) array( + return (object) [ 'errors' => $errors, 'url' => $this->get_cart_url(), @@ -2407,12 +2407,12 @@ class Cart implements \JsonSerializable { 'extra' => $this->get_extra_params(), - 'dates' => (object) array( + 'dates' => (object) [ 'date_trial_end' => $this->get_billing_start_date(), 'date_next_charge' => $this->get_billing_next_charge_date(), - ), + ], - ); + ]; } /** @@ -2423,23 +2423,23 @@ class Cart implements \JsonSerializable { */ public function to_membership_data() { - $membership_data = array(); + $membership_data = []; $all_additional_products = $this->get_line_items_by_type( 'product', - array( - array('product_id', '!=', $this->get_plan_id()), - ) + [ + ['product_id', '!=', $this->get_plan_id()], + ] ); - $addon_list = array(); + $addon_list = []; foreach ($all_additional_products as $line_item) { $addon_list[ $line_item->get_product_id() ] = $line_item->get_quantity(); } $membership_data = array_merge( - array( + [ 'recurring' => $this->has_recurring(), 'plan_id' => $this->get_plan() ? $this->get_plan()->get_id() : 0, 'initial_amount' => $this->get_total(), @@ -2452,7 +2452,7 @@ class Cart implements \JsonSerializable { 'billing_cycles' => $this->get_plan() ? $this->get_plan()->get_billing_cycles() : 0, 'auto_renew' => false, // @todo: revisit 'upgraded_from' => false, // @todo: revisit - ) + ] ); return $membership_data; @@ -2466,10 +2466,10 @@ class Cart implements \JsonSerializable { */ public function to_payment_data() { - $payment_data = array(); + $payment_data = []; // Creates the pending payment - $payment_data = array( + $payment_data = [ 'status' => 'pending', 'tax_total' => $this->get_total_taxes(), 'fees' => $this->get_total_fees(), @@ -2478,7 +2478,7 @@ class Cart implements \JsonSerializable { 'discount_code' => $this->get_discount_code() ? $this->get_discount_code()->get_code() : '', 'subtotal' => $this->get_subtotal(), 'total' => $this->get_total(), - ); + ]; return $payment_data; } @@ -2523,7 +2523,7 @@ class Cart implements \JsonSerializable { * @param mixed $currency The currency code. * @return void */ - public function set_currency($currency) { + public function set_currency($currency): void { $this->currency = $currency; } @@ -2568,7 +2568,7 @@ class Cart implements \JsonSerializable { * @param \WP_Ultimo\Models\Membership $membership A valid membership object. * @return void */ - public function set_membership($membership) { + public function set_membership($membership): void { $this->membership = $membership; } @@ -2580,7 +2580,7 @@ class Cart implements \JsonSerializable { * @param \WP_Ultimo\Models\Customer $customer A valid customer object. * @return void */ - public function set_customer($customer) { + public function set_customer($customer): void { $this->customer = $customer; } @@ -2592,7 +2592,7 @@ class Cart implements \JsonSerializable { * @param \WP_Ultimo\Models\Payment $payment A valid payment object. * @return void */ - public function set_payment($payment) { + public function set_payment($payment): void { $this->payment = $payment; } @@ -2637,7 +2637,7 @@ class Cart implements \JsonSerializable { * @param string $country The country of the customer. * @return void */ - public function set_country($country) { + public function set_country($country): void { $this->country = $country; } @@ -2668,7 +2668,7 @@ class Cart implements \JsonSerializable { $all_products = $this->products; - $products_list = array(); + $products_list = []; foreach ($all_products as $product) { if ($product->get_id() !== $this->plan_id) { @@ -2677,9 +2677,9 @@ class Cart implements \JsonSerializable { } return add_query_arg( - array( + [ 'products' => $products_list, - ), + ], $base_url ); } diff --git a/inc/checkout/class-checkout-pages.php b/inc/checkout/class-checkout-pages.php index ea25e95..b0831c8 100644 --- a/inc/checkout/class-checkout-pages.php +++ b/inc/checkout/class-checkout-pages.php @@ -27,18 +27,18 @@ class Checkout_Pages { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - add_filter('display_post_states', array($this, 'add_wp_ultimo_status_annotation'), 10, 2); + add_filter('display_post_states', [$this, 'add_wp_ultimo_status_annotation'], 10, 2); - add_action('wu_thank_you_site_block', array($this, 'add_verify_email_notice'), 10, 3); + add_action('wu_thank_you_site_block', [$this, 'add_verify_email_notice'], 10, 3); - add_shortcode('wu_confirmation', array($this, 'render_confirmation_page')); + add_shortcode('wu_confirmation', [$this, 'render_confirmation_page']); - add_filter('lostpassword_redirect', array($this, 'filter_lost_password_redirect')); + add_filter('lostpassword_redirect', [$this, 'filter_lost_password_redirect']); if (is_main_site()) { - add_action('before_signup_header', array($this, 'redirect_to_registration_page')); + add_action('before_signup_header', [$this, 'redirect_to_registration_page']); $use_custom_login = wu_get_setting('enable_custom_login_page', false); @@ -46,30 +46,30 @@ class Checkout_Pages { return; } - add_filter('login_url', array($this, 'filter_login_url'), 10, 3); + add_filter('login_url', [$this, 'filter_login_url'], 10, 3); - add_filter('lostpassword_url', array($this, 'filter_login_url'), 10, 3); + add_filter('lostpassword_url', [$this, 'filter_login_url'], 10, 3); - add_filter('retrieve_password_message', array($this, 'replace_reset_password_link'), 10, 4); + add_filter('retrieve_password_message', [$this, 'replace_reset_password_link'], 10, 4); - add_filter('network_site_url', array($this, 'maybe_change_wp_login_on_urls')); + add_filter('network_site_url', [$this, 'maybe_change_wp_login_on_urls']); - add_action('login_init', array($this, 'maybe_obfuscate_login_url'), 9); + add_action('login_init', [$this, 'maybe_obfuscate_login_url'], 9); - add_action('template_redirect', array($this, 'maybe_redirect_to_admin_panel')); + add_action('template_redirect', [$this, 'maybe_redirect_to_admin_panel']); - add_action('after_password_reset', array($this, 'maybe_redirect_to_confirm_screen')); + add_action('after_password_reset', [$this, 'maybe_redirect_to_confirm_screen']); - add_action('lost_password', array($this, 'maybe_handle_password_reset_errors')); + add_action('lost_password', [$this, 'maybe_handle_password_reset_errors']); - add_action('validate_password_reset', array($this, 'maybe_handle_password_reset_errors')); + add_action('validate_password_reset', [$this, 'maybe_handle_password_reset_errors']); /** * Adds the force elements controls. */ - add_action('post_submitbox_misc_actions', array($this, 'render_compat_mode_setting')); + add_action('post_submitbox_misc_actions', [$this, 'render_compat_mode_setting']); - add_action('save_post', array($this, 'handle_compat_mode_setting')); + add_action('save_post', [$this, 'handle_compat_mode_setting']); } } @@ -95,7 +95,7 @@ class Checkout_Pages { * @since 2.0.0 * @return void */ - public function render_compat_mode_setting() { + public function render_compat_mode_setting(): void { $post_id = get_the_ID(); @@ -129,7 +129,7 @@ class Checkout_Pages { * @param int $post_id The id of the post being saved. * @return void */ - public function handle_compat_mode_setting($post_id) { + public function handle_compat_mode_setting($post_id): void { if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return; @@ -163,7 +163,7 @@ class Checkout_Pages { * Only perform computational-heavy tasks if the URL has * wp-login.php in it to begin with. */ - if (strpos($url, 'wp-login.php') === false) { + if (! str_contains($url, 'wp-login.php')) { return $url; } @@ -189,7 +189,7 @@ class Checkout_Pages { */ public function get_error_message($error_code, $username = '') { - $messages = array( + $messages = [ 'incorrect_password' => sprintf(__('Error: The password you entered is incorrect.', 'wp-ultimo')), // From here we are using the same messages as WordPress core. 'expired' => __('Your session has expired. Please log in to continue where you left off.'), @@ -206,7 +206,7 @@ class Checkout_Pages { 'password_reset_mismatch' => __('Error: The passwords do not match.'), 'invalidkey' => __('Error: Your password reset link appears to be invalid. Please request a new link below.'), 'expiredkey' => __('Error: Your password reset link has expired. Please request a new link below.'), - ); + ]; /** * Filter the error messages. @@ -231,15 +231,15 @@ class Checkout_Pages { * @param \WP_Error $errors The error object. * @return void */ - public function maybe_handle_password_reset_errors($errors) { + public function maybe_handle_password_reset_errors($errors): void { if ($errors->has_errors()) { $url = add_query_arg( - array( + [ 'action' => wu_request('action', ''), 'user_login' => wu_request('user_login', ''), 'error' => $errors->get_error_code(), - ), + ], wp_login_url() ); @@ -260,7 +260,7 @@ class Checkout_Pages { * @since 2.0.0 * @return void */ - public function maybe_redirect_to_confirm_screen() { + public function maybe_redirect_to_confirm_screen(): void { if (wu_request('redirect_to')) { wp_redirect(wu_request('redirect_to')); @@ -286,7 +286,7 @@ class Checkout_Pages { return $message; } - $results = array(); + $results = []; preg_match_all('/.*\/wp-login\.php.*/', $message, $results); @@ -300,12 +300,12 @@ class Checkout_Pages { $switched_locale = switch_to_locale($locale); $new_url = add_query_arg( - array( + [ 'action' => 'rp', 'key' => $key, 'login' => rawurlencode($user_login), 'wp_lang' => $locale, - ), + ], wp_login_url() ); @@ -327,7 +327,7 @@ class Checkout_Pages { * @since 2.0.0 * @return void */ - public function maybe_redirect_to_admin_panel() { + public function maybe_redirect_to_admin_panel(): void { global $post; @@ -356,14 +356,14 @@ class Checkout_Pages { */ $exclusion_list = apply_filters( 'wu_maybe_redirect_to_admin_panel_exclusion_list', - array( + [ 'preview', // WordPress Preview 'ct_builder', // Oxygen Builder 'fl_builder', // Beaver Builder 'elementor-preview', // Elementor 'brizy-edit', // Brizy 'brizy-edit-iframe', // Brizy - ), + ], $custom_login_page, $post, $this @@ -410,7 +410,7 @@ class Checkout_Pages { * @param \WP_Ultimo\Models\Customer $customer the current customer. * @return void */ - public function add_verify_email_notice($payment, $membership, $customer) { + public function add_verify_email_notice($payment, $membership, $customer): void { if ($payment->get_total() == 0 && $customer->get_email_verification() === 'pending') { $html = '
%s
'; @@ -429,7 +429,7 @@ class Checkout_Pages { * @since 2.0.0 * @return void */ - public function maybe_obfuscate_login_url() { + public function maybe_obfuscate_login_url(): void { $use_custom_login = wu_get_setting('enable_custom_login_page', false); @@ -484,7 +484,7 @@ class Checkout_Pages { * @since 2.0.0 * @return void */ - public function redirect_to_registration_page() { + public function redirect_to_registration_page(): void { $registration_url = $this->get_page_url('register'); @@ -520,7 +520,7 @@ class Checkout_Pages { return $login_url; } - $params = array(); + $params = []; $old_url_params = wp_parse_url($login_url, PHP_URL_QUERY); @@ -555,13 +555,13 @@ class Checkout_Pages { */ public function get_signup_pages() { - return array( + return [ 'register' => wu_guess_registration_page(), 'update' => wu_get_setting('default_update_page', false), 'login' => wu_get_setting('default_login_page', false), 'block_frontend' => wu_get_setting('default_block_frontend_page', false), 'new_site' => wu_get_setting('default_new_site_page', false), - ); + ]; } /** * Returns the WP_Post object for one of the pages. @@ -617,13 +617,13 @@ class Checkout_Pages { return $states; } - $labels = array( + $labels = [ 'register' => __('WP Multisite WaaS - Register Page', 'wp-ultimo'), 'login' => __('WP Multisite WaaS - Login Page', 'wp-ultimo'), 'block_frontend' => __('WP Multisite WaaS - Site Blocked Page', 'wp-ultimo'), 'update' => __('WP Multisite WaaS - Membership Update Page', 'wp-ultimo'), 'new_site' => __('WP Multisite WaaS - New Site Page', 'wp-ultimo'), - ); + ]; $pages = array_map('absint', $this->get_signup_pages()); @@ -649,10 +649,10 @@ class Checkout_Pages { return wu_get_template_contents( 'checkout/confirmation', - array( + [ 'errors' => Checkout::get_instance()->errors, 'membership' => wu_get_membership_by_hash(wu_request('membership')), - ) + ] ); } } diff --git a/inc/checkout/class-checkout.php b/inc/checkout/class-checkout.php index 98c439b..9c80c2c 100644 --- a/inc/checkout/class-checkout.php +++ b/inc/checkout/class-checkout.php @@ -159,44 +159,44 @@ class Checkout { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { /* * Setup and handle checkout */ - add_action('wu_setup_checkout', array($this, 'setup_checkout')); + add_action('wu_setup_checkout', [$this, 'setup_checkout']); - add_action('wu_setup_checkout', array($this, 'maybe_process_checkout'), 20); + add_action('wu_setup_checkout', [$this, 'maybe_process_checkout'], 20); /* * Add the rewrite rules. */ - add_action('init', array($this, 'add_rewrite_rules'), 20); + add_action('init', [$this, 'add_rewrite_rules'], 20); - add_filter('wu_request', array($this, 'get_checkout_from_query_vars'), 10, 2); + add_filter('wu_request', [$this, 'get_checkout_from_query_vars'], 10, 2); /* * Creates the order object to display to the customer */ - add_action('wu_ajax_wu_create_order', array($this, 'create_order')); + add_action('wu_ajax_wu_create_order', [$this, 'create_order']); - add_action('wu_ajax_nopriv_wu_create_order', array($this, 'create_order')); + add_action('wu_ajax_nopriv_wu_create_order', [$this, 'create_order']); /* * Validates form and process preflight. */ - add_action('wu_ajax_wu_validate_form', array($this, 'maybe_handle_order_submission')); + add_action('wu_ajax_wu_validate_form', [$this, 'maybe_handle_order_submission']); - add_action('wu_ajax_nopriv_wu_validate_form', array($this, 'maybe_handle_order_submission')); + add_action('wu_ajax_nopriv_wu_validate_form', [$this, 'maybe_handle_order_submission']); /* * Adds the necessary scripts */ - add_action('wu_checkout_scripts', array($this, 'register_scripts')); + add_action('wu_checkout_scripts', [$this, 'register_scripts']); /* * Errors */ - add_action('wu_checkout_errors', array($this, 'maybe_display_checkout_errors')); + add_action('wu_checkout_errors', [$this, 'maybe_display_checkout_errors']); } /** @@ -213,7 +213,7 @@ class Checkout { * @since 2.0.0 * @return void */ - public function add_rewrite_rules() { + public function add_rewrite_rules(): void { $register = Checkout_Pages::get_instance()->get_signup_page('register'); @@ -297,13 +297,13 @@ class Checkout { $cart_arguments = apply_filters( 'wu_get_checkout_from_query_vars', - array( + [ 'products', 'duration', 'duration_unit', 'template_id', 'wu_preselected', - ) + ] ); /** @@ -345,7 +345,7 @@ class Checkout { * @param \WP_Ultimo\UI\Checkout_Element $element The checkout element. * @return void */ - public function setup_checkout($element = null) { + public function setup_checkout($element = null): void { if ($this->already_setup) { return; @@ -362,7 +362,7 @@ class Checkout { if ( ! $checkout_form_slug && is_a($element, \WP_Ultimo\UI\Checkout_Element::class)) { $pre_loaded_checkout_form_slug = $element->get_pre_loaded_attribute('slug', $checkout_form_slug); - $checkout_form_slug = $pre_loaded_checkout_form_slug ? $pre_loaded_checkout_form_slug : $checkout_form_slug; + $checkout_form_slug = $pre_loaded_checkout_form_slug ?: $checkout_form_slug; } $this->checkout_form = wu_get_checkout_form_by_slug($checkout_form_slug); @@ -382,7 +382,7 @@ class Checkout { $this->step = $this->checkout_form->get_step($this->step_name, true); - $this->step['fields'] ??= array(); + $this->step['fields'] ??= []; $this->auto_submittable_field = $this->contains_auto_submittable_field($this->step['fields']); @@ -408,19 +408,19 @@ class Checkout { */ public function contains_auto_submittable_field($fields) { - $relevant_fields = array(); + $relevant_fields = []; - $field_types_to_ignore = array( + $field_types_to_ignore = [ 'hidden', 'products', 'submit_button', 'period_selection', 'steps', - ); + ]; // Extra check to prevent error messages from being displayed. if ( ! is_array($fields)) { - $fields = array(); + $fields = []; } foreach ($fields as $field) { @@ -457,10 +457,10 @@ class Checkout { * while the value should be the parameter we should watch for changes * so we can submit the form when we detect one. */ - $auto_submittable_fields = array( + $auto_submittable_fields = [ 'template_selection' => 'template_id', 'pricing_table' => 'products', - ); + ]; return apply_filters('wu_checkout_get_auto_submittable_fields', $auto_submittable_fields, $this); } @@ -471,7 +471,7 @@ class Checkout { * @since 2.0.0 * @return void */ - public function maybe_handle_order_submission() { + public function maybe_handle_order_submission(): void { $this->setup_checkout(); @@ -484,7 +484,7 @@ class Checkout { wp_send_json_error($validation); } - wp_send_json_success(array()); + wp_send_json_success([]); } } @@ -498,7 +498,7 @@ class Checkout { * @since 2.0.0 * @return void */ - public function handle_order_submission() { + public function handle_order_submission(): void { global $wpdb; @@ -545,7 +545,7 @@ class Checkout { $wpdb->query('COMMIT'); - $this->session->set('signup', array()); + $this->session->set('signup', []); $this->session->commit(); wp_send_json_success($results); @@ -589,8 +589,8 @@ class Checkout { $cart = new Cart( apply_filters( 'wu_cart_parameters', - array( - 'products' => $this->request_or_session('products', array()), + [ + 'products' => $this->request_or_session('products', []), 'discount_code' => $this->request_or_session('discount_code'), 'country' => $this->request_or_session('billing_country'), 'state' => $this->request_or_session('billing_state'), @@ -601,7 +601,7 @@ class Checkout { 'duration' => $this->request_or_session('duration'), 'duration_unit' => $this->request_or_session('duration_unit'), 'cart_type' => $this->request_or_session('cart_type', 'new'), - ), + ], $this ) ); @@ -684,7 +684,7 @@ class Checkout { /* * Handles display names, if needed. */ - add_filter('pre_user_display_name', array($this, 'handle_display_name')); + add_filter('pre_user_display_name', [$this, 'handle_display_name']); /* * If we get to this point, most of the validations are done. @@ -834,7 +834,7 @@ class Checkout { $gateway->trigger_payment_processed($this->payment, $this->membership); } - $success_data = array( + $success_data = [ 'nonce' => wp_create_nonce('wp-ultimo-register-nonce'), 'customer' => $this->customer->to_search_results(), 'total' => $this->order->get_total(), @@ -843,11 +843,11 @@ class Checkout { 'payment_id' => $this->payment->get_id(), 'cart_type' => $this->order->get_cart_type(), 'auto_renew' => $this->order->should_auto_renew(), - 'gateway' => array( + 'gateway' => [ 'slug' => $gateway->get_id(), - 'data' => array(), - ), - ); + 'data' => [], + ], + ]; /* * Let's the gateway do its thing. @@ -862,7 +862,7 @@ class Checkout { /* * Attach the gateway results to the return array. */ - $success_data['gateway']['data'] = $result && is_array($result) ? $result : array(); + $success_data['gateway']['data'] = $result && is_array($result) ? $result : []; /* * On error, bail. @@ -941,24 +941,24 @@ class Checkout { * * Next step then would be to create one. */ - $customer_data = array( + $customer_data = [ 'username' => $username, 'email' => $this->request_or_session('email_address'), 'password' => $this->request_or_session('password'), 'email_verification' => $this->get_customer_email_verification_status(), 'signup_form' => $form_slug, - 'meta' => array(), - ); + 'meta' => [], + ]; /* * If the user is logged in, * we use the existing email address to create the customer. */ if ($this->is_existing_user()) { - $customer_data = array( + $customer_data = [ 'email' => wp_get_current_user()->user_email, 'email_verification' => 'verified', - ); + ]; } elseif (isset($customer_data['email']) && get_user_by('email', $customer_data['email'])) { return new \WP_Error('email_exists', __('The email address you entered is already in use.', 'wp-ultimo')); } @@ -993,7 +993,7 @@ class Checkout { * class, so there's no problem in passing * the entire post array in here. */ - $session = $this->session->get('signup') ?? array(); + $session = $this->session->get('signup') ?? []; $billing_address->attributes(array_merge($session, $_POST)); /* @@ -1068,7 +1068,7 @@ class Checkout { if ($checkout_form) { $customer_meta_fields = $checkout_form->get_all_meta_fields('customer_meta'); - $meta_repository = array(); + $meta_repository = []; foreach ($customer_meta_fields as $customer_meta_field) { /* @@ -1106,7 +1106,7 @@ class Checkout { $user = $customer->get_user(); - $user_meta_repository = array(); + $user_meta_repository = []; foreach ($user_meta_fields as $user_meta_field) { /* @@ -1239,7 +1239,7 @@ class Checkout { if ($auto_generate_url === 'username') { $site_url = $this->customer->get_username(); - $site_title = $site_title ? $site_title : $site_url; + $site_title = $site_title ?: $site_url; } else { $site_url = strtolower(str_replace(' ', '', preg_replace('/&([a-z])[a-z]+;/i', '$1', htmlentities(trim((string) $site_title))))); } @@ -1278,7 +1278,7 @@ class Checkout { * that way we can use it when actually registering * the site on WordPress. */ - $transient = array(); + $transient = []; if ($this->checkout_form) { $site_meta_fields = $this->checkout_form->get_all_fields(); @@ -1289,7 +1289,7 @@ class Checkout { * to make sure plain passwords do not get stored * on the database. */ - if (strpos((string) $site_meta_field['id'], 'password') !== false ) { + if (str_contains((string) $site_meta_field['id'], 'password') ) { continue; } @@ -1310,7 +1310,7 @@ class Checkout { */ $template_id = apply_filters('wu_checkout_template_id', (int) $this->request_or_session('template_id'), $this->membership, $this); - $site_data = array( + $site_data = [ 'domain' => $d->domain, 'path' => $d->path, 'title' => $site_title, @@ -1321,7 +1321,7 @@ class Checkout { 'signup_options' => $this->get_site_meta_fields($form_slug, 'site_option'), 'signup_meta' => $this->get_site_meta_fields($form_slug, 'site_meta'), 'type' => Site_Type::CUSTOMER_OWNED, - ); + ]; $pending_site = $this->membership->create_pending_site($site_data); @@ -1340,12 +1340,12 @@ class Checkout { protected function get_site_meta_fields($form_slug, $meta_type = 'site_meta') { if (empty($form_slug) || $form_slug === 'none') { - return array(); + return []; } $checkout_form = wu_get_checkout_form_by_slug($form_slug); - $list = array(); + $list = []; if ($checkout_form) { $site_meta_fields = $checkout_form->get_all_meta_fields($meta_type); @@ -1389,11 +1389,11 @@ class Checkout { */ $previous_payment = $this->membership->get_last_pending_payment(); - $cancel_types = array( + $cancel_types = [ 'upgrade', 'downgrade', 'addon', - ); + ]; if ($previous_payment && in_array($this->type, $cancel_types, true)) { $previous_payment->set_status(Payment_Status::CANCELLED); @@ -1444,12 +1444,12 @@ class Checkout { */ if ($this->order->has_trial()) { $payment->attributes( - array( + [ 'tax_total' => 0, 'subtotal' => 0, 'refund_total' => 0, 'total' => 0, - ) + ] ); $payment->save(); @@ -1464,7 +1464,7 @@ class Checkout { * @since 2.0.0 * @return void */ - public function validate_form() { + public function validate_form(): void { $validation = $this->validate(); @@ -1481,7 +1481,7 @@ class Checkout { * @since 2.0.0 * @return void */ - public function create_order() { + public function create_order(): void { $this->setup_checkout(); @@ -1493,8 +1493,8 @@ class Checkout { $cart = new Cart( apply_filters( 'wu_cart_parameters', - array( - 'products' => $this->request_or_session('products', array()), + [ + 'products' => $this->request_or_session('products', []), 'discount_code' => $this->request_or_session('discount_code'), 'country' => $country, 'state' => $state, @@ -1505,7 +1505,7 @@ class Checkout { 'duration' => $this->request_or_session('duration'), 'duration_unit' => $this->request_or_session('duration_unit'), 'cart_type' => $this->request_or_session('cart_type', 'new'), - ), + ], $this ) ); @@ -1518,15 +1518,15 @@ class Checkout { $country_data = wu_get_country($cart->get_country()); wp_send_json_success( - array( + [ 'order' => $cart->done(), 'states' => wu_key_map_to_array($country_data->get_states_as_options(), 'code', 'name'), 'cities' => wu_key_map_to_array($country_data->get_cities_as_options($state), 'code', 'name'), - 'labels' => array( + 'labels' => [ 'state_field' => $country_data->get_administrative_division_name(null, true), 'city_field' => $country_data->get_municipality_name(null, true), - ), - ) + ], + ] ); } @@ -1543,11 +1543,11 @@ class Checkout { /* * Localized strings. */ - $i18n = array( + $i18n = [ 'loading' => __('Loading...', 'wp-ultimo'), 'added_to_order' => __('The item was added!', 'wp-ultimo'), 'weak_password' => __('The Password entered is too weak.', 'wp-ultimo'), - ); + ]; /* * Get the default gateway. @@ -1579,14 +1579,14 @@ class Checkout { } } - $products = array_merge($this->request_or_session('products', array()), wu_request('products', array())); + $products = array_merge($this->request_or_session('products', []), wu_request('products', [])); $geolocation = \WP_Ultimo\Geolocation::geolocate_ip('', true); /* * Set the default variables. */ - $variables = array( + $variables = [ 'i18n' => $i18n, 'ajaxurl' => wu_ajax_url(), 'late_ajaxurl' => wu_ajax_url('init'), @@ -1603,7 +1603,7 @@ class Checkout { 'needs_billing_info' => true, 'auto_renew' => true, 'products' => array_unique($products), - ); + ]; /* * There's a couple of things we need to determine. @@ -1651,7 +1651,7 @@ class Checkout { $variables['membership_id'] = $membership_id; } - list($plan, $other_products) = wu_segregate_products($variables['products']); + [$plan, $other_products] = wu_segregate_products($variables['products']); $variables['plan'] = $plan ? $plan->get_id() : 0; @@ -1700,7 +1700,7 @@ class Checkout { * * First, let's set upm the general rules: */ - $rules = array( + $rules = [ 'email_address' => 'required_without:user_id|email|unique:\WP_User,email', 'username' => 'required_without:user_id|alpha_dash|min:4|lowercase|unique:\WP_User,login', 'password' => 'required_without:user_id|min:6', @@ -1713,7 +1713,7 @@ class Checkout { 'billing_zip_code' => 'required_with:billing_zip_code', 'billing_state' => 'state', 'billing_city' => 'city', - ); + ]; /* * Add rules for site when creating a new account. @@ -1745,7 +1745,7 @@ class Checkout { $validation_rules = $this->validation_rules(); if (wu_request('pre-flight') || wu_request('checkout_form') === 'wu-finish-checkout') { - $validation_rules = array(); + $validation_rules = []; return $validation_rules; } @@ -1764,10 +1764,10 @@ class Checkout { } // We'll use this to validate product fields - $product_fields = array( + $product_fields = [ 'pricing_table', 'products', - ); + ]; /** * Add the additional required fields. @@ -1825,9 +1825,9 @@ class Checkout { $rules = $this->get_validation_rules(); } - $base_aliases = array(); + $base_aliases = []; - $checkout_form_fields = $this->checkout_form ? $this->checkout_form->get_all_fields() : array(); + $checkout_form_fields = $this->checkout_form ? $this->checkout_form->get_all_fields() : []; // Add current form fields foreach ($checkout_form_fields as $field) { @@ -1841,13 +1841,13 @@ class Checkout { // Add some hidden or compound fields ids $validation_aliases = array_merge( - array( + [ 'password_conf' => __('Password confirmation', 'wp-ultimo'), 'template_id' => __('Template ID', 'wp-ultimo'), 'valid_password' => __('Valid password', 'wp-ultimo'), 'products' => __('Products', 'wp-ultimo'), 'gateway' => __('Payment Gateway', 'wp-ultimo'), - ), + ], $base_aliases ); @@ -1885,7 +1885,7 @@ class Checkout { * @since 2.0.0 * @return void */ - public function maybe_process_checkout() { + public function maybe_process_checkout(): void { /* * Sets up the checkout * environment. @@ -1944,10 +1944,10 @@ class Checkout { */ if ($payment) { $redirect_url = add_query_arg( - array( + [ 'payment' => $payment->get_hash(), 'status' => 'error', - ), + ], $redirect_url ); } @@ -1973,11 +1973,11 @@ class Checkout { * have checkout_ on their name, or start * with a underscore. */ - $to_save = array_filter($_POST, fn($item) => strncmp((string) $item, 'checkout_', strlen('checkout_')) !== 0 && strncmp((string) $item, '_', strlen('_')) !== 0, ARRAY_FILTER_USE_KEY); + $to_save = array_filter($_POST, fn($item) => ! str_starts_with((string) $item, 'checkout_') && ! str_starts_with((string) $item, '_'), ARRAY_FILTER_USE_KEY); if (isset($to_save['pre-flight'])) { unset($to_save['pre-flight']); - $this->session->add_values('signup', array('pre_selected' => $to_save)); + $this->session->add_values('signup', ['pre_selected' => $to_save]); } /* @@ -2119,12 +2119,12 @@ class Checkout { if (has_action('wp_ultimo_registration')) { $_payment = wu_get_payment($payment->get_id()); - $args = array( + $args = [ 0, // Site ID is not yet available at this point $customer->get_user_id(), $this->session->get('signup'), $_payment && $_payment->get_membership() ? new \WU_Plan($_payment->get_membership()->get_plan()) : false, - ); + ]; ob_start(); @@ -2152,10 +2152,10 @@ class Checkout { $redirect_url = apply_filters('wp_ultimo_redirect_url_after_signup', $redirect_url, 0, get_current_user_id(), $_POST); $redirect_url = add_query_arg( - array( + [ 'payment' => $payment ? $payment->get_hash() : 'none', 'status' => 'done', - ), + ], $redirect_url ); } @@ -2174,10 +2174,10 @@ class Checkout { return new \WP_Error( 'error', $e->getMessage(), - array( + [ 'trace' => $e->getTrace(), 'payment' => $payment, - ) + ] ); } } @@ -2254,7 +2254,7 @@ class Checkout { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { $custom_css = apply_filters('wu_checkout_custom_css', ''); @@ -2264,7 +2264,7 @@ class Checkout { wp_enqueue_style('wu-admin'); - wp_register_script('wu-checkout', wu_get_asset('checkout.js', 'js'), array('jquery-core', 'wu-vue', 'moment', 'wu-block-ui', 'wu-functions', 'password-strength-meter', 'underscore', 'wp-polyfill', 'wp-hooks', 'wu-cookie-helpers'), wu_get_version(), true); + wp_register_script('wu-checkout', wu_get_asset('checkout.js', 'js'), ['jquery-core', 'wu-vue', 'moment', 'wu-block-ui', 'wu-functions', 'password-strength-meter', 'underscore', 'wp-polyfill', 'wp-hooks', 'wu-cookie-helpers'], wu_get_version(), true); wp_localize_script('wu-checkout', 'wu_checkout', $this->get_checkout_variables()); @@ -2326,7 +2326,7 @@ class Checkout { $index = $current_step_index + 1; - return isset($keys[ $index ]) ? $keys[ $index ] : $keys[ $current_step_index ]; + return $keys[ $index ] ?? $keys[ $current_step_index ]; } /** @@ -2390,7 +2390,7 @@ class Checkout { * @since 2.0.0 * @return void */ - public function maybe_display_checkout_errors() { + public function maybe_display_checkout_errors(): void { if (wu_request('status') !== 'error') { return; diff --git a/inc/checkout/class-legacy-checkout.php b/inc/checkout/class-legacy-checkout.php index 20f48c8..affa119 100644 --- a/inc/checkout/class-legacy-checkout.php +++ b/inc/checkout/class-legacy-checkout.php @@ -90,26 +90,26 @@ class Legacy_Checkout { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { $this->session = wu_get_session('signup'); - $this->templates = array( + $this->templates = [ 'signup-main.php' => __('WP Multisite WaaS Legacy Signup', 'wp-ultimo'), - ); + ]; // add_filter('request', array($this, 'maybe_render_legacy_signup')); - add_action('wu_signup_enqueue_scripts', array($this, 'register_scripts')); + add_action('wu_signup_enqueue_scripts', [$this, 'register_scripts']); - add_filter('theme_page_templates', array($this, 'add_new_template')); + add_filter('theme_page_templates', [$this, 'add_new_template']); // Add a filter to the save post to inject out template into the page cache - add_filter('wp_insert_post_data', array($this, 'register_legacy_templates')); + add_filter('wp_insert_post_data', [$this, 'register_legacy_templates']); // Add a filter to the template include to determine if the page has our // template assigned and return it's path - add_filter('template_include', array($this, 'view_legacy_template')); + add_filter('template_include', [$this, 'view_legacy_template']); } @@ -153,7 +153,7 @@ class Legacy_Checkout { if (empty($templates)) { - $templates = array(); + $templates = []; } @@ -228,21 +228,21 @@ class Legacy_Checkout { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { wp_enqueue_script('wu-block-ui'); - wp_register_script('wu-legacy-signup', wu_get_asset('legacy-signup.js', 'js'), array('wu-functions')); + wp_register_script('wu-legacy-signup', wu_get_asset('legacy-signup.js', 'js'), ['wu-functions']); - wp_localize_script('wu-legacy-signup', 'wpu', array( + wp_localize_script('wu-legacy-signup', 'wpu', [ 'default_pricing_option' => 1, - )); + ]); wp_enqueue_script('wu-legacy-signup'); - wp_enqueue_style('legacy-signup', wu_get_asset('legacy-signup.css', 'css'), array('dashicons', 'install', 'admin-bar')); + wp_enqueue_style('legacy-signup', wu_get_asset('legacy-signup.css', 'css'), ['dashicons', 'install', 'admin-bar']); - wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), array('dashicons', 'install')); + wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), ['dashicons', 'install']); wp_add_inline_style('legacy-signup', $this->get_legacy_dynamic_styles()); @@ -315,9 +315,9 @@ class Legacy_Checkout { $checkout_page_slug = 'register'; - $page_name = isset($request['pagename']) ? $request['pagename'] : ''; + $page_name = $request['pagename'] ?? ''; - if (strncmp((string) $page_name, $checkout_page_slug, strlen($checkout_page_slug)) === 0) { + if (str_starts_with((string) $page_name, $checkout_page_slug)) { $page = explode('/', (string) $page_name); /** @@ -347,13 +347,13 @@ class Legacy_Checkout { * @since 2.0.0 * @return void */ - public function legacy_signup() { + public function legacy_signup(): void { status_header(200); $this->session = wu_get_session('signup'); - $this->session->set('form', array('not-empty')); + $this->session->set('form', ['not-empty']); // Apply a filter so we can add steps in the future $this->steps = $this->get_steps(); @@ -365,9 +365,9 @@ class Legacy_Checkout { wu_get_template( 'legacy/signup/signup-main', - array( + [ 'signup' => $this, - ) + ] ); exit; @@ -378,7 +378,7 @@ class Legacy_Checkout { * * @return void */ - public function check_geolocation() { + public function check_geolocation(): void { $location = \WP_Ultimo\Geolocation::geolocate_ip(); @@ -425,7 +425,7 @@ class Legacy_Checkout { if (isset($current_step['handler']) && $current_step['handler']) { $handler_function = $current_step['handler']; } else { - $handler_function = array($this, 'default_save'); + $handler_function = [$this, 'default_save']; } /** Allows for handler rewrite */ @@ -441,7 +441,7 @@ class Legacy_Checkout { * @since 1.4.0 * @return void */ - public function begin_signup() { + public function begin_signup(): void { /** * Check Geo-location @@ -452,9 +452,9 @@ class Legacy_Checkout { $uniqid = uniqid('', true); /** Initializes the content holder with the honeypot unique id */ - $content = array( + $content = [ 'honeypot_id' => uniqid(''), - ); + ]; /** * Saves the coupon code in the request, only if that option is available @@ -519,7 +519,7 @@ class Legacy_Checkout { */ public static function is_customizer(): bool { - $exclude_list = apply_filters('wu_replace_signup_urls_exclude', array('wu-signup-customizer-preview')); + $exclude_list = apply_filters('wu_replace_signup_urls_exclude', ['wu-signup-customizer-preview']); foreach ($exclude_list as $replace_word) { if (isset($_GET[ $replace_word ])) { @@ -556,7 +556,7 @@ class Legacy_Checkout { $current_step = wu_request('step', current(array_keys($this->steps))); // Always get the first step for the customizer // - if ($this->is_customizer()) { + if (static::is_customizer()) { $current_step = $this->get_first_step(); } @@ -569,7 +569,7 @@ class Legacy_Checkout { * @param string $step The current step. * @return void */ - public function get_step_view($step) { + public function get_step_view($step): void { $transient = $this->session->get('form'); $geo = $this->session->get('geolocation'); @@ -578,7 +578,7 @@ class Legacy_Checkout { * Set the errors */ if ($this->results === null) { - $this->results = array('errors' => new \WP_Error()); + $this->results = ['errors' => new \WP_Error()]; } if (empty($_POST)) { @@ -588,12 +588,12 @@ class Legacy_Checkout { /** * Builds the array containing the available elements inside the template */ - $args = array( + $args = [ 'signup' => $this, 'transient' => $transient, - 'fields' => isset($this->steps[ $step ]['fields']) ? $this->steps[ $step ]['fields'] : array(), + 'fields' => $this->steps[ $step ]['fields'] ?? [], 'results' => $this->results, - ); + ]; /** * Checks if anything is passed to the view element @@ -626,47 +626,47 @@ class Legacy_Checkout { public function get_steps($include_hidden = true, $filtered = true) { // Set the Steps - $steps = array(); + $steps = []; // Plan Selector - $steps['plan'] = array( + $steps['plan'] = [ 'name' => __('Pick a Plan', 'wp-ultimo'), 'desc' => __('Which one of our amazing plans you want to get?', 'wp-ultimo'), 'view' => 'step-plans', - 'handler' => array($this, 'plans_save'), + 'handler' => [$this, 'plans_save'], 'order' => 10, 'fields' => false, 'core' => true, - ); + ]; - $site_templates = array( + $site_templates = [ 2, - ); + ]; // We add template selection if this has template if ($site_templates) { - $steps['template'] = array( + $steps['template'] = [ 'name' => __('Template Selection', 'wp-ultimo'), 'desc' => __('Select the base template of your new site.', 'wp-ultimo'), 'view' => 'step-template', 'order' => 20, 'handler' => false, 'core' => true, - ); + ]; } // Domain registering - $steps['domain'] = array( + $steps['domain'] = [ 'name' => __('Site Details', 'wp-ultimo'), 'desc' => __('Ok, now it\'s time to pick your site url and title!', 'wp-ultimo'), - 'handler' => array($this, 'domain_save'), + 'handler' => [$this, 'domain_save'], 'view' => false, 'order' => 30, 'core' => true, 'fields' => apply_filters( 'wu_signup_fields_domain', - array( - 'blog_title' => array( + [ + 'blog_title' => [ 'order' => 10, 'name' => apply_filters('wu_signup_site_title_label', __('Site Title', 'wp-ultimo')), 'type' => 'text', @@ -675,8 +675,8 @@ class Legacy_Checkout { 'tooltip' => apply_filters('wu_signup_site_title_tooltip', __('Select the title your site is going to have.', 'wp-ultimo')), 'required' => true, 'core' => true, - ), - 'blogname' => array( + ], + 'blogname' => [ 'order' => 20, 'name' => apply_filters('wu_signup_site_url_label', __('URL', 'wp-ultimo')), 'type' => 'text', @@ -685,30 +685,30 @@ class Legacy_Checkout { 'tooltip' => apply_filters('wu_signup_site_url_tooltip', __('Site urls can only contain lowercase letters (a-z) and numbers and must be at least 4 characters. .', 'wp-ultimo')), 'required' => true, 'core' => true, - ), - 'url_preview' => array( + ], + 'url_preview' => [ 'order' => 30, 'name' => __('Site URL Preview', 'wp-ultimo'), 'type' => 'html', 'content' => wu_get_template_contents('legacy/signup/steps/step-domain-url-preview'), - ), - 'submit' => array( + ], + 'submit' => [ 'order' => 100, 'type' => 'submit', 'name' => __('Continue to the next step', 'wp-ultimo'), 'core' => true, - ), - ) + ], + ] ), - ); + ]; /** * Since there are some conditional fields on the accounts step, we need to declare the variable before * so we can append items and filter it later */ - $account_fields = array( + $account_fields = [ - 'user_name' => array( + 'user_name' => [ 'order' => 10, 'name' => apply_filters('wu_signup_username_label', __('Username', 'wp-ultimo')), 'type' => 'text', @@ -717,9 +717,9 @@ class Legacy_Checkout { 'tooltip' => apply_filters('wu_signup_username_tooltip', __('Username must be at least 4 characters.', 'wp-ultimo')), 'required' => true, 'core' => true, - ), + ], - 'user_email' => array( + 'user_email' => [ 'order' => 20, 'name' => apply_filters('wu_signup_email_label', __('Email', 'wp-ultimo')), 'type' => 'email', @@ -728,9 +728,9 @@ class Legacy_Checkout { 'tooltip' => apply_filters('wu_signup_email_tooltip', ''), 'required' => true, 'core' => true, - ), + ], - 'user_pass' => array( + 'user_pass' => [ 'order' => 30, 'name' => apply_filters('wu_signup_password_label', __('Password', 'wp-ultimo')), 'type' => 'password', @@ -739,9 +739,9 @@ class Legacy_Checkout { 'tooltip' => apply_filters('wu_signup_password_tooltip', __('Your password should be at least 6 characters long.', 'wp-ultimo')), 'required' => true, 'core' => true, - ), + ], - 'user_pass_conf' => array( + 'user_pass_conf' => [ 'order' => 40, 'name' => apply_filters('wu_signup_password_conf_label', __('Confirm Password', 'wp-ultimo')), 'type' => 'password', @@ -750,28 +750,28 @@ class Legacy_Checkout { 'tooltip' => apply_filters('wu_signup_password_conf_tooltip', ''), 'required' => true, 'core' => true, - ), + ], /** * HoneyPot Field */ - 'site_url' => array( - 'order' => rand(1, 59), // Use random order for Honeypot + 'site_url' => [ + 'order' => random_int(1, 59), // Use random order for Honeypot 'name' => __('Site URL', 'wp-ultimo'), 'type' => 'text', 'default' => '', 'placeholder' => '', 'tooltip' => '', 'core' => true, - 'wrapper_attributes' => array( + 'wrapper_attributes' => [ 'style' => 'display: none;', - ), - 'attributes' => array( + ], + 'attributes' => [ 'autocomplete' => 'nope', - ), - ), + ], + ], - ); + ]; /** * Check and Add Coupon Code Fields @@ -819,22 +819,22 @@ class Legacy_Checkout { /** * Submit Field */ - $account_fields['submit'] = array( + $account_fields['submit'] = [ 'order' => 100, 'type' => 'submit', 'name' => __('Create Account', 'wp-ultimo'), 'core' => true, - ); + ]; // Account registering - $steps['account'] = array( + $steps['account'] = [ 'name' => __('Account Details', 'wp-ultimo'), 'view' => false, - 'handler' => array($this, 'account_save'), + 'handler' => [$this, 'account_save'], 'order' => 40, 'core' => true, 'fields' => apply_filters('wu_signup_fields_account', $account_fields), - ); + ]; /** * Add additional steps via filters @@ -842,21 +842,21 @@ class Legacy_Checkout { $steps = $filtered ? apply_filters('wp_ultimo_registration_steps', $steps) : $steps; // Sort elements based on their order - uasort($steps, array($this, 'sort_steps_and_fields')); + uasort($steps, [$this, 'sort_steps_and_fields']); // Sorts each of the fields block foreach ($steps as &$step) { $step = wp_parse_args( $step, - array( + [ 'hidden' => false, - ) + ] ); if (isset($step['fields']) && is_array($step['fields'])) { // Sort elements based on their order - uasort($step['fields'], array($this, 'sort_steps_and_fields')); + uasort($step['fields'], [$this, 'sort_steps_and_fields']); } } @@ -865,32 +865,32 @@ class Legacy_Checkout { * * @since 1.4.0 */ - $begin_signup = array( - 'begin-signup' => array( + $begin_signup = [ + 'begin-signup' => [ 'name' => __('Begin Signup Process', 'wp-ultimo'), - 'handler' => array($this, 'begin_signup'), + 'handler' => [$this, 'begin_signup'], 'view' => false, 'hidden' => true, 'order' => 0, 'core' => true, - ), - ); + ], + ]; /** * Adds the hidden step now responsible for validating data entry and the actual account creation * * @since 1.4.0 */ - $create_account = array( - 'create-account' => array( + $create_account = [ + 'create-account' => [ 'name' => __('Creating Account', 'wp-ultimo'), - 'handler' => array($this, 'create_account'), + 'handler' => [$this, 'create_account'], 'view' => false, 'hidden' => true, 'core' => true, 'order' => 1_000_000_000, - ), - ); + ], + ]; /** * Glue the required steps together with the filterable ones @@ -923,9 +923,9 @@ class Legacy_Checkout { public static function get_transient($die = true) { if (self::is_customizer()) { - $transient = array( + $transient = [ 'not-empty' => '', - ); + ]; } else { $transient = wu_get_session('signup')->get('form'); } @@ -936,7 +936,7 @@ class Legacy_Checkout { } if (is_null($transient)) { - return array(); + return []; } return $transient; @@ -947,7 +947,7 @@ class Legacy_Checkout { * * @param array $transient Array containing the transient data. */ - public function update_transient($transient) { + public function update_transient($transient): void { $this->session->set('form', $transient); @@ -958,7 +958,7 @@ class Legacy_Checkout { */ public function has_plan_step(): bool { - $transient = $this->get_transient(); + $transient = static::get_transient(); if (isset($transient['skip_plan']) && isset($transient['plan_id']) && isset($transient['plan_freq'])) { return false; @@ -973,7 +973,7 @@ class Legacy_Checkout { * @param array $params The params. * @return string The link for the next step */ - public function get_next_step_link($params = array()) { + public function get_next_step_link($params = []) { // Add CS if (isset($_GET['cs'])) { @@ -1020,7 +1020,7 @@ class Legacy_Checkout { * @param array $args Arguments to build the URL. * @return void */ - public function next_step($args = array()) { + public function next_step($args = []): void { /** Redirect the user to the next step */ wp_redirect(esc_url_raw($this->get_next_step_link($args))); @@ -1035,7 +1035,7 @@ class Legacy_Checkout { * @param array $params The params. * @return string The link for the previous step */ - public function get_prev_step_link($params = array()) { + public function get_prev_step_link($params = []) { // Add CS if (isset($_GET['cs'])) { @@ -1089,10 +1089,10 @@ class Legacy_Checkout { * @param integer $freq The freq. * @return void */ - public function form_fields($current_plan = false, $step = 'plan', $freq = false) { + public function form_fields($current_plan = false, $step = 'plan', $freq = false): void { /** Select the default frequency */ - $freq = $freq ? $freq : wu_get_setting('default_pricing_option'); + $freq = $freq ?: wu_get_setting('default_pricing_option'); ?> @@ -1127,7 +1127,7 @@ class Legacy_Checkout { */ public function get_site_url_for_previewer() { - $domain_options = array(); + $domain_options = []; $site = get_current_site(); @@ -1153,10 +1153,10 @@ class Legacy_Checkout { /** * We pass the following info */ - public function plans_save() { + public function plans_save(): void { // Get transient - $transient = $this->get_transient(); + $transient = static::get_transient(); // Check referer check_admin_referer('signup_form_1', '_signup_form'); @@ -1200,10 +1200,10 @@ class Legacy_Checkout { /** * Personal Info Settings. */ - public function domain_save() { + public function domain_save(): void { // Get transient - $transient = $this->get_transient(); + $transient = static::get_transient(); // Check referer check_admin_referer('signup_form_1', '_signup_form'); @@ -1247,7 +1247,7 @@ class Legacy_Checkout { */ public function filter_post_array($post, $exclude_list = false) { - $exclude_list = $exclude_list ? $exclude_list : array('_signup_form', '_wp_http_referer'); + $exclude_list = $exclude_list ?: ['_signup_form', '_wp_http_referer']; /** Filter Array */ $post = $this->array_filter_key($post, fn($element_key) => ! in_array($element_key, $exclude_list, true)); @@ -1267,7 +1267,7 @@ class Legacy_Checkout { */ public function array_filter_key(array $array, $callback): array { - $matched_keys = array_filter(array_keys($array), $callback === null ? fn($v, $k): bool => ! empty($v) : $callback, $callback === null ? ARRAY_FILTER_USE_BOTH : 0); + $matched_keys = array_filter(array_keys($array), $callback ?? fn($v, $k): bool => ! empty($v), $callback === null ? ARRAY_FILTER_USE_BOTH : 0); return array_intersect_key($array, array_flip($matched_keys)); } @@ -1296,7 +1296,7 @@ class Legacy_Checkout { * @param array $step The step info. * @return void */ - public function add_signup_step($id, $order, $step) { + public function add_signup_step($id, $order, $step): void { add_filter( 'wp_ultimo_registration_steps', @@ -1325,7 +1325,7 @@ class Legacy_Checkout { * @param array $field The field. * @return void */ - public function add_signup_field($step, $id, $order, $field) { + public function add_signup_field($step, $id, $order, $field): void { add_filter( 'wp_ultimo_registration_steps', diff --git a/inc/checkout/class-line-item.php b/inc/checkout/class-line-item.php index e7487f4..ec26c78 100644 --- a/inc/checkout/class-line-item.php +++ b/inc/checkout/class-line-item.php @@ -305,7 +305,7 @@ class Line_Item implements \JsonSerializable { * @param array $data Array of key => values billing address fields. * @return void */ - public function attributes($data) { + public function attributes($data): void { /* * Set type first to allow for overriding the other parameters. */ @@ -368,7 +368,7 @@ class Line_Item implements \JsonSerializable { * @param string $type The line item type. * @return void */ - public function set_type($type) { + public function set_type($type): void { $this->type = $type; } @@ -407,7 +407,7 @@ class Line_Item implements \JsonSerializable { * @param Product $product Product associated with this line item. * @return void */ - public function set_product($product) { + public function set_product($product): void { $this->product_id = $product->get_id(); @@ -491,12 +491,12 @@ class Line_Item implements \JsonSerializable { $taxes = 0; } - $totals = array( + $totals = [ 'subtotal' => $sub_total, 'discount_total' => $discounts, 'tax_total' => $taxes, 'total' => $total, - ); + ]; $this->attributes($totals); @@ -521,7 +521,7 @@ class Line_Item implements \JsonSerializable { * @param float $quantity Quantity of the given product. * @return void */ - public function set_quantity($quantity) { + public function set_quantity($quantity): void { $this->quantity = $quantity; } @@ -544,7 +544,7 @@ class Line_Item implements \JsonSerializable { * @param integer $unit_price Unit price of the product. * @return void */ - public function set_unit_price($unit_price) { + public function set_unit_price($unit_price): void { $this->unit_price = $unit_price; } @@ -567,7 +567,7 @@ class Line_Item implements \JsonSerializable { * @param float $tax_rate Tax amount, absolute or percentage. * @return void */ - public function set_tax_rate($tax_rate) { + public function set_tax_rate($tax_rate): void { $this->tax_rate = $tax_rate; } @@ -590,7 +590,7 @@ class Line_Item implements \JsonSerializable { * @param string $tax_type Type of the tax, percentage or absolute. * @return void */ - public function set_tax_type($tax_type) { + public function set_tax_type($tax_type): void { $this->tax_type = $tax_type; } @@ -613,7 +613,7 @@ class Line_Item implements \JsonSerializable { * @param boolean $tax_inclusive If tax are included in the price or not. * @return void */ - public function set_tax_inclusive($tax_inclusive) { + public function set_tax_inclusive($tax_inclusive): void { $this->tax_inclusive = $tax_inclusive; } @@ -636,7 +636,7 @@ class Line_Item implements \JsonSerializable { * @param boolean $tax_exempt If the line item is tax exempt ot not. * @return void */ - public function set_tax_exempt($tax_exempt) { + public function set_tax_exempt($tax_exempt): void { $this->tax_exempt = $tax_exempt; } @@ -659,7 +659,7 @@ class Line_Item implements \JsonSerializable { * @param float $tax_total The amount, in currency, of the tax. * @return void */ - public function set_tax_total($tax_total) { + public function set_tax_total($tax_total): void { $this->tax_total = $tax_total; } @@ -682,7 +682,7 @@ class Line_Item implements \JsonSerializable { * @param float $total The total value of the line. * @return void */ - public function set_total($total) { + public function set_total($total): void { $this->total = $total; } @@ -705,7 +705,7 @@ class Line_Item implements \JsonSerializable { * @param boolean $recurring If this item is recurring or not. * @return void */ - public function set_recurring($recurring) { + public function set_recurring($recurring): void { $this->recurring = $recurring; } @@ -728,7 +728,7 @@ class Line_Item implements \JsonSerializable { * @param float $subtotal Value before taxes, discounts, fees and etc. * @return void */ - public function set_subtotal($subtotal) { + public function set_subtotal($subtotal): void { $this->subtotal = $subtotal; } @@ -751,7 +751,7 @@ class Line_Item implements \JsonSerializable { * @param int $duration The billing cycle duration. * @return void */ - public function set_duration($duration) { + public function set_duration($duration): void { $this->duration = $duration; } @@ -774,7 +774,7 @@ class Line_Item implements \JsonSerializable { * @param string $duration_unit The duration unit. * @return void */ - public function set_duration_unit($duration_unit) { + public function set_duration_unit($duration_unit): void { $this->duration_unit = $duration_unit; } @@ -797,7 +797,7 @@ class Line_Item implements \JsonSerializable { * @param int $billing_cycles The number of billing cycles. * @return void */ - public function set_billing_cycles($billing_cycles) { + public function set_billing_cycles($billing_cycles): void { $this->billing_cycles = $billing_cycles; } @@ -820,7 +820,7 @@ class Line_Item implements \JsonSerializable { * @param float $discount_total The total value of discounts. * @return void */ - public function set_discount_total($discount_total) { + public function set_discount_total($discount_total): void { $this->discount_total = $discount_total; } @@ -843,7 +843,7 @@ class Line_Item implements \JsonSerializable { * @param string $tax_category The tax category. * @return void */ - public function set_tax_category($tax_category) { + public function set_tax_category($tax_category): void { $this->tax_category = $tax_category; } @@ -866,7 +866,7 @@ class Line_Item implements \JsonSerializable { * @param boolean $discountable If the line is discountable. * @return void */ - public function set_discountable($discountable) { + public function set_discountable($discountable): void { $this->discountable = $discountable; } @@ -889,7 +889,7 @@ class Line_Item implements \JsonSerializable { * @param boolean $taxable If the item is taxable or not. * @return void */ - public function set_taxable($taxable) { + public function set_taxable($taxable): void { $this->taxable = $taxable; } @@ -912,7 +912,7 @@ class Line_Item implements \JsonSerializable { * @param float $discount_rate The discount amount (flat or percentage). * @return void */ - public function set_discount_rate($discount_rate) { + public function set_discount_rate($discount_rate): void { $this->discount_rate = $discount_rate; } @@ -935,7 +935,7 @@ class Line_Item implements \JsonSerializable { * @param string $discount_type The type of discount, percentage or absolute. * @return void */ - public function set_discount_type($discount_type) { + public function set_discount_type($discount_type): void { $this->discount_type = $discount_type; } @@ -958,7 +958,7 @@ class Line_Item implements \JsonSerializable { * @param string $discount_label Discount Label. * @return void */ - public function set_discount_label($discount_label) { + public function set_discount_label($discount_label): void { $this->discount_label = $discount_label; } @@ -981,7 +981,7 @@ class Line_Item implements \JsonSerializable { * @param boolean $apply_discount_to_renewals If we should apply discount to renewals. * @return void */ - public function set_apply_discount_to_renewals($apply_discount_to_renewals) { + public function set_apply_discount_to_renewals($apply_discount_to_renewals): void { $this->apply_discount_to_renewals = $apply_discount_to_renewals; } @@ -1004,7 +1004,7 @@ class Line_Item implements \JsonSerializable { * @param int $product_id The product id. * @return void */ - public function set_product_id($product_id) { + public function set_product_id($product_id): void { $this->product_id = $product_id; } @@ -1027,7 +1027,7 @@ class Line_Item implements \JsonSerializable { * @param string $title The line item title. * @return void */ - public function set_title($title) { + public function set_title($title): void { $this->title = $title; } @@ -1050,7 +1050,7 @@ class Line_Item implements \JsonSerializable { * @param string $description The line item description. * @return void */ - public function set_description($description) { + public function set_description($description): void { $this->description = $description; } @@ -1073,7 +1073,7 @@ class Line_Item implements \JsonSerializable { * @param string $tax_label Label of the tax applied. * @return void */ - public function set_tax_label($tax_label) { + public function set_tax_label($tax_label): void { $this->tax_label = $tax_label; } @@ -1135,17 +1135,17 @@ class Line_Item implements \JsonSerializable { * @param array $query Query arguments. * @return array */ - public static function get_line_items($query = array()) { + public static function get_line_items($query = []) { global $wpdb; $query = wp_parse_args( $query, - array( + [ 'number' => 100, - 'date_query' => array(), + 'date_query' => [], 'payment_status' => false, - ) + ] ); $query['date_query']['column'] = 'p.date_created'; @@ -1154,7 +1154,7 @@ class Line_Item implements \JsonSerializable { $date_query_sql = $date_query->get_sql(); - $taxes_paid_list = array(); + $taxes_paid_list = []; $status_query_sql = ''; @@ -1219,7 +1219,7 @@ class Line_Item implements \JsonSerializable { * @param null|string $product_slug The product slug. * @return void */ - public function set_product_slug($product_slug) { + public function set_product_slug($product_slug): void { $this->product_slug = $product_slug; } diff --git a/inc/checkout/signup-fields/class-base-signup-field.php b/inc/checkout/signup-fields/class-base-signup-field.php index 738d2f5..d9112b2 100644 --- a/inc/checkout/signup-fields/class-base-signup-field.php +++ b/inc/checkout/signup-fields/class-base-signup-field.php @@ -144,7 +144,7 @@ abstract class Base_Signup_Field { */ public function get_field_as_type_option() { - return array( + return [ 'title' => $this->get_title(), 'desc' => $this->get_description(), 'tooltip' => $this->get_tooltip(), @@ -154,8 +154,8 @@ abstract class Base_Signup_Field { 'default_fields' => $this->default_fields(), 'force_attributes' => $this->force_attributes(), 'all_attributes' => $this->get_all_attributes(), - 'fields' => array($this, 'get_editor_fields'), - ); + 'fields' => [$this, 'get_editor_fields'], + ]; } /** @@ -180,10 +180,10 @@ abstract class Base_Signup_Field { */ public function get_tabs() { - return array( + return [ 'content', 'style', - ); + ]; } /** @@ -219,7 +219,7 @@ abstract class Base_Signup_Field { */ public function calculate_style_attr() { - $styles = array(); + $styles = []; $width = (int) wu_get_isset($this->attributes, 'width'); @@ -244,7 +244,7 @@ abstract class Base_Signup_Field { * @param array $attributes Array containing settings for the field. * @return void */ - public function set_attributes($attributes) { + public function set_attributes($attributes): void { $this->attributes = $attributes; } @@ -257,7 +257,7 @@ abstract class Base_Signup_Field { */ public function force_attributes() { - return array(); + return []; } /** @@ -268,7 +268,7 @@ abstract class Base_Signup_Field { */ public function defaults() { - return array(); + return []; } /** @@ -279,14 +279,14 @@ abstract class Base_Signup_Field { */ public function default_fields() { - return array( + return [ 'id', 'name', 'placeholder', 'tooltip', 'default', 'required', - ); + ]; } /** @@ -297,7 +297,7 @@ abstract class Base_Signup_Field { * @param array $attributes The list of attributes of the field. * @return array */ - public function get_editor_fields($attributes = array()) { + public function get_editor_fields($attributes = []) { $final_field_list = $this->get_fields(); @@ -305,28 +305,28 @@ abstract class Base_Signup_Field { * Checks if this is a site field */ if ($this->is_site_field()) { - $final_field_list[ '_site_notice_field_' . uniqid() ] = array( + $final_field_list[ '_site_notice_field_' . uniqid() ] = [ 'type' => 'note', 'classes' => 'wu--mt-px', 'desc' => sprintf('
%s
', __('This is a site-related field. For that reason, this field will not show up when no plans are present on the shopping cart.', 'wp-ultimo')), 'order' => 98.5, - ); + ]; } /* * Checks if this is a user field */ if ($this->is_user_field()) { - $final_field_list[ '_user_notice_field_' . uniqid() ] = array( + $final_field_list[ '_user_notice_field_' . uniqid() ] = [ 'type' => 'note', 'classes' => 'wu--mt-px', 'desc' => sprintf('
%s
', __('This is a customer-related field. For that reason, this field will not show up when the user is logged and already has a customer on file.', 'wp-ultimo')), 'order' => 98.5, - ); + ]; } foreach ($final_field_list as $key => &$field) { - $field['html_attr'] = wu_get_isset($field, 'html_attr', array()); + $field['html_attr'] = wu_get_isset($field, 'html_attr', []); $value = wu_get_isset($attributes, $key, null); @@ -382,11 +382,11 @@ abstract class Base_Signup_Field { $tab = wu_get_isset($field, 'tab', 'content'); $field['wrapper_html_attr'] = array_merge( - wu_get_isset($field, 'wrapper_html_attr', array()), - array( + wu_get_isset($field, 'wrapper_html_attr', []), + [ 'v-cloak' => 1, 'v-show' => sprintf('require("type", "%s") && require("tab", "%s")', $this->get_type(), $tab) . ($show_reqs ? " && $show_reqs" : ''), - ) + ] ); } @@ -401,14 +401,14 @@ abstract class Base_Signup_Field { */ public function get_all_attributes() { - $styles = array( + $styles = [ 'wrapper_element_classes', 'element_classes', 'element_id', 'from_request', 'width', 'logged', - ); + ]; $field_keys = array_keys($this->get_fields()); @@ -436,34 +436,34 @@ abstract class Base_Signup_Field { */ public static function fields_list() { - $fields = array(); + $fields = []; - $fields['id'] = array( + $fields['id'] = [ 'type' => 'text', 'title' => __('Field ID', 'wp-ultimo'), 'placeholder' => __('e.g. info-name', 'wp-ultimo'), 'tooltip' => __('Only alpha-numeric and hyphens allowed.', 'wp-ultimo'), 'desc' => __('The ID of the field. This is used to reference the field.', 'wp-ultimo'), 'value' => wu_request('id', ''), - 'html_attr' => array( + 'html_attr' => [ 'v-on:input' => 'id = $event.target.value.toLowerCase().replace(/[^a-z0-9-_]+/g, "")', 'v-bind:value' => 'id', - ), - ); + ], + ]; - $fields['name'] = array( + $fields['name'] = [ 'type' => 'text', 'title' => __('Field Label', 'wp-ultimo'), 'placeholder' => __('e.g. Your Name', 'wp-ultimo'), 'desc' => __('This is what your customer see as the field title.', 'wp-ultimo'), 'tooltip' => __('Leave blank to hide the field label. You can also set a placeholder value and tip in the "Additional Settings" tab.', 'wp-ultimo'), 'value' => '', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'name', - ), - ); + ], + ]; - $fields['placeholder'] = array( + $fields['placeholder'] = [ 'type' => 'text', 'title' => __('Field Placeholder', 'wp-ultimo'), 'placeholder' => __('e.g. Placeholder value', 'wp-ultimo'), @@ -471,12 +471,12 @@ abstract class Base_Signup_Field { 'tooltip' => '', 'value' => '', 'tab' => 'advanced', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'placeholder', - ), - ); + ], + ]; - $fields['tooltip'] = array( + $fields['tooltip'] = [ 'type' => 'textarea', 'title' => __('Field Tooltip', 'wp-ultimo'), 'placeholder' => __('e.g. This field is great, be sure to fill it.', 'wp-ultimo'), @@ -485,60 +485,60 @@ abstract class Base_Signup_Field { 'tooltip' => '', 'value' => '', 'tab' => 'advanced', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'tooltip', 'rows' => 4, - ), - ); + ], + ]; - $fields['default_value'] = array( + $fields['default_value'] = [ 'type' => 'text', 'title' => __('Default Value', 'wp-ultimo'), 'placeholder' => __('e.g. None', 'wp-ultimo'), 'value' => '', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'default_value', - ), - ); + ], + ]; - $fields['note'] = array( + $fields['note'] = [ 'type' => 'textarea', 'title' => __('Content', 'wp-ultimo'), 'placeholder' => '', 'tooltip' => '', 'value' => '', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'content', - ), - ); + ], + ]; - $fields['limits'] = array( + $fields['limits'] = [ 'type' => 'group', 'title' => __('Field Length', 'wp-ultimo'), 'tooltip' => '', - 'fields' => array( - 'min' => array( + 'fields' => [ + 'min' => [ 'type' => 'number', 'value' => '', 'placeholder' => __('Min', 'wp-ultimo'), 'wrapper_classes' => 'wu-w-1/2', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'min', - ), - ), - 'max' => array( + ], + ], + 'max' => [ 'type' => 'number', 'value' => '', 'placeholder' => __('Max', 'wp-ultimo'), 'wrapper_classes' => 'wu-ml-2 wu-w-1/2', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'max', - ), - ), - ), - ); + ], + ], + ], + ]; - $fields['save_as'] = array( + $fields['save_as'] = [ 'type' => 'select', 'title' => __('Save As', 'wp-ultimo'), 'desc' => __('Select how you want to save this piece of meta data. You can attach it to the customer or the site as site meta or as site option.', 'wp-ultimo'), @@ -546,28 +546,28 @@ abstract class Base_Signup_Field { 'tooltip' => '', 'value' => 'customer_meta', 'order' => 99.5, - 'options' => array( + 'options' => [ 'customer_meta' => __('Customer Meta', 'wp-ultimo'), 'user_meta' => __('User Meta', 'wp-ultimo'), 'site_meta' => __('Site Meta', 'wp-ultimo'), 'site_option' => __('Site Option', 'wp-ultimo'), 'nothing' => __('Do not save', 'wp-ultimo'), - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'save_as', - ), - ); + ], + ]; - $fields['required'] = array( + $fields['required'] = [ 'type' => 'toggle', 'title' => __('Required', 'wp-ultimo'), 'desc' => __('Mark this field as required. The checkout will not proceed unless this field is filled.', 'wp-ultimo'), 'value' => 0, 'order' => 98, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'required', - ), - ); + ], + ]; return $fields; } diff --git a/inc/checkout/signup-fields/class-signup-field-billing-address.php b/inc/checkout/signup-fields/class-signup-field-billing-address.php index c80c161..cf0e5d5 100644 --- a/inc/checkout/signup-fields/class-signup-field-billing-address.php +++ b/inc/checkout/signup-fields/class-signup-field-billing-address.php @@ -122,9 +122,9 @@ class Signup_Field_Billing_Address extends Base_Signup_Field { */ public function defaults() { - return array( + return [ 'zip_and_country' => true, - ); + ]; } /** @@ -135,9 +135,9 @@ class Signup_Field_Billing_Address extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ 'name', - ); + ]; } /** @@ -148,10 +148,10 @@ class Signup_Field_Billing_Address extends Base_Signup_Field { */ public function force_attributes() { - return array( + return [ 'id' => 'billing_address', 'required' => true, - ); + ]; } /** @@ -162,14 +162,14 @@ class Signup_Field_Billing_Address extends Base_Signup_Field { */ public function get_fields() { - return array( - 'zip_and_country' => array( + return [ + 'zip_and_country' => [ 'type' => 'toggle', 'title' => __('Display only ZIP and Country?', 'wp-ultimo'), 'desc' => __('Checking this option will only add the ZIP and country fields, instead of all the normal billing address fields.', 'wp-ultimo'), 'value' => true, - ), - ); + ], + ]; } /** @@ -197,7 +197,7 @@ class Signup_Field_Billing_Address extends Base_Signup_Field { $field['type'] = 'select'; $field['options_template'] = $option_template; - $field['options'] = array(); + $field['options'] = []; $field['required'] = true; $field['wrapper_html_attr']['v-if'] = "{$data_key_name}.length"; $field['html_attr']['required'] = 'required'; @@ -234,16 +234,16 @@ class Signup_Field_Billing_Address extends Base_Signup_Field { } if (isset($fields['billing_country'])) { - $fields['billing_country']['html_attr'] = array( + $fields['billing_country']['html_attr'] = [ 'v-model' => 'country', - ); + ]; } if ( ! $zip_only) { if (isset($fields['billing_state'])) { - $fields['billing_state']['html_attr'] = array( + $fields['billing_state']['html_attr'] = [ 'v-model.lazy' => 'state', - ); + ]; /** * Format the state field accordingly. @@ -254,9 +254,9 @@ class Signup_Field_Billing_Address extends Base_Signup_Field { } if (isset($fields['billing_city'])) { - $fields['billing_city']['html_attr'] = array( + $fields['billing_city']['html_attr'] = [ 'v-model.lazy' => 'city', - ); + ]; /** * Format the city field accordingly. diff --git a/inc/checkout/signup-fields/class-signup-field-checkbox.php b/inc/checkout/signup-fields/class-signup-field-checkbox.php index ef12f82..b6ad748 100644 --- a/inc/checkout/signup-fields/class-signup-field-checkbox.php +++ b/inc/checkout/signup-fields/class-signup-field-checkbox.php @@ -122,9 +122,9 @@ class Signup_Field_Checkbox extends Base_Signup_Field { */ public function defaults() { - return array( + return [ '', - ); + ]; } /** @@ -135,13 +135,13 @@ class Signup_Field_Checkbox extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ 'id', 'name', 'tooltip', 'save_as', 'required', - ); + ]; } /** @@ -152,7 +152,7 @@ class Signup_Field_Checkbox extends Base_Signup_Field { */ public function force_attributes() { - return array(); + return []; } /** @@ -163,15 +163,15 @@ class Signup_Field_Checkbox extends Base_Signup_Field { */ public function get_fields() { - return array( - 'default_state' => array( + return [ + 'default_state' => [ 'type' => 'toggle', 'title' => __('Default State', 'wp-ultimo'), 'desc' => __('Use the toggle to the set the default state of the checkbox.', 'wp-ultimo'), 'value' => 0, 'order' => 12, - ), - ); + ], + ]; } /** @@ -184,16 +184,16 @@ class Signup_Field_Checkbox extends Base_Signup_Field { */ public function to_fields_array($attributes) { - $checkout_fields = array(); + $checkout_fields = []; - $checkout_fields[ $attributes['id'] ] = array( + $checkout_fields[ $attributes['id'] ] = [ 'type' => 'checkbox', 'id' => $attributes['id'], 'name' => $attributes['name'], 'tooltip' => $attributes['tooltip'], 'required' => $attributes['required'], 'wrapper_classes' => $attributes['element_classes'], - ); + ]; if ($attributes['default_state']) { $checkout_fields[ $attributes['id'] ]['html_attr']['checked'] = 'checked'; diff --git a/inc/checkout/signup-fields/class-signup-field-color.php b/inc/checkout/signup-fields/class-signup-field-color.php index d2e4ffb..3a129a0 100644 --- a/inc/checkout/signup-fields/class-signup-field-color.php +++ b/inc/checkout/signup-fields/class-signup-field-color.php @@ -108,9 +108,9 @@ class Signup_Field_Color extends Base_Signup_Field { */ public function defaults() { - return array( + return [ '', - ); + ]; } /** @@ -121,14 +121,14 @@ class Signup_Field_Color extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ 'id', 'name', 'placeholder', 'tooltip', 'required', 'save_as', - ); + ]; } /** @@ -139,7 +139,7 @@ class Signup_Field_Color extends Base_Signup_Field { */ public function force_attributes() { - return array(); + return []; } /** @@ -150,14 +150,14 @@ class Signup_Field_Color extends Base_Signup_Field { */ public function get_fields() { - return array( - 'default_value' => array( + return [ + 'default_value' => [ 'type' => 'color-picker', 'order' => 12, 'title' => __('Default Color', 'wp-ultimo'), 'desc' => __('Set the default value for this color field.', 'wp-ultimo'), - ), - ); + ], + ]; } /** @@ -170,8 +170,8 @@ class Signup_Field_Color extends Base_Signup_Field { */ public function to_fields_array($attributes) { - return array( - $attributes['id'] => array( + return [ + $attributes['id'] => [ 'type' => 'color', 'id' => $attributes['id'], 'name' => $attributes['name'], @@ -182,10 +182,10 @@ class Signup_Field_Color extends Base_Signup_Field { 'wrapper_classes' => $attributes['element_classes'], 'classes' => 'wu-rounded', 'value' => $this->get_value(), - 'html_attr' => array( + 'html_attr' => [ 'style' => 'width: 50px !important', - ), - ), - ); + ], + ], + ]; } } diff --git a/inc/checkout/signup-fields/class-signup-field-discount-code.php b/inc/checkout/signup-fields/class-signup-field-discount-code.php index 1e7a623..0accc39 100644 --- a/inc/checkout/signup-fields/class-signup-field-discount-code.php +++ b/inc/checkout/signup-fields/class-signup-field-discount-code.php @@ -108,10 +108,10 @@ class Signup_Field_Discount_Code extends Base_Signup_Field { */ public function defaults() { - return array( + return [ 'placeholder' => '', 'default' => '', - ); + ]; } /** @@ -122,11 +122,11 @@ class Signup_Field_Discount_Code extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ 'name', 'placeholder', 'tooltip', - ); + ]; } /** @@ -137,9 +137,9 @@ class Signup_Field_Discount_Code extends Base_Signup_Field { */ public function force_attributes() { - return array( + return [ 'id' => 'discount_code', - ); + ]; } /** @@ -150,7 +150,7 @@ class Signup_Field_Discount_Code extends Base_Signup_Field { */ public function get_fields() { - return array(); + return []; } /** @@ -163,19 +163,19 @@ class Signup_Field_Discount_Code extends Base_Signup_Field { */ public function to_fields_array($attributes) { - $checkout_fields = array(); + $checkout_fields = []; - $checkout_fields['discount_code_checkbox'] = array( + $checkout_fields['discount_code_checkbox'] = [ 'id' => 'discount_code', 'type' => 'toggle', 'name' => __('Have a coupon code?', 'wp-ultimo'), 'class' => 'wu-w-auto', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'toggle_discount_code', - ), - ); + ], + ]; - $checkout_fields['discount_code'] = array( + $checkout_fields['discount_code'] = [ 'type' => 'text', 'id' => 'discount_code', 'name' => $attributes['name'], @@ -184,16 +184,16 @@ class Signup_Field_Discount_Code extends Base_Signup_Field { 'default' => $attributes['default'], 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''), 'classes' => wu_get_isset($attributes, 'element_classes', ''), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'toggle_discount_code', 'style' => $this->calculate_style_attr(), - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model.lazy' => 'discount_code', 'v-init:discount_code' => "'{$this->get_value()}'", 'v-init:toggle_discount_code' => ! empty($this->get_value()), - ), - ); + ], + ]; return $checkout_fields; } diff --git a/inc/checkout/signup-fields/class-signup-field-email.php b/inc/checkout/signup-fields/class-signup-field-email.php index 59d01b1..6824382 100644 --- a/inc/checkout/signup-fields/class-signup-field-email.php +++ b/inc/checkout/signup-fields/class-signup-field-email.php @@ -115,9 +115,9 @@ class Signup_Field_Email extends Base_Signup_Field { */ public function defaults() { - return array( + return [ 'display_notices' => true, - ); + ]; } /** @@ -128,11 +128,11 @@ class Signup_Field_Email extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ 'name', 'placeholder', 'tooltip', - ); + ]; } /** @@ -143,10 +143,10 @@ class Signup_Field_Email extends Base_Signup_Field { */ public function force_attributes() { - return array( + return [ 'id' => 'email_address', 'required' => true, - ); + ]; } /** @@ -157,18 +157,18 @@ class Signup_Field_Email extends Base_Signup_Field { */ public function get_fields() { - return array( - 'display_notices' => array( + return [ + 'display_notices' => [ 'type' => 'toggle', 'title' => __('Display Notices', 'wp-ultimo'), 'desc' => __('When the customer is already logged in, a box with the customer\'s username and a link to logout is displayed instead of the email field. Disable this option if you do not want that box to show up.', 'wp-ultimo'), 'tooltip' => '', 'value' => 1, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'display_notices', - ), - ), - ); + ], + ], + ]; } /** @@ -181,34 +181,34 @@ class Signup_Field_Email extends Base_Signup_Field { */ public function to_fields_array($attributes) { - $checkout_fields = array(); + $checkout_fields = []; if (is_user_logged_in()) { if ($attributes['display_notices']) { - $checkout_fields['login_note'] = array( + $checkout_fields['login_note'] = [ 'type' => 'note', 'title' => __('Not you?', 'wp-ultimo'), - 'desc' => array($this, 'render_not_you_customer_message'), + 'desc' => [$this, 'render_not_you_customer_message'], 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'style' => $this->calculate_style_attr(), - ), - ); + ], + ]; } } else { if ($attributes['display_notices']) { - $checkout_fields['login_note'] = array( + $checkout_fields['login_note'] = [ 'type' => 'note', 'title' => __('Existing customer?', 'wp-ultimo'), - 'desc' => array($this, 'render_existing_customer_message'), + 'desc' => [$this, 'render_existing_customer_message'], 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'style' => $this->calculate_style_attr(), - ), - ); + ], + ]; } - $checkout_fields['email_address'] = array( + $checkout_fields['email_address'] = [ 'type' => 'text', 'id' => 'email_address', 'name' => $attributes['name'], @@ -218,10 +218,10 @@ class Signup_Field_Email extends Base_Signup_Field { 'required' => true, 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''), 'classes' => wu_get_isset($attributes, 'element_classes', ''), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'style' => $this->calculate_style_attr(), - ), - ); + ], + ]; } return $checkout_fields; diff --git a/inc/checkout/signup-fields/class-signup-field-hidden.php b/inc/checkout/signup-fields/class-signup-field-hidden.php index 50c4df3..03bf559 100644 --- a/inc/checkout/signup-fields/class-signup-field-hidden.php +++ b/inc/checkout/signup-fields/class-signup-field-hidden.php @@ -108,9 +108,9 @@ class Signup_Field_Hidden extends Base_Signup_Field { */ public function defaults() { - return array( + return [ 'from_request' => true, - ); + ]; } /** @@ -121,10 +121,10 @@ class Signup_Field_Hidden extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ 'id', 'save_as', - ); + ]; } /** @@ -135,7 +135,7 @@ class Signup_Field_Hidden extends Base_Signup_Field { */ public function force_attributes() { - return array(); + return []; } /** @@ -146,8 +146,8 @@ class Signup_Field_Hidden extends Base_Signup_Field { */ public function get_fields() { - return array( - 'fixed_value' => array( + return [ + 'fixed_value' => [ 'order' => 12, 'type' => 'text', 'title' => __('Pre-filled Value', 'wp-ultimo'), @@ -155,8 +155,8 @@ class Signup_Field_Hidden extends Base_Signup_Field { 'placeholder' => __('e.g. blue', 'wp-ultimo'), 'tooltip' => '', 'value' => '', - ), - ); + ], + ]; } /** @@ -186,13 +186,13 @@ class Signup_Field_Hidden extends Base_Signup_Field { */ public function to_fields_array($attributes) { - return array( - $attributes['id'] => array( + return [ + $attributes['id'] => [ 'type' => 'hidden', 'id' => $attributes['id'], 'wrapper_classes' => $attributes['element_classes'], 'value' => $this->get_value(), - ), - ); + ], + ]; } } diff --git a/inc/checkout/signup-fields/class-signup-field-order-bump.php b/inc/checkout/signup-fields/class-signup-field-order-bump.php index 44ef87a..5134fb7 100644 --- a/inc/checkout/signup-fields/class-signup-field-order-bump.php +++ b/inc/checkout/signup-fields/class-signup-field-order-bump.php @@ -109,10 +109,10 @@ class Signup_Field_Order_Bump extends Base_Signup_Field { */ public function defaults() { - return array( + return [ 'order_bump_template' => 'simple', 'display_product_description' => 0, - ); + ]; } /** @@ -123,10 +123,10 @@ class Signup_Field_Order_Bump extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ // 'id', 'name', - ); + ]; } /** @@ -137,9 +137,9 @@ class Signup_Field_Order_Bump extends Base_Signup_Field { */ public function force_attributes() { - return array( + return [ 'order_bump_template' => 'simple', - ); + ]; } /** @@ -163,37 +163,37 @@ class Signup_Field_Order_Bump extends Base_Signup_Field { */ public function get_fields() { - $editor_fields = array( - 'product' => array( + $editor_fields = [ + 'product' => [ 'type' => 'model', 'title' => __('Product', 'wp-ultimo'), 'placeholder' => __('e.g. Premium', 'wp-ultimo'), 'desc' => __('Select the product that will be presented to the customer as an add-on option.', 'wp-ultimo'), 'tooltip' => '', 'order' => 12, - 'html_attr' => array( + 'html_attr' => [ 'data-model' => 'product', 'data-value-field' => 'id', 'data-label-field' => 'name', 'data-search-field' => 'name', 'data-max-items' => 1, - ), - ), - 'display_product_description' => array( + ], + ], + 'display_product_description' => [ 'order' => 13, 'type' => 'toggle', 'title' => __('Display Product Description', 'wp-ultimo'), 'desc' => __('Toggle to display the product description as well, if one is available.', 'wp-ultimo'), 'value' => 0, - ), - 'display_product_image' => array( + ], + 'display_product_image' => [ 'order' => 14, 'type' => 'toggle', 'title' => __('Display Product Image', 'wp-ultimo'), 'desc' => __('Toggle to display the product image as well, if one is available.', 'wp-ultimo'), 'value' => 1, - ), - ); + ], + ]; // $editor_fields['order_bump_template'] = array( // 'type' => 'group', @@ -240,7 +240,7 @@ class Signup_Field_Order_Bump extends Base_Signup_Field { $product = is_numeric($product_id) ? wu_get_product($product_id) : wu_get_product_by_slug($product_id); if ( ! $product) { - return array(); + return []; } $attributes['product'] = $product; @@ -249,12 +249,12 @@ class Signup_Field_Order_Bump extends Base_Signup_Field { $content = $template_class ? $template_class->render_container($attributes) : __('Template does not exist.', 'wp-ultimo'); - return array( - $attributes['id'] => array( + return [ + $attributes['id'] => [ 'type' => 'note', 'desc' => $content, 'wrapper_classes' => $attributes['element_classes'], - ), - ); + ], + ]; } } diff --git a/inc/checkout/signup-fields/class-signup-field-order-summary.php b/inc/checkout/signup-fields/class-signup-field-order-summary.php index dc16bc8..846dd31 100644 --- a/inc/checkout/signup-fields/class-signup-field-order-summary.php +++ b/inc/checkout/signup-fields/class-signup-field-order-summary.php @@ -104,10 +104,10 @@ class Signup_Field_Order_Summary extends Base_Signup_Field { */ public function defaults() { - return array( + return [ 'order_summary_template' => 'clean', 'table_columns' => 'simple', - ); + ]; } /** @@ -118,9 +118,9 @@ class Signup_Field_Order_Summary extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ 'name', - ); + ]; } /** @@ -131,9 +131,9 @@ class Signup_Field_Order_Summary extends Base_Signup_Field { */ public function force_attributes() { - return array( + return [ 'id' => 'order_summary', - ); + ]; } /** @@ -157,34 +157,34 @@ class Signup_Field_Order_Summary extends Base_Signup_Field { */ public function get_fields() { - $editor_fields = array(); + $editor_fields = []; - $editor_fields['table_columns'] = array( + $editor_fields['table_columns'] = [ 'type' => 'select', 'title' => __('Table Columns', 'wp-ultimo'), 'desc' => __('"Simplified" will condense all discount and tax info into separate rows to keep the table with only two columns. "Display All" adds a discounts and taxes column to each product row.', 'wp-ultimo'), - 'options' => array( + 'options' => [ 'simple' => __('Simplified', 'wp-ultimo'), 'full' => __('Display All', 'wp-ultimo'), - ), - ); + ], + ]; - $editor_fields['order_summary_template'] = array( + $editor_fields['order_summary_template'] = [ 'type' => 'group', 'desc' => Field_Templates_Manager::get_instance()->render_preview_block('order_summary'), - 'fields' => array( - 'order_summary_template' => array( + 'fields' => [ + 'order_summary_template' => [ 'type' => 'select', 'title' => __('Layout', 'wp-ultimo'), 'placeholder' => __('Select your Layout', 'wp-ultimo'), - 'options' => array($this, 'get_templates'), + 'options' => [$this, 'get_templates'], 'wrapper_classes' => 'wu-flex-grow', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'order_summary_template', - ), - ), - ), - ); + ], + ], + ], + ]; // @todo: re-add developer notes. // $editor_fields['_dev_note_develop_your_own_template_order_summary'] = array( @@ -208,7 +208,7 @@ class Signup_Field_Order_Summary extends Base_Signup_Field { */ public function to_fields_array($attributes) { - $checkout_fields = array(); + $checkout_fields = []; /* * Backwards compatibility with previous betas @@ -221,15 +221,15 @@ class Signup_Field_Order_Summary extends Base_Signup_Field { $content = $template_class ? $template_class->render_container($attributes) : __('Template does not exist.', 'wp-ultimo'); - $checkout_fields[ $attributes['id'] ] = array( + $checkout_fields[ $attributes['id'] ] = [ 'type' => 'note', 'desc' => $content, 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''), 'classes' => wu_get_isset($attributes, 'element_classes', ''), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'style' => $this->calculate_style_attr(), - ), - ); + ], + ]; return $checkout_fields; } diff --git a/inc/checkout/signup-fields/class-signup-field-password.php b/inc/checkout/signup-fields/class-signup-field-password.php index f3d0c87..f356192 100644 --- a/inc/checkout/signup-fields/class-signup-field-password.php +++ b/inc/checkout/signup-fields/class-signup-field-password.php @@ -122,10 +122,10 @@ class Signup_Field_Password extends Base_Signup_Field { */ public function defaults() { - return array( + return [ 'password_confirm_field' => false, 'password_confirm_label' => __('Confirm Password', 'wp-ultimo'), - ); + ]; } /** @@ -136,11 +136,11 @@ class Signup_Field_Password extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ 'name', 'placeholder', 'tooltip', - ); + ]; } /** @@ -151,10 +151,10 @@ class Signup_Field_Password extends Base_Signup_Field { */ public function force_attributes() { - return array( + return [ 'id' => 'password', 'required' => true, - ); + ]; } /** @@ -165,20 +165,20 @@ class Signup_Field_Password extends Base_Signup_Field { */ public function get_fields() { - return array( - 'password_strength_meter' => array( + return [ + 'password_strength_meter' => [ 'type' => 'toggle', 'title' => __('Display Password Strength Meter', 'wp-ultimo'), 'desc' => __('Adds a password strength meter below the password field. Enabling this option also enforces passwords to be strong.', 'wp-ultimo'), 'value' => 1, - ), - 'password_confirm_field' => array( + ], + 'password_confirm_field' => [ 'type' => 'toggle', 'title' => __('Display Password Confirm Field', 'wp-ultimo'), 'desc' => __('Adds a "Confirm your Password" field below the default password field to reduce the chance or making a mistake.', 'wp-ultimo'), 'value' => 1, - ), - ); + ], + ]; } /** @@ -194,12 +194,12 @@ class Signup_Field_Password extends Base_Signup_Field { * Logged in user, bail. */ if (is_user_logged_in()) { - return array(); + return []; } - $checkout_fields = array(); + $checkout_fields = []; - $checkout_fields['password'] = array( + $checkout_fields['password'] = [ 'type' => 'password', 'id' => 'password', 'name' => $attributes['name'], @@ -209,16 +209,16 @@ class Signup_Field_Password extends Base_Signup_Field { 'required' => true, 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''), 'classes' => wu_get_isset($attributes, 'element_classes', ''), - 'html_attr' => array( + 'html_attr' => [ 'autocomplete' => 'new-password', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'style' => $this->calculate_style_attr(), - ), - ); + ], + ]; if ($attributes['password_confirm_field']) { - $checkout_fields['password_conf'] = array( + $checkout_fields['password_conf'] = [ 'type' => 'password', 'id' => 'password_conf', 'name' => $attributes['password_confirm_label'], @@ -228,13 +228,13 @@ class Signup_Field_Password extends Base_Signup_Field { 'required' => true, 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''), 'classes' => wu_get_isset($attributes, 'element_classes', ''), - 'html_attr' => array( + 'html_attr' => [ 'autocomplete' => 'new-password', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'style' => $this->calculate_style_attr(), - ), - ); + ], + ]; } return $checkout_fields; diff --git a/inc/checkout/signup-fields/class-signup-field-payment.php b/inc/checkout/signup-fields/class-signup-field-payment.php index 9f6fb48..ea46890 100644 --- a/inc/checkout/signup-fields/class-signup-field-payment.php +++ b/inc/checkout/signup-fields/class-signup-field-payment.php @@ -109,9 +109,9 @@ class Signup_Field_Payment extends Base_Signup_Field { */ public function defaults() { - return array( + return [ '', - ); + ]; } /** @@ -122,9 +122,9 @@ class Signup_Field_Payment extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ 'name', - ); + ]; } /** @@ -135,9 +135,9 @@ class Signup_Field_Payment extends Base_Signup_Field { */ public function force_attributes() { - return array( + return [ 'id' => 'payment', - ); + ]; } /** @@ -148,7 +148,7 @@ class Signup_Field_Payment extends Base_Signup_Field { */ public function get_fields() { - return array(); + return []; } /** @@ -161,24 +161,24 @@ class Signup_Field_Payment extends Base_Signup_Field { */ public function to_fields_array($attributes) { - $fields = array( - 'payment_template' => array( + $fields = [ + 'payment_template' => [ 'type' => 'text', 'id' => 'payment_template', 'name' => '', 'classes' => 'wu-hidden', - ), - 'payment' => array( + ], + 'payment' => [ 'type' => 'payment-methods', 'id' => 'payment', 'name' => $attributes['name'], 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''), 'classes' => wu_get_isset($attributes, 'element_classes', ''), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'style' => $this->calculate_style_attr(), - ), - ), - ); + ], + ], + ]; /* * Checks if we need to add the @@ -187,22 +187,22 @@ class Signup_Field_Payment extends Base_Signup_Field { if ( ! wu_get_setting('force_auto_renew', 1)) { $auto_renewable_gateways = Gateway_Manager::get_instance()->get_auto_renewable_gateways(); - $fields['auto_renew'] = array( + $fields['auto_renew'] = [ 'type' => 'toggle', 'id' => 'auto_renew', 'name' => __('Auto-renew', 'wp-ultimo'), 'tooltip' => '', 'value' => '1', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'auto_renew', 'true-value' => '1', 'false-value' => '0', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-cloak' => 1, 'v-show' => sprintf('%s.includes(gateway) && order.should_collect_payment && order.has_recurring', json_encode($auto_renewable_gateways)), - ), - ); + ], + ]; } return $fields; diff --git a/inc/checkout/signup-fields/class-signup-field-period-selection.php b/inc/checkout/signup-fields/class-signup-field-period-selection.php index 7ea5cca..25a6d5e 100644 --- a/inc/checkout/signup-fields/class-signup-field-period-selection.php +++ b/inc/checkout/signup-fields/class-signup-field-period-selection.php @@ -104,9 +104,9 @@ class Signup_Field_Period_Selection extends Base_Signup_Field { */ public function defaults() { - return array( + return [ 'period_selection_template' => 'clean', - ); + ]; } /** @@ -117,9 +117,9 @@ class Signup_Field_Period_Selection extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ // 'name', - ); + ]; } /** @@ -130,11 +130,11 @@ class Signup_Field_Period_Selection extends Base_Signup_Field { */ public function force_attributes() { - return array( + return [ 'id' => 'period_selection', 'name' => __('Plan Duration Switch', 'wp-ultimo'), 'required' => true, - ); + ]; } /** @@ -158,119 +158,119 @@ class Signup_Field_Period_Selection extends Base_Signup_Field { */ public function get_fields() { - $editor_fields = array(); + $editor_fields = []; - $editor_fields['period_selection_template'] = array( + $editor_fields['period_selection_template'] = [ 'type' => 'group', 'order' => 98.4, 'desc' => Field_Templates_Manager::get_instance()->render_preview_block('period_selection'), - 'fields' => array( - 'period_selection_template' => array( + 'fields' => [ + 'period_selection_template' => [ 'type' => 'select', 'title' => __('Period Selector Template', 'wp-ultimo'), 'placeholder' => __('Select your Template', 'wp-ultimo'), - 'options' => array($this, 'get_template_options'), + 'options' => [$this, 'get_template_options'], 'wrapper_classes' => 'wu-flex-grow', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'period_selection_template', - ), - ), - ), - ); + ], + ], + ], + ]; - $editor_fields['period_options_header'] = array( + $editor_fields['period_options_header'] = [ 'type' => 'small-header', 'title' => __('Options', 'wp-ultimo'), 'desc' => __('Add different options below. These need to match your product price variations.', 'wp-ultimo'), 'order' => 90, - ); + ]; - $editor_fields['period_options_empty'] = array( + $editor_fields['period_options_empty'] = [ 'type' => 'note', 'desc' => __('Add the first option using the button below.', 'wp-ultimo'), 'classes' => 'wu-text-gray-600 wu-text-xs wu-text-center wu-w-full', 'wrapper_classes' => 'wu-bg-gray-100 wu-items-end', 'order' => 90.5, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'period_options.length === 0', 'v-cloak' => '1', - ), - ); + ], + ]; - $editor_fields['period_options'] = array( + $editor_fields['period_options'] = [ 'type' => 'group', 'tooltip' => '', 'order' => 91, 'wrapper_classes' => 'wu-relative wu-bg-gray-100 wu-pb-2', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'period_options.length', 'v-for' => '(period_option, index) in period_options', 'v-cloak' => '1', - ), - 'fields' => array( - 'period_options_remove' => array( + ], + 'fields' => [ + 'period_options_remove' => [ 'type' => 'note', 'desc' => sprintf('', __('Remove', 'wp-ultimo')), 'wrapper_classes' => 'wu-absolute wu-top-0 wu-right-0', - ), - 'period_options_duration' => array( + ], + 'period_options_duration' => [ 'type' => 'number', 'title' => __('Duration', 'wp-ultimo'), 'placeholder' => '', 'wrapper_classes' => 'wu-w-2/12', 'min' => 1, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'period_option.duration', 'steps' => 1, 'v-bind:name' => '"period_options[" + index + "][duration]"', - ), - ), - 'period_options_duration_unit' => array( + ], + ], + 'period_options_duration_unit' => [ 'type' => 'select', 'title' => ' ', 'placeholder' => '', 'wrapper_classes' => 'wu-w-5/12 wu-mx-2', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'period_option.duration_unit', 'v-bind:name' => '"period_options[" + index + "][duration_unit]"', - ), - 'options' => array( + ], + 'options' => [ 'day' => __('Days', 'wp-ultimo'), 'week' => __('Weeks', 'wp-ultimo'), 'month' => __('Months', 'wp-ultimo'), 'year' => __('Years', 'wp-ultimo'), - ), - ), - 'period_options_label' => array( + ], + ], + 'period_options_label' => [ 'type' => 'text', 'title' => __('Label', 'wp-ultimo'), 'placeholder' => __('e.g. Monthly', 'wp-ultimo'), 'wrapper_classes' => 'wu-w-5/12', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'period_option.label', 'v-bind:name' => '"period_options[" + index + "][label]"', - ), - ), - ), - ); + ], + ], + ], + ]; - $editor_fields['repeat'] = array( + $editor_fields['repeat'] = [ 'order' => 92, 'type' => 'submit', 'title' => __('+ Add option', 'wp-ultimo'), 'classes' => 'wu-uppercase wu-text-2xs wu-text-blue-700 wu-border-none wu-bg-transparent wu-font-bold wu-text-right wu-w-full wu-cursor-pointer', 'wrapper_classes' => 'wu-bg-gray-100 wu-items-end', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-on:click.prevent' => '() => period_options.push({ duration: 1, duration_unit: "month", label: "", })', - ), - ); + ], + ]; return $editor_fields; } @@ -286,39 +286,39 @@ class Signup_Field_Period_Selection extends Base_Signup_Field { public function to_fields_array($attributes) { if (wu_get_isset($attributes, 'period_selection_template') === 'legacy') { - wp_register_script('wu-legacy-signup', wu_get_asset('legacy-signup.js', 'js'), array('wu-functions'), wu_get_version()); + wp_register_script('wu-legacy-signup', wu_get_asset('legacy-signup.js', 'js'), ['wu-functions'], wu_get_version()); wp_enqueue_script('wu-legacy-signup'); - wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), array('dashicons'), wu_get_version()); + wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), ['dashicons'], wu_get_version()); } $template_class = Field_Templates_Manager::get_instance()->get_template_class('period_selection', $attributes['period_selection_template']); $content = $template_class ? $template_class->render_container($attributes) : __('Template does not exist.', 'wp-ultimo'); - $checkout_fields = array(); + $checkout_fields = []; - $checkout_fields[ $attributes['id'] ] = array( + $checkout_fields[ $attributes['id'] ] = [ 'type' => 'note', 'id' => $attributes['id'], 'wrapper_classes' => $attributes['element_classes'], 'desc' => $content, - ); + ]; - $checkout_fields['duration'] = array( + $checkout_fields['duration'] = [ 'type' => 'hidden', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'duration', - ), - ); + ], + ]; - $checkout_fields['duration_unit'] = array( + $checkout_fields['duration_unit'] = [ 'type' => 'hidden', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'duration_unit', - ), - ); + ], + ]; return $checkout_fields; } diff --git a/inc/checkout/signup-fields/class-signup-field-pricing-table.php b/inc/checkout/signup-fields/class-signup-field-pricing-table.php index e4c6817..23fe975 100644 --- a/inc/checkout/signup-fields/class-signup-field-pricing-table.php +++ b/inc/checkout/signup-fields/class-signup-field-pricing-table.php @@ -104,12 +104,12 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field { */ public function defaults() { - return array( + return [ 'pricing_table_products' => implode(',', array_keys(wu_get_plans_as_options())), 'pricing_table_template' => 'list', 'force_different_durations' => false, 'hide_pricing_table_when_pre_selected' => false, - ); + ]; } /** @@ -120,9 +120,9 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ // 'name', - ); + ]; } /** @@ -133,11 +133,11 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field { */ public function force_attributes() { - return array( + return [ 'id' => 'pricing_table', 'name' => __('Plan Selection', 'wp-ultimo'), 'required' => true, - ); + ]; } /** @@ -161,66 +161,66 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field { */ public function get_fields() { - $editor_fields = array(); + $editor_fields = []; - $editor_fields['pricing_table_products'] = array( + $editor_fields['pricing_table_products'] = [ 'type' => 'model', 'title' => __('Products', 'wp-ultimo'), 'placeholder' => __('e.g. Premium', 'wp-ultimo'), 'desc' => __('Be sure to add the products in the order you want them to show up.', 'wp-ultimo'), 'tooltip' => '', 'order' => 20, - 'html_attr' => array( + 'html_attr' => [ 'data-model' => 'product', 'data-value-field' => 'id', 'data-label-field' => 'name', 'data-search-field' => 'name', 'data-include' => implode(',', array_keys(wu_get_plans_as_options())), 'data-max-items' => 999, - ), - ); + ], + ]; - $editor_fields['force_different_durations'] = array( + $editor_fields['force_different_durations'] = [ 'type' => 'toggle', 'title' => __('Force Different Durations', 'wp-ultimo'), 'desc' => __('Check this option to force the display of plans with different recurring durations.', 'wp-ultimo'), 'tooltip' => '', 'value' => 0, 'order' => 22, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'force_different_durations', - ), - ); + ], + ]; - $editor_fields['hide_pricing_table_when_pre_selected'] = array( + $editor_fields['hide_pricing_table_when_pre_selected'] = [ 'type' => 'toggle', 'title' => __('Hide when Pre-Selected', 'wp-ultimo'), 'desc' => __('Prevent customers from seeing this field when a plan was already selected via the URL.', 'wp-ultimo'), 'tooltip' => __('If the pricing table field is the only field in the current step, the step will be skipped.', 'wp-ultimo'), 'value' => 0, 'order' => 24, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'hide_pricing_table_when_pre_selected', - ), - ); + ], + ]; - $editor_fields['pricing_table_template'] = array( + $editor_fields['pricing_table_template'] = [ 'type' => 'group', 'desc' => Field_Templates_Manager::get_instance()->render_preview_block('pricing_table'), 'order' => 26, - 'fields' => array( - 'pricing_table_template' => array( + 'fields' => [ + 'pricing_table_template' => [ 'type' => 'select', 'title' => __('Pricing Table Template', 'wp-ultimo'), 'placeholder' => __('Select your Template', 'wp-ultimo'), - 'options' => array($this, 'get_pricing_table_templates'), + 'options' => [$this, 'get_pricing_table_templates'], 'wrapper_classes' => 'wu-flex-grow', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'pricing_table_template', - ), - ), - ), - ); + ], + ], + ], + ]; // @todo: re-add developer notes. // $editor_fields['_dev_note_develop_your_own_template_2'] = array( @@ -245,7 +245,7 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field { public function to_fields_array($attributes) { if (wu_get_isset($attributes, 'pricing_table_template') === 'legacy') { - wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), array('dashicons'), wu_get_version()); + wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), ['dashicons'], wu_get_version()); wp_add_inline_style('legacy-shortcodes', \WP_Ultimo\Checkout\Legacy_Checkout::get_instance()->get_legacy_dynamic_styles()); } @@ -263,32 +263,32 @@ class Signup_Field_Pricing_Table extends Base_Signup_Field { * Hide when pre-selected. */ if (wu_should_hide_form_field($attributes)) { - return array(); + return []; } - $template_attributes = array( + $template_attributes = [ 'products' => $products, 'name' => $attributes['name'], 'force_different_durations' => $attributes['force_different_durations'], 'classes' => wu_get_isset($attributes, 'element_classes', ''), - ); + ]; $template_class = Field_Templates_Manager::get_instance()->get_template_class('pricing_table', $attributes['pricing_table_template']); $content = $template_class ? $template_class->render_container($template_attributes) : __('Template does not exist.', 'wp-ultimo'); - $checkout_fields = array(); + $checkout_fields = []; - $checkout_fields[ $attributes['id'] ] = array( + $checkout_fields[ $attributes['id'] ] = [ 'type' => 'note', 'id' => $attributes['id'], 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''), 'classes' => wu_get_isset($attributes, 'element_classes', ''), 'desc' => $content, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'style' => $this->calculate_style_attr(), - ), - ); + ], + ]; return $checkout_fields; } diff --git a/inc/checkout/signup-fields/class-signup-field-products.php b/inc/checkout/signup-fields/class-signup-field-products.php index d4177ac..8c9261b 100644 --- a/inc/checkout/signup-fields/class-signup-field-products.php +++ b/inc/checkout/signup-fields/class-signup-field-products.php @@ -103,9 +103,9 @@ class Signup_Field_Products extends Base_Signup_Field { */ public function defaults() { - return array( + return [ '', - ); + ]; } /** @@ -116,7 +116,7 @@ class Signup_Field_Products extends Base_Signup_Field { */ public function default_fields() { - return array(); + return []; } /** @@ -127,10 +127,10 @@ class Signup_Field_Products extends Base_Signup_Field { */ public function force_attributes() { - return array( + return [ 'name' => __('Pre-selected Products', 'wp-ultimo'), 'id' => 'products', - ); + ]; } /** @@ -141,22 +141,22 @@ class Signup_Field_Products extends Base_Signup_Field { */ public function get_fields() { - return array( - 'products' => array( + return [ + 'products' => [ 'type' => 'model', 'title' => __('Products', 'wp-ultimo'), 'placeholder' => __('Products', 'wp-ultimo'), 'desc' => __('Use this field to pre-select products. This is useful when you have a signup page for specific offering/bundles and do not want your customers to be able to choose plans and other products manually.', 'wp-ultimo'), 'tooltip' => '', - 'html_attr' => array( + 'html_attr' => [ 'data-model' => 'product', 'data-value-field' => 'id', 'data-label-field' => 'name', 'data-search-field' => 'name', 'data-max-items' => 10, - ), - ), - ); + ], + ], + ]; } /** @@ -169,18 +169,18 @@ class Signup_Field_Products extends Base_Signup_Field { */ public function to_fields_array($attributes) { - $checkout_fields = array(); + $checkout_fields = []; $products = explode(',', (string) $attributes['products']); foreach ($products as $product_id) { - $checkout_fields[ "products[{$product_id}]" ] = array( + $checkout_fields[ "products[{$product_id}]" ] = [ 'type' => 'hidden', 'value' => $product_id, - 'html_attr' => array( + 'html_attr' => [ 'v-bind:name' => "'products[]'", - ), - ); + ], + ]; } $this->insert_products_in_form($products); diff --git a/inc/checkout/signup-fields/class-signup-field-select.php b/inc/checkout/signup-fields/class-signup-field-select.php index 29fd1de..959069f 100644 --- a/inc/checkout/signup-fields/class-signup-field-select.php +++ b/inc/checkout/signup-fields/class-signup-field-select.php @@ -108,9 +108,9 @@ class Signup_Field_Select extends Base_Signup_Field { */ public function defaults() { - return array( + return [ '', - ); + ]; } /** @@ -121,7 +121,7 @@ class Signup_Field_Select extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ 'id', 'name', 'placeholder', @@ -129,7 +129,7 @@ class Signup_Field_Select extends Base_Signup_Field { 'tooltip', 'required', 'save_as', - ); + ]; } /** @@ -140,7 +140,7 @@ class Signup_Field_Select extends Base_Signup_Field { */ public function force_attributes() { - return array(); + return []; } /** @@ -151,81 +151,81 @@ class Signup_Field_Select extends Base_Signup_Field { */ public function get_fields() { - $editor_fields = array(); + $editor_fields = []; - $editor_fields['options_header'] = array( + $editor_fields['options_header'] = [ 'order' => 12, 'type' => 'small-header', 'title' => __('Options', 'wp-ultimo'), 'desc' => __('Add different options below. The first option is used as the default.', 'wp-ultimo'), - ); + ]; - $editor_fields['options_empty'] = array( + $editor_fields['options_empty'] = [ 'type' => 'note', 'desc' => __('Add the first option using the button below.', 'wp-ultimo'), 'classes' => 'wu-text-gray-600 wu-text-xs wu-text-center wu-w-full', 'wrapper_classes' => 'wu-bg-gray-100 wu-items-end', 'order' => 13, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'options.length === 0', 'v-cloak' => '1', - ), - ); + ], + ]; - $editor_fields['options'] = array( + $editor_fields['options'] = [ 'order' => 14, 'type' => 'group', 'tooltip' => '', 'wrapper_classes' => 'wu-relative wu-bg-gray-100', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'options.length', 'v-for' => '(option, index) in options', 'v-cloak' => '1', - ), - 'fields' => array( - 'options_remove' => array( + ], + 'fields' => [ + 'options_remove' => [ 'type' => 'note', 'desc' => sprintf('', __('Remove', 'wp-ultimo')), 'wrapper_classes' => 'wu-absolute wu-top-0 wu-right-0', - ), - 'options_key' => array( + ], + 'options_key' => [ 'type' => 'text', 'title' => __('Option Value', 'wp-ultimo'), 'placeholder' => __('e.g. option1', 'wp-ultimo'), 'wrapper_classes' => 'wu-w-1/2 wu-mr-2', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'option.key', 'steps' => 1, 'v-bind:name' => '"options[" + index + "][key]"', - ), - ), - 'options_label' => array( + ], + ], + 'options_label' => [ 'type' => 'text', 'title' => __('Label', 'wp-ultimo'), 'placeholder' => __('e.g. Option 1', 'wp-ultimo'), 'wrapper_classes' => 'wu-w-1/2 wu-ml-2', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'option.label', 'v-bind:name' => '"options[" + index + "][label]"', - ), - ), - ), - ); + ], + ], + ], + ]; - $editor_fields['repeat_select_option'] = array( + $editor_fields['repeat_select_option'] = [ 'order' => 16, 'type' => 'submit', 'title' => __('+ Add option', 'wp-ultimo'), 'classes' => 'wu-uppercase wu-text-2xs wu-text-blue-700 wu-border-none wu-bg-transparent wu-font-bold wu-text-right wu-w-full wu-cursor-pointer', 'wrapper_classes' => 'wu-bg-gray-100 wu-items-end', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'type' => 'button', 'v-on:click.prevent' => '() => options.push({})', - ), - ); + ], + ]; return $editor_fields; } @@ -240,14 +240,14 @@ class Signup_Field_Select extends Base_Signup_Field { */ public function to_fields_array($attributes) { - $options = array(); + $options = []; foreach ($attributes['options'] as $_option) { $options[ $_option['key'] ] = $_option['label']; } - return array( - $attributes['id'] => array( + return [ + $attributes['id'] => [ 'type' => 'select', 'id' => $attributes['id'], 'name' => $attributes['name'], @@ -258,7 +258,7 @@ class Signup_Field_Select extends Base_Signup_Field { 'wrapper_classes' => $attributes['element_classes'], 'options' => $options, 'value' => $this->get_value(), - ), - ); + ], + ]; } } diff --git a/inc/checkout/signup-fields/class-signup-field-shortcode.php b/inc/checkout/signup-fields/class-signup-field-shortcode.php index 49e497d..71a8310 100644 --- a/inc/checkout/signup-fields/class-signup-field-shortcode.php +++ b/inc/checkout/signup-fields/class-signup-field-shortcode.php @@ -103,9 +103,9 @@ class Signup_Field_Shortcode extends Base_Signup_Field { */ public function defaults() { - return array( + return [ '', - ); + ]; } /** @@ -116,10 +116,10 @@ class Signup_Field_Shortcode extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ // 'id', // 'name', - ); + ]; } /** @@ -130,9 +130,9 @@ class Signup_Field_Shortcode extends Base_Signup_Field { */ public function force_attributes() { - return array( + return [ 'name' => __('Shortcode', 'wp-ultimo'), - ); + ]; } /** @@ -143,14 +143,14 @@ class Signup_Field_Shortcode extends Base_Signup_Field { */ public function get_fields() { - return array( - 'shortcode_code' => array( + return [ + 'shortcode_code' => [ 'type' => 'text', 'title' => __('Shortcode', 'wp-ultimo'), 'placeholder' => __('e.g. [shortcode]', 'wp-ultimo'), 'desc' => __('Please, enter the full shortcode, including [].', 'wp-ultimo'), - ), - ); + ], + ]; } /** @@ -163,16 +163,16 @@ class Signup_Field_Shortcode extends Base_Signup_Field { */ public function to_fields_array($attributes) { - return array( - $attributes['id'] => array( + return [ + $attributes['id'] => [ 'type' => 'note', 'desc' => fn() => do_shortcode($attributes['shortcode_code']), 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''), 'classes' => wu_get_isset($attributes, 'element_classes', ''), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'style' => $this->calculate_style_attr(), - ), - ), - ); + ], + ], + ]; } } diff --git a/inc/checkout/signup-fields/class-signup-field-site-title.php b/inc/checkout/signup-fields/class-signup-field-site-title.php index 528f655..4bfa42a 100644 --- a/inc/checkout/signup-fields/class-signup-field-site-title.php +++ b/inc/checkout/signup-fields/class-signup-field-site-title.php @@ -119,9 +119,9 @@ class Signup_Field_Site_Title extends Base_Signup_Field { */ public function defaults() { - return array( + return [ 'auto_generate_site_title' => false, - ); + ]; } /** @@ -132,11 +132,11 @@ class Signup_Field_Site_Title extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ 'name', 'placeholder', 'tooltip', - ); + ]; } /** @@ -147,10 +147,10 @@ class Signup_Field_Site_Title extends Base_Signup_Field { */ public function force_attributes() { - return array( + return [ 'id' => 'site_title', 'required' => true, - ); + ]; } /** @@ -161,18 +161,18 @@ class Signup_Field_Site_Title extends Base_Signup_Field { */ public function get_fields() { - return array( - 'auto_generate_site_title' => array( + return [ + 'auto_generate_site_title' => [ 'type' => 'toggle', 'title' => __('Auto-generate?', 'wp-ultimo'), 'desc' => __('Check this option to auto-generate this field based on the username of the customer.', 'wp-ultimo'), 'tooltip' => '', 'value' => 0, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'auto_generate_site_title', - ), - ), - ); + ], + ], + ]; } /** @@ -188,24 +188,24 @@ class Signup_Field_Site_Title extends Base_Signup_Field { * If we should auto-generate, add as hidden. */ if (isset($attributes['auto_generate_site_title']) && $attributes['auto_generate_site_title']) { - return array( - 'auto_generate_site_title' => array( + return [ + 'auto_generate_site_title' => [ 'type' => 'hidden', 'id' => 'auto_generate_site_title', 'value' => 'username', - ), - 'site_title' => array( + ], + 'site_title' => [ 'type' => 'hidden', 'id' => 'site_title', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:value' => 'username', - ), - ), - ); + ], + ], + ]; } - return array( - 'site_title' => array( + return [ + 'site_title' => [ 'type' => 'text', 'id' => 'site_title', 'required' => true, @@ -215,10 +215,10 @@ class Signup_Field_Site_Title extends Base_Signup_Field { 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''), 'classes' => wu_get_isset($attributes, 'element_classes', ''), 'value' => $this->get_value(), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'style' => $this->calculate_style_attr(), - ), - ), - ); + ], + ], + ]; } } diff --git a/inc/checkout/signup-fields/class-signup-field-site-url.php b/inc/checkout/signup-fields/class-signup-field-site-url.php index a059668..0beaa36 100644 --- a/inc/checkout/signup-fields/class-signup-field-site-url.php +++ b/inc/checkout/signup-fields/class-signup-field-site-url.php @@ -114,13 +114,13 @@ class Signup_Field_Site_Url extends Base_Signup_Field { global $current_site; - return array( + return [ 'auto_generate_site_url' => false, 'display_url_preview' => true, 'enable_domain_selection' => false, 'display_field_attachments' => true, 'available_domains' => $current_site->domain . PHP_EOL, - ); + ]; } /** @@ -131,11 +131,11 @@ class Signup_Field_Site_Url extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ 'name', 'placeholder', 'tooltip', - ); + ]; } /** @@ -146,10 +146,10 @@ class Signup_Field_Site_Url extends Base_Signup_Field { */ public function force_attributes() { - return array( + return [ 'id' => 'site_url', 'required' => true, - ); + ]; } /** @@ -162,19 +162,19 @@ class Signup_Field_Site_Url extends Base_Signup_Field { global $current_site; - return array( - 'auto_generate_site_url' => array( + return [ + 'auto_generate_site_url' => [ 'order' => 12, 'type' => 'toggle', 'title' => __('Auto-generate', 'wp-ultimo'), 'desc' => __('Check this option to auto-generate this field based on the username of the customer.', 'wp-ultimo'), 'tooltip' => '', 'value' => 0, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'auto_generate_site_url', - ), - ), - 'display_field_attachments' => array( + ], + ], + 'display_field_attachments' => [ 'order' => 18, 'type' => 'toggle', 'title' => __('Display URL field attachments', 'wp-ultimo'), @@ -182,14 +182,14 @@ class Signup_Field_Site_Url extends Base_Signup_Field { 'tooltip' => '', 'value' => 1, 'tab' => 'content', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => '!auto_generate_site_url', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'display_field_attachments', - ), - ), - 'display_url_preview' => array( + ], + ], + 'display_url_preview' => [ 'order' => 19, 'type' => 'toggle', 'title' => __('Display URL preview block', 'wp-ultimo'), @@ -197,14 +197,14 @@ class Signup_Field_Site_Url extends Base_Signup_Field { 'tooltip' => '', 'value' => 1, 'tab' => 'content', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => '!auto_generate_site_url', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'display_url_preview', - ), - ), - 'enable_domain_selection' => array( + ], + ], + 'enable_domain_selection' => [ 'order' => 20, 'type' => 'toggle', 'title' => __('Enable Domain Selection', 'wp-ultimo'), @@ -212,15 +212,15 @@ class Signup_Field_Site_Url extends Base_Signup_Field { 'tooltip' => '', 'value' => 0, 'tab' => 'content', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => '!auto_generate_site_url', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'enable_domain_selection', 'rows' => 5, - ), - ), - 'available_domains' => array( + ], + ], + 'available_domains' => [ 'order' => 30, 'type' => 'textarea', 'title' => __('Available Domains', 'wp-ultimo'), @@ -228,14 +228,14 @@ class Signup_Field_Site_Url extends Base_Signup_Field { 'desc' => __('Enter one domain option per line.', 'wp-ultimo'), 'value' => $current_site->domain . PHP_EOL, 'tab' => 'content', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => '!auto_generate_site_url && enable_domain_selection', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'rows' => 4, - ), - ), - ); + ], + ], + ]; } /** @@ -246,10 +246,10 @@ class Signup_Field_Site_Url extends Base_Signup_Field { */ public function get_url_preview_templates() { - $templates = array( + $templates = [ 'legacy/signup/steps/step-domain-url-preview' => __('New URL Preview', 'wp-ultimo'), // 'legacy/signup/steps/step-domain-url-preview' => __('Legacy Template', 'wp-ultimo'), - ); + ]; return apply_filters('wu_get_pricing_table_templates', $templates); } @@ -267,23 +267,23 @@ class Signup_Field_Site_Url extends Base_Signup_Field { * If we should auto-generate, add as hidden. */ if ($attributes['auto_generate_site_url']) { - return array( - 'auto_generate_site_url' => array( + return [ + 'auto_generate_site_url' => [ 'type' => 'hidden', 'id' => 'auto_generate_site_url', 'value' => 'username', - ), - 'site_url' => array( + ], + 'site_url' => [ 'type' => 'hidden', 'id' => 'site_url', 'value' => uniqid(), - ), - ); + ], + ]; } - $checkout_fields = array(); + $checkout_fields = []; - $checkout_fields['site_url'] = array( + $checkout_fields['site_url'] = [ 'type' => 'text', 'id' => 'site_url', 'wrapper_classes' => 'wu-flex-grow wu-my-0', @@ -294,40 +294,40 @@ class Signup_Field_Site_Url extends Base_Signup_Field { 'required' => true, 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', 'wu-my-1'), 'classes' => wu_get_isset($attributes, 'element_classes', ''), - 'html_attr' => array( + 'html_attr' => [ 'autocomplete' => 'off', 'v-on:input' => 'site_url = $event.target.value.toLowerCase().replace(/[^a-z0-9-]+/g, "")', 'v-bind:value' => 'site_url', - ), - ); + ], + ]; if ($attributes['display_field_attachments']) { $checkout_fields['site_url']['classes'] .= ' xs:wu-rounded-none'; $checkout_fields['site_url']['prefix'] = ' '; - $checkout_fields['site_url']['prefix_html_attr'] = array( + $checkout_fields['site_url']['prefix_html_attr'] = [ 'class' => 'wu-flex wu-items-center wu-px-3 wu-mt-1 sm:wu-mb-1 wu-border-box wu-font-mono wu-justify-center sm:wu-border-r-0', 'style' => 'background-color: rgba(0, 0, 0, 0.008); border: 1px solid #eee; margin-right: -1px; font-size: 90%;', 'v-html' => 'is_subdomain ? "https://" : "https://" + site_domain + "/"', 'v-cloak' => 1, - ); + ]; $checkout_fields['site_url']['suffix'] = ' '; - $checkout_fields['site_url']['suffix_html_attr'] = array( + $checkout_fields['site_url']['suffix_html_attr'] = [ 'class' => 'wu-flex wu-items-center wu-px-3 sm:wu-mt-1 wu-mb-1 wu-border-box wu-font-mono wu-justify-center sm:wu-border-l-0', 'style' => 'background-color: rgba(0, 0, 0, 0.008); border: 1px solid #eee; margin-left: -1px; font-size: 90%;', 'v-html' => '"." + site_domain', 'v-cloak' => 1, 'v-show' => 'is_subdomain', - ); + ]; } if ($attributes['available_domains'] && $attributes['enable_domain_selection']) { $options = $this->get_domain_options($attributes['available_domains']); - $checkout_fields['site_domain'] = array( + $checkout_fields['site_domain'] = [ 'name' => __('Domain', 'wp-ultimo'), 'options' => $options, 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''), @@ -337,27 +337,27 @@ class Signup_Field_Site_Url extends Base_Signup_Field { 'id' => 'site_domain', 'type' => 'select', 'classes' => 'input', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'site_domain', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'style' => $this->calculate_style_attr(), - ), - ); + ], + ]; } if ($attributes['display_url_preview']) { $content = wu_get_template_contents('legacy/signup/steps/step-domain-url-preview'); - $checkout_fields['site_url_preview'] = array( + $checkout_fields['site_url_preview'] = [ 'type' => 'note', 'desc' => $content, 'wrapper_classes' => wu_get_isset($attributes, 'wrapper_element_classes', ''), 'classes' => wu_get_isset($attributes, 'element_classes', ''), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'style' => $this->calculate_style_attr(), - ), - ); + ], + ]; } return $checkout_fields; diff --git a/inc/checkout/signup-fields/class-signup-field-steps.php b/inc/checkout/signup-fields/class-signup-field-steps.php index 374ce08..e4a93d3 100644 --- a/inc/checkout/signup-fields/class-signup-field-steps.php +++ b/inc/checkout/signup-fields/class-signup-field-steps.php @@ -104,9 +104,9 @@ class Signup_Field_Steps extends Base_Signup_Field { */ public function defaults() { - return array( + return [ 'steps_template' => 'clean', - ); + ]; } /** @@ -117,7 +117,7 @@ class Signup_Field_Steps extends Base_Signup_Field { */ public function default_fields() { - return array(); + return []; } /** @@ -128,9 +128,9 @@ class Signup_Field_Steps extends Base_Signup_Field { */ public function force_attributes() { - return array( + return [ 'id' => 'steps', - ); + ]; } /** @@ -154,23 +154,23 @@ class Signup_Field_Steps extends Base_Signup_Field { */ public function get_fields() { - $editor_fields['steps_template'] = array( + $editor_fields['steps_template'] = [ 'type' => 'group', 'desc' => Field_Templates_Manager::get_instance()->render_preview_block('steps'), 'order' => 98, - 'fields' => array( - 'steps_template' => array( + 'fields' => [ + 'steps_template' => [ 'type' => 'select', 'title' => __('Layout', 'wp-ultimo'), 'placeholder' => __('Select your Layout', 'wp-ultimo'), - 'options' => array($this, 'get_templates'), + 'options' => [$this, 'get_templates'], 'wrapper_classes' => 'wu-flex-grow', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'steps_template', - ), - ), - ), - ); + ], + ], + ], + ]; // @todo: re-add developer notes. // $editor_fields['_dev_note_develop_your_own_template_steps'] = array( @@ -195,7 +195,7 @@ class Signup_Field_Steps extends Base_Signup_Field { public function to_fields_array($attributes) { if (wu_get_isset($attributes, 'steps_template') === 'legacy') { - wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), array('dashicons'), wu_get_version()); + wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), ['dashicons'], wu_get_version()); wp_add_inline_style('legacy-shortcodes', \WP_Ultimo\Checkout\Legacy_Checkout::get_instance()->get_legacy_dynamic_styles()); } @@ -207,12 +207,12 @@ class Signup_Field_Steps extends Base_Signup_Field { $content = $template_class ? $template_class->render_container($attributes) : __('Template does not exist.', 'wp-ultimo'); - return array( - $attributes['id'] => array( + return [ + $attributes['id'] => [ 'type' => 'note', 'desc' => $content, 'wrapper_classes' => $attributes['element_classes'], - ), - ); + ], + ]; } } diff --git a/inc/checkout/signup-fields/class-signup-field-submit-button.php b/inc/checkout/signup-fields/class-signup-field-submit-button.php index f4214c6..a14ceb8 100644 --- a/inc/checkout/signup-fields/class-signup-field-submit-button.php +++ b/inc/checkout/signup-fields/class-signup-field-submit-button.php @@ -108,10 +108,10 @@ class Signup_Field_Submit_Button extends Base_Signup_Field { */ public function defaults() { - return array( + return [ 'enable_go_back_button' => false, 'back_button_label' => __('← Go Back', 'wp-ultimo'), - ); + ]; } /** @@ -122,10 +122,10 @@ class Signup_Field_Submit_Button extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ 'id', 'name', - ); + ]; } /** @@ -136,7 +136,7 @@ class Signup_Field_Submit_Button extends Base_Signup_Field { */ public function force_attributes() { - return array(); + return []; } /** @@ -147,29 +147,29 @@ class Signup_Field_Submit_Button extends Base_Signup_Field { */ public function get_fields() { - return array( - 'enable_go_back_button' => array( + return [ + 'enable_go_back_button' => [ 'type' => 'toggle', 'title' => __('Add "Go Back" button', 'wp-ultimo'), 'desc' => __('Enable this option to add a "Go Back" button. Useful for multi-step checkout forms.', 'wp-ultimo'), 'tooltip' => '', 'value' => 0, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'enable_go_back_button', - ), - ), - 'back_button_label' => array( + ], + ], + 'back_button_label' => [ 'type' => 'text', 'title' => __('"Go Back" Button Label', 'wp-ultimo'), 'desc' => __('Value to be used as the "Go Back" label.', 'wp-ultimo'), 'placeholder' => __('e.g. ← Go Back', 'wp-ultimo'), 'value' => __('← Go Back', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => '1', 'v-show' => 'enable_go_back_button', - ), - ), - ); + ], + ], + ]; } /** @@ -184,24 +184,24 @@ class Signup_Field_Submit_Button extends Base_Signup_Field { $uniqid = uniqid(); - $fields = array(); + $fields = []; - $fields[ $attributes['id'] . '_errors' ] = array( + $fields[ $attributes['id'] . '_errors' ] = [ 'type' => 'html', 'wrapper_classes' => 'wu_submit_button_errors wu-clear-both', 'content' => '', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'get_errors()', - ), - ); + ], + ]; - $fields[ $attributes['id'] . '_group' ] = array( + $fields[ $attributes['id'] . '_group' ] = [ 'type' => 'group', 'raw' => true, - 'default' => array(), + 'default' => [], 'wrapper_classes' => '', - 'fields' => array(), - ); + 'fields' => [], + ]; $button_wrapper_classes = 'wu_submit_button'; @@ -211,29 +211,29 @@ class Signup_Field_Submit_Button extends Base_Signup_Field { $is_first_step = isset($steps[0]) && $steps[0]['id'] === $attributes['step']; if ( ! $is_first_step) { - $fields[ $attributes['id'] . '_group' ]['fields'][ $attributes['id'] . '_go_back' ] = array( + $fields[ $attributes['id'] . '_group' ]['fields'][ $attributes['id'] . '_go_back' ] = [ 'type' => 'html', 'wrapper_classes' => 'md:wu-w-1/2 wu-box-border wu-float-left wu--mt-4', 'id' => $attributes['id'] . '_go_back', 'content' => sprintf('%s', $attributes['back_button_label']), - ); + ]; $button_wrapper_classes .= ' md:wu-w-1/2 wu-box-border wu-float-left wu-text-right'; } } - $fields[ $attributes['id'] . '_group' ]['fields'][ $attributes['id'] ] = array( + $fields[ $attributes['id'] . '_group' ]['fields'][ $attributes['id'] ] = [ 'type' => 'submit', 'wrapper_classes' => trim($button_wrapper_classes . ' ' . wu_get_isset($attributes, 'wrapper_element_classes', '')), 'classes' => trim('button button-primary btn-primary' . ' ' . wu_get_isset($attributes, 'element_classes', '')), 'id' => $attributes['id'], 'name' => $attributes['name'], - ); + ]; if ($attributes['enable_go_back_button']) { - $fields[ $attributes['id'] . '_clear' ] = array( + $fields[ $attributes['id'] . '_clear' ] = [ 'type' => 'clear', - ); + ]; } return $fields; diff --git a/inc/checkout/signup-fields/class-signup-field-template-selection.php b/inc/checkout/signup-fields/class-signup-field-template-selection.php index 0b2b054..7115eae 100644 --- a/inc/checkout/signup-fields/class-signup-field-template-selection.php +++ b/inc/checkout/signup-fields/class-signup-field-template-selection.php @@ -105,13 +105,13 @@ class Signup_Field_Template_Selection extends Base_Signup_Field { */ public function defaults() { - return array( - 'template_selection_sites' => implode(',', wu_get_site_templates(array('fields' => 'ids'))), + return [ + 'template_selection_sites' => implode(',', wu_get_site_templates(['fields' => 'ids'])), 'template_selection_type' => 'name', 'template_selection_template' => 'clean', 'cols' => 3, 'hide_template_selection_when_pre_selected' => false, - ); + ]; } /** @@ -122,9 +122,9 @@ class Signup_Field_Template_Selection extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ // 'name', - ); + ]; } /** @@ -135,11 +135,11 @@ class Signup_Field_Template_Selection extends Base_Signup_Field { */ public function force_attributes() { - return array( + return [ 'id' => 'template_selection', 'name' => __('Template Selection', 'wp-ultimo'), 'required' => true, - ); + ]; } /** @@ -163,50 +163,50 @@ class Signup_Field_Template_Selection extends Base_Signup_Field { */ public function get_fields() { - $editor_fields = array(); + $editor_fields = []; - $editor_fields['cols'] = array( + $editor_fields['cols'] = [ 'type' => 'hidden', - ); + ]; - $editor_fields['template_selection_type'] = array( + $editor_fields['template_selection_type'] = [ 'type' => 'select', 'title' => __('Available templates', 'wp-ultimo'), 'desc' => __('How do you want to choose available which templates will be available.', 'wp-ultimo'), 'order' => 20, - 'options' => array( + 'options' => [ 'name' => __('Select by names'), 'categories' => __('Select by categories'), 'all' => __('All templates'), - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-model' => 'template_selection_type', - ), - ); + ], + ]; - $editor_fields['template_selection_categories'] = array( + $editor_fields['template_selection_categories'] = [ 'type' => 'select', 'title' => __('Template Categories', 'wp-ultimo'), 'placeholder' => __('e.g.: Landing Page, Health...', 'wp-ultimo'), 'desc' => __('Customers will be able to filter by categories during signup.', 'wp-ultimo'), 'order' => 21, 'options' => Site::get_all_categories(), - 'html_attr' => array( + 'html_attr' => [ 'data-selectize-categories' => 1, 'multiple' => 1, - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'template_selection_type === "categories"', - ), - ); + ], + ]; - $editor_fields['template_selection_sites'] = array( + $editor_fields['template_selection_sites'] = [ 'type' => 'model', 'title' => __('Template Sites', 'wp-ultimo'), 'placeholder' => __('e.g. Template Site 1, My Agency', 'wp-ultimo'), 'desc' => __('Be sure to add the templates in the order you want them to show up.', 'wp-ultimo'), 'order' => 22, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'template_selection_sites', 'data-model' => 'site', 'data-value-field' => 'blog_id', @@ -216,46 +216,46 @@ class Signup_Field_Template_Selection extends Base_Signup_Field { 'data-include' => implode( ',', wu_get_site_templates( - array( + [ 'fields' => 'blog_id', - ) + ] ) ), - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'template_selection_type === \'name\'', - ), - ); + ], + ]; - $editor_fields['hide_template_selection_when_pre_selected'] = array( + $editor_fields['hide_template_selection_when_pre_selected'] = [ 'type' => 'toggle', 'title' => __('Hide when Pre-Selected', 'wp-ultimo'), 'desc' => __('Prevent customers from seeing this field when a template was already selected via the URL.', 'wp-ultimo'), 'tooltip' => __('If the template selection field is the only field in the current step, the step will be skipped.', 'wp-ultimo'), 'value' => 0, 'order' => 23, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'hide_template_selection_when_pre_selected', - ), - ); + ], + ]; - $editor_fields['template_selection_template'] = array( + $editor_fields['template_selection_template'] = [ 'type' => 'group', 'order' => 24, 'desc' => Field_Templates_Manager::get_instance()->render_preview_block('template_selection'), - 'fields' => array( - 'template_selection_template' => array( + 'fields' => [ + 'template_selection_template' => [ 'type' => 'select', 'title' => __('Template Selector Template', 'wp-ultimo'), 'placeholder' => __('Select your Template', 'wp-ultimo'), - 'options' => array($this, 'get_template_selection_templates'), + 'options' => [$this, 'get_template_selection_templates'], 'wrapper_classes' => 'wu-flex-grow', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'template_selection_template', - ), - ), - ), - ); + ], + ], + ], + ]; // @todo: re-add developer notes. // $editor_fields['_dev_note_develop_your_own_template_1'] = array( @@ -296,14 +296,14 @@ class Signup_Field_Template_Selection extends Base_Signup_Field { */ public function to_fields_array($attributes) { - $checkout_fields = array(); + $checkout_fields = []; - $checkout_fields['template_id'] = array( + $checkout_fields['template_id'] = [ 'type' => 'hidden', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'template_id', - ), - ); + ], + ]; /** * Hide when pre-selected. @@ -313,22 +313,22 @@ class Signup_Field_Template_Selection extends Base_Signup_Field { } if (wu_get_isset($attributes, 'template_selection_template') === 'legacy') { - wp_register_script('wu-legacy-signup', wu_get_asset('legacy-signup.js', 'js'), array('wu-functions'), wu_get_version()); + wp_register_script('wu-legacy-signup', wu_get_asset('legacy-signup.js', 'js'), ['wu-functions'], wu_get_version()); wp_enqueue_script('wu-legacy-signup'); - wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), array('dashicons'), wu_get_version()); + wp_enqueue_style('legacy-shortcodes', wu_get_asset('legacy-shortcodes.css', 'css'), ['dashicons'], wu_get_version()); } $site_list = $this->site_list($attributes); - $customer_sites = array(); + $customer_sites = []; if (wu_get_setting('allow_own_site_as_template')) { $customer = wu_get_current_customer(); if ($customer) { - $customer_sites = $customer->get_sites(array('fields' => 'ids')); + $customer_sites = $customer->get_sites(['fields' => 'ids']); $site_list = array_merge( $customer_sites, @@ -344,23 +344,23 @@ class Signup_Field_Template_Selection extends Base_Signup_Field { // Remove inactive sites $sites = array_filter($sites, fn($site) => $site->is_active()); - $template_attributes = array( + $template_attributes = [ 'sites' => $sites, 'name' => $attributes['name'], 'cols' => $attributes['cols'], 'categories' => $attributes['template_selection_categories'] ?? \WP_Ultimo\Models\Site::get_all_categories($sites), 'customer_sites' => $customer_sites, - ); + ]; $template_class = Field_Templates_Manager::get_instance()->get_template_class('template_selection', $attributes['template_selection_template']); $content = $template_class ? $template_class->render_container($template_attributes, $this) : __('Template does not exist.', 'wp-ultimo'); - $checkout_fields[ $attributes['id'] ] = array( + $checkout_fields[ $attributes['id'] ] = [ 'type' => 'note', 'desc' => $content, 'wrapper_classes' => $attributes['element_classes'], - ); + ]; return $checkout_fields; } @@ -380,16 +380,16 @@ class Signup_Field_Template_Selection extends Base_Signup_Field { } if ($selection_type === 'all') { - return wu_get_site_templates(array('fields' => 'blog_id')); + return wu_get_site_templates(['fields' => 'blog_id']); } if ($selection_type === 'categories') { return array_column( \WP_Ultimo\Models\Site::get_all_by_categories( $attributes['template_selection_categories'], - array( - 'fields' => array('blog_id'), - ), + [ + 'fields' => ['blog_id'], + ], ), 'blog_id' ); diff --git a/inc/checkout/signup-fields/class-signup-field-terms-of-use.php b/inc/checkout/signup-fields/class-signup-field-terms-of-use.php index c0204e5..7746cbb 100644 --- a/inc/checkout/signup-fields/class-signup-field-terms-of-use.php +++ b/inc/checkout/signup-fields/class-signup-field-terms-of-use.php @@ -122,9 +122,9 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field { */ public function defaults() { - return array( + return [ 'tou_name' => __('I agree with the terms of use.', 'wp-ultimo'), - ); + ]; } /** @@ -135,7 +135,7 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field { */ public function default_fields() { - return array(); + return []; } /** @@ -146,10 +146,10 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field { */ public function force_attributes() { - return array( + return [ 'id' => 'terms_of_use', 'name' => __('Terms of Use', 'wp-ultimo'), - ); + ]; } /** @@ -160,21 +160,21 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field { */ public function get_fields() { - return array( - 'tou_name' => array( + return [ + 'tou_name' => [ 'order' => 10, 'type' => 'text', 'title' => __('Terms Checkbox Label', 'wp-ultimo'), 'placeholder' => __('e.g. I agree with the terms of use.', 'wp-ultimo'), - ), - 'tou_url' => array( + ], + 'tou_url' => [ 'order' => 20, 'type' => 'url', 'title' => __('Link to the Terms Page', 'wp-ultimo'), 'desc' => __('Enter the link to the terms of use content.', 'wp-ultimo'), 'placeholder' => __('e.g. https://yoursite.com/terms', 'wp-ultimo'), - ), - ); + ], + ]; } /** @@ -187,18 +187,18 @@ class Signup_Field_Terms_Of_Use extends Base_Signup_Field { */ public function to_fields_array($attributes) { - $checkout_fields = array(); + $checkout_fields = []; $tou_link = sprintf('%s', $attributes['tou_url'], __('Read here', 'wp-ultimo')); - $checkout_fields['terms_of_use'] = array( + $checkout_fields['terms_of_use'] = [ 'type' => 'checkbox', 'id' => 'terms_of_use', 'name' => $attributes['tou_name'] . ' - ', 'desc' => $tou_link, 'wrapper_classes' => $attributes['element_classes'], 'required' => true, - ); + ]; return $checkout_fields; } diff --git a/inc/checkout/signup-fields/class-signup-field-text.php b/inc/checkout/signup-fields/class-signup-field-text.php index 1ce3760..686a816 100644 --- a/inc/checkout/signup-fields/class-signup-field-text.php +++ b/inc/checkout/signup-fields/class-signup-field-text.php @@ -108,9 +108,9 @@ class Signup_Field_Text extends Base_Signup_Field { */ public function defaults() { - return array( + return [ '', - ); + ]; } /** @@ -121,7 +121,7 @@ class Signup_Field_Text extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ 'id', 'name', 'placeholder', @@ -129,7 +129,7 @@ class Signup_Field_Text extends Base_Signup_Field { 'tooltip', 'required', 'save_as', - ); + ]; } /** @@ -140,7 +140,7 @@ class Signup_Field_Text extends Base_Signup_Field { */ public function force_attributes() { - return array(); + return []; } /** @@ -151,7 +151,7 @@ class Signup_Field_Text extends Base_Signup_Field { */ public function get_fields() { - return array(); + return []; } /** @@ -164,8 +164,8 @@ class Signup_Field_Text extends Base_Signup_Field { */ public function to_fields_array($attributes) { - $fields = array( - $attributes['id'] => array( + $fields = [ + $attributes['id'] => [ 'type' => 'text', 'id' => $attributes['id'], 'name' => $attributes['name'], @@ -174,8 +174,8 @@ class Signup_Field_Text extends Base_Signup_Field { 'required' => $attributes['required'], 'wrapper_classes' => $attributes['element_classes'], 'value' => $this->get_value(), - ), - ); + ], + ]; return $fields; } diff --git a/inc/checkout/signup-fields/class-signup-field-username.php b/inc/checkout/signup-fields/class-signup-field-username.php index ac0e4cc..5241773 100644 --- a/inc/checkout/signup-fields/class-signup-field-username.php +++ b/inc/checkout/signup-fields/class-signup-field-username.php @@ -122,9 +122,9 @@ class Signup_Field_Username extends Base_Signup_Field { */ public function defaults() { - return array( + return [ 'auto_generate_username' => false, - ); + ]; } /** @@ -135,11 +135,11 @@ class Signup_Field_Username extends Base_Signup_Field { */ public function default_fields() { - return array( + return [ 'name', 'placeholder', 'tooltip', - ); + ]; } /** @@ -150,10 +150,10 @@ class Signup_Field_Username extends Base_Signup_Field { */ public function force_attributes() { - return array( + return [ 'id' => 'username', 'required' => true, - ); + ]; } /** @@ -164,18 +164,18 @@ class Signup_Field_Username extends Base_Signup_Field { */ public function get_fields() { - return array( - 'auto_generate_username' => array( + return [ + 'auto_generate_username' => [ 'type' => 'toggle', 'title' => __('Auto-generate', 'wp-ultimo'), 'desc' => __('Check this option to auto-generate this field based on the email address of the customer.', 'wp-ultimo'), 'tooltip' => '', 'value' => 0, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'auto_generate_username', - ), - ), - ); + ], + ], + ]; } /** @@ -191,26 +191,26 @@ class Signup_Field_Username extends Base_Signup_Field { * Logged in user, bail. */ if (is_user_logged_in()) { - return array(); + return []; } if (isset($attributes['auto_generate_username']) && $attributes['auto_generate_username']) { - return array( - 'auto_generate_username' => array( + return [ + 'auto_generate_username' => [ 'type' => 'hidden', 'id' => 'auto_generate_username', 'value' => 'email', - ), - 'username' => array( + ], + 'username' => [ 'type' => 'hidden', 'id' => 'username', 'value' => uniqid(), - ), - ); + ], + ]; } - return array( - 'username' => array( + return [ + 'username' => [ 'type' => 'text', 'id' => 'username', 'name' => $attributes['name'], @@ -220,15 +220,15 @@ class Signup_Field_Username extends Base_Signup_Field { 'classes' => wu_get_isset($attributes, 'element_classes', ''), 'required' => true, 'value' => $this->get_value(), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'username', 'v-init:username' => "'{$this->get_value()}'", 'autocomplete' => 'username', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'style' => $this->calculate_style_attr(), - ), - ), - ); + ], + ], + ]; } } diff --git a/inc/checkout/signup-fields/field-templates/class-base-field-template.php b/inc/checkout/signup-fields/field-templates/class-base-field-template.php index eb8207b..acfe9c6 100644 --- a/inc/checkout/signup-fields/field-templates/class-base-field-template.php +++ b/inc/checkout/signup-fields/field-templates/class-base-field-template.php @@ -32,7 +32,7 @@ class Base_Field_Template { /** * @var array */ - protected $attributes = array(); + protected $attributes = []; /** * Field Template Constructor @@ -41,7 +41,7 @@ class Base_Field_Template { * * @param array $attributes The attributes passed to the field. */ - public function __construct($attributes = array()) { + public function __construct($attributes = []) { $this->attributes = $attributes; } diff --git a/inc/checkout/signup-fields/field-templates/order-bump/class-simple-order-bump-field-template.php b/inc/checkout/signup-fields/field-templates/order-bump/class-simple-order-bump-field-template.php index 80d8590..56eb491 100644 --- a/inc/checkout/signup-fields/field-templates/order-bump/class-simple-order-bump-field-template.php +++ b/inc/checkout/signup-fields/field-templates/order-bump/class-simple-order-bump-field-template.php @@ -88,7 +88,7 @@ class Simple_Order_Bump_Field_Template extends Base_Field_Template { */ public function get_preview(): string { - return wu_get_asset('checkout-forms/clean-template-selection.png'); + return wu_get_asset('checkout-forms/clean-template-selection.webp'); } /** @@ -99,7 +99,7 @@ class Simple_Order_Bump_Field_Template extends Base_Field_Template { * @param array $attributes The field template attributes. * @return void */ - public function output($attributes) { + public function output($attributes): void { /** * Loads the actual order-bump template diff --git a/inc/checkout/signup-fields/field-templates/order-summary/class-clean-order-summary-field-template.php b/inc/checkout/signup-fields/field-templates/order-summary/class-clean-order-summary-field-template.php index 34e411d..f3fe23f 100644 --- a/inc/checkout/signup-fields/field-templates/order-summary/class-clean-order-summary-field-template.php +++ b/inc/checkout/signup-fields/field-templates/order-summary/class-clean-order-summary-field-template.php @@ -88,7 +88,7 @@ class Clean_Order_Summary_Field_Template extends Base_Field_Template { */ public function get_preview(): string { - return wu_get_asset('checkout-forms/clean-order-summary.png'); + return wu_get_asset('checkout-forms/clean-order-summary.webp'); } /** @@ -99,7 +99,7 @@ class Clean_Order_Summary_Field_Template extends Base_Field_Template { * @param array $attributes The field template attributes. * @return void */ - public function output($attributes) { + public function output($attributes): void { /** * Loads the actual order-summary template diff --git a/inc/checkout/signup-fields/field-templates/period-selection/class-clean-period-selection-field-template.php b/inc/checkout/signup-fields/field-templates/period-selection/class-clean-period-selection-field-template.php index b2ec553..475e752 100644 --- a/inc/checkout/signup-fields/field-templates/period-selection/class-clean-period-selection-field-template.php +++ b/inc/checkout/signup-fields/field-templates/period-selection/class-clean-period-selection-field-template.php @@ -90,7 +90,7 @@ class Clean_Period_Selection_Field_Template extends Base_Field_Template { */ public function get_preview(): string { - return wu_get_asset('checkout-forms/clean-period-selection.png'); + return wu_get_asset('checkout-forms/clean-period-selection.webp'); } /** @@ -101,7 +101,7 @@ class Clean_Period_Selection_Field_Template extends Base_Field_Template { * @param array $attributes The field template attributes. * @return void */ - public function output($attributes) { + public function output($attributes): void { wu_get_template('checkout/templates/period-selection/clean', $attributes); } diff --git a/inc/checkout/signup-fields/field-templates/period-selection/class-legacy-period-selection-field-template.php b/inc/checkout/signup-fields/field-templates/period-selection/class-legacy-period-selection-field-template.php index 77441b9..5cc182e 100644 --- a/inc/checkout/signup-fields/field-templates/period-selection/class-legacy-period-selection-field-template.php +++ b/inc/checkout/signup-fields/field-templates/period-selection/class-legacy-period-selection-field-template.php @@ -90,7 +90,7 @@ class Legacy_Period_Selection_Field_Template extends Base_Field_Template { */ public function get_preview(): string { - return wu_get_asset('checkout-forms/legacy-period-selection.png'); + return wu_get_asset('checkout-forms/legacy-period-selection.webp'); } /** @@ -101,7 +101,7 @@ class Legacy_Period_Selection_Field_Template extends Base_Field_Template { * @param array $attributes The field template attributes. * @return void */ - public function output($attributes) { + public function output($attributes): void { wu_get_template('checkout/templates/period-selection/legacy', $attributes); } diff --git a/inc/checkout/signup-fields/field-templates/pricing-table/class-legacy-pricing-table-field-template.php b/inc/checkout/signup-fields/field-templates/pricing-table/class-legacy-pricing-table-field-template.php index 3fddec6..0fdd83e 100644 --- a/inc/checkout/signup-fields/field-templates/pricing-table/class-legacy-pricing-table-field-template.php +++ b/inc/checkout/signup-fields/field-templates/pricing-table/class-legacy-pricing-table-field-template.php @@ -90,7 +90,7 @@ class Legacy_Pricing_Table_Field_Template extends Base_Field_Template { */ public function get_preview(): string { - return wu_get_asset('checkout-forms/legacy-pricing-table.png'); + return wu_get_asset('checkout-forms/legacy-pricing-table.webp'); } /** @@ -101,7 +101,7 @@ class Legacy_Pricing_Table_Field_Template extends Base_Field_Template { * @param array $attributes The field template attributes. * @return void */ - public function output($attributes) { + public function output($attributes): void { wu_get_template('checkout/templates/pricing-table/legacy', $attributes); } diff --git a/inc/checkout/signup-fields/field-templates/pricing-table/class-list-pricing-table-field-template.php b/inc/checkout/signup-fields/field-templates/pricing-table/class-list-pricing-table-field-template.php index af5a121..dac11a5 100644 --- a/inc/checkout/signup-fields/field-templates/pricing-table/class-list-pricing-table-field-template.php +++ b/inc/checkout/signup-fields/field-templates/pricing-table/class-list-pricing-table-field-template.php @@ -68,7 +68,7 @@ class List_Pricing_Table_Field_Template extends Base_Field_Template { */ public function get_preview(): string { - return wu_get_asset('checkout-forms/list-pricing-table.png'); + return wu_get_asset('checkout-forms/list-pricing-table.webp'); } /** @@ -79,7 +79,7 @@ class List_Pricing_Table_Field_Template extends Base_Field_Template { * @param array $attributes The field template attributes. * @return void */ - public function output($attributes) { + public function output($attributes): void { wu_get_template('checkout/templates/pricing-table/list', $attributes); } diff --git a/inc/checkout/signup-fields/field-templates/steps/class-clean-steps-field-template.php b/inc/checkout/signup-fields/field-templates/steps/class-clean-steps-field-template.php index 5eb2beb..6c2d49e 100644 --- a/inc/checkout/signup-fields/field-templates/steps/class-clean-steps-field-template.php +++ b/inc/checkout/signup-fields/field-templates/steps/class-clean-steps-field-template.php @@ -88,7 +88,7 @@ class Clean_Steps_Field_Template extends Base_Field_Template { */ public function get_preview(): string { - return wu_get_asset('checkout-forms/clean-steps.png'); + return wu_get_asset('checkout-forms/clean-steps.webp'); } /** @@ -99,7 +99,7 @@ class Clean_Steps_Field_Template extends Base_Field_Template { * @param array $attributes The field template attributes. * @return void */ - public function output($attributes) { + public function output($attributes): void { wu_get_template('checkout/templates/steps/clean', $attributes); } diff --git a/inc/checkout/signup-fields/field-templates/steps/class-legacy-steps-field-template.php b/inc/checkout/signup-fields/field-templates/steps/class-legacy-steps-field-template.php index fddfaf5..55107ce 100644 --- a/inc/checkout/signup-fields/field-templates/steps/class-legacy-steps-field-template.php +++ b/inc/checkout/signup-fields/field-templates/steps/class-legacy-steps-field-template.php @@ -88,7 +88,7 @@ class Legacy_Steps_Field_Template extends Base_Field_Template { */ public function get_preview(): string { - return wu_get_asset('checkout-forms/legacy-steps.png'); + return wu_get_asset('checkout-forms/legacy-steps.webp'); } /** @@ -99,7 +99,7 @@ class Legacy_Steps_Field_Template extends Base_Field_Template { * @param array $attributes The field template attributes. * @return void */ - public function output($attributes) { + public function output($attributes): void { wu_get_template('checkout/templates/steps/legacy', $attributes); } diff --git a/inc/checkout/signup-fields/field-templates/steps/class-minimal-steps-field-template.php b/inc/checkout/signup-fields/field-templates/steps/class-minimal-steps-field-template.php index 939b7cd..da84848 100644 --- a/inc/checkout/signup-fields/field-templates/steps/class-minimal-steps-field-template.php +++ b/inc/checkout/signup-fields/field-templates/steps/class-minimal-steps-field-template.php @@ -88,7 +88,7 @@ class Minimal_Steps_Field_Template extends Base_Field_Template { */ public function get_preview(): string { - return wu_get_asset('checkout-forms/minimal-steps.png'); + return wu_get_asset('checkout-forms/minimal-steps.webp'); } /** @@ -99,7 +99,7 @@ class Minimal_Steps_Field_Template extends Base_Field_Template { * @param array $attributes The field template attributes. * @return void */ - public function output($attributes) { + public function output($attributes): void { wu_get_template('checkout/templates/steps/minimal', $attributes); } diff --git a/inc/checkout/signup-fields/field-templates/template-selection/class-clean-template-selection-field-template.php b/inc/checkout/signup-fields/field-templates/template-selection/class-clean-template-selection-field-template.php index d882a61..8b5b899 100644 --- a/inc/checkout/signup-fields/field-templates/template-selection/class-clean-template-selection-field-template.php +++ b/inc/checkout/signup-fields/field-templates/template-selection/class-clean-template-selection-field-template.php @@ -88,7 +88,7 @@ class Clean_Template_Selection_Field_Template extends Base_Field_Template { */ public function get_preview(): string { - return wu_get_asset('checkout-forms/clean-template-selection.png'); + return wu_get_asset('checkout-forms/clean-template-selection.webp'); } /** @@ -99,7 +99,7 @@ class Clean_Template_Selection_Field_Template extends Base_Field_Template { * @param array $attributes The field template attributes. * @return void */ - public function output($attributes) { + public function output($attributes): void { wu_get_template('checkout/templates/template-selection/clean', $attributes); } diff --git a/inc/checkout/signup-fields/field-templates/template-selection/class-legacy-template-selection-field-template.php b/inc/checkout/signup-fields/field-templates/template-selection/class-legacy-template-selection-field-template.php index 3623c2f..c02ed84 100644 --- a/inc/checkout/signup-fields/field-templates/template-selection/class-legacy-template-selection-field-template.php +++ b/inc/checkout/signup-fields/field-templates/template-selection/class-legacy-template-selection-field-template.php @@ -79,7 +79,7 @@ class Legacy_Template_Selection_Field_Template extends Base_Field_Template { */ public function get_preview(): string { - return wu_get_asset('checkout-forms/legacy-template-selection.png'); + return wu_get_asset('checkout-forms/legacy-template-selection.webp'); } /** @@ -90,7 +90,7 @@ class Legacy_Template_Selection_Field_Template extends Base_Field_Template { * @param array $attributes The field template attributes. * @return void */ - public function output($attributes) { + public function output($attributes): void { wu_get_template('checkout/templates/template-selection/legacy', $attributes); } diff --git a/inc/checkout/signup-fields/field-templates/template-selection/class-minimal-template-selection-field-template.php b/inc/checkout/signup-fields/field-templates/template-selection/class-minimal-template-selection-field-template.php index bf47de5..df52a75 100644 --- a/inc/checkout/signup-fields/field-templates/template-selection/class-minimal-template-selection-field-template.php +++ b/inc/checkout/signup-fields/field-templates/template-selection/class-minimal-template-selection-field-template.php @@ -77,7 +77,7 @@ class Minimal_Template_Selection_Field_Template extends Base_Field_Template { */ public function get_preview(): string { - return wu_get_asset('checkout-forms/minimal-template-selection.png'); + return wu_get_asset('checkout-forms/minimal-template-selection.webp'); } /** @@ -88,7 +88,7 @@ class Minimal_Template_Selection_Field_Template extends Base_Field_Template { * @param array $attributes The field template attributes. * @return void */ - public function output($attributes) { + public function output($attributes): void { wu_get_template('checkout/templates/template-selection/minimal', $attributes); } diff --git a/inc/class-admin-notices.php b/inc/class-admin-notices.php index bbdccae..bbe2a55 100644 --- a/inc/class-admin-notices.php +++ b/inc/class-admin-notices.php @@ -27,24 +27,24 @@ class Admin_Notices { * @since 2.0.0 * @var array */ - protected $notices = array( - 'admin' => array(), - 'network-admin' => array(), - 'user' => array(), - ); + protected $notices = [ + 'admin' => [], + 'network-admin' => [], + 'user' => [], + ]; /** * Loads the hooks we need for dismissing notices * * @since 2.0.0 */ - public function init() { + public function init(): void { - add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); + add_action('admin_enqueue_scripts', [$this, 'enqueue_scripts']); - add_action('in_admin_header', array($this, 'display_notices')); + add_action('in_admin_header', [$this, 'display_notices']); - add_action('wp_ajax_wu_dismiss_admin_notice', array($this, 'ajax_dismiss_admin_notices')); + add_action('wp_ajax_wu_dismiss_admin_notice', [$this, 'ajax_dismiss_admin_notices']); } /** @@ -57,7 +57,7 @@ class Admin_Notices { $dismissed = get_user_meta(get_current_user_id(), 'wu_dismissed_admin_notices', true); - $dismissed = $dismissed ? $dismissed : array(); + $dismissed = $dismissed ?: []; return $dismissed; } @@ -77,16 +77,16 @@ class Admin_Notices { * @param array $actions List of buttons to add to the notification block. * @return void */ - public function add($notice, $type = 'success', $panel = 'admin', $dismissible_key = false, $actions = array()) { + public function add($notice, $type = 'success', $panel = 'admin', $dismissible_key = false, $actions = []): void { - $id = $dismissible_key ? $dismissible_key : md5($notice); + $id = $dismissible_key ?: md5($notice); - $this->notices[ $panel ][ $id ] = array( + $this->notices[ $panel ][ $id ] = [ 'type' => $type, 'message' => $notice, 'dismissible_key' => is_string($dismissible_key) ? $dismissible_key : false, 'actions' => $actions, - ); + ]; } /** @@ -100,7 +100,7 @@ class Admin_Notices { */ public function get_notices($panel = 'admin', $filter = true) { - $notices = isset($this->notices[ $panel ]) ? $this->notices[ $panel ] : array(); + $notices = $this->notices[ $panel ] ?? []; $dismissed_messages = $this->get_dismissed_notices(); @@ -129,9 +129,9 @@ class Admin_Notices { * @since 2.0.0 * @return void */ - public function enqueue_scripts() { + public function enqueue_scripts(): void { - wp_enqueue_script('wu-admin-notices', wu_get_asset('admin-notices.js', 'js'), array('jquery'), wu_get_version()); + wp_enqueue_script('wu-admin-notices', wu_get_asset('admin-notices.js', 'js'), ['jquery'], wu_get_version()); } /** @@ -161,7 +161,7 @@ class Admin_Notices { * @since 2.0.0 * @return void */ - public function display_notices() { + public function display_notices(): void { $panel = $this->get_current_panel(); @@ -169,10 +169,10 @@ class Admin_Notices { wu_get_template( 'admin-notices', - array( + [ 'notices' => $notices, 'nonce' => wp_create_nonce('wu-dismiss-admin-notice'), - ) + ] ); } @@ -182,7 +182,7 @@ class Admin_Notices { * @since 2.0.0 * @return void */ - public function ajax_dismiss_admin_notices() { + public function ajax_dismiss_admin_notices(): void { if ( ! wp_verify_nonce($_POST['nonce'], 'wu-dismiss-admin-notice')) { die('-1'); diff --git a/inc/class-admin-themes-compatibility.php b/inc/class-admin-themes-compatibility.php index c683bdb..6777da4 100644 --- a/inc/class-admin-themes-compatibility.php +++ b/inc/class-admin-themes-compatibility.php @@ -28,7 +28,7 @@ class Admin_Themes_Compatibility { */ public function __construct() { - add_filter('admin_body_class', array($this, 'add_body_classes')); + add_filter('admin_body_class', [$this, 'add_body_classes']); } /** @@ -62,26 +62,26 @@ class Admin_Themes_Compatibility { return apply_filters( 'wu_admin_themes_compatibility', - array( - 'material-wp' => array( + [ + 'material-wp' => [ 'activated' => class_exists('MaterialWP'), - ), - 'pro-theme' => array( + ], + 'pro-theme' => [ 'activated' => class_exists('PROTheme'), - ), - 'admin-2020' => array( + ], + 'admin-2020' => [ 'activated' => function_exists('run_admin_2020'), - ), - 'clientside' => array( + ], + 'clientside' => [ 'activated' => class_exists('Clientside'), - ), - 'wphave' => array( + ], + 'wphave' => [ 'activated' => class_exists('wphave_admin'), - ), - 'waaspro' => array( + ], + 'waaspro' => [ 'activated' => class_exists('AdminUIPRO') || class_exists('AdminUIPROflat'), - ), - ) + ], + ] ); } } diff --git a/inc/class-ajax.php b/inc/class-ajax.php index 4b58f6e..71354e5 100644 --- a/inc/class-ajax.php +++ b/inc/class-ajax.php @@ -30,17 +30,17 @@ class Ajax { /* * Load search endpoints. */ - add_action('wu_ajax_wu_search', array($this, 'search_models')); + add_action('wu_ajax_wu_search', [$this, 'search_models']); /* * Adds the Selectize templates to the admin_footer. */ - add_action('in_admin_footer', array($this, 'render_selectize_templates')); + add_action('in_admin_footer', [$this, 'render_selectize_templates']); /* * Load search endpoints. */ - add_action('wp_ajax_wu_list_table_fetch_ajax_results', array($this, 'refresh_list_table')); + add_action('wp_ajax_wu_list_table_fetch_ajax_results', [$this, 'refresh_list_table']); } /** * Reverts the name of the table being processed. @@ -60,7 +60,7 @@ class Ajax { * @since 2.0.0 * @return void */ - public function refresh_list_table() { + public function refresh_list_table(): void { $table_id = wu_request('table_id'); @@ -83,7 +83,7 @@ class Ajax { * @since 2.0.0 * @return void */ - public function search_models() { + public function search_models(): void { /** * Fires before the processing of the search request. @@ -100,18 +100,18 @@ class Ajax { $args = wp_parse_args( $_REQUEST, - array( + [ 'model' => 'membership', - 'query' => array(), - 'exclude' => array(), - ) + 'query' => [], + 'exclude' => [], + ] ); $query = array_merge( $args['query'], - array( + [ 'number' => -1, - ) + ] ); if ($args['exclude']) { @@ -151,18 +151,18 @@ class Ajax { } } - $results = array(); + $results = []; if ($args['model'] === 'user') { $results = $this->search_wordpress_users($query); } elseif ($args['model'] === 'page') { $results = get_posts( - array( + [ 'post_type' => 'page', 'post_status' => 'publish', 'numberposts' => -1, - 'exclude' => isset($query['id__not_in']) ? $query['id__not_in'] : '', - ) + 'exclude' => $query['id__not_in'] ?? '', + ] ); } elseif ($args['model'] === 'setting') { $results = $this->search_wp_ultimo_setting($query); @@ -181,7 +181,7 @@ class Ajax { if (function_exists($model_func)) { $result = $model_func(trim((string) $query['search'], '*')); - $results = $result ? array($result) : array(); + $results = $result ? [$result] : []; } } @@ -196,13 +196,13 @@ class Ajax { * @since 2.0.0 * @return void */ - public function search_all_models() { + public function search_all_models(): void { $query = array_merge( - wu_request('query', array()), - array( + wu_request('query', []), + [ 'number' => 10000, - ) + ] ); $results_user = array_map( @@ -242,7 +242,7 @@ class Ajax { */ $data_sources = apply_filters( 'wu_search_models_functions', - array( + [ 'wu_get_customers', 'wu_get_products', 'wu_get_plans', @@ -252,7 +252,7 @@ class Ajax { 'wu_get_payments', 'wu_get_broadcasts', 'wu_get_checkout_forms', - ) + ] ); foreach ($data_sources as $function) { @@ -265,9 +265,9 @@ class Ajax { $item->value = wu_network_admin_url( "wp-ultimo-edit-{$url}", - array( + [ 'id' => $item->get_id(), - ) + ] ); $item->group = ucwords((string) $item->model) . 's'; @@ -284,9 +284,9 @@ class Ajax { $discount['value'] = wu_network_admin_url( 'wp-ultimo-edit-discount-code', - array( + [ 'id' => $discount['id'], - ) + ] ); $discount['group'] = 'Discount Codes'; @@ -312,7 +312,7 @@ class Ajax { $sections = \WP_Ultimo\Settings::get_instance()->get_sections(); - $all_fields = array(); + $all_fields = []; foreach ($sections as $section_slug => $section) { $section['fields'] = array_map( @@ -324,9 +324,9 @@ class Ajax { $item['url'] = wu_network_admin_url( 'wp-ultimo-settings', - array( + [ 'tab' => $section_slug, - ) + ] ) . '#' . $item['setting_id']; return $item; @@ -339,13 +339,13 @@ class Ajax { $_settings = \Arrch\Arrch::find( $all_fields, - array( + [ 'sort_key' => 'title', - 'where' => array( - array('setting_id', '~', trim((string) $query['search'], '*')), - array('type', '!=', 'header'), - ), - ) + 'where' => [ + ['setting_id', '~', trim((string) $query['search'], '*')], + ['type', '!=', 'header'], + ], + ] ); return array_values($_settings); @@ -362,18 +362,18 @@ class Ajax { public function search_wordpress_users($query) { $results = get_users( - array( + [ 'blog_id' => 0, 'search' => '*' . $query['search'] . '*', - 'search_columns' => array( + 'search_columns' => [ 'ID', 'user_login', 'user_email', 'user_url', 'user_nicename', 'display_name', - ), - ) + ], + ] ); $results = array_map( @@ -386,10 +386,10 @@ class Ajax { 40, 'identicon', '', - array( + [ 'force_display' => true, 'class' => 'wu-rounded-full wu-mr-3', - ) + ] ); return $item->data; @@ -406,7 +406,7 @@ class Ajax { * @since 2.0.0 * @return void */ - public function render_selectize_templates() { + public function render_selectize_templates(): void { if (current_user_can('manage_network')) { wu_get_template('ui/selectize-templates'); diff --git a/inc/class-api.php b/inc/class-api.php index 9a16487..e249be7 100644 --- a/inc/class-api.php +++ b/inc/class-api.php @@ -50,35 +50,35 @@ class API { * * @since 1.7.4 */ - add_action('init', array($this, 'add_settings')); + add_action('init', [$this, 'add_settings']); /** * Refreshing API credentials * * @since 1.7.4 */ - add_action('wu_before_save_settings', array($this, 'refresh_API_credentials'), 10); + add_action('wu_before_save_settings', [$this, 'refresh_API_credentials'], 10); /** * Register the routes * * @since 1.7.4 */ - add_action('rest_api_init', array($this, 'register_routes')); + add_action('rest_api_init', [$this, 'register_routes']); /** * Log API errors * * @since 2.0.0 */ - add_action('rest_request_after_callbacks', array($this, 'log_api_errors'), 10, 3); + add_action('rest_request_after_callbacks', [$this, 'log_api_errors'], 10, 3); /** * We need to bypass the WP Core auth errors in our routes so we can use our api keys * * @since 2.1.2 */ - add_filter('rest_authentication_errors', array($this, 'maybe_bypass_wp_auth'), 1); + add_filter('rest_authentication_errors', [$this, 'maybe_bypass_wp_auth'], 1); } /** @@ -101,7 +101,7 @@ class API { $rest_url = rest_url(); $rest_path = rtrim(parse_url($rest_url, PHP_URL_PATH), '/'); - if (strncmp((string) $current_route, $rest_path . '/' . $this->get_namespace(), strlen($rest_path . '/' . $this->get_namespace())) !== 0) { + if (! str_starts_with((string) $current_route, $rest_path . '/' . $this->get_namespace())) { return $result; } @@ -114,7 +114,7 @@ class API { * @since 1.7.4 * @return void */ - public function refresh_API_credentials() { // phpcs:ignore + public function refresh_API_credentials(): void { // phpcs:ignore if (wu_request('submit_button') === 'refresh_api_credentials') { wu_save_setting('api_url', network_site_url()); @@ -134,40 +134,40 @@ class API { * * @since 1.7.4 */ - public function add_settings() { + public function add_settings(): void { /* * API & Webhooks * This section holds the API settings of the WP Multisite WaaS Plugin. */ wu_register_settings_section( 'api', - array( + [ 'title' => __('API & Webhooks', 'wp-ultimo'), 'desc' => __('API & Webhooks', 'wp-ultimo'), 'icon' => 'dashicons-wu-paper-plane', 'order' => 95, - ) + ] ); wu_register_settings_field( 'api', 'api_header', - array( + [ 'title' => __('API Settings', 'wp-ultimo'), 'desc' => __('Options related to WP Multisite WaaS API endpoints.', 'wp-ultimo'), 'type' => 'header', - ) + ] ); wu_register_settings_field( 'api', 'enable_api', - array( + [ 'title' => __('Enable API', 'wp-ultimo'), 'desc' => __('Tick this box if you want WP Multisite WaaS to add its own endpoints to the WordPress REST API. This is required for some integrations to work, most notabily, Zapier.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 1, - ) + ] ); $refreshed_tag = ''; @@ -179,23 +179,23 @@ class API { wu_register_settings_field( 'api', 'api_url', - array( + [ 'title' => __('API URL', 'wp-ultimo'), 'desc' => '', 'tooltip' => '', 'copy' => true, 'type' => 'text-display', 'default' => network_site_url(), - 'require' => array( + 'require' => [ 'enable_api' => true, - ), - ) + ], + ] ); wu_register_settings_field( 'api', 'api_key', - array( + [ 'title' => __('API Key', 'wp-ultimo') . $refreshed_tag, 'desc' => '', 'tooltip' => '', @@ -203,89 +203,89 @@ class API { 'copy' => true, 'default' => wp_generate_password(24, false), 'wrapper_classes' => 'sm:wu-w-1/2 wu-float-left', - 'require' => array( + 'require' => [ 'enable_api' => true, - ), - ) + ], + ] ); wu_register_settings_field( 'api', 'api_secret', - array( + [ 'title' => __('API Secret', 'wp-ultimo') . $refreshed_tag, 'tooltip' => '', 'type' => 'text-display', 'copy' => true, 'default' => wp_generate_password(24, false), 'wrapper_classes' => 'sm:wu-border-l-0 sm:wu-w-1/2 wu-float-left', - 'require' => array( + 'require' => [ 'enable_api' => 1, - ), - ) + ], + ] ); wu_register_settings_field( 'api', 'api_note', - array( + [ 'desc' => __('This is your API Key. You cannot change it directly. To reset the API key and secret, use the button "Refresh API credentials" below.', 'wp-ultimo'), 'type' => 'note', 'classes' => 'wu-text-gray-700 wu-text-xs', 'wrapper_classes' => 'wu-bg-white sm:wu-border-t-0 sm:wu-mt-0 sm:wu-pt-0', - 'require' => array( + 'require' => [ 'enable_api' => 1, - ), - ) + ], + ] ); wu_register_settings_field( 'api', 'refresh_api_credentials', - array( + [ 'title' => __('Refresh API Credentials', 'wp-ultimo'), 'type' => 'submit', 'classes' => 'button wu-ml-auto', 'wrapper_classes' => 'wu-bg-white sm:wu-border-t-0 sm:wu-mt-0 sm:wu-pt-0', - 'require' => array( + 'require' => [ 'enable_api' => 1, - ), - ) + ], + ] ); wu_register_settings_field( 'api', 'api_log_calls', - array( + [ 'title' => __('Log API calls (Advanced)', 'wp-ultimo'), 'desc' => __('Tick this box if you want to log all calls received via WP Multisite WaaS API endpoints. You can access the logs on WP Multisite WaaS → System Info → Logs.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, - 'require' => array( + 'require' => [ 'enable_api' => 1, - ), - ) + ], + ] ); wu_register_settings_field( 'api', 'webhook_header', - array( + [ 'title' => __('Webhook Settings', 'wp-ultimo'), 'desc' => __('Options related to WP Multisite WaaS API webhooks.', 'wp-ultimo'), 'type' => 'header', - ) + ] ); wu_register_settings_field( 'api', 'webhook_calls_blocking', - array( + [ 'title' => __('Wait for Response (Advanced)', 'wp-ultimo'), 'desc' => __('Tick this box if you want the WP Multisite WaaS\'s webhook calls to wait for the remote server to respond. Keeping this option enabled can have huge effects on your network\'s performance, only enable it if you know what you are doing and need to debug webhook calls.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, - ) + ] ); } @@ -308,10 +308,10 @@ class API { */ public function get_auth() { - return array( + return [ 'api_key' => wu_get_setting('api_key', 'prevent'), 'api_secret' => wu_get_setting('api_secret', 'prevent'), - ); + ]; } /** @@ -345,15 +345,15 @@ class API { * * @param WP_REST_Request $request The request sent. */ - public function maybe_log_api_call($request) { + public function maybe_log_api_call($request): void { if ($this->should_log_api_calls()) { - $payload = array( + $payload = [ 'route' => $request->get_route(), 'method' => $request->get_method(), 'url_params' => $request->get_url_params(), 'body_params' => $request->get_body(), - ); + ]; wu_log_add('api-calls', json_encode($payload, JSON_PRETTY_PRINT)); } @@ -371,17 +371,17 @@ class API { */ public function log_api_errors($result, $handler, $request) { - if (is_wp_error($result) && strncmp($request->get_route(), '/wu', strlen('/wu')) === 0) { + if (is_wp_error($result) && str_starts_with($request->get_route(), '/wu')) { /* * Log API call here if we didn't log it before. */ if ( ! $this->should_log_api_calls()) { - $payload = array( + $payload = [ 'route' => $request->get_route(), 'method' => $request->get_method(), 'url_params' => $request->get_url_params(), 'body_params' => $request->get_body(), - ); + ]; wu_log_add('api-errors', json_encode($payload, JSON_PRETTY_PRINT)); } @@ -441,7 +441,7 @@ class API { * @since 1.7.4 * @return void */ - public function register_routes() { + public function register_routes(): void { if ( ! $this->is_api_enabled()) { return; @@ -452,11 +452,11 @@ class API { register_rest_route( $namespace, '/auth', - array( + [ 'methods' => 'GET', - 'callback' => array($this, 'auth'), - 'permission_callback' => array($this, 'check_authorization'), - ) + 'callback' => [$this, 'auth'], + 'permission_callback' => [$this, 'check_authorization'], + ] ); /** @@ -478,16 +478,16 @@ class API { * @param \WP_REST_Request $request WP Request Object. * @return void */ - public function auth($request) { + public function auth($request): void { $current_site = get_current_site(); wp_send_json( - array( + [ 'success' => true, 'label' => $current_site->site_name, 'message' => __('Welcome to our API', 'wp-ultimo'), - ) + ] ); } } diff --git a/inc/class-async-calls.php b/inc/class-async-calls.php index 1bc3e28..2c5de4c 100644 --- a/inc/class-async-calls.php +++ b/inc/class-async-calls.php @@ -33,7 +33,7 @@ class Async_Calls { * * @var array */ - static $registry = array(); + static $registry = []; /** * Registers a new listener. @@ -45,12 +45,12 @@ class Async_Calls { * @param mixed ...$args Arguments to be passed to the callback. * @return void */ - public static function register_listener($id, $callable, ...$args) { + public static function register_listener($id, $callable, ...$args): void { - self::$registry[ $id ] = array( + self::$registry[ $id ] = [ 'callable' => $callable, 'args' => $args, - ); + ]; } /** @@ -59,7 +59,7 @@ class Async_Calls { * @since 2.0.7 * @return void */ - public static function install_listeners() { + public static function install_listeners(): void { foreach (self::$registry as $id => $listener) { add_action( @@ -105,23 +105,23 @@ class Async_Calls { * @param array $args Additional arguments to be passed. * @return array The list of paginates URLs to call. */ - public static function build_url_list($id, $total, $chunk_size, $args = array()) { + public static function build_url_list($id, $total, $chunk_size, $args = []) { $pages = ceil($total / $chunk_size); - $urls = array(); + $urls = []; for ($i = 1; $i <= $pages; $i++) { $urls[] = self::build_base_url( $id, array_merge( $args, - array( + [ 'action' => "wu_async_call_listener_$id", 'parallel' => 1, 'page' => $i, 'per_page' => $chunk_size, - ) + ] ) ); } @@ -162,7 +162,7 @@ class Async_Calls { * @param integer $parallel_threads The number of parallel threads to be run. * @return true|\WP_Error */ - public static function run($id, $args, $total, $chunk_size = 10, $parallel_threads = 3) { + public static function run($id, $args, $total, $chunk_size = 10, $parallel_threads = 3): void { $client = self::get_client(); @@ -171,7 +171,7 @@ class Async_Calls { $coroutine = \Amp\call( static function () use ($id, $total, $chunk_size, $parallel_threads, $client, $urls) { - $results = array(); + $results = []; $chunker = new LocalSemaphore($parallel_threads); diff --git a/inc/class-autoloader.php b/inc/class-autoloader.php index 8210b75..64653b7 100644 --- a/inc/class-autoloader.php +++ b/inc/class-autoloader.php @@ -40,7 +40,7 @@ class Autoloader { * @deprecated 2.3.5 * @return void */ - public static function init() { + public static function init(): void { // do nothing now. Composer autoloader does the work. } diff --git a/inc/class-cron.php b/inc/class-cron.php index 436b75d..632434a 100644 --- a/inc/class-cron.php +++ b/inc/class-cron.php @@ -36,11 +36,11 @@ class Cron { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { /* * Creates general schedules for general uses. */ - add_action('init', array($this, 'create_schedules')); + add_action('init', [$this, 'create_schedules']); /* * Deals with renewals for non-auto-renewing @@ -50,22 +50,22 @@ class Cron { * The second hook adds the handler to be called on that schedule. * The third one deals with each membership that needs to be manually renewed. */ - add_action('init', array($this, 'schedule_membership_check')); + add_action('init', [$this, 'schedule_membership_check']); - add_action('wu_membership_check', array($this, 'membership_renewal_check'), 10); + add_action('wu_membership_check', [$this, 'membership_renewal_check'], 10); - add_action('wu_membership_check', array($this, 'membership_trial_check'), 10); + add_action('wu_membership_check', [$this, 'membership_trial_check'], 10); - add_action('wu_async_create_renewal_payment', array($this, 'async_create_renewal_payment'), 10, 2); + add_action('wu_async_create_renewal_payment', [$this, 'async_create_renewal_payment'], 10, 2); /* * On that same check, we'll * search for expired memberships * and mark them as such. */ - add_action('wu_membership_check', array($this, 'membership_expired_check'), 20); + add_action('wu_membership_check', [$this, 'membership_expired_check'], 20); - add_action('wu_async_mark_membership_as_expired', array($this, 'async_mark_membership_as_expired'), 10); + add_action('wu_async_mark_membership_as_expired', [$this, 'async_mark_membership_as_expired'], 10); } /** @@ -76,21 +76,21 @@ class Cron { * @since 2.0.0 * @return void */ - public function create_schedules() { + public function create_schedules(): void { /* * Hourly check */ if (wu_next_scheduled_action('wu_hourly') === false) { $next_hour = strtotime(gmdate('Y-m-d H:00:00', strtotime('+1 hour'))); - wu_schedule_recurring_action($next_hour, HOUR_IN_SECONDS, 'wu_hourly', array(), 'wu_cron'); + wu_schedule_recurring_action($next_hour, HOUR_IN_SECONDS, 'wu_hourly', [], 'wu_cron'); } /* * Daily check */ if (wu_next_scheduled_action('wu_daily') === false) { - wu_schedule_recurring_action(strtotime('tomorrow'), DAY_IN_SECONDS, 'wu_daily', array(), 'wu_cron'); + wu_schedule_recurring_action(strtotime('tomorrow'), DAY_IN_SECONDS, 'wu_daily', [], 'wu_cron'); } /* @@ -99,7 +99,7 @@ class Cron { if (wu_next_scheduled_action('wu_monthly') === false) { $next_month = strtotime(gmdate('Y-m-01 00:00:00', strtotime('+1 month'))); - wu_schedule_recurring_action($next_month, MONTH_IN_SECONDS, 'wu_monthly', array(), 'wu_cron'); + wu_schedule_recurring_action($next_month, MONTH_IN_SECONDS, 'wu_monthly', [], 'wu_cron'); } } @@ -113,12 +113,12 @@ class Cron { * @since 2.0.0 * @return void */ - public function schedule_membership_check() { + public function schedule_membership_check(): void { $interval = apply_filters('wu_schedule_membership_check_interval', 1 * HOUR_IN_SECONDS); if (wu_next_scheduled_action('wu_membership_check') === false) { - wu_schedule_recurring_action(time(), $interval, 'wu_membership_check', array(), 'wu_cron'); + wu_schedule_recurring_action(time(), $interval, 'wu_membership_check', [], 'wu_cron'); } } @@ -131,7 +131,7 @@ class Cron { * @since 2.0.0 * @return void */ - public function membership_renewal_check() { + public function membership_renewal_check(): void { /* * Define how many days before we need to * create pending payments. @@ -140,18 +140,18 @@ class Cron { $query_params = apply_filters( 'wu_membership_renewal_check_query_params', - array( + [ 'auto_renew' => false, - 'status__in' => array( + 'status__in' => [ Membership_Status::ACTIVE, - ), - 'date_query' => array( + ], + 'date_query' => [ 'column' => 'date_expiration', 'before' => "+{$days_before_expiring} days", 'after' => 'yesterday', 'inclusive' => true, - ), - ), + ], + ], $days_before_expiring ); @@ -164,9 +164,9 @@ class Cron { foreach ($memberships as $membership) { wu_enqueue_async_action( 'wu_async_create_renewal_payment', - array( + [ 'membership_id' => $membership->get_id(), - ), + ], 'wu_cron_check' ); } @@ -181,21 +181,21 @@ class Cron { * @since 2.0.0 * @return void */ - public function membership_trial_check() { + public function membership_trial_check(): void { $query_params = apply_filters( 'wu_membership_trial_check_query_params', - array( + [ 'auto_renew' => false, - 'status__in' => array( + 'status__in' => [ Membership_Status::TRIALING, - ), - 'date_query' => array( + ], + 'date_query' => [ 'column' => 'date_trial_end', 'before' => '-3 hours', 'inclusive' => true, - ), - ) + ], + ] ); $memberships = wu_get_memberships($query_params); @@ -207,10 +207,10 @@ class Cron { foreach ($memberships as $membership) { wu_enqueue_async_action( 'wu_async_create_renewal_payment', - array( + [ 'membership_id' => $membership->get_id(), 'trial' => true, - ), + ], 'wu_cron_check' ); } @@ -255,16 +255,16 @@ class Cron { $saved = $membership->save(); $payment_url = add_query_arg( - array( + [ 'payment' => $new_payment->get_hash(), - ), + ], wu_get_registration_url() ); $payload = array_merge( - array( + [ 'default_payment_url' => $payment_url, - ), + ], wu_generate_event_payload('payment', $new_payment), wu_generate_event_payload('membership', $membership), wu_generate_event_payload('customer', $membership->get_customer()) @@ -284,7 +284,7 @@ class Cron { * @since 2.0.0 * @return void */ - public function membership_expired_check() { + public function membership_expired_check(): void { /* * Define how many grace period * days we allow for our customers. @@ -293,19 +293,19 @@ class Cron { $query_params = apply_filters( 'wu_membership_expired_check_query_params', - array( + [ 'auto_renew' => false, - 'status__in' => array( + 'status__in' => [ Membership_Status::ACTIVE, Membership_Status::ON_HOLD, - ), - 'date_expiration__not_in' => array(null, '0000-00-00 00:00:00'), - 'date_query' => array( + ], + 'date_expiration__not_in' => [null, '0000-00-00 00:00:00'], + 'date_query' => [ 'column' => 'date_expiration', 'before' => "-{$grace_period_days} days", 'inclusive' => true, - ), - ), + ], + ], $grace_period_days ); @@ -318,9 +318,9 @@ class Cron { foreach ($memberships as $membership) { wu_enqueue_async_action( 'wu_async_mark_membership_as_expired', - array( + [ 'membership_id' => $membership->get_id(), - ), + ], 'wu_cron_check' ); } diff --git a/inc/class-current.php b/inc/class-current.php index b9cc46d..c177039 100644 --- a/inc/class-current.php +++ b/inc/class-current.php @@ -75,21 +75,21 @@ class Current { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { /* * Add rewrite rules */ - add_action('init', array($this, 'add_rewrite_rules')); - add_filter('query_vars', array($this, 'add_query_vars')); + add_action('init', [$this, 'add_rewrite_rules']); + add_filter('query_vars', [$this, 'add_query_vars']); - add_action('wu_after_save_settings', array($this, 'flush_rewrite_rules_on_update')); - add_action('wu_core_update', array($this, 'flush_rewrite_rules_on_update')); + add_action('wu_after_save_settings', [$this, 'flush_rewrite_rules_on_update']); + add_action('wu_core_update', [$this, 'flush_rewrite_rules_on_update']); /* * Instantiate the currents. */ - add_action('init', array($this, 'load_currents')); - add_action('wp', array($this, 'load_currents')); + add_action('init', [$this, 'load_currents']); + add_action('wp', [$this, 'load_currents']); } /** @@ -98,7 +98,7 @@ class Current { * @since 2.0.0 * @return void */ - public function flush_rewrite_rules_on_update() { + public function flush_rewrite_rules_on_update(): void { flush_rewrite_rules(); } @@ -111,7 +111,7 @@ class Current { * @since 2.0.0 * @return void */ - public function add_rewrite_rules() { + public function add_rewrite_rules(): void { $site_url_param = self::param_key('site'); @@ -159,11 +159,11 @@ class Current { */ public static function param_key($type = 'site') { - $params = array( + $params = [ 'site' => apply_filters('wu_current_get_site_param', 'site'), 'customer' => apply_filters('wu_current_get_customer_param', 'customer'), 'membership' => apply_filters('wu_current_get_membership_param', 'membership'), - ); + ]; return wu_get_isset($params, $type, $type); } @@ -190,7 +190,7 @@ class Current { /* * Check if the current URL already has a site parameter and remove it. */ - if (strpos($current_url, '/' . $url_param . '/') !== false) { + if (str_contains($current_url, '/' . $url_param . '/')) { $current_url = preg_replace('/\/' . $url_param . '\/(.+)/', '/', $current_url); } @@ -220,7 +220,7 @@ class Current { * @since 2.0.0 * @return void */ - public function load_currents() { + public function load_currents(): void { $site = false; @@ -316,7 +316,7 @@ class Current { * @param \WP_Ultimo\Models\Site $site The current site instance. * @return void */ - public function set_site($site) { + public function set_site($site): void { /** * Allow developers to modify the default behavior and set @@ -362,7 +362,7 @@ class Current { * @param \WP_Ultimo\Models\Customer $customer The current customer instance. * @return void */ - public function set_customer($customer) { + public function set_customer($customer): void { /** * Allow developers to modify the default behavior and set @@ -397,7 +397,7 @@ class Current { * @param \WP_Ultimo\Models\Membership $membership The current membership instance. * @return void */ - public function set_membership($membership) { + public function set_membership($membership): void { /** * Allow developers to modify the default behavior and set diff --git a/inc/class-dashboard-statistics.php b/inc/class-dashboard-statistics.php index 289bc5b..97cd397 100644 --- a/inc/class-dashboard-statistics.php +++ b/inc/class-dashboard-statistics.php @@ -46,7 +46,7 @@ class Dashboard_Statistics { * * @var array */ - protected $types = array(); + protected $types = []; /** * Loads the hooks we need for dismissing notices @@ -56,7 +56,7 @@ class Dashboard_Statistics { * @param array $args With the start_date, end_date and the data type functions. * @return void. */ - public function __construct($args = array()) { + public function __construct($args = []) { if ($args) { $this->start_date = $args['start_date']; @@ -83,7 +83,7 @@ class Dashboard_Statistics { */ public function statistics_data() { - $data = array(); + $data = []; foreach ($this->types as $key => $type) { $data_function = 'get_data_' . $type; @@ -102,80 +102,80 @@ class Dashboard_Statistics { */ public function get_data_mrr_growth() { - $payments_per_month = array( - 'january' => array( + $payments_per_month = [ + 'january' => [ 'total' => 0, 'cancelled' => 0, - ), - 'february' => array( + ], + 'february' => [ 'total' => 0, 'cancelled' => 0, - ), - 'march' => array( + ], + 'march' => [ 'total' => 0, 'cancelled' => 0, - ), - 'april' => array( + ], + 'april' => [ 'total' => 0, 'cancelled' => 0, - ), - 'may' => array( + ], + 'may' => [ 'total' => 0, 'cancelled' => 0, - ), - 'june' => array( + ], + 'june' => [ 'total' => 0, 'cancelled' => 0, - ), - 'july' => array( + ], + 'july' => [ 'total' => 0, 'cancelled' => 0, - ), - 'august' => array( + ], + 'august' => [ 'total' => 0, 'cancelled' => 0, - ), - 'september' => array( + ], + 'september' => [ 'total' => 0, 'cancelled' => 0, - ), - 'october' => array( + ], + 'october' => [ 'total' => 0, 'cancelled' => 0, - ), - 'november' => array( + ], + 'november' => [ 'total' => 0, 'cancelled' => 0, - ), - 'december' => array( + ], + 'december' => [ 'total' => 0, 'cancelled' => 0, - ), - ); + ], + ]; $memberships = wu_get_memberships( - array( - 'date_query' => array( + [ + 'date_query' => [ 'column' => 'date_created', 'compare' => 'BETWEEN', 'relation' => '', - array( + [ 'year' => current_time('Y', true), - ), - ), - ) + ], + ], + ] ); - $mrr_status = array( + $mrr_status = [ 'active', 'cancelled', 'expired', - ); + ]; - $churn_status = array( + $churn_status = [ 'cancelled', 'expired', - ); + ]; foreach ($memberships as $membership) { if ( ! $membership->is_recurring()) { diff --git a/inc/class-dashboard-widgets.php b/inc/class-dashboard-widgets.php index 096d159..ae75df9 100644 --- a/inc/class-dashboard-widgets.php +++ b/inc/class-dashboard-widgets.php @@ -37,7 +37,7 @@ class Dashboard_Widgets { * @since 2.0.0 * @var array */ - public $core_metaboxes = array(); + public $core_metaboxes = []; /** * Runs on singleton instantiation. @@ -45,19 +45,19 @@ class Dashboard_Widgets { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); + add_action('admin_enqueue_scripts', [$this, 'enqueue_scripts']); - add_action('wp_network_dashboard_setup', array($this, 'register_network_widgets')); + add_action('wp_network_dashboard_setup', [$this, 'register_network_widgets']); - add_action('wp_dashboard_setup', array($this, 'register_widgets')); + add_action('wp_dashboard_setup', [$this, 'register_widgets']); - add_action('wp_ajax_wu_fetch_rss', array($this, 'process_ajax_fetch_rss')); + add_action('wp_ajax_wu_fetch_rss', [$this, 'process_ajax_fetch_rss']); - add_action('wp_ajax_wu_fetch_activity', array($this, 'process_ajax_fetch_events')); + add_action('wp_ajax_wu_fetch_activity', [$this, 'process_ajax_fetch_events']); - add_action('wp_ajax_wu_generate_csv', array($this, 'handle_table_csv')); + add_action('wp_ajax_wu_generate_csv', [$this, 'handle_table_csv']); } /** @@ -66,7 +66,7 @@ class Dashboard_Widgets { * @since 2.0.0 * @return void */ - public function enqueue_scripts() { + public function enqueue_scripts(): void { global $pagenow; @@ -85,48 +85,48 @@ class Dashboard_Widgets { * @since 2.0.0 * @return void */ - public function register_network_widgets() { + public function register_network_widgets(): void { - add_meta_box('wp-ultimo-setup', __('WP Multisite WaaS - First Steps', 'wp-ultimo'), array($this, 'output_widget_first_steps'), $this->screen_id, 'normal', 'high'); + add_meta_box('wp-ultimo-setup', __('WP Multisite WaaS - First Steps', 'wp-ultimo'), [$this, 'output_widget_first_steps'], $this->screen_id, 'normal', 'high'); - add_meta_box('wp-ultimo-summary', __('WP Multisite WaaS - Summary', 'wp-ultimo'), array($this, 'output_widget_summary'), $this->screen_id, 'normal', 'high'); + add_meta_box('wp-ultimo-summary', __('WP Multisite WaaS - Summary', 'wp-ultimo'), [$this, 'output_widget_summary'], $this->screen_id, 'normal', 'high'); - add_meta_box('wp-ultimo-activity-stream', __('WP Multisite WaaS - Activity Stream', 'wp-ultimo'), array($this, 'output_widget_activity_stream'), $this->screen_id, 'normal', 'high'); + add_meta_box('wp-ultimo-activity-stream', __('WP Multisite WaaS - Activity Stream', 'wp-ultimo'), [$this, 'output_widget_activity_stream'], $this->screen_id, 'normal', 'high'); \WP_Ultimo\UI\Tours::get_instance()->create_tour( 'dashboard', - array( - array( + [ + [ 'id' => 'welcome', 'title' => __('Welcome!', 'wp-ultimo'), - 'text' => array( + 'text' => [ __('Welcome to your new network dashboard!', 'wp-ultimo'), __('You will notice that WP Multisite WaaS adds a couple of useful widgets here so you can keep an eye on how your network is doing.', 'wp-ultimo'), - ), - ), - array( + ], + ], + [ 'id' => 'finish-your-setup', 'title' => __('Finish your setup', 'wp-ultimo'), - 'text' => array( + 'text' => [ __('You still have a couple of things to do configuration-wise. Check the steps on this list and make sure you complete them all.', 'wp-ultimo'), - ), - 'attachTo' => array( + ], + 'attachTo' => [ 'element' => '#wp-ultimo-setup', 'on' => 'left', - ), - ), - array( + ], + ], + [ 'id' => 'wp-ultimo-menu', 'title' => __('Our home', 'wp-ultimo'), - 'text' => array( + 'text' => [ __('You can always find WP Multisite WaaS settings and other pages under our menu item, here on the Network-level dashboard. 😃', 'wp-ultimo'), - ), - 'attachTo' => array( + ], + 'attachTo' => [ 'element' => '.toplevel_page_wp-ultimo', 'on' => 'left', - ), - ), - ) + ], + ], + ] ); } @@ -136,7 +136,7 @@ class Dashboard_Widgets { * @since 2.0.0 * @return void */ - public function register_widgets() { + public function register_widgets(): void { $screen = get_current_screen(); @@ -176,55 +176,55 @@ class Dashboard_Widgets { * * @return void */ - public function output_widget_first_steps() { + public function output_widget_first_steps(): void { $initial_setup_done = get_network_option(null, 'wu_setup_finished', false); - $steps = array( - 'inital-setup' => array( + $steps = [ + 'inital-setup' => [ 'title' => __('Initial Setup', 'wp-ultimo'), 'desc' => __('Go through the initial Setup Wizard to configure the basic settings of your network.', 'wp-ultimo'), 'action_label' => __('Finish the Setup Wizard', 'wp-ultimo'), 'action_link' => wu_network_admin_url('wp-ultimo-setup'), 'done' => wu_string_to_bool($initial_setup_done), - ), - 'payment-method' => array( + ], + 'payment-method' => [ 'title' => __('Payment Method', 'wp-ultimo'), 'desc' => __('You will need to configure at least one payment gateway to be able to receive money from your customers.', 'wp-ultimo'), 'action_label' => __('Add a Payment Method', 'wp-ultimo'), 'action_link' => wu_network_admin_url( 'wp-ultimo-settings', - array( + [ 'tab' => 'payment-gateways', - ) + ] ), 'done' => ! empty(wu_get_active_gateways()), - ), - 'your-first-customer' => array( + ], + 'your-first-customer' => [ 'done' => ! empty(wu_get_customers()), 'title' => __('Your First Customer', 'wp-ultimo'), 'desc' => __('Open the link below in an incognito tab and go through your newly created signup form.', 'wp-ultimo'), 'action_link' => wp_registration_url(), 'action_label' => __('Create a test Account', 'wp-ultimo'), - ), - ); + ], + ]; $done = \Arrch\Arrch::find( $steps, - array( - 'where' => array( - array('done', true), - ), - ) + [ + 'where' => [ + ['done', true], + ], + ] ); wu_get_template( 'dashboard-widgets/first-steps', - array( + [ 'steps' => $steps, 'percentage' => round(count($done) / count($steps) * 100), 'all_done' => count($done) === count($steps), - ) + ] ); } @@ -235,7 +235,7 @@ class Dashboard_Widgets { * * @return void */ - public function output_widget_activity_stream() { + public function output_widget_activity_stream(): void { wu_get_template('dashboard-widgets/activity-stream'); } @@ -247,28 +247,28 @@ class Dashboard_Widgets { * * @return void */ - public function output_widget_summary() { + public function output_widget_summary(): void { /* * Get today's signups. */ $signups = wu_get_customers( - array( + [ 'count' => true, - 'date_query' => array( + 'date_query' => [ 'column' => 'date_registered', 'after' => 'today', 'inclusive' => true, - ), - ) + ], + ] ); wu_get_template( 'dashboard-widgets/summary', - array( + [ 'signups' => $signups, 'mrr' => wu_calculate_mrr(), 'gross_revenue' => wu_calculate_revenue('today'), - ) + ] ); } @@ -278,18 +278,18 @@ class Dashboard_Widgets { * @since 2.0.0 * @return void */ - public function process_ajax_fetch_rss() { + public function process_ajax_fetch_rss(): void { $atts = wp_parse_args( $_GET, - array( + [ 'url' => 'https://community.wpultimo.com/topics/feed', 'title' => __('Forum Discussions', 'wp-ultimo'), 'items' => 3, 'show_summary' => 1, 'show_author' => 0, 'show_date' => 1, - ) + ] ); wp_widget_rss_output($atts); @@ -303,29 +303,29 @@ class Dashboard_Widgets { * @since 2.0.0 * @return void */ - public function process_ajax_fetch_events() { + public function process_ajax_fetch_events(): void { check_ajax_referer('wu_activity_stream'); $count = wu_get_events( - array( + [ 'count' => true, 'number' => -1, - ) + ] ); $data = wu_get_events( - array( + [ 'offset' => (wu_request('page', 1) - 1) * 5, 'number' => 5, - ) + ] ); wp_send_json_success( - array( + [ 'events' => $data, 'count' => $count, - ) + ] ); } @@ -335,7 +335,7 @@ class Dashboard_Widgets { * @since 2.0.0 * @return void */ - public function handle_table_csv() { + public function handle_table_csv(): void { $date_range = wu_request('date_range'); $headers = json_decode(stripslashes((string) wu_request('headers'))); @@ -343,7 +343,7 @@ class Dashboard_Widgets { $file_name = sprintf('wp-ultimo-%s_%s_(%s)', wu_request('slug'), $date_range, gmdate('Y-m-d', wu_get_current_time('timestamp'))); - $data = array_merge(array($headers), $data); + $data = array_merge([$headers], $data); wu_generate_csv($file_name, $data); @@ -370,14 +370,14 @@ class Dashboard_Widgets { ob_clean(); // Prevent eventual echos. - $dashboard_widgets = wu_get_isset($wp_meta_boxes, 'dashboard-network', array()); + $dashboard_widgets = wu_get_isset($wp_meta_boxes, 'dashboard-network', []); - $options = array( + $options = [ 'normal:core:dashboard_right_now' => __('At a Glance'), 'normal:core:network_dashboard_right_now' => __('Right Now'), 'normal:core:dashboard_activity' => __('Activity'), 'normal:core:dashboard_primary' => __('WordPress Events and News'), - ); + ]; foreach ($dashboard_widgets as $position => $priorities) { foreach ($priorities as $priority => $widgets) { @@ -388,11 +388,11 @@ class Dashboard_Widgets { $key = implode( ':', - array( + [ $position, $priority, $widget_key, - ) + ] ); /** @@ -402,7 +402,7 @@ class Dashboard_Widgets { * I don't know why $options would ever be a boolean here, though. */ if ( ! is_array($options)) { - $options = array(); + $options = []; } $options[ $key ] = $widget['title']; diff --git a/inc/class-documentation.php b/inc/class-documentation.php index c4a5ac0..48563a7 100644 --- a/inc/class-documentation.php +++ b/inc/class-documentation.php @@ -43,9 +43,9 @@ class Documentation { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - $links = array(); + $links = []; // WP Multisite WaaS Dashboard $links['wp-ultimo'] = 'https://help.wpultimo.com/en/articles/4803213-understanding-the-wp-ultimo-dashboard'; @@ -133,7 +133,7 @@ class Documentation { * @param string $link The documentation link. * @return void */ - public function register_link($slug, $link) { + public function register_link($slug, $link): void { $this->links[ $slug ] = $link; } diff --git a/inc/class-domain-mapping.php b/inc/class-domain-mapping.php index e580c73..bf6ef34 100644 --- a/inc/class-domain-mapping.php +++ b/inc/class-domain-mapping.php @@ -45,9 +45,9 @@ class Domain_Mapping { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - if ($this->should_skip_checks()) { + if (static::should_skip_checks()) { $this->startup(); } else { $this->maybe_startup(); @@ -71,7 +71,7 @@ class Domain_Mapping { * @since 2.0.0 * @return void */ - public function maybe_startup() { + public function maybe_startup(): void { /* * Don't run during installation... */ @@ -104,7 +104,7 @@ class Domain_Mapping { * @since 2.0.0 * @return void */ - public function startup() { + public function startup(): void { /* * Adds the necessary tables to the $wpdb global. */ @@ -115,22 +115,22 @@ class Domain_Mapping { } // Ensure cache is shared - wp_cache_add_global_groups(array('domain_mappings', 'network_mappings')); + wp_cache_add_global_groups(['domain_mappings', 'network_mappings']); /* * Check if the URL being accessed right now is a mapped domain */ - add_filter('pre_get_site_by_path', array($this, 'check_domain_mapping'), 10, 2); + add_filter('pre_get_site_by_path', [$this, 'check_domain_mapping'], 10, 2); /* * When a site gets delete, clean up the mapped domains */ - add_action('wp_delete_site', array($this, 'clear_mappings_on_delete')); + add_action('wp_delete_site', [$this, 'clear_mappings_on_delete']); /* * Adds the filters that will change the URLs when a mapped domains is in use */ - add_action('ms_loaded', array($this, 'register_mapped_filters'), 11); + add_action('ms_loaded', [$this, 'register_mapped_filters'], 11); // add_action('allowed_http_origin', array($this, 'add_mapped_domains_as_allowed_origins')); @@ -138,7 +138,7 @@ class Domain_Mapping { * On WP Multisite WaaS 1.X builds we used Mercator. The Mercator actions and filters are now deprecated. */ if (has_action('mercator_load')) { - do_action_deprecated('mercator_load', array(), '2.0.0', 'wu_domain_mapping_load'); + do_action_deprecated('mercator_load', [], '2.0.0', 'wu_domain_mapping_load'); } add_action( @@ -146,12 +146,12 @@ class Domain_Mapping { function ($list, $site_id): array { $domains = wu_get_domains( - array( + [ 'active' => true, 'blog_id' => $site_id, 'stage__not_in' => \WP_Ultimo\Models\Domain::INACTIVE_STAGES, 'fields' => 'domain', - ) + ] ); return array_merge($list, $domains); @@ -231,7 +231,7 @@ class Domain_Mapping { */ public function get_www_and_nowww_versions($domain) { - if (strncmp($domain, 'www.', strlen('www.')) === 0) { + if (str_starts_with($domain, 'www.')) { $www = $domain; $nowww = substr($domain, 4); } else { @@ -239,7 +239,7 @@ class Domain_Mapping { $www = 'www.' . $domain; } - return array($nowww, $www); + return [$nowww, $www]; } /** * Checks if we have a site associated with the domain being accessed @@ -269,11 +269,11 @@ class Domain_Mapping { } if (has_filter('mercator.use_mapping')) { - $deprecated_args = array( + $deprecated_args = [ $mapping->is_active(), $mapping, $domain, - ); + ]; $is_active = apply_filters_deprecated('mercator.use_mapping', $deprecated_args, '2.0.0', 'wu_use_domain_mapping'); } @@ -339,7 +339,7 @@ class Domain_Mapping { * * @param WP_Site $site Site being deleted. */ - public function clear_mappings_on_delete($site) { + public function clear_mappings_on_delete($site): void { $mappings = Domain::get_by_site($site->blog_id); @@ -366,7 +366,7 @@ class Domain_Mapping { * @since 2.0.0 * @return void */ - public function register_mapped_filters() { + public function register_mapped_filters(): void { $current_site = $GLOBALS['current_blog']; @@ -393,27 +393,27 @@ class Domain_Mapping { $this->current_mapping = $mapping; - add_filter('site_url', array($this, 'mangle_url'), -10, 4); - add_filter('home_url', array($this, 'mangle_url'), -10, 4); + add_filter('site_url', [$this, 'mangle_url'], -10, 4); + add_filter('home_url', [$this, 'mangle_url'], -10, 4); - add_filter('theme_file_uri', array($this, 'mangle_url')); - add_filter('stylesheet_directory_uri', array($this, 'mangle_url')); - add_filter('template_directory_uri', array($this, 'mangle_url')); - add_filter('plugins_url', array($this, 'mangle_url'), -10, 3); + add_filter('theme_file_uri', [$this, 'mangle_url']); + add_filter('stylesheet_directory_uri', [$this, 'mangle_url']); + add_filter('template_directory_uri', [$this, 'mangle_url']); + add_filter('plugins_url', [$this, 'mangle_url'], -10, 3); - add_filter('autoptimize_filter_base_replace_cdn', array($this, 'mangle_url'), 8); // @since 1.8.2 - Fix for Autoptimizer + add_filter('autoptimize_filter_base_replace_cdn', [$this, 'mangle_url'], 8); // @since 1.8.2 - Fix for Autoptimizer // Fix srcset - add_filter('wp_calculate_image_srcset', array($this, 'fix_srcset')); // @since 1.5.5 + add_filter('wp_calculate_image_srcset', [$this, 'fix_srcset']); // @since 1.5.5 // If on network site, also filter network urls if (is_main_site()) { - add_filter('network_site_url', array($this, 'mangle_url'), -10, 3); - add_filter('network_home_url', array($this, 'mangle_url'), -10, 3); + add_filter('network_site_url', [$this, 'mangle_url'], -10, 3); + add_filter('network_home_url', [$this, 'mangle_url'], -10, 3); } - add_filter('jetpack_sync_home_url', array($this, 'mangle_url')); - add_filter('jetpack_sync_site_url', array($this, 'mangle_url')); + add_filter('jetpack_sync_home_url', [$this, 'mangle_url']); + add_filter('jetpack_sync_site_url', [$this, 'mangle_url']); /** * Some plugins will save URL before the mapping was active @@ -431,7 +431,7 @@ class Domain_Mapping { * @param self This object. * @return void */ - do_action('wu_domain_mapping_register_filters', array($this, 'mangle_url'), $this); + do_action('wu_domain_mapping_register_filters', [$this, 'mangle_url'], $this); } /** @@ -442,7 +442,7 @@ class Domain_Mapping { * @param string|array $hooks List of hooks to apply the callback to. * @return void */ - public static function apply_mapping_to_url($hooks) { + public static function apply_mapping_to_url($hooks): void { add_action( 'wu_domain_mapping_register_filters', diff --git a/inc/class-faker.php b/inc/class-faker.php index e897d67..0ed26b6 100644 --- a/inc/class-faker.php +++ b/inc/class-faker.php @@ -79,20 +79,20 @@ class Faker { public function get_fake_data_generated($model = '') { if (empty($this->fake_data_generated)) { - $this->fake_data_generated = array( - 'customers' => array(), - 'products' => array(), - 'memberships' => array(), - 'domains' => array(), - 'events' => array(), - 'discount_codes' => array(), - 'checkout_forms' => array(), - 'emails' => array(), - 'broadcasts' => array(), - 'webhooks' => array(), - 'payments' => array(), - 'sites' => array(), - ); + $this->fake_data_generated = [ + 'customers' => [], + 'products' => [], + 'memberships' => [], + 'domains' => [], + 'events' => [], + 'discount_codes' => [], + 'checkout_forms' => [], + 'emails' => [], + 'broadcasts' => [], + 'webhooks' => [], + 'payments' => [], + 'sites' => [], + ]; } if (empty($model)) { @@ -102,7 +102,7 @@ class Faker { if (isset($this->fake_data_generated[ $model ])) { return $this->fake_data_generated[ $model ]; } else { - return array(); + return []; } } @@ -113,7 +113,7 @@ class Faker { * @param string $model The model name. * @param string $value The value to identify the fake data generated. */ - public function set_fake_data_generated($model, $value) { + public function set_fake_data_generated($model, $value): void { $this->get_fake_data_generated(); @@ -130,20 +130,20 @@ class Faker { return wu_get_option( 'debug_faker', - array( - 'customers' => array(), - 'products' => array(), - 'memberships' => array(), - 'domains' => array(), - 'events' => array(), - 'discount_codes' => array(), - 'checkout_forms' => array(), - 'emails' => array(), - 'broadcasts' => array(), - 'webhooks' => array(), - 'payments' => array(), - 'sites' => array(), - ) + [ + 'customers' => [], + 'products' => [], + 'memberships' => [], + 'domains' => [], + 'events' => [], + 'discount_codes' => [], + 'checkout_forms' => [], + 'emails' => [], + 'broadcasts' => [], + 'webhooks' => [], + 'payments' => [], + 'sites' => [], + ] ); } @@ -159,12 +159,12 @@ class Faker { if ($model) { $faker = $this->get_faker(); - $data_saved = wu_get_isset($this->get_option_debug_faker(), $model, array()); + $data_saved = wu_get_isset($this->get_option_debug_faker(), $model, []); $data_in_memory = $this->get_fake_data_generated($model); if ( ! empty($data_saved) && ! empty($data_in_memory)) { - $data_saved_or_in_memory = $faker->randomElement(array('data_saved', 'data_in_memory')); + $data_saved_or_in_memory = $faker->randomElement(['data_saved', 'data_in_memory']); $data_index = $faker->numberBetween(0, count(${$data_saved_or_in_memory}) - 1); @@ -319,7 +319,7 @@ class Faker { * @param int $number The number of fake data that will be generated. * @throws \Exception In case of failures, an exception is thrown. */ - public function generate_fake_customers($number = 1) { + public function generate_fake_customers($number = 1): void { for ($i = 0; $i < $number; $i++) { $user_name = $this->get_faker()->userName; @@ -333,21 +333,21 @@ class Faker { remove_user_from_blog($user_id); $customer = wu_create_customer( - array( + [ 'user_id' => $user_id, 'vip' => $this->get_faker()->boolean, 'date_registered' => $this->get_faker()->dateTimeThisYear()->format('Y-m-d H:i:s'), 'email_verification' => $this->get_faker()->randomElement( - array( + [ 'none', 'pending', 'verified', - ) + ] ), - 'meta' => array( + 'meta' => [ 'ip_country' => $this->get_faker()->countryCode, - ), - ) + ], + ] ); if (is_wp_error($customer)) { @@ -366,28 +366,28 @@ class Faker { * @param int $number The number of fake data that will be generated. * @throws \Exception In case of failures, an exception is thrown. */ - public function generate_fake_products($number = 1) { + public function generate_fake_products($number = 1): void { $faker = $this->get_faker(); - $product_type_options = array( + $product_type_options = [ 'plan', 'package', 'service', - ); - $pricing_type_options = array( + ]; + $pricing_type_options = [ 'paid', 'free', 'contact_us', - ); - $duration_unit_options = array( + ]; + $duration_unit_options = [ 'day', 'week', 'month', 'year', - ); + ]; for ($i = 0; $i < $number; $i++) { - $product_data = array(); + $product_data = []; $type = $faker->optional(0.5, $product_type_options[0])->randomElement($product_type_options); $pricing_type = $faker->optional(0.2, $pricing_type_options[0])->randomElement($pricing_type_options); @@ -425,7 +425,7 @@ class Faker { * @param int $number The number of fake data that will be generated. * @throws \Exception In case of failures, an exception is thrown. */ - public function generate_fake_memberships($number = 1) { + public function generate_fake_memberships($number = 1): void { $faker = $this->get_faker(); @@ -433,15 +433,15 @@ class Faker { $customer = $this->get_random_customer(true); $product = $this->get_random_product(true); - $status_options = array( + $status_options = [ 'pending', 'active', 'on-hold', 'expired', 'cancelled', - ); + ]; - $membership_data = array(); + $membership_data = []; $membership_data['customer_id'] = $customer ? $customer->get_id() : 0; $membership_data['plan_id'] = $product ? $product->get_id() : 0; @@ -453,8 +453,8 @@ class Faker { $membership_data = array_merge( $membership_data, - $product ? $product->to_array() : array(), - $customer ? $customer->to_array() : array() + $product ? $product->to_array() : [], + $customer ? $customer->to_array() : [] ); $membership = wu_create_membership($membership_data); @@ -474,14 +474,14 @@ class Faker { * @param int $number The number of fake data that will be generated. * @throws \Exception In case of failures, an exception is thrown. */ - public function generate_fake_domain($number = 1) { + public function generate_fake_domain($number = 1): void { $faker = $this->get_faker(); - $stage_options = array( + $stage_options = [ 'checking-dns', 'checking-ssl-cert', 'done', - ); + ]; $stage_checking_dns = $stage_options[0]; @@ -491,14 +491,14 @@ class Faker { $site = $this->get_random_site(); $domain = wu_create_domain( - array( + [ 'domain' => $faker->domainName, // phpcs:disable WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase 'stage' => $stage, 'blog_id' => $site ? $site->get_blog_id() : 0, 'primary_domain' => $faker->boolean(25), 'active' => $faker->boolean(75), 'secure' => $faker->boolean(25), - ) + ] ); if (is_wp_error($domain)) { @@ -516,27 +516,27 @@ class Faker { * @param int $number The number of fake data that will be generated. * @throws \Exception In case of failures, an exception is thrown. */ - public function generate_fake_events($number = 1) { + public function generate_fake_events($number = 1): void { $faker = $this->get_faker(); - $initiator_options = array( + $initiator_options = [ 'system', 'manual', - ); + ]; - $payload = array( + $payload = [ 'key' => '1234', 'old_value' => 'None', 'new_value' => 'created', - ); + ]; for ($i = 0; $i < $number; $i++) { - $membership = $this->get_random_membership(true); + $membership = $this->get_random_membership(); $author_id = $membership->get_id(); - $event_data = array( + $event_data = [ 'severity' => 3, 'initiator' => $faker->randomElement($initiator_options), 'author_id' => $author_id > 0 ? $author_id : 1, @@ -545,7 +545,7 @@ class Faker { 'slug' => 'created', 'payload' => $payload, 'date_created' => $faker->dateTimeThisYear()->format('Y-m-d H:i:s'), - ); + ]; $event_data = wu_create_event($event_data); @@ -564,13 +564,13 @@ class Faker { * @param int $number The number of fake data that will be generated. * @throws \Exception In case of failures, an exception is thrown. */ - public function generate_fake_discount_code($number = 1) { + public function generate_fake_discount_code($number = 1): void { $faker = $this->get_faker(); - $type_options = array( + $type_options = [ 'percentage', 'absolute', - ); + ]; $type_options_percentage = $type_options[0]; for ($i = 0; $i < $number; $i++) { @@ -583,7 +583,7 @@ class Faker { $expiration_date = $faker->dateTimeBetween('now', '+4 weeks', 'UTC'); $discount_code = wu_create_discount_code( - array( + [ 'name' => $name, 'description' => $faker->sentence(), 'code' => $code, @@ -595,7 +595,7 @@ class Faker { 'date_start' => $start_date->format('Y-m-d H:i:s'), 'date_expiration' => $expiration_date->format('Y-m-d H:i:s'), 'active' => true, - ) + ] ); if (is_wp_error($discount_code)) { @@ -613,7 +613,7 @@ class Faker { * @param int $number The number of fake data that will be generated. * @throws \Exception In case of failures, an exception is thrown. */ - public function generate_fake_checkout_form($number = 1) { + public function generate_fake_checkout_form($number = 1): void { $faker = $this->get_faker(); @@ -621,16 +621,16 @@ class Faker { $checkout_form_slug = str_replace(' ', '-', $checkout_form_name); for ($i = 0; $i < $number; $i++) { - $checkout_form_data = array( + $checkout_form_data = [ 'name' => $checkout_form_name, 'slug' => strtolower($checkout_form_slug), 'active' => true, - 'settings' => array(), + 'settings' => [], 'custom_css' => '', 'allowed_countries' => '', 'date_created' => $faker->dateTimeThisYear()->format('Y-m-d H:i:s'), 'date_modified' => $faker->dateTimeThisYear()->format('Y-m-d H:i:s'), - ); + ]; $checkout_form = wu_create_checkout_form($checkout_form_data); @@ -649,19 +649,19 @@ class Faker { * @param int $number The number of fake data that will be generated. * @throws \Exception In case of failures, an exception is thrown. */ - public function generate_fake_email($number = 1) { + public function generate_fake_email($number = 1): void { $faker = $this->get_faker(); - $schedule_type_options = array( + $schedule_type_options = [ 'days', 'hours', - ); + ]; - $target_options = array( + $target_options = [ 'customer', 'admin', - ); + ]; for ($i = 0; $i < $number; $i++) { $email_title = rtrim((string) $faker->sentence(2), '.'); @@ -669,7 +669,7 @@ class Faker { $user_name = $this->get_faker()->userName; $user_email = $this->get_faker()->safeEmail; - $email_data = array( + $email_data = [ 'schedule' => 0, 'type' => 'system_email', 'event' => $faker->sentence(2), @@ -686,7 +686,7 @@ class Faker { 'send_copy_to_admin' => 0, 'active' => 1, 'legacy' => 0, - ); + ]; $email = wu_create_email($email_data); @@ -705,31 +705,31 @@ class Faker { * @param int $number The number of fake data that will be generated. * @throws \Exception In case of failures, an exception is thrown. */ - public function generate_fake_broadcast($number = 1) { + public function generate_fake_broadcast($number = 1): void { $faker = $this->get_faker(); - $notice_type_optinos = array( + $notice_type_optinos = [ 'info', 'success', 'warning', 'error', - ); + ]; - $type_optinos = array( + $type_optinos = [ 'broadcast_email', 'broadcast_notice', - ); + ]; for ($i = 0; $i < $number; $i++) { - $broadcast_data = array( + $broadcast_data = [ 'notice_type' => $faker->randomElement($notice_type_optinos), 'status' => 'publish', 'name' => rtrim((string) $faker->sentence(3), '.'), 'title' => rtrim((string) $faker->sentence(3), '.'), 'content' => rtrim((string) $faker->sentence(8), '.'), 'type' => $faker->randomElement($type_optinos), - ); + ]; $broadcast = wu_create_broadcast($broadcast_data); @@ -748,10 +748,10 @@ class Faker { * @param int $number The number of fake data that will be generated. * @throws \Exception In case of failures, an exception is thrown. */ - public function generate_fake_webhook($number = 1) { + public function generate_fake_webhook($number = 1): void { $faker = $this->get_faker(); - $event_options = array( + $event_options = [ 'account_created', 'account_deleted', 'new_domain_mapping', @@ -760,10 +760,10 @@ class Faker { 'payment_failed', 'refund_issued', 'plan_change', - ); + ]; for ($i = 0; $i < $number; $i++) { - $webhook_data = array( + $webhook_data = [ 'name' => rtrim((string) $faker->sentence(2), '.'), 'webhook_url' => 'https://' . $faker->domainName, 'event' => $faker->randomElement($event_options), @@ -772,7 +772,7 @@ class Faker { 'hidden' => 0, 'integration' => rtrim((string) $faker->sentence(3), '.'), 'date_last_failed' => '', - ); + ]; $webhook = wu_create_webhook($webhook_data); @@ -791,14 +791,14 @@ class Faker { * @param int $number The number of fake data that will be generated. * @throws \Exception In case of failures, an exception is thrown. */ - public function generate_fake_payment($number = 1) { + public function generate_fake_payment($number = 1): void { $faker = $this->get_faker(); - $type_options = array( + $type_options = [ 'percentage', 'absolute', - ); - $status_options = array( + ]; + $status_options = [ 'pending', 'completed', 'refunded', @@ -806,7 +806,7 @@ class Faker { 'partially-paid', 'failed', 'cancelled', - ); + ]; $type_options_percentage = $type_options[0]; $status_options_pending = $status_options[0]; @@ -815,7 +815,7 @@ class Faker { for ($i = 0; $i < $number; $i++) { $membership = $this->get_random_membership(); - $payment_data = array( + $payment_data = [ 'description' => $faker->sentence(), 'parent_id' => 0, 'status' => $faker->randomElement($status_options), @@ -834,7 +834,7 @@ class Faker { 'gateway' => '', 'gateway_payment_id' => '', 'date_created' => $faker->dateTimeThisYear()->format('Y-m-d H:i:s'), - ); + ]; $payment = wu_create_payment($payment_data); @@ -856,20 +856,20 @@ class Faker { * @param string $type The type of site to favor. * @throws \Exception In case of failures, an exception is thrown. */ - public function generate_fake_site($number = 1, $type = 'customer_owned') { + public function generate_fake_site($number = 1, $type = 'customer_owned'): void { $faker = $this->get_faker(); - $type_options = array( + $type_options = [ 'default', 'site_template', 'customer_owned', - ); + ]; $type_customer_owned = $type_options[2]; for ($i = 0; $i < $number; $i++) { - $site_data = array(); + $site_data = []; $title = rtrim((string) $faker->sentence(2), '.'); $path = strtolower(implode('-', explode(' ', $title))); diff --git a/inc/class-geolocation.php b/inc/class-geolocation.php index a08df71..1a8196d 100644 --- a/inc/class-geolocation.php +++ b/inc/class-geolocation.php @@ -45,20 +45,20 @@ class Geolocation { /** * API endpoints for looking up user IP address. */ - private static array $ip_lookup_apis = array( + private static array $ip_lookup_apis = [ 'ipify' => 'http://api.ipify.org/', 'ipecho' => 'http://ipecho.net/plain', 'ident' => 'http://ident.me', 'whatismyipaddress' => 'http://bot.whatismyipaddress.com', - ); + ]; /** * API endpoints for geolocating an IP address */ - private static array $geoip_apis = array( + private static array $geoip_apis = [ 'ipinfo.io' => 'https://ipinfo.io/%s/json', 'ip-api.com' => 'http://ip-api.com/json/%s', - ); + ]; /** * Check if server supports MaxMind GeoLite2 Reader. @@ -76,7 +76,7 @@ class Geolocation { * @param string $current_settings Current geolocation settings. */ private static function is_geolocation_enabled($current_settings ): bool { - return in_array( $current_settings, array( 'geolocation', 'geolocation_ajax' ), true ); + return in_array( $current_settings, [ 'geolocation', 'geolocation_ajax' ], true ); } @@ -99,17 +99,17 @@ class Geolocation { /** * Hook in geolocation functionality. */ - public static function init() { + public static function init(): void { if ( self::supports_geolite2() ) { // Only download the database from MaxMind if the geolocation function is enabled, or a plugin specifically requests it. if ( self::is_geolocation_enabled( get_option( 'wu_default_customer_address' ) ) || apply_filters( 'wu_geolocation_update_database_periodically', false ) ) { - add_action( 'wu_geoip_updater', array( __CLASS__, 'update_database' ) ); + add_action( 'wu_geoip_updater', [ self::class, 'update_database' ] ); } // Trigger database update when settings are changed to enable geolocation. - add_filter( 'pre_update_option_wu_default_customer_address', array( __CLASS__, 'maybe_update_database' ), 10, 2 ); + add_filter( 'pre_update_option_wu_default_customer_address', [ self::class, 'maybe_update_database' ], 10, 2 ); } else { - add_filter( 'pre_option_wu_default_customer_address', array( __CLASS__, 'disable_geolocation_on_legacy_php' ) ); + add_filter( 'pre_option_wu_default_customer_address', [ self::class, 'disable_geolocation_on_legacy_php' ] ); } } @@ -171,7 +171,7 @@ class Geolocation { foreach ( $ip_lookup_services_keys as $service_name ) { $service_endpoint = $ip_lookup_services[ $service_name ]; - $response = wp_safe_remote_get( $service_endpoint, array( 'timeout' => 2 ) ); + $response = wp_safe_remote_get( $service_endpoint, [ 'timeout' => 2 ] ); if ( !is_wp_error( $response ) && rest_is_ip_address( $response['body'] ) ) { $external_ip_address = apply_filters( 'wu_geolocation_ip_lookup_api_response', ( $response['body'] ), $service_name ); @@ -209,7 +209,7 @@ class Geolocation { // VIP Go has a variable available also. $country_code = strtoupper( sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_COUNTRY_CODE'] ) ) ); // WPCS: input var ok, CSRF ok. } else { - $ip_address = $ip_address ? $ip_address : self::get_ip_address(); + $ip_address = $ip_address ?: self::get_ip_address(); $database = self::get_local_database_path(); if ( self::supports_geolite2() && file_exists( $database ) ) { @@ -227,11 +227,11 @@ class Geolocation { } } - return array( + return [ 'ip' => $ip_address, 'country' => $country_code, 'state' => '', - ); + ]; } @@ -251,11 +251,11 @@ class Geolocation { * * Extract files with PharData. Tool built into PHP since 5.3. */ - public static function update_database() { + public static function update_database(): void { $logger = wc_get_logger(); if ( !self::supports_geolite2() ) { - $logger->notice( 'Requires PHP 5.4 to be able to download MaxMind GeoLite2 database', array( 'source' => 'geolocation' ) ); + $logger->notice( 'Requires PHP 5.4 to be able to download MaxMind GeoLite2 database', [ 'source' => 'geolocation' ] ); return; } @@ -283,7 +283,7 @@ class Geolocation { $wp_filesystem->move( trailingslashit( dirname( $tmp_database_path ) ) . $file_path, $target_database_path, true ); $wp_filesystem->delete( trailingslashit( dirname( $tmp_database_path ) ) . $file->current()->getFileName() ); } catch ( Exception $e ) { - $logger->notice( $e->getMessage(), array( 'source' => 'geolocation' ) ); + $logger->notice( $e->getMessage(), [ 'source' => 'geolocation' ] ); // Reschedule download of DB. wp_clear_scheduled_hook( 'wu_geoip_updater' ); @@ -294,7 +294,7 @@ class Geolocation { } else { $logger->notice( 'Unable to download GeoIP Database: ' . $tmp_database_path->get_error_message(), - array( 'source' => 'geolocation' ) + [ 'source' => 'geolocation' ] ); } } @@ -346,17 +346,17 @@ class Geolocation { foreach ( $geoip_services_keys as $service_name ) { $service_endpoint = $geoip_services[ $service_name ]; - $response = wp_safe_remote_get( sprintf( $service_endpoint, $ip_address ), array( 'timeout' => 2 ) ); + $response = wp_safe_remote_get( sprintf( $service_endpoint, $ip_address ), [ 'timeout' => 2 ] ); if ( !is_wp_error( $response ) && $response['body'] ) { switch ( $service_name ) { case 'ipinfo.io': $data = json_decode( $response['body'] ); - $country_code = isset( $data->country ) ? $data->country : ''; + $country_code = $data->country ?? ''; break; case 'ip-api.com': $data = json_decode( $response['body'] ); - $country_code = isset( $data->countryCode ) ? $data->countryCode : ''; // @codingStandardsIgnoreLine + $country_code = $data->countryCode ?? ''; // @codingStandardsIgnoreLine break; default: $country_code = apply_filters( 'wu_geolocation_geoip_response_' . $service_name, '', $response['body'] ); diff --git a/inc/class-helper.php b/inc/class-helper.php index de86a16..e6f867a 100644 --- a/inc/class-helper.php +++ b/inc/class-helper.php @@ -74,7 +74,7 @@ class Helper { * @param string|false $default_view View to be used if the view passed is not found. Used as fallback. * @return void */ - public function render($view, $vars = false, $default_view = false) { + public function render($view, $vars = false, $default_view = false): void { _deprecated_function(__METHOD__, '2.0.11', 'wu_get_template'); @@ -105,7 +105,7 @@ class Helper { * @param mixed $default The default value. * @return mixed */ - public function get_option($option_name = 'settings', $default = array()) { + public function get_option($option_name = 'settings', $default = []) { _deprecated_function(__METHOD__, '2.0.11', 'wu_get_option'); @@ -181,7 +181,7 @@ class Helper { * * @return void */ - public function drop_tables() { + public function drop_tables(): void { _deprecated_function(__METHOD__, '2.0.11', 'wu_drop_tables'); diff --git a/inc/class-hooks.php b/inc/class-hooks.php index 5f56eb5..5bf09ab 100644 --- a/inc/class-hooks.php +++ b/inc/class-hooks.php @@ -30,22 +30,22 @@ class Hooks { * @since 2.0.0 * @return void */ - public static function init() { + public static function init(): void { /** * Runs on WP Multisite WaaS activation */ - register_activation_hook(WP_ULTIMO_PLUGIN_FILE, array('WP_Ultimo\Hooks', 'on_activation')); + register_activation_hook(WP_ULTIMO_PLUGIN_FILE, [self::class, 'on_activation']); /** * Runs on WP Multisite WaaS deactivation */ - register_deactivation_hook(WP_ULTIMO_PLUGIN_FILE, array('WP_Ultimo\Hooks', 'on_deactivation')); + register_deactivation_hook(WP_ULTIMO_PLUGIN_FILE, [self::class, 'on_deactivation']); /** * Runs the activation hook. */ - add_action('plugins_loaded', array('WP_Ultimo\Hooks', 'on_activation_do'), 1); + add_action('plugins_loaded', [self::class, 'on_activation_do'], 1); } /** @@ -54,7 +54,7 @@ class Hooks { * @since 1.9.6 It now uses hook-based approach, it is up to each sub-class to attach their own routines. * @since 1.2.0 */ - public static function on_activation() { + public static function on_activation(): void { wu_log_add('wp-ultimo-core', __('Activating WP Multisite WaaS...', 'wp-ultimo')); @@ -70,7 +70,7 @@ class Hooks { * @since 2.0.0 * @return void */ - public static function on_activation_do() { + public static function on_activation_do(): void { if (get_network_option(null, 'wu_activation') === 'yes' && wu_request('activate')) { @@ -98,7 +98,7 @@ class Hooks { * @since 1.9.6 It now uses hook-based approach, it is up to each sub-class to attach their own routines. * @since 1.2.0 */ - public static function on_deactivation() { + public static function on_deactivation(): void { wu_log_add('wp-ultimo-core', __('Deactivating WP Multisite WaaS...', 'wp-ultimo')); diff --git a/inc/class-light-ajax.php b/inc/class-light-ajax.php index 025afe5..ae3c763 100644 --- a/inc/class-light-ajax.php +++ b/inc/class-light-ajax.php @@ -36,7 +36,7 @@ class Light_Ajax { wu_x_header("X-Ultimo-Ajax-When: $action"); - add_action($action, array($this, 'process_light_ajax'), 20); + add_action($action, [$this, 'process_light_ajax'], 20); } } @@ -50,7 +50,7 @@ class Light_Ajax { $allowed_actions = apply_filters( 'wu_light_ajax_should_skip_referer_check', - array( + [ /** * Checkout Form Actions @@ -64,7 +64,7 @@ class Light_Ajax { 'wu_create_order', 'wu_validate_form', - ) + ] ); return in_array(wu_request('action', 'no-action'), $allowed_actions, true); @@ -93,12 +93,12 @@ class Light_Ajax { */ $allowed_list = apply_filters( 'wu_light_ajax_allowed_hooks', - array( + [ 'plugins_loaded', 'setup_theme', 'after_setup_theme', 'init', - ) + ] ); $action = isset($_REQUEST['wu-when']) ? base64_decode((string) $_REQUEST['wu-when']) : 'plugins_loaded'; @@ -112,7 +112,7 @@ class Light_Ajax { * @since 1.9.14 * @return void */ - public function process_light_ajax() { + public function process_light_ajax(): void { // mimic the actual admin-ajax define('DOING_AJAX', true); // phpcs:ignore diff --git a/inc/class-logger.php b/inc/class-logger.php index 8cf07d0..455e3cd 100644 --- a/inc/class-logger.php +++ b/inc/class-logger.php @@ -51,7 +51,7 @@ class Logger extends AbstractLogger { * @param string|\WP_Error $message Log message to write. * @param string $log_level Log level to write. */ - public static function add($handle, $message, $log_level = LogLevel::INFO) { + public static function add($handle, $message, $log_level = LogLevel::INFO): void { $allowed_log_level = wu_get_setting('error_logging_level', 'default'); @@ -67,7 +67,7 @@ class Logger extends AbstractLogger { */ $reporting_level = error_reporting(); - $psr_log_levels = array( + $psr_log_levels = [ E_ERROR => LogLevel::ERROR, E_WARNING => LogLevel::WARNING, E_PARSE => LogLevel::ERROR, @@ -83,9 +83,9 @@ class Logger extends AbstractLogger { E_RECOVERABLE_ERROR => LogLevel::ERROR, E_DEPRECATED => LogLevel::NOTICE, E_USER_DEPRECATED => LogLevel::NOTICE, - ); + ]; - $current_log_levels = array(); + $current_log_levels = []; foreach ($psr_log_levels as $php_level => $psr_level) { if ($reporting_level & $php_level) { @@ -127,7 +127,7 @@ class Logger extends AbstractLogger { $file = self::get_logs_folder() . "/$handle.log"; if ( ! file_exists($file)) { - return array(); + return []; } // read file @@ -150,7 +150,7 @@ class Logger extends AbstractLogger { * * @param mixed $handle Name of the log file to clear. */ - public static function clear($handle) { + public static function clear($handle): void { $file = self::get_logs_folder() . "/$handle.log"; @@ -195,7 +195,7 @@ class Logger extends AbstractLogger { * * @param string $log_file The log file path. */ - public function set_log_file($log_file) { + public function set_log_file($log_file): void { $this->log_file = $log_file; } @@ -211,7 +211,7 @@ class Logger extends AbstractLogger { * * @return void */ - public function log($level, $message, array $context = array()) { + public function log($level, $message, array $context = []): void { if ( ! $this->is_valid_log_level($level) ) { return; @@ -231,7 +231,7 @@ class Logger extends AbstractLogger { */ protected function is_valid_log_level($level): bool { - $valid_log_levels = array( + $valid_log_levels = [ LogLevel::EMERGENCY, LogLevel::ALERT, LogLevel::CRITICAL, @@ -240,7 +240,7 @@ class Logger extends AbstractLogger { LogLevel::NOTICE, LogLevel::INFO, LogLevel::DEBUG, - ); + ]; return in_array($level, $valid_log_levels, true); } @@ -255,7 +255,7 @@ class Logger extends AbstractLogger { * @param array $context The context of the message. * @return string */ - protected function format_message($level, $message, $context = array()) { + protected function format_message($level, $message, $context = []) { $date = new \DateTime(); diff --git a/inc/class-maintenance-mode.php b/inc/class-maintenance-mode.php index 9c464a6..07cb324 100644 --- a/inc/class-maintenance-mode.php +++ b/inc/class-maintenance-mode.php @@ -28,9 +28,9 @@ class Maintenance_Mode { * * @since 2.0.0 */ - public function init() { + public function init(): void { - add_action('wp_ultimo_load', array($this, 'add_settings')); + add_action('wp_ultimo_load', [$this, 'add_settings']); if (wu_get_setting('maintenance_mode')) { $this->hooks(); @@ -43,19 +43,19 @@ class Maintenance_Mode { * @since 2.0.0 * @return void */ - public function hooks() { + public function hooks(): void { - add_action('wu_ajax_toggle_maintenance_mode', array($this, 'toggle_maintenance_mode')); + add_action('wu_ajax_toggle_maintenance_mode', [$this, 'toggle_maintenance_mode']); if ( ! is_main_site()) { - add_action('admin_bar_menu', array($this, 'add_notice_to_admin_bar'), 15); + add_action('admin_bar_menu', [$this, 'add_notice_to_admin_bar'], 15); } if (self::check_maintenance_mode()) { add_filter('pre_option_blog_public', '__return_true'); if ( ! is_admin()) { - add_action('wp', array($this, 'render_page')); + add_action('wp', [$this, 'render_page']); if (function_exists('wp_robots_no_robots')) { add_filter('wp_robots', 'wp_robots_no_robots'); // WordPress 5.7+ @@ -74,23 +74,23 @@ class Maintenance_Mode { * @param WP_Admin_Bar $wp_admin_bar The Admin Bar class. * @return void */ - public function add_notice_to_admin_bar($wp_admin_bar) { + public function add_notice_to_admin_bar($wp_admin_bar): void { if ( ! current_user_can('manage_options')) { return; } if (is_admin() || self::check_maintenance_mode()) { - $args = array( + $args = [ 'id' => 'wu-maintenance-mode', 'parent' => 'top-secondary', 'title' => __('Maintenance Mode - Active', 'wp-ultimo'), 'href' => '#wp-ultimo-site-maintenance-element', - 'meta' => array( + 'meta' => [ 'class' => 'wu-maintenance-mode ' . (self::check_maintenance_mode() ? '' : 'hidden'), 'title' => __('This means that your site is not available for visitors at the moment. Only you and other logged users have access to it. Click here to toggle this option.', 'wp-ultimo'), - ), - ); + ], + ]; $wp_admin_bar->add_node($args); } @@ -102,7 +102,7 @@ class Maintenance_Mode { * @since 2.0.0 * @return void */ - public function render_page() { + public function render_page(): void { if (is_main_site() || current_user_can('read')) { return; @@ -146,10 +146,10 @@ class Maintenance_Mode { if ( ! current_user_can_for_blog($site_id, 'manage_options')) { return wp_send_json_error( - array( + [ 'message' => __('You do not have the necessary permissions to perform this option.', 'wp-ultimo'), 'value' => false, - ) + ] ); } @@ -159,10 +159,10 @@ class Maintenance_Mode { update_site_meta($site_id, 'wu_maintenance_mode', $value); - $return = array( + $return = [ 'message' => __('New maintenance settings saved.', 'wp-ultimo'), 'value' => $value, - ); + ]; // Flush the cache so the maintenance mode new status is applied immediately. Cache_Manager::get_instance()->flush_known_caches(); @@ -176,18 +176,18 @@ class Maintenance_Mode { * @since 2.0.0 * @return void */ - public function add_settings() { + public function add_settings(): void { wu_register_settings_field( 'sites', 'maintenance_mode', - array( + [ 'title' => __('Site Maintenance Mode', 'wp-ultimo'), 'desc' => __('Allow your customers and super admins to quickly take sites offline via a toggle on the site dashboard.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, 'order' => 23, - ) + ] ); } } diff --git a/inc/class-newsletter.php b/inc/class-newsletter.php index a5ad983..9893c61 100644 --- a/inc/class-newsletter.php +++ b/inc/class-newsletter.php @@ -7,21 +7,21 @@ class Newsletter { const SETTING_FIELD_SLUG = 'newsletter_optin'; - public function init() { - add_action('wu_settings_login', array($this, 'add_settings'), 20); - add_filter('wu_pre_save_settings', array($this, 'maybe_update_newsletter_subscription'), 10, 3); + public function init(): void { + add_action('wu_settings_login', [$this, 'add_settings'], 20); + add_filter('wu_pre_save_settings', [$this, 'maybe_update_newsletter_subscription'], 10, 3); } - public function add_settings() { + public function add_settings(): void { wu_register_settings_field( 'general', self::SETTING_FIELD_SLUG, - array( + [ 'title' => __('Signup for WP Multisite WaaS Newsletter', 'wp-ultimo'), 'desc' => __('Be informed of new releases and all things related to running a WaaS Network.', 'wp-ultimo'), 'type' => 'toggle', 'value' => '1', - ), + ], 45 ); } @@ -42,40 +42,40 @@ class Newsletter { if ( isset($settings_to_save[ self::SETTING_FIELD_SLUG ]) && $settings_to_save[ self::SETTING_FIELD_SLUG ] && $settings_to_save[ self::SETTING_FIELD_SLUG ] != $saved_settings[ self::SETTING_FIELD_SLUG ] ) { $response = wp_remote_post( 'https://wpmultisitewaas.org/wp-json/newsletter/v2/subscribers', - array( + [ 'method' => 'PUT', 'body' => wp_json_encode( - array( + [ 'email' => $settings['company_email'], 'status' => 'confirmed', 'first_name' => $settings['company_name'], 'country' => $settings['company_country'], - ) + ] ), - 'headers' => array( + 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Authorization' => 'Basic ' . base64_encode('30220d7fb4ec49a7410b3a309b9346c18410bd56:0407cd731d6f074cd0b96f2643b7619e89af1ed2'), - ), - ) + ], + ] ); } elseif ( empty($settings_to_save[ self::SETTING_FIELD_SLUG ]) && ! empty($saved_settings[ self::SETTING_FIELD_SLUG ]) ) { $response = wp_remote_post( 'https://wpmultisitewaas.org/wp-json/newsletter/v2/subscribers', - array( + [ 'method' => 'PUT', 'body' => wp_json_encode( - array( + [ 'email' => $settings['company_email'], 'status' => 'unsubscribed', - ) + ] ), - 'headers' => array( + 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Authorization' => 'Basic ' . base64_encode('30220d7fb4ec49a7410b3a309b9346c18410bd56:0407cd731d6f074cd0b96f2643b7619e89af1ed2'), - ), - ) + ], + ] ); } diff --git a/inc/class-requirements.php b/inc/class-requirements.php index 97a8ee8..13e7925 100644 --- a/inc/class-requirements.php +++ b/inc/class-requirements.php @@ -9,8 +9,8 @@ namespace WP_Ultimo; -use \WP_Ultimo\Loaders\Table_Loader; -use \WP_Ultimo\Installers\Core_Installer; +use WP_Ultimo\Loaders\Table_Loader; +use WP_Ultimo\Installers\Core_Installer; // Exit if accessed directly defined('ABSPATH') || exit; @@ -136,7 +136,7 @@ class Requirements { public static function check_php_version(): bool { if (version_compare(phpversion(), self::$php_version, '<')) { - add_action('network_admin_notices', array('WP_Ultimo\Requirements', 'notice_unsupported_php_version')); + add_action('network_admin_notices', [self::class, 'notice_unsupported_php_version']); return false; } @@ -153,7 +153,7 @@ class Requirements { global $wp_version; if (version_compare($wp_version, self::$wp_version, '<')) { - add_action('network_admin_notices', array('WP_Ultimo\Requirements', 'notice_unsupported_wp_version')); + add_action('network_admin_notices', [self::class, 'notice_unsupported_wp_version']); return false; } @@ -197,14 +197,14 @@ class Requirements { $cron_request = apply_filters( 'cron_request', // phpcs:ignore - array( + [ 'url' => site_url('wp-cron.php?doing_wp_cron=' . $doing_wp_cron), - 'args' => array( + 'args' => [ 'timeout' => 3, 'blocking' => true, 'sslverify' => apply_filters('https_local_ssl_verify', $sslverify), // phpcs:ignore - ), - ) + ], + ] ); $result = wp_remote_post($cron_request['url'], $cron_request['args']); @@ -225,7 +225,7 @@ class Requirements { public static function is_multisite(): bool { if (! is_multisite()) { - add_action('admin_notices', array('WP_Ultimo\Requirements', 'notice_not_multisite')); + add_action('admin_notices', [self::class, 'notice_not_multisite']); return false; } @@ -260,7 +260,7 @@ class Requirements { } if (! is_plugin_active_for_network(WP_ULTIMO_PLUGIN_BASENAME) && ! self::is_unit_test()) { - add_action('admin_notices', array('WP_Ultimo\Requirements', 'notice_not_network_active')); + add_action('admin_notices', [self::class, 'notice_not_network_active']); return false; } @@ -274,7 +274,7 @@ class Requirements { * @since 2.0.0 * @return void */ - public static function notice_unsupported_php_version() { + public static function notice_unsupported_php_version(): void { // translators: the %1$s placeholder is the required PHP version, while the %2$s is the current PHP version. $message = sprintf(__('WP Multisite WaaS requires at least PHP version %1$s to run. Your current PHP version is %2$s. Please, contact your hosting company support to upgrade your PHP version. If you want maximum performance consider upgrading your PHP to version 7.0 or later.', 'wp-ultimo'), self::$php_version, phpversion()); @@ -288,7 +288,7 @@ class Requirements { * @since 2.0.0 * @return void */ - public static function notice_unsupported_wp_version() { + public static function notice_unsupported_wp_version(): void { global $wp_version; @@ -304,7 +304,7 @@ class Requirements { * @since 2.0.0 * @return void */ - public static function notice_not_multisite() { + public static function notice_not_multisite(): void { $message = __('WP Multisite WaaS requires a multisite install to run properly. To know more about WordPress Networks, visit this link: Create a Network →', 'wp-ultimo'); @@ -317,7 +317,7 @@ class Requirements { * @since 2.0.0 * @return void */ - public static function notice_not_network_active() { + public static function notice_not_network_active(): void { // translators: %s is a placeholder for the Network Admin plugins page URL. $message = sprintf(__('WP Multisite WaaS needs to be network active to run properly. You can "Network Activate" it here', 'wp-ultimo'), network_admin_url('plugins.php')); diff --git a/inc/class-scripts.php b/inc/class-scripts.php index e6386c7..fc320cd 100644 --- a/inc/class-scripts.php +++ b/inc/class-scripts.php @@ -27,19 +27,19 @@ class Scripts { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - add_action('init', array($this, 'register_default_scripts')); + add_action('init', [$this, 'register_default_scripts']); - add_action('init', array($this, 'register_default_styles')); + add_action('init', [$this, 'register_default_styles']); - add_action('admin_init', array($this, 'enqueue_default_admin_styles')); + add_action('admin_init', [$this, 'enqueue_default_admin_styles']); - add_action('admin_init', array($this, 'enqueue_default_admin_scripts')); + add_action('admin_init', [$this, 'enqueue_default_admin_scripts']); - add_action('wp_ajax_wu_toggle_container', array($this, 'update_use_container')); + add_action('wp_ajax_wu_toggle_container', [$this, 'update_use_container']); - add_filter('admin_body_class', array($this, 'add_body_class_container_boxed')); + add_filter('admin_body_class', [$this, 'add_body_class_container_boxed']); } /** @@ -52,7 +52,7 @@ class Scripts { * @param array $deps List of dependency scripts. * @return void */ - public function register_script($handle, $src, $deps = array()) { + public function register_script($handle, $src, $deps = []): void { wp_register_script($handle, $src, $deps, wu_get_version()); } @@ -67,7 +67,7 @@ class Scripts { * @param array $deps List of dependency scripts. * @return void */ - public function register_style($handle, $src, $deps = array()) { + public function register_style($handle, $src, $deps = []): void { wp_register_style($handle, $src, $deps, wu_get_version()); } @@ -78,7 +78,7 @@ class Scripts { * @since 2.0.0 * @return void */ - public function register_default_scripts() { + public function register_default_scripts(): void { /* * Adds Vue JS */ @@ -97,48 +97,48 @@ class Scripts { /* * Adds tipTip */ - $this->register_script('wu-tiptip', wu_get_asset('lib/tiptip.js', 'js'), array('jquery-core')); + $this->register_script('wu-tiptip', wu_get_asset('lib/tiptip.js', 'js'), ['jquery-core']); /* * Ajax list Table pagination */ - $this->register_script('wu-ajax-list-table', wu_get_asset('list-tables.js', 'js'), array('jquery', 'wu-vue', 'underscore', 'wu-flatpicker')); + $this->register_script('wu-ajax-list-table', wu_get_asset('list-tables.js', 'js'), ['jquery', 'wu-vue', 'underscore', 'wu-flatpicker']); /* * Adds jQueryBlockUI */ - $this->register_script('wu-block-ui', wu_get_asset('lib/jquery.blockUI.js', 'js'), array('jquery-core')); + $this->register_script('wu-block-ui', wu_get_asset('lib/jquery.blockUI.js', 'js'), ['jquery-core']); /* * Adds FontIconPicker */ - $this->register_script('wu-fonticonpicker', wu_get_asset('lib/jquery.fonticonpicker.js', 'js'), array('jquery')); + $this->register_script('wu-fonticonpicker', wu_get_asset('lib/jquery.fonticonpicker.js', 'js'), ['jquery']); /* * Adds Accounting.js */ - $this->register_script('wu-accounting', wu_get_asset('lib/accounting.js', 'js'), array('jquery-core')); + $this->register_script('wu-accounting', wu_get_asset('lib/accounting.js', 'js'), ['jquery-core']); /* * Adds Cookie Helpers */ - $this->register_script('wu-cookie-helpers', wu_get_asset('cookie-helpers.js', 'js'), array('jquery-core')); + $this->register_script('wu-cookie-helpers', wu_get_asset('cookie-helpers.js', 'js'), ['jquery-core']); /* * Adds Input Masking */ - $this->register_script('wu-money-mask', wu_get_asset('lib/v-money.js', 'js'), array('wu-vue')); - $this->register_script('wu-input-mask', wu_get_asset('lib/vue-the-mask.js', 'js'), array('wu-vue')); + $this->register_script('wu-money-mask', wu_get_asset('lib/v-money.js', 'js'), ['wu-vue']); + $this->register_script('wu-input-mask', wu_get_asset('lib/vue-the-mask.js', 'js'), ['wu-vue']); /* * Adds General Functions */ - $this->register_script('wu-functions', wu_get_asset('functions.js', 'js'), array('jquery-core', 'wu-tiptip', 'wu-flatpicker', 'wu-block-ui', 'wu-accounting', 'clipboard', 'wp-hooks')); + $this->register_script('wu-functions', wu_get_asset('functions.js', 'js'), ['jquery-core', 'wu-tiptip', 'wu-flatpicker', 'wu-block-ui', 'wu-accounting', 'clipboard', 'wp-hooks']); wp_localize_script( 'wu-functions', 'wu_settings', - array( + [ 'currency' => wu_get_setting('currency_symbol', 'USD'), 'currency_symbol' => wu_get_currency_symbol(), 'currency_position' => wu_get_setting('currency_position'), @@ -147,13 +147,13 @@ class Scripts { 'precision' => wu_get_setting('precision', 2), 'use_container' => get_user_setting('wu_use_container', false), 'disable_image_zoom' => wu_get_setting('disable_image_zoom', false), - ) + ] ); /* * Adds Fields & Components */ - $this->register_script('wu-fields', wu_get_asset('fields.js', 'js'), array('jquery', 'wu-vue', 'wu-selectizer', 'wp-color-picker')); + $this->register_script('wu-fields', wu_get_asset('fields.js', 'js'), ['jquery', 'wu-vue', 'wu-selectizer', 'wp-color-picker']); /* * Localize components @@ -161,29 +161,29 @@ class Scripts { wp_localize_script( 'wu-fields', 'wu_fields', - array( - 'l10n' => array( + [ + 'l10n' => [ 'image_picker_title' => __('Select an Image.', 'wp-ultimo'), 'image_picker_button_text' => __('Use this image', 'wp-ultimo'), - ), - ) + ], + ] ); /* * Adds Admin Script */ - $this->register_script('wu-admin', wu_get_asset('admin.js', 'js'), array('jquery', 'wu-functions')); + $this->register_script('wu-admin', wu_get_asset('admin.js', 'js'), ['jquery', 'wu-functions']); /* * Adds Vue Apps */ - $this->register_script('wu-vue-apps', wu_get_asset('vue-apps.js', 'js'), array('wu-functions', 'wu-vue', 'wu-money-mask', 'wu-input-mask', 'wp-hooks')); + $this->register_script('wu-vue-apps', wu_get_asset('vue-apps.js', 'js'), ['wu-functions', 'wu-vue', 'wu-money-mask', 'wu-input-mask', 'wp-hooks']); /* * Adds Selectizer */ - $this->register_script('wu-selectize', wu_get_asset('lib/selectize.js', 'js'), array('jquery')); - $this->register_script('wu-selectizer', wu_get_asset('selectizer.js', 'js'), array('wu-selectize', 'underscore', 'wu-vue-apps')); + $this->register_script('wu-selectize', wu_get_asset('lib/selectize.js', 'js'), ['jquery']); + $this->register_script('wu-selectizer', wu_get_asset('selectizer.js', 'js'), ['wu-selectize', 'underscore', 'wu-vue-apps']); /* * Localize selectizer @@ -191,9 +191,9 @@ class Scripts { wp_localize_script( 'wu-functions', 'wu_selectizer', - array( + [ 'ajaxurl' => wu_ajax_url(), - ) + ] ); /* @@ -202,22 +202,22 @@ class Scripts { wp_localize_script( 'wu-functions', 'wu_ticker', - array( + [ 'server_clock_offset' => (wu_get_current_time('timestamp') - time()) / 60 / 60, // phpcs:ignore 'moment_clock_timezone_name' => wp_date('e'), 'moment_clock_timezone_offset' => wp_date('Z'), - ) + ] ); /* * Adds our thickbox fork. */ - $this->register_script('wubox', wu_get_asset('wubox.js', 'js'), array('wu-vue-apps')); + $this->register_script('wubox', wu_get_asset('wubox.js', 'js'), ['wu-vue-apps']); wp_localize_script( 'wubox', 'wuboxL10n', - array( + [ 'next' => __('Next >'), 'prev' => __('< Prev'), 'image' => __('Image'), @@ -225,7 +225,7 @@ class Scripts { 'close' => __('Close'), 'noiframes' => __('This feature requires inline frames. You have iframes disabled or your browser does not support them.'), 'loadingAnimation' => includes_url('js/thickbox/loadingAnimation.gif'), - ) + ] ); /* @@ -249,7 +249,7 @@ class Scripts { $long_date_formats = array_map( 'wu_convert_php_date_format_to_moment_js_format', - array( + [ 'LT' => $time_format, 'LTS' => str_replace(':i', ':i:s', (string) $time_format), /* translators: the day/month/year date format used by WP Multisite WaaS. You can changed it to localize this date format to your language. the default value is d/m/Y, which is the format 31/12/2021. */ @@ -257,12 +257,12 @@ class Scripts { 'LL' => $date_format, 'LLL' => sprintf('%s %s', $date_format, $time_format), 'LLLL' => sprintf('%s %s', $date_format, $time_format), - ) + ] ); // phpcs:disable - $strings = array( - 'relativeTime' => array( + $strings = [ + 'relativeTime' => [ 'future' => __('in %s', 'wp-ultimo'), 'past' => __('%s ago', 'wp-ultimo'), 's' => __('a few seconds', 'wp-ultimo'), @@ -279,9 +279,9 @@ class Scripts { 'MM' => __('%d months', 'wp-ultimo'), 'y' => __('a year', 'wp-ultimo'), 'yy' => __('%d years', 'wp-ultimo'), - ), + ], 'longDateFormat' => $long_date_formats, - ); + ]; // phpcs:enable $inline_script = sprintf("moment.updateLocale( '%s', %s );", get_user_locale(), wp_json_encode($strings)); @@ -295,15 +295,15 @@ class Scripts { * @since 2.0.0 * @return void */ - public function register_default_styles() { + public function register_default_styles(): void { - $this->register_style('wu-styling', wu_get_asset('framework.css', 'css'), array(), wu_get_version()); + $this->register_style('wu-styling', wu_get_asset('framework.css', 'css'), []); - $this->register_style('wu-admin', wu_get_asset('admin.css', 'css'), array('wu-styling'), wu_get_version()); + $this->register_style('wu-admin', wu_get_asset('admin.css', 'css'), ['wu-styling']); - $this->register_style('wu-checkout', wu_get_asset('checkout.css', 'css'), array(), wu_get_version()); + $this->register_style('wu-checkout', wu_get_asset('checkout.css', 'css'), []); - $this->register_style('wu-flags', wu_get_asset('flags.css', 'css'), array(), wu_get_version()); + $this->register_style('wu-flags', wu_get_asset('flags.css', 'css'), []); } /** @@ -312,7 +312,7 @@ class Scripts { * @since 2.0.0 * @return void */ - public function enqueue_default_admin_styles() { + public function enqueue_default_admin_styles(): void { wp_enqueue_style('wu-admin'); } @@ -323,7 +323,7 @@ class Scripts { * @since 2.0.0 * @return void */ - public function enqueue_default_admin_scripts() { + public function enqueue_default_admin_scripts(): void { wp_enqueue_script('wu-admin'); } @@ -334,7 +334,7 @@ class Scripts { * @since 2.0.0 * @return void */ - public function update_use_container() { + public function update_use_container(): void { check_ajax_referer('wu_toggle_container', 'nonce'); diff --git a/inc/class-session-cookie.php b/inc/class-session-cookie.php index a3bd4e3..2bd6bbc 100644 --- a/inc/class-session-cookie.php +++ b/inc/class-session-cookie.php @@ -27,7 +27,7 @@ class Session_Cookie implements Session { * * @var array */ - protected $data = array(); + protected $data = []; /** * If the session has already loaded @@ -115,7 +115,7 @@ class Session_Cookie implements Session { */ public function add_values($key, $values): bool { - $old_values = isset($this->data[ $key ]) ? $this->data[ $key ] : array(); + $old_values = $this->data[ $key ] ?? []; $this->data[ $key ] = array_merge($old_values, $values); @@ -157,9 +157,9 @@ class Session_Cookie implements Session { * * @since 2.0.18 */ - public function clear() { + public function clear(): void { - $this->data = array(); + $this->data = []; } /** diff --git a/inc/class-settings.php b/inc/class-settings.php index 0f42040..05bc11d 100644 --- a/inc/class-settings.php +++ b/inc/class-settings.php @@ -60,17 +60,17 @@ class Settings { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - add_action('init', array($this, 'handle_legacy_filters'), 2); + add_action('init', [$this, 'handle_legacy_filters'], 2); - add_action('wu_render_settings', array($this, 'handle_legacy_scripts')); + add_action('wu_render_settings', [$this, 'handle_legacy_scripts']); - add_filter('pre_site_option_registration', array($this, 'force_registration_status'), 10, 3); + add_filter('pre_site_option_registration', [$this, 'force_registration_status'], 10, 3); - add_filter('pre_site_option_add_new_users', array($this, 'force_add_new_users'), 10, 3); + add_filter('pre_site_option_add_new_users', [$this, 'force_add_new_users'], 10, 3); - add_filter('pre_site_option_menu_items', array($this, 'force_plugins_menu'), 10, 3); + add_filter('pre_site_option_menu_items', [$this, 'force_plugins_menu'], 10, 3); } /** @@ -156,9 +156,9 @@ class Settings { if ($this->settings === false || empty($this->settings)) { if ( ! $this->saving) { $this->saving = true; - $this->settings = $this->save_settings(array(), true); + $this->settings = $this->save_settings([], true); } else { - return array(); + return []; } } @@ -181,11 +181,11 @@ class Settings { $settings = $this->get_all(); - if (strpos($setting, '-') !== false) { + if (str_contains($setting, '-')) { _doing_it_wrong($setting, __('Dashes are no longer supported when registering a setting. You should change it to underscores in later versions.', 'wp-ultimo'), '2.0.0'); } - $setting_value = isset($settings[ $setting ]) ? $settings[ $setting ] : $default; + $setting_value = $settings[ $setting ] ?? $default; return apply_filters('wu_get_setting', $setting_value, $setting, $default, $settings); } @@ -228,23 +228,23 @@ class Settings { * @param boolean $reset If true, WP Multisite WaaS will override the saved settings with the default values. * @return array */ - public function save_settings($settings_to_save = array(), $reset = false) { + public function save_settings($settings_to_save = [], $reset = false) { - $settings = array(); + $settings = []; $sections = $this->get_sections(); - $saved_settings = ! $reset ? $this->get_all() : array(); + $saved_settings = ! $reset ? $this->get_all() : []; do_action('wu_before_save_settings', $settings_to_save); foreach ($sections as $section_slug => $section) { foreach ($section['fields'] as $field_slug => $field_atts) { - $existing_value = isset($saved_settings[ $field_slug ]) ? $saved_settings[ $field_slug ] : false; + $existing_value = $saved_settings[ $field_slug ] ?? false; $field = new Field($field_slug, $field_atts); - $new_value = isset($settings_to_save[ $field_slug ]) ? $settings_to_save[ $field_slug ] : $existing_value; + $new_value = $settings_to_save[ $field_slug ] ?? $existing_value; /** * For the current tab, we need to assume toggle fields. @@ -301,18 +301,18 @@ class Settings { $this->default_sections(); $this->sections = apply_filters( 'wu_settings_get_sections', - array( + [ /* * Add a default invisible section that we can use * to register settings that will not have a control. */ - 'core' => array( + 'core' => [ 'invisible' => true, 'order' => 1_000_000, - 'fields' => apply_filters('wu_settings_section_core_fields', array()), - ), - ) + 'fields' => apply_filters('wu_settings_section_core_fields', []), + ], + ] ); uasort($this->sections, 'wu_sort_by_order'); @@ -335,9 +335,9 @@ class Settings { return wu_get_isset( $sections, $section_name, - array( - 'fields' => array(), - ) + [ + 'fields' => [], + ] ); } @@ -354,7 +354,7 @@ class Settings { * @param array $atts Section attributes such as title, description and so on. * @return void */ - public function add_section($section_slug, $atts) { + public function add_section($section_slug, $atts): void { add_filter( 'wu_settings_get_sections', @@ -364,14 +364,14 @@ class Settings { $atts = wp_parse_args( $atts, - array( + [ 'icon' => 'dashicons-wu-cog', 'order' => $default_order, 'capability' => 'manage_network', - ) + ] ); - $atts['fields'] = apply_filters("wu_settings_section_{$section_slug}_fields", array()); + $atts['fields'] = apply_filters("wu_settings_section_{$section_slug}_fields", []); $sections[ $section_slug ] = $atts; @@ -393,7 +393,7 @@ class Settings { * @param array $atts Field attributes such as title, description, tooltip, default value, etc. * @return void */ - public function add_field($section_slug, $field_slug, $atts, $priority = 10) { + public function add_field($section_slug, $field_slug, $atts, $priority = 10): void { /* * Adds the field to the desired fields array. */ @@ -403,7 +403,7 @@ class Settings { /* * We no longer support settings with hyphens. */ - if (strpos($field_slug, '-') !== false) { + if (str_contains($field_slug, '-')) { _doing_it_wrong($field_slug, __('Dashes are no longer supported when registering a setting. You should change it to underscores in later versions.', 'wp-ultimo'), '2.0.0'); } @@ -411,16 +411,16 @@ class Settings { $atts = wp_parse_args( $atts, - array( + [ 'setting_id' => $field_slug, 'title' => '', 'desc' => '', 'order' => $default_order, 'default' => null, 'capability' => 'manage_network', - 'wrapper_html_attr' => array(), - 'require' => array(), - 'html_attr' => array(), + 'wrapper_html_attr' => [], + 'require' => [], + 'html_attr' => [], 'value' => fn() => wu_get_setting($field_slug), 'display_value' => fn() => wu_get_setting($field_slug), 'img' => function () use ($field_slug) { @@ -435,7 +435,7 @@ class Settings { return $custom_logo_args ? $custom_logo_args[0] : ''; }, - ) + ] ); /** @@ -477,7 +477,7 @@ class Settings { } if ( ! empty($atts['require'])) { - $require_rules = array(); + $require_rules = []; foreach ($atts['require'] as $attr => $value) { $attr = str_replace('-', '_', $attr); @@ -513,7 +513,7 @@ class Settings { * @since 2.0.0 * @return void */ - public function default_sections() { + public function default_sections(): void { /* * General Settings * This section holds the General settings of the WP Multisite WaaS Plugin. @@ -524,166 +524,166 @@ class Settings { $this->add_section( 'general', - array( + [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General', 'wp-ultimo'), - ) + ] ); $this->add_field( 'general', 'company_header', - array( + [ 'title' => __('Your Business', 'wp-ultimo'), 'desc' => __('General information about your business..', 'wp-ultimo'), 'type' => 'header', - ), + ], 10 ); $this->add_field( 'general', 'company_name', - array( + [ 'title' => __('Company Name', 'wp-ultimo'), 'desc' => __('This name is used when generating invoices, for example.', 'wp-ultimo'), 'type' => 'text', 'default' => get_network_option(null, 'site_name'), - ), + ], 20 ); $this->add_field( 'general', 'company_logo', - array( + [ 'title' => __('Upload Company Logo', 'wp-ultimo'), 'desc' => __('Add your company logo to be used on the login page and other places.', 'wp-ultimo'), 'type' => 'image', 'default' => '', - ), + ], 30 ); $this->add_field( 'general', 'company_email', - array( + [ 'title' => __('Company Email Address', 'wp-ultimo'), 'desc' => __('This email is used when generating invoices, for example.', 'wp-ultimo'), 'type' => 'text', 'default' => get_network_option(null, 'admin_email'), - ), + ], 40 ); $this->add_field( 'general', 'company_address', - array( + [ 'title' => __('Company Address', 'wp-ultimo'), 'desc' => __('This address is used when generating invoices.', 'wp-ultimo'), 'type' => 'textarea', 'placeholder' => "350 Fifth Avenue\nManhattan, \nNew York City, NY \n10118", 'default' => '', - 'html_attr' => array( + 'html_attr' => [ 'rows' => 5, - ), - ), + ], + ], 50 ); $this->add_field( 'general', 'company_country', - array( + [ 'title' => __('Company Country', 'wp-ultimo'), 'desc' => __('This info is used when generating invoices, as well as for calculating when taxes apply in some contexts.', 'wp-ultimo'), 'type' => 'select', 'options' => 'wu_get_countries', - 'default' => array($this, 'get_default_company_country'), - ), + 'default' => [$this, 'get_default_company_country'], + ], 60 ); $this->add_field( 'general', 'currency_header', - array( + [ 'title' => __('Currency Options', 'wp-ultimo'), 'desc' => __('The following options affect how prices are displayed on the frontend, the backend and in reports.', 'wp-ultimo'), 'type' => 'header', - ), + ], 70 ); $this->add_field( 'general', 'currency_symbol', - array( + [ 'title' => __('Currency', 'wp-ultimo'), 'desc' => __('Select the currency to be used in WP Multisite WaaS.', 'wp-ultimo'), 'type' => 'select', 'default' => 'USD', 'options' => 'wu_get_currencies', - ), + ], 80 ); $this->add_field( 'general', 'currency_position', - array( + [ 'title' => __('Currency Position', 'wp-ultimo'), 'desc' => __('This setting affects all prices displayed across the plugin elements.', 'wp-ultimo'), 'desc' => '', 'type' => 'select', 'default' => '%s %v', - 'options' => array( + 'options' => [ '%s%v' => __('Left ($99.99)', 'wp-ultimo'), '%v%s' => __('Right (99.99$)', 'wp-ultimo'), '%s %v' => __('Left with space ($ 99.99)', 'wp-ultimo'), '%v %s' => __('Right with space (99.99 $)', 'wp-ultimo'), - ), - ), + ], + ], 90 ); $this->add_field( 'general', 'decimal_separator', - array( + [ 'title' => __('Decimal Separator', 'wp-ultimo'), 'desc' => __('This setting affects all prices displayed across the plugin elements.', 'wp-ultimo'), 'type' => 'text', 'default' => '.', - ), + ], 100 ); $this->add_field( 'general', 'thousand_separator', - array( + [ 'title' => __('Thousand Separator', 'wp-ultimo'), 'desc' => __('This setting affects all prices displayed across the plugin elements.', 'wp-ultimo'), 'type' => 'text', 'default' => ',', 'raw' => true, - ), + ], 110 ); $this->add_field( 'general', 'precision', - array( + [ 'title' => __('Number of Decimals', 'wp-ultimo'), 'desc' => __('This setting affects all prices displayed across the plugin elements.', 'wp-ultimo'), 'type' => 'number', 'default' => '2', 'min' => 0, - ), + ], 120 ); @@ -694,55 +694,55 @@ class Settings { $this->add_section( 'login-and-registration', - array( + [ 'title' => __('Login & Registration', 'wp-ultimo'), 'desc' => __('Login & Registration', 'wp-ultimo'), 'icon' => 'dashicons-wu-key', - ) + ] ); $this->add_field( 'login-and-registration', 'registration_header', - array( + [ 'title' => __('Login and Registration Options', 'wp-ultimo'), 'desc' => __('Options related to registration and login behavior.', 'wp-ultimo'), 'type' => 'header', - ) + ] ); $this->add_field( 'login-and-registration', 'enable_registration', - array( + [ 'title' => __('Enable Registration', 'wp-ultimo'), 'desc' => __('Turning this toggle off will disable registration in all checkout forms across the network.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 1, - ) + ] ); $this->add_field( 'login-and-registration', 'enable_email_verification', - array( + [ 'title' => __('Enable email verification', 'wp-ultimo'), 'desc' => __('Enabling this option will require the customer to verify their email address when subscribing to a free plan or a plan with a trial period. Sites will not be created until the customer email verification status is changed to verified.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 1, - ) + ] ); $this->add_field( 'login-and-registration', 'default_registration_page', - array( + [ 'type' => 'model', 'title' => __('Default Registration Page', 'wp-ultimo'), 'placeholder' => __('Search pages on the main site...', 'wp-ultimo'), 'desc' => __('Only published pages on the main site are available for selection, and you need to make sure they contain a [wu_checkout] shortcode.', 'wp-ultimo'), 'tooltip' => '', - 'html_attr' => array( + 'html_attr' => [ 'data-base-link' => get_admin_url(wu_get_main_site_id(), 'post.php?action=edit&post'), 'data-model' => 'page', 'data-value-field' => 'ID', @@ -750,129 +750,129 @@ class Settings { 'data-search-field' => 'post_title', 'data-max-items' => 1, 'data-exclude' => $filter_default_signup_pages, - ), - ) + ], + ] ); $this->add_field( 'login-and-registration', 'enable_custom_login_page', - array( + [ 'title' => __('Use Custom Login Page', 'wp-ultimo'), 'desc' => __('Turn this toggle on to select a custom page to be used as the login page.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, - ) + ] ); $this->add_field( 'login-and-registration', 'default_login_page', - array( + [ 'type' => 'model', 'title' => __('Default Login Page', 'wp-ultimo'), 'placeholder' => __('Search pages on the main site...', 'wp-ultimo'), 'desc' => __('Only published pages on the main site are available for selection, and you need to make sure they contain a [wu_login_form] shortcode.', 'wp-ultimo'), 'tooltip' => '', - 'html_attr' => array( + 'html_attr' => [ 'data-base-link' => get_admin_url(wu_get_main_site_id(), 'post.php?action=edit&post'), 'data-model' => 'page', 'data-value-field' => 'ID', 'data-label-field' => 'post_title', 'data-search-field' => 'post_title', 'data-max-items' => 1, - ), - 'require' => array( + ], + 'require' => [ 'enable_custom_login_page' => true, - ), - ) + ], + ] ); $this->add_field( 'login-and-registration', 'obfuscate_original_login_url', - array( + [ 'title' => __('Obfuscate the Original Login URL (wp-login.php)', 'wp-ultimo'), 'desc' => __('If this option is enabled, we will display a 404 error when a user tries to access the original wp-login.php link. This is useful to prevent brute-force attacks.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, - 'require' => array( + 'require' => [ 'enable_custom_login_page' => 1, - ), - ) + ], + ] ); $this->add_field( 'login-and-registration', 'subsite_custom_login_logo', - array( + [ 'title' => __('Use Sub-site logo on Login Page', 'wp-ultimo'), 'desc' => __('Toggle this option to replace the WordPress logo on the sub-site login page with the logo set for that sub-site. If unchecked, the network logo will be used instead.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, - 'require' => array( + 'require' => [ 'enable_custom_login_page' => 0, - ), - ) + ], + ] ); $this->add_field( 'login-and-registration', 'force_publish_sites_sync', - array( + [ 'title' => __('Force Synchronous Site Publication ', 'wp-ultimo'), 'desc' => __('By default, when a new pending site needs to be converted into a real network site, the publishing process happens via Job Queue, asynchronously. Enable this option to force the publication to happen in the same request as the signup. Be careful, as this can cause timeouts depending on the size of the site templates being copied.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, - ) + ] ); $this->add_field( 'login-and-registration', 'other_header', - array( + [ 'title' => __('Other Options', 'wp-ultimo'), 'desc' => __('Other registration-related options.', 'wp-ultimo'), 'type' => 'header', - ) + ] ); $this->add_field( 'login-and-registration', 'default_role', - array( + [ 'title' => __('Default Role', 'wp-ultimo'), 'desc' => __('Set the role to be applied to the user during the signup process.', 'wp-ultimo'), 'type' => 'select', 'default' => 'administrator', 'options' => 'wu_get_roles_as_options', - ) + ] ); $this->add_field( 'login-and-registration', 'add_users_to_main_site', - array( + [ 'title' => __('Add Users to the Main Site as well?', 'wp-ultimo'), 'desc' => __('Enabling this option will also add the user to the main site of your network.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, - ) + ] ); $this->add_field( 'login-and-registration', 'main_site_default_role', - array( + [ 'title' => __('Add to Main Site with Role...', 'wp-ultimo'), 'desc' => __('Select the role WP Multisite WaaS should use when adding the user to the main site of your network. Be careful.', 'wp-ultimo'), 'type' => 'select', 'default' => 'subscriber', 'options' => 'wu_get_roles_as_options', - 'require' => array( + 'require' => [ 'add_users_to_main_site' => 1, - ), - ) + ], + ] ); do_action('wu_settings_login'); @@ -884,23 +884,23 @@ class Settings { $this->add_section( 'memberships', - array( + [ 'title' => __('Memberships', 'wp-ultimo'), 'desc' => __('Memberships', 'wp-ultimo'), 'icon' => 'dashicons-wu-infinity', - ) + ] ); $this->add_field( 'memberships', 'default_update_page', - array( + [ 'type' => 'model', 'title' => __('Default Membership Update Page', 'wp-ultimo'), 'placeholder' => __('Search pages on the main site...', 'wp-ultimo'), 'desc' => __('Only published pages on the main site are available for selection, and you need to make sure they contain a [wu_checkout] shortcode.', 'wp-ultimo'), 'tooltip' => '', - 'html_attr' => array( + 'html_attr' => [ 'data-base-link' => get_admin_url(wu_get_main_site_id(), 'post.php?action=edit&post'), 'data-model' => 'page', 'data-value-field' => 'ID', @@ -908,216 +908,216 @@ class Settings { 'data-search-field' => 'post_title', 'data-max-items' => 1, 'data-exclude' => $filter_default_signup_pages, - ), - ) + ], + ] ); $this->add_field( 'memberships', 'block_frontend', - array( + [ 'title' => __('Block Frontend Access', 'wp-ultimo'), 'desc' => __('Block the frontend access of network sites after a membership is no longer active.', 'wp-ultimo'), 'tooltip' => __('By default, if a user does not pay and the account goes inactive, only the admin panel will be blocked, but the user\'s site will still be accessible on the frontend. If enabled, this option will also block frontend access in those cases.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, - ) + ] ); $this->add_field( 'memberships', 'block_frontend_grace_period', - array( + [ 'title' => __('Frontend Block Grace Period', 'wp-ultimo'), 'desc' => __('Select the number of days WP Multisite WaaS should wait after the membership goes inactive before blocking the frontend access. Leave 0 to block immediately after the membership becomes inactive.', 'wp-ultimo'), 'type' => 'number', 'default' => 0, 'min' => 0, - 'require' => array( + 'require' => [ 'block_frontend' => 1, - ), - ) + ], + ] ); $this->add_field( 'memberships', 'default_block_frontend_page', - array( + [ 'title' => __('Frontend Block Page', 'wp-ultimo'), 'desc' => __('Select a page on the main site to redirect user if access is blocked', 'wp-ultimo'), 'tooltip' => '', - 'html_attr' => array( + 'html_attr' => [ 'data-base-link' => get_admin_url(wu_get_main_site_id(), 'post.php?action=edit&post'), 'data-model' => 'page', 'data-value-field' => 'ID', 'data-label-field' => 'post_title', 'data-search-field' => 'post_title', 'data-max-items' => 1, - ), - 'require' => array( + ], + 'require' => [ 'block_frontend' => 1, - ), - ) + ], + ] ); $this->add_field( 'memberships', 'enable_multiple_memberships', - array( + [ 'title' => __('Enable Multiple Memberships per Customer', 'wp-ultimo'), 'desc' => __('Enabling this option will allow your users to create more than one membership.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, - ) + ] ); $this->add_field( 'memberships', 'enable_multiple_sites', - array( + [ 'title' => __('Enable Multiple Sites per Membership', 'wp-ultimo'), 'desc' => __('Enabling this option will allow your customers to create more than one site. You can limit how many sites your users can create in a per plan basis.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, - ) + ] ); $this->add_field( 'memberships', 'block_sites_on_downgrade', - array( + [ 'title' => __('Block Sites on Downgrade', 'wp-ultimo'), 'desc' => __('Choose how WP Multisite WaaS should handle client sites above their plan quota on downgrade.', 'wp-ultimo'), 'type' => 'select', 'default' => 'none', - 'options' => array( + 'options' => [ 'none' => __('Keep sites as is (do nothing)', 'wp-ultimo'), 'block-frontend' => __('Block only frontend access', 'wp-ultimo'), 'block-backend' => __('Block only backend access', 'wp-ultimo'), 'block-both' => __('Block both frontend and backend access', 'wp-ultimo'), - ), - 'require' => array( + ], + 'require' => [ 'enable_multiple_sites' => true, - ), - ) + ], + ] ); $this->add_field( 'memberships', 'move_posts_on_downgrade', - array( + [ 'title' => __('Move Posts on Downgrade', 'wp-ultimo'), 'desc' => __('Select how you want to handle the posts above the quota on downgrade. This will apply to all post types with quotas set.', 'wp-ultimo'), 'type' => 'select', 'default' => 'none', - 'options' => array( + 'options' => [ 'none' => __('Keep posts as is (do nothing)', 'wp-ultimo'), 'trash' => __('Move posts above the new quota to the Trash', 'wp-ultimo'), 'draft' => __('Mark posts above the new quota as Drafts', 'wp-ultimo'), - ), - ) + ], + ] ); $this->add_field( 'memberships', 'emulated_post_types_header', - array( + [ 'type' => 'header', 'title' => __('Emulated Post Types', 'wp-ultimo'), 'desc' => __('Emulates the registering of a custom post type to be able to create limits for it without having to activate plugins on the main site.', 'wp-ultimo'), - ) + ] ); $this->add_field( 'memberships', 'emulated_post_types_explanation', - array( + [ 'type' => 'note', 'desc' => __('By default, WP Multisite WaaS only allows super admins to limit post types that are registered on the main site. This makes sense from a technical stand-point but it also forces you to have plugins network-activated in order to be able to set limitations for their custom post types. Using this option, you can emulate the registering of a post type. This will register them on the main site and allow you to create limits for them on your products.', 'wp-ultimo'), 'classes' => '', 'wrapper_classes' => '', - ) + ] ); $this->add_field( 'memberships', 'emulated_post_types_empty', - array( + [ 'type' => 'note', 'desc' => __('Add the first post type using the button below.', 'wp-ultimo'), 'classes' => 'wu-text-gray-600 wu-text-xs wu-text-center wu-w-full', 'wrapper_classes' => 'wu-bg-gray-100 wu-items-end', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'emulated_post_types.length === 0', 'v-cloak' => '1', - ), - ) + ], + ] ); $this->add_field( 'memberships', 'emulated_post_types', - array( + [ 'type' => 'group', 'tooltip' => '', 'raw' => true, - 'default' => array(), + 'default' => [], 'wrapper_classes' => 'wu-relative wu-bg-gray-100 wu-pb-2', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'emulated_post_types.length', 'v-for' => '(emulated_post_type, index) in emulated_post_types', 'v-cloak' => '1', - ), - 'fields' => array( - 'emulated_post_types_remove' => array( + ], + 'fields' => [ + 'emulated_post_types_remove' => [ 'type' => 'note', 'desc' => sprintf('', __('Remove', 'wp-ultimo')), 'wrapper_classes' => 'wu-absolute wu-top-0 wu-right-0', - ), - 'emulated_post_types_slug' => array( + ], + 'emulated_post_types_slug' => [ 'type' => 'text', 'title' => __('Post Type Slug', 'wp-ultimo'), 'placeholder' => __('e.g. product', 'wp-ultimo'), 'wrapper_classes' => 'wu-w-5/12', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'emulated_post_type.post_type', 'v-bind:name' => '"emulated_post_types[" + index + "][post_type]"', - ), - ), - 'emulated_post_types_label' => array( + ], + ], + 'emulated_post_types_label' => [ 'type' => 'text', 'title' => __('Post Type Label', 'wp-ultimo'), 'placeholder' => __('e.g. Products', 'wp-ultimo'), 'wrapper_classes' => 'wu-w-7/12 wu-ml-2', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'emulated_post_type.label', 'v-bind:name' => '"emulated_post_types[" + index + "][label]"', - ), - ), - ), - ) + ], + ], + ], + ] ); $this->add_field( 'memberships', 'emulated_post_types_repeat', - array( + [ 'type' => 'submit', 'title' => __('+ Add Post Type', 'wp-ultimo'), 'classes' => 'wu-uppercase wu-text-2xs wu-text-blue-700 wu-border-none wu-bg-transparent wu-font-bold wu-text-right wu-w-full wu-cursor-pointer', 'wrapper_classes' => 'wu-bg-gray-100 wu-items-end', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => '1', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'v-on:click.prevent' => '() => { emulated_post_types = Array.isArray(emulated_post_types) ? emulated_post_types : []; emulated_post_types.push({ post_type: "", label: "", }) }', - ), - ) + ], + ] ); do_action('wu_settings_memberships'); @@ -1129,33 +1129,33 @@ class Settings { $this->add_section( 'sites', - array( + [ 'title' => __('Sites', 'wp-ultimo'), 'desc' => __('Sites', 'wp-ultimo'), 'icon' => 'dashicons-wu-browser', - ) + ] ); $this->add_field( 'sites', 'sites_features_heading', - array( + [ 'title' => __('Site Options', 'wp-ultimo'), 'desc' => __('Configure certain aspects of how network Sites behave.', 'wp-ultimo'), 'type' => 'header', - ) + ] ); $this->add_field( 'sites', 'default_new_site_page', - array( + [ 'type' => 'model', 'title' => __('Default New Site Page', 'wp-ultimo'), 'placeholder' => __('Search pages on the main site...', 'wp-ultimo'), 'desc' => __('Only published pages on the main site are available for selection, and you need to make sure they contain a [wu_checkout] shortcode.', 'wp-ultimo'), 'tooltip' => '', - 'html_attr' => array( + 'html_attr' => [ 'data-base-link' => get_admin_url(wu_get_main_site_id(), 'post.php?action=edit&post'), 'data-model' => 'page', 'data-value-field' => 'ID', @@ -1163,121 +1163,121 @@ class Settings { 'data-search-field' => 'post_title', 'data-max-items' => 1, 'data-exclude' => $filter_default_signup_pages, - ), - ) + ], + ] ); $this->add_field( 'sites', 'enable_visits_limiting', - array( + [ 'title' => __('Enable Visits Limitation & Counting', 'wp-ultimo'), 'desc' => __('Enabling this option will add visits limitation settings to the plans and add the functionality necessary to count site visits on the front-end.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 1, - ) + ] ); $this->add_field( 'sites', 'enable_screenshot_generator', - array( + [ 'title' => __('Enable Screenshot Generator', 'wp-ultimo'), 'desc' => __('With this option is enabled, WP Multisite WaaS will take a screenshot for every newly created site on your network and set the resulting image as that site\'s featured image. This features requires a valid license key to work and it is not supported for local sites.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 1, - ) + ] ); $this->add_field( 'sites', 'wordpress_features_heading', - array( + [ 'title' => __('WordPress Features', 'wp-ultimo'), 'desc' => __('Override default WordPress settings for network Sites.', 'wp-ultimo'), 'type' => 'header', - ) + ] ); $this->add_field( 'sites', 'menu_items_plugin', - array( + [ 'title' => __('Enable Plugins Menu', 'wp-ultimo'), 'desc' => __('Do you want to let users on the network to have access to the Plugins page, activating plugins for their sites? If this option is disabled, the customer will not be able to manage the site plugins.', 'wp-ultimo'), 'tooltip' => __('You can select which plugins the user will be able to use for each plan.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 1, - ) + ] ); $this->add_field( 'sites', 'add_new_users', - array( + [ 'title' => __('Add New Users', 'wp-ultimo'), 'desc' => __('Allow site administrators to add new users to their site via the "Users → Add New" page.', 'wp-ultimo'), 'tooltip' => __('You can limit the number of users allowed for each plan.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 1, - ) + ] ); $this->add_field( 'sites', 'site_template_features_heading', - array( + [ 'title' => __('Site Template Options', 'wp-ultimo'), 'desc' => __('Configure certain aspects of how Site Templates behave.', 'wp-ultimo'), 'type' => 'header', - ) + ] ); $this->add_field( 'sites', 'allow_template_switching', - array( + [ 'title' => __('Allow Template Switching', 'wp-ultimo'), 'desc' => __("Enabling this option will add an option on your client's dashboard to switch their site template to another one available on the catalog of available templates. The data is lost after a switch as the data from the new template is copied over.", 'wp-ultimo'), 'type' => 'toggle', 'default' => 1, - ) + ] ); $this->add_field( 'sites', 'allow_own_site_as_template', - array( + [ 'title' => __('Allow Users to use their own Sites as Templates', 'wp-ultimo'), 'desc' => __('Enabling this option will add the user own sites to the template screen, allowing them to create a new site based on the content and customizations they made previously.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, - 'require' => array( + 'require' => [ 'allow_template_switching' => true, - ), - ) + ], + ] ); $this->add_field( 'sites', 'copy_media', - array( + [ 'title' => __('Copy Media on Template Duplication?', 'wp-ultimo'), 'desc' => __('Checking this option will copy the media uploaded on the template site to the newly created site. This can be overridden on each of the plans.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 1, - ) + ] ); $this->add_field( 'sites', 'stop_template_indexing', - array( + [ 'title' => __('Prevent Search Engines from indexing Site Templates', 'wp-ultimo'), 'desc' => __('Checking this option will discourage search engines from indexing all the Site Templates on your network.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, - ) + ] ); do_action('wu_settings_site_templates'); @@ -1289,116 +1289,116 @@ class Settings { $this->add_section( 'payment-gateways', - array( + [ 'title' => __('Payments', 'wp-ultimo'), 'desc' => __('Payments', 'wp-ultimo'), 'icon' => 'dashicons-wu-credit-card', - ) + ] ); $this->add_field( 'payment-gateways', 'main_header', - array( + [ 'title' => __('Payment Settings', 'wp-ultimo'), 'desc' => __('The following options affect how prices are displayed on the frontend, the backend and in reports.', 'wp-ultimo'), 'type' => 'header', 'show_as_submenu' => true, - ) + ] ); $this->add_field( 'payment-gateways', 'force_auto_renew', - array( + [ 'title' => __('Force Auto-Renew', 'wp-ultimo'), 'desc' => __('Enable this option if you want to make sure memberships are created with auto-renew activated whenever the selected gateway supports it. Disabling this option will show an auto-renew option during checkout.', 'wp-ultimo'), 'tooltip' => '', 'type' => 'toggle', 'default' => 1, - ) + ] ); $this->add_field( 'payment-gateways', 'allow_trial_without_payment_method', - array( + [ 'title' => __('Allow Trials without Payment Method', 'wp-ultimo'), 'desc' => __('By default, WP Multisite WaaS asks customers to add a payment method on sign-up even if a trial period is present. Enable this option to only ask for a payment method when the trial period is over.', 'wp-ultimo'), 'tooltip' => '', 'type' => 'toggle', 'default' => 0, - ) + ] ); $this->add_field( 'payment-gateways', 'attach_invoice_pdf', - array( + [ 'title' => __('Send Invoice on Payment Confirmation', 'wp-ultimo'), 'desc' => __('Enabling this option will attach a PDF invoice (marked paid) with the payment confirmation email. This option does not apply to the Manual Gateway, which sends invoices regardless of this option.', 'wp-ultimo'), 'tooltip' => __('The invoice files will be saved on the wp-content/uploads/wu-invoices folder.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 1, - ) + ] ); $this->add_field( 'payment-gateways', 'invoice_numbering_scheme', - array( + [ 'title' => __('Invoice Numbering Scheme', 'wp-ultimo'), 'desc' => __('What should WP Multisite WaaS use as the invoice number?', 'wp-ultimo'), 'type' => 'select', 'default' => 'reference_code', 'tooltip' => '', - 'options' => array( + 'options' => [ 'reference_code' => __('Payment Reference Code', 'wp-ultimo'), 'sequential_number' => __('Sequential Number', 'wp-ultimo'), - ), - ) + ], + ] ); $this->add_field( 'payment-gateways', 'next_invoice_number', - array( + [ 'title' => __('Next Invoice Number', 'wp-ultimo'), 'desc' => __('This number will be used as the invoice number for the next invoice generated on the system. It is incremented by one every time a new invoice is created. You can change it and save it to reset the invoice sequential number to a specific value.', 'wp-ultimo'), 'type' => 'number', 'default' => '1', 'min' => 0, - 'require' => array( + 'require' => [ 'invoice_numbering_scheme' => 'sequential_number', - ), - ) + ], + ] ); $this->add_field( 'payment-gateways', 'invoice_prefix', - array( + [ 'title' => __('Invoice Number Prefix', 'wp-ultimo'), 'placeholder' => __('INV00', 'wp-ultimo'), 'desc' => sprintf(__('Use %%YEAR%%, %%MONTH%%, and %%DAY%% to create a dynamic placeholder. E.g. %%YEAR%%-%%MONTH%%-INV will become %s.', 'wp-ultimo'), date('Y') . '-' . date('m') . '-INV'), // phpcs:ignore 'default' => '', 'type' => 'text', 'raw' => true, // Necessary to prevent the removal of the %% tags. - 'require' => array( + 'require' => [ 'invoice_numbering_scheme' => 'sequential_number', - ), - ) + ], + ] ); $this->add_field( 'payment-gateways', 'gateways_header', - array( + [ 'title' => __('Payment Gateways', 'wp-ultimo'), 'desc' => __('Activate and configure the installed payment gateways in this section.', 'wp-ultimo'), 'type' => 'header', 'show_as_submenu' => true, - ) + ] ); do_action('wu_settings_payment_gateways'); @@ -1409,11 +1409,11 @@ class Settings { */ $this->add_section( 'emails', - array( + [ 'title' => __('Emails', 'wp-ultimo'), 'desc' => __('Emails', 'wp-ultimo'), 'icon' => 'dashicons-wu-email', - ) + ] ); do_action('wu_settings_emails'); @@ -1425,11 +1425,11 @@ class Settings { $this->add_section( 'domain-mapping', - array( + [ 'title' => __('Domain Mapping', 'wp-ultimo'), 'desc' => __('Domain Mapping', 'wp-ultimo'), 'icon' => 'dashicons-wu-link', - ) + ] ); do_action('wu_settings_domain_mapping'); @@ -1441,11 +1441,11 @@ class Settings { $this->add_section( 'sso', - array( + [ 'title' => __('Single Sign-On', 'wp-ultimo'), 'desc' => __('Single Sign-On', 'wp-ultimo'), 'icon' => 'dashicons-wu-add-user', - ) + ] ); do_action('wu_settings_sso'); @@ -1457,22 +1457,22 @@ class Settings { $this->add_section( 'integrations', - array( + [ 'title' => __('Integrations', 'wp-ultimo'), 'desc' => __('Integrations', 'wp-ultimo'), 'icon' => 'dashicons-wu-power-plug', - ) + ] ); $this->add_field( 'integrations', 'hosting_providers_header', - array( + [ 'title' => __('Hosting or Panel Providers', 'wp-ultimo'), 'desc' => __('Configure and manage the integration with your Hosting or Panel Provider.', 'wp-ultimo'), 'type' => 'header', 'show_as_submenu' => true, - ) + ] ); do_action('wu_settings_integrations'); @@ -1484,103 +1484,103 @@ class Settings { $this->add_section( 'other', - array( + [ 'title' => __('Other Options', 'wp-ultimo'), 'desc' => __('Other Options', 'wp-ultimo'), 'icon' => 'dashicons-wu-switch', 'order' => 1000, - ) + ] ); $this->add_field( 'other', 'Other_header', - array( + [ 'title' => __('Miscellaneous', 'wp-ultimo'), 'desc' => __('Other options that do not fit anywhere else.', 'wp-ultimo'), 'type' => 'header', - ) + ] ); - $preview_image = wu_preview_image(wu_get_asset('settings/settings-hide-ui-tours.png')); + $preview_image = wu_preview_image(wu_get_asset('settings/settings-hide-ui-tours.webp')); $this->add_field( 'other', 'hide_tours', - array( + [ 'title' => __('Hide UI Tours', 'wp-ultimo') . $preview_image, 'desc' => __('The UI tours showed by WP Multisite WaaS should permanently hide themselves after being seen but if they persist for whatever reason, toggle this option to force them into their viewed state - which will prevent them from showing up again.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, - ) + ] ); - $preview_image_2 = wu_preview_image(wu_get_asset('settings/settings-disable-hover-to-zoom.png')); + $preview_image_2 = wu_preview_image(wu_get_asset('settings/settings-disable-hover-to-zoom.webp')); $this->add_field( 'other', 'disable_image_zoom', - array( + [ 'title' => __('Disable "Hover to Zoom"', 'wp-ultimo') . $preview_image_2, 'desc' => __('By default, WP Multisite WaaS adds a "hover to zoom" feature, allowing network admins to see larger version of site screenshots and other images across the UI in full-size when hovering over them. You can disable that feature here. Preview tags like the above are not affected.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, - ) + ] ); $this->add_field( 'other', 'error_reporting_header', - array( + [ 'title' => __('Logging', 'wp-ultimo'), 'desc' => __('Log WP Multisite WaaS data. This is useful for debugging purposes.', 'wp-ultimo'), 'type' => 'header', - ) + ] ); $this->add_field( 'other', 'error_logging_level', - array( + [ 'title' => __('Logging Level', 'wp-ultimo'), 'desc' => __('Select the level of logging you want to use.', 'wp-ultimo'), 'type' => 'select', 'default' => 'default', - 'options' => array( + 'options' => [ 'default' => __('PHP Default', 'wp-ultimo'), 'disabled' => __('Disabled', 'wp-ultimo'), 'errors' => __('Errors Only', 'wp-ultimo'), 'all' => __('Everything', 'wp-ultimo'), - ), - ) + ], + ] ); $this->add_field( 'other', 'enable_error_reporting', - array( + [ 'title' => __('Send Error Data to WP Multisite WaaS Developers', 'wp-ultimo'), 'desc' => __('With this option enabled, every time your installation runs into an error related to WP Multisite WaaS, that error data will be sent to us. No sensitive data gets collected, only environmental stuff (e.g. if this is this is a subdomain network, etc).', 'wp-ultimo'), 'type' => 'toggle', 'default' => 1, - ) + ] ); $this->add_field( 'other', 'advanced_header', - array( + [ 'title' => __('Advanced Options', 'wp-ultimo'), 'desc' => __('Change the plugin and wordpress behavior.', 'wp-ultimo'), 'type' => 'header', - ) + ] ); $plans = get_posts( - array( + [ 'post_type' => 'wpultimo_plan', 'numberposts' => 1, - ) + ] ); if ( ! empty($plans)) { @@ -1599,11 +1599,11 @@ class Settings { $this->add_field( 'other', 'run_migration', - array( + [ 'title' => $title, 'type' => 'note', 'desc' => $html, - ) + ] ); } @@ -1616,25 +1616,25 @@ class Settings { $this->add_field( 'other', 'security_mode', - array( + [ 'title' => __('Security Mode', 'wp-ultimo'), // Translators: Placeholder adds the security mode key and current site url with query string 'desc' => sprintf(__('Only WP Multisite WaaS and other must-use plugins will run on your WordPress install while this option is enabled.
Important: Copy the following URL to disable security mode if something goes wrong and this page becomes unavailable:%2$s
', 'wp-ultimo'), $security_mode_key, get_site_url() . $security_mode_key), 'type' => 'toggle', 'default' => 0, - ) + ] ); } $this->add_field( 'other', 'uninstall_wipe_tables', - array( + [ 'title' => __('Remove Data on Uninstall', 'wp-ultimo'), 'desc' => __('Remove all saved data for WP Multisite WaaS when the plugin is uninstalled.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, - ) + ] ); } diff --git a/inc/class-sunrise.php b/inc/class-sunrise.php index d85087b..505d3d7 100644 --- a/inc/class-sunrise.php +++ b/inc/class-sunrise.php @@ -41,7 +41,7 @@ class Sunrise { * @since 2.0.11 * @return void */ - public static function init() { + public static function init(): void { require_once __DIR__ . '/functions/sunrise.php'; @@ -66,13 +66,13 @@ class Sunrise { * Enqueue the main hooks that deal with Sunrise * loading and maintenance. */ - add_action('ms_loaded', array('\WP_Ultimo\Sunrise', 'load')); + add_action('ms_loaded', [self::class, 'load']); - add_action('ms_loaded', array('\WP_Ultimo\Sunrise', 'loaded'), 999); + add_action('ms_loaded', [self::class, 'loaded'], 999); - add_action('init', array('\WP_Ultimo\Sunrise', 'maybe_tap_on_init')); + add_action('init', [self::class, 'maybe_tap_on_init']); - add_filter('wu_system_info_data', array('\WP_Ultimo\Sunrise', 'system_info')); + add_filter('wu_system_info_data', [self::class, 'system_info']); } /** @@ -102,7 +102,7 @@ class Sunrise { * @since 2.0.11 * @return void */ - public static function load_dependencies() { + public static function load_dependencies(): void { require_once __DIR__ . '/deprecated/early-deprecated.php'; @@ -145,7 +145,7 @@ class Sunrise { * @since 2.0.11 * @return void */ - public static function load_domain_mapping() { + public static function load_domain_mapping(): void { $should_startup = self::should_startup(); @@ -167,7 +167,7 @@ class Sunrise { * @since 2.0.0 * @return void */ - public static function load() { + public static function load(): void { $should_startup = self::should_startup(); @@ -209,9 +209,9 @@ class Sunrise { /** * Disable all plugins except WP Multisite WaaS */ - add_filter('option_active_plugins', fn() => array()); + add_filter('option_active_plugins', fn() => []); - add_filter('site_option_active_sitewide_plugins', fn($plugins) => array(basename(dirname(__DIR__)) . '/wp-ultimo.php' => 1)); + add_filter('site_option_active_sitewide_plugins', fn($plugins) => [basename(dirname(__DIR__)) . '/wp-ultimo.php' => 1]); } } } @@ -229,7 +229,7 @@ class Sunrise { * @since 2.0.11 * @return void */ - public static function loaded() { + public static function loaded(): void { do_action('wu_sunrise_loaded'); } @@ -240,7 +240,7 @@ class Sunrise { * @since 2.0.0 * @return void */ - public static function manage_sunrise_updates() { + public static function manage_sunrise_updates(): void { /* * Get current version of the sunrise.php file */ @@ -260,10 +260,10 @@ class Sunrise { */ public static function try_upgrade() { - $possible_sunrises = array( + $possible_sunrises = [ WP_PLUGIN_DIR . '/wp-multisite-waas/sunrise.php', WPMU_PLUGIN_DIR . '/wp-multisite-waas/sunrise.php', - ); + ]; $sunrise_found = false; @@ -292,9 +292,9 @@ class Sunrise { } if ($sunrise_found === false) { - $error = array( + $error = [ 'message' => __('File not found.', 'wp-ultimo'), - ); + ]; } if ( ! empty($error)) { @@ -322,7 +322,7 @@ class Sunrise { $sunrise_meta = get_network_option(null, 'wu_sunrise_meta', null); - $existing = array(); + $existing = []; if ($sunrise_meta) { $existing = $sunrise_meta; @@ -346,40 +346,40 @@ class Sunrise { $sys_info = array_merge( $sys_info, - array( - 'Sunrise Data' => array( - 'sunrise-status' => array( + [ + 'Sunrise Data' => [ + 'sunrise-status' => [ 'tooltip' => '', 'title' => 'Active', 'value' => $data['active'] ? 'Enabled' : 'Disabled', - ), - 'sunrise-data' => array( + ], + 'sunrise-data' => [ 'tooltip' => '', 'title' => 'Version', 'value' => self::$version, - ), - 'sunrise-created' => array( + ], + 'sunrise-created' => [ 'tooltip' => '', 'title' => 'Created', 'value' => gmdate('Y-m-d @ H:i:s', $data['created']), - ), - 'sunrise-last-activated' => array( + ], + 'sunrise-last-activated' => [ 'tooltip' => '', 'title' => 'Last Activated', 'value' => gmdate('Y-m-d @ H:i:s', $data['last_activated']), - ), - 'sunrise-last-deactivated' => array( + ], + 'sunrise-last-deactivated' => [ 'tooltip' => '', 'title' => 'Last Deactivated', 'value' => gmdate('Y-m-d @ H:i:s', $data['last_deactivated']), - ), - 'sunrise-last-modified' => array( + ], + 'sunrise-last-modified' => [ 'tooltip' => '', 'title' => 'Last Modified', 'value' => gmdate('Y-m-d @ H:i:s', $data['last_modified']), - ), - ), - ) + ], + ], + ] ); return $sys_info; @@ -404,7 +404,7 @@ class Sunrise { * @since 2.0.11 * @return void */ - public static function maybe_tap_on_init() { + public static function maybe_tap_on_init(): void { $state = function_exists('WP_Ultimo') && WP_Ultimo()->is_loaded(); @@ -443,18 +443,18 @@ class Sunrise { * @param array $existing Existing meta file values. * @return bool */ - protected static function tap($mode = 'activating', $existing = array()) { + protected static function tap($mode = 'activating', $existing = []) { $now = gmdate('U'); $to_save = wp_parse_args( $existing, - array( + [ 'active' => false, 'created' => $now, 'last_activated' => 'unknown', 'last_deactivated' => 'unknown', - ) + ] ); if ($mode === 'activating') { diff --git a/inc/class-user-switching.php b/inc/class-user-switching.php index e0fe985..2c0f40b 100644 --- a/inc/class-user-switching.php +++ b/inc/class-user-switching.php @@ -28,7 +28,7 @@ class User_Switching { */ public function __construct() { - add_action('plugins_loaded', array($this, 'register_forms')); + add_action('plugins_loaded', [$this, 'register_forms']); } /** * Check if Plugin User Switching is activated @@ -47,13 +47,13 @@ class User_Switching { * * @return void */ - public function register_forms() { + public function register_forms(): void { wu_register_form( 'install_user_switching', - array( - 'render' => array($this, 'render_install_user_switching'), - ) + [ + 'render' => [$this, 'render_install_user_switching'], + ] ); } @@ -64,42 +64,42 @@ class User_Switching { * * @return void */ - public function render_install_user_switching() { + public function render_install_user_switching(): void { - $fields = array( - 'title' => array( + $fields = [ + 'title' => [ 'type' => 'text-display', 'title' => '', 'display_value' => __('This feature requires the plugin User Switching to be installed and active.', 'wp-ultimo'), 'tooltip' => '', - ), - 'link' => array( + ], + 'link' => [ 'type' => 'link', 'display_value' => __('Install User Switching', 'wp-ultimo'), 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end wu-text-center wu-bg-gray-100', - 'html_attr' => array( + 'html_attr' => [ 'href' => add_query_arg( - array( + [ 's' => 'user-switching', 'tab' => 'search', 'type' => 'tag', - ), + ], network_admin_url('plugin-install.php') ), - ), - ), - ); + ], + ], + ]; $form = new \WP_Ultimo\UI\Form( 'install_user_switching', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array(), - ) + 'html_attr' => [], + ] ); $form->render(); diff --git a/inc/class-views.php b/inc/class-views.php index 3738a8d..bc7809b 100644 --- a/inc/class-views.php +++ b/inc/class-views.php @@ -26,9 +26,9 @@ class Views { * * @since 1.9.0 */ - public function init() { + public function init(): void { - add_filter('wu_view_override', array($this, 'view_override'), 10, 3); + add_filter('wu_view_override', [$this, 'view_override'], 10, 3); } /** @@ -93,6 +93,6 @@ class Views { $found = $this->custom_locate_template("wp-ultimo/$view.php"); - return $found ? $found : $original_path; + return $found ?: $original_path; } } diff --git a/inc/class-whitelabel.php b/inc/class-whitelabel.php index 8433298..3d66516 100644 --- a/inc/class-whitelabel.php +++ b/inc/class-whitelabel.php @@ -43,7 +43,7 @@ class Whitelabel { * @since 2.0.0 * @var array */ - protected $search = array(); + protected $search = []; /** * Array of terms to replace with. Must be a 1 to 1 relationship with the search array. @@ -51,7 +51,7 @@ class Whitelabel { * @since 2.0.0 * @var array */ - protected $replace = array(); + protected $replace = []; /** * Adds the hooks. @@ -59,15 +59,15 @@ class Whitelabel { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - add_action('wp_ultimo_load', array($this, 'add_settings'), 20); + add_action('wp_ultimo_load', [$this, 'add_settings'], 20); - add_action('admin_init', array($this, 'clear_footer_texts')); + add_action('admin_init', [$this, 'clear_footer_texts']); - add_action('init', array($this, 'hooks')); + add_action('init', [$this, 'hooks']); - add_filter('gettext', array($this, 'replace_text'), 10, 3); + add_filter('gettext', [$this, 'replace_text'], 10, 3); } /** @@ -76,22 +76,22 @@ class Whitelabel { * @since 2.0.0 * @return void */ - public function hooks() { + public function hooks(): void { if (wu_get_setting('hide_wordpress_logo', true)) { - add_action('wp_before_admin_bar_render', array($this, 'wp_logo_admin_bar_remove'), 0); + add_action('wp_before_admin_bar_render', [$this, 'wp_logo_admin_bar_remove'], 0); - add_action('wp_user_dashboard_setup', array($this, 'remove_dashboard_widgets'), 11); + add_action('wp_user_dashboard_setup', [$this, 'remove_dashboard_widgets'], 11); - add_action('wp_dashboard_setup', array($this, 'remove_dashboard_widgets'), 11); + add_action('wp_dashboard_setup', [$this, 'remove_dashboard_widgets'], 11); - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles')); + add_action('admin_enqueue_scripts', [$this, 'enqueue_styles']); - add_action('wp_enqueue_scripts', array($this, 'enqueue_styles')); + add_action('wp_enqueue_scripts', [$this, 'enqueue_styles']); } if (wu_get_setting('hide_sites_menu', true)) { - add_action('network_admin_menu', array($this, 'remove_sites_admin_menu')); + add_action('network_admin_menu', [$this, 'remove_sites_admin_menu']); } } @@ -101,7 +101,7 @@ class Whitelabel { * @since 2.0.0 * @return void */ - public function enqueue_styles() { + public function enqueue_styles(): void { WP_Ultimo()->scripts->register_style('wu-whitelabel', wu_get_asset('whitelabel.css', 'css')); @@ -123,10 +123,10 @@ class Whitelabel { if ($this->allowed_domains === null) { $this->allowed_domains = apply_filters( 'wu_replace_text_allowed_domains', - array( + [ 'default', 'wp-ultimo', - ) + ] ); } @@ -144,12 +144,12 @@ class Whitelabel { * * @since 2.1.0 */ - if (strncmp($translation, 'http', strlen('http')) === 0) { + if (str_starts_with($translation, 'http')) { return $translation; } if ($this->init === false) { - $search_and_replace = array(); + $search_and_replace = []; $site_plural = wu_get_setting('rename_site_plural'); @@ -196,87 +196,87 @@ class Whitelabel { * * @return void */ - public function add_settings() { + public function add_settings(): void { wu_register_settings_section( 'whitelabel', - array( + [ 'title' => __('Whitelabel', 'wp-ultimo'), 'desc' => __('Basic Whitelabel', 'wp-ultimo'), 'icon' => 'dashicons-wu-eye', - ) + ] ); wu_register_settings_field( 'whitelabel', 'whitelabel_header', - array( + [ 'title' => __('Whitelabel', 'wp-ultimo'), 'desc' => __('Hide a couple specific WordPress elements and rename others.', 'wp-ultimo'), 'type' => 'header', - ) + ] ); - $preview_image = wu_preview_image(wu_get_asset('settings/settings-hide-wp-logo-preview.png')); + $preview_image = wu_preview_image(wu_get_asset('settings/settings-hide-wp-logo-preview.webp')); wu_register_settings_field( 'whitelabel', 'hide_wordpress_logo', - array( + [ 'title' => __('Hide WordPress Logo', 'wp-ultimo') . $preview_image, 'desc' => __('Hide the WordPress logo from the top-bar and replace the same logo on the My Sites top-bar item with a more generic icon.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 1, - ) + ] ); wu_register_settings_field( 'whitelabel', 'hide_sites_menu', - array( + [ 'title' => __('Hide Sites Admin Menu', 'wp-ultimo'), 'desc' => __('We recommend that you manage all of your sites using the WP Multisite WaaS → Sites page. To avoid confusion, you can hide the default "Sites" item from the WordPress admin menu by toggling this option.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, - ) + ] ); wu_register_settings_field( 'whitelabel', 'rename_wordpress', - array( + [ 'title' => __('Replace the word "WordPress"', 'wp-ultimo'), 'placeholder' => __('e.g. My App', 'wp-ultimo'), 'desc' => __('Replace all occurrences of the word "WordPress" with a different word.', 'wp-ultimo'), 'type' => 'text', 'default' => '', - ) + ] ); wu_register_settings_field( 'whitelabel', 'rename_site_singular', - array( + [ 'title' => __('Replace the word "Site" (singular)', 'wp-ultimo'), 'placeholder' => __('e.g. App', 'wp-ultimo'), 'desc' => __('Replace all occurrences of the word "Site" with a different word.', 'wp-ultimo'), 'type' => 'text', 'default' => '', 'wrapper_classes' => 'wu-w-1/2', - ) + ] ); wu_register_settings_field( 'whitelabel', 'rename_site_plural', - array( + [ 'title' => __('Replace the word "Sites" (plural)', 'wp-ultimo'), 'placeholder' => __('e.g. Apps', 'wp-ultimo'), 'desc' => __('Replace all occurrences of the word "Sites" with a different word.', 'wp-ultimo'), 'type' => 'text', 'default' => '', 'wrapper_classes' => 'wu-w-1/2', - ) + ] ); } @@ -286,7 +286,7 @@ class Whitelabel { * @since 2.0.0 * @return void */ - public function wp_logo_admin_bar_remove() { + public function wp_logo_admin_bar_remove(): void { global $wp_admin_bar; @@ -299,7 +299,7 @@ class Whitelabel { * @since 2.0.0 * @return void */ - public function remove_dashboard_widgets() { + public function remove_dashboard_widgets(): void { global $wp_meta_boxes; @@ -319,7 +319,7 @@ class Whitelabel { * @since 2.0.0 * @return void */ - public function clear_footer_texts() { + public function clear_footer_texts(): void { if (current_user_can('manage_network')) { return; @@ -336,7 +336,7 @@ class Whitelabel { * @since 2.0.0 * @return void */ - public function remove_sites_admin_menu() { + public function remove_sites_admin_menu(): void { global $menu; diff --git a/inc/class-wp-ultimo.php b/inc/class-wp-ultimo.php index ad15778..0258c32 100644 --- a/inc/class-wp-ultimo.php +++ b/inc/class-wp-ultimo.php @@ -44,7 +44,7 @@ final class WP_Ultimo { * * @var array */ - public $tables = array(); + public $tables = []; /** * Checks if WP Multisite WaaS was loaded or not. @@ -100,7 +100,7 @@ final class WP_Ultimo { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { /* * Core Helper Functions */ @@ -229,7 +229,7 @@ final class WP_Ultimo { * @since 0.0.1 * @return void */ - public function setup_textdomain() { + public function setup_textdomain(): void { /* * Loads the translation files. */ @@ -242,7 +242,7 @@ final class WP_Ultimo { * @since 2.0.0 * @return void */ - public function setup_tables() { + public function setup_tables(): void { $this->tables = \WP_Ultimo\Loaders\Table_Loader::get_instance(); } @@ -257,7 +257,7 @@ final class WP_Ultimo { * @since 2.0.0 * @return void */ - public function load_public_apis() { + public function load_public_apis(): void { /** * Primitive Helpers @@ -423,7 +423,7 @@ final class WP_Ultimo { * @since 2.0.0 * @return void */ - protected function load_extra_components() { + protected function load_extra_components(): void { /* * SSO Functionality */ @@ -634,7 +634,7 @@ final class WP_Ultimo { * @since 2.0.0 * @return void */ - protected function load_admin_pages() { + protected function load_admin_pages(): void { /* * Migration Wizard Alert */ @@ -798,7 +798,7 @@ final class WP_Ultimo { * @since 2.0.0 * @return void */ - protected function load_managers() { + protected function load_managers(): void { /* * Loads the Event manager. */ diff --git a/inc/compat/class-discount-code-compat.php b/inc/compat/class-discount-code-compat.php index a35c73f..0d127eb 100644 --- a/inc/compat/class-discount-code-compat.php +++ b/inc/compat/class-discount-code-compat.php @@ -29,9 +29,9 @@ class Discount_Code_Compat { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - add_filter('update_post_metadata', array($this, 'check_update_coupon'), 10, 5); + add_filter('update_post_metadata', [$this, 'check_update_coupon'], 10, 5); } /** diff --git a/inc/compat/class-elementor-compat.php b/inc/compat/class-elementor-compat.php index c4e1463..792f1de 100644 --- a/inc/compat/class-elementor-compat.php +++ b/inc/compat/class-elementor-compat.php @@ -29,13 +29,13 @@ class Elementor_Compat { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - add_action('wu_duplicate_site', array($this, 'regenerate_css')); + add_action('wu_duplicate_site', [$this, 'regenerate_css']); - add_filter('wu_should_redirect_to_primary_domain', array($this, 'maybe_prevent_redirection')); + add_filter('wu_should_redirect_to_primary_domain', [$this, 'maybe_prevent_redirection']); - add_action('elementor/widget/shortcode/skins_init', array($this, 'maybe_setup_preview')); + add_action('elementor/widget/shortcode/skins_init', [$this, 'maybe_setup_preview']); } /** @@ -45,7 +45,7 @@ class Elementor_Compat { * @param array $site Info about the duplicated site. * @return void */ - public function regenerate_css($site) { + public function regenerate_css($site): void { if ( ! class_exists('\Elementor\Plugin')) { return; @@ -85,12 +85,12 @@ class Elementor_Compat { * @since 2.0.5 * @return void */ - public function maybe_setup_preview() { + public function maybe_setup_preview(): void { - $elementor_actions = array( + $elementor_actions = [ 'elementor', 'elementor_ajax', - ); + ]; if (in_array(wu_request('action'), $elementor_actions, true)) { wu_element_setup_preview(); diff --git a/inc/compat/class-general-compat.php b/inc/compat/class-general-compat.php index 4163bbb..da6e613 100644 --- a/inc/compat/class-general-compat.php +++ b/inc/compat/class-general-compat.php @@ -29,7 +29,7 @@ class General_Compat { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { /** * Woocommerce @@ -38,46 +38,46 @@ class General_Compat { * * @see https://wordpress.org/plugins/woocommerce/ */ - add_action('woocommerce_loaded', array($this, 'replace_wc_wpdb_table_fix')); + add_action('woocommerce_loaded', [$this, 'replace_wc_wpdb_table_fix']); /** * WP Typography. * * @see https://de.wordpress.org/plugins/wp-typography/ */ - add_action('load-settings_page_wp-typography', array($this, 'add_wp_typography_warning_message')); + add_action('load-settings_page_wp-typography', [$this, 'add_wp_typography_warning_message']); - add_filter('typo_settings', array($this, 'fix_wp_typography')); + add_filter('typo_settings', [$this, 'fix_wp_typography']); /** * Brizy Page Builder. * * @see https://wordpress.org/plugins/brizy/ */ - add_filter('wu_append_preview_parameter', array($this, 'fix_brizy_preview_url')); + add_filter('wu_append_preview_parameter', [$this, 'fix_brizy_preview_url']); - add_filter('wu_should_redirect_to_primary_domain', array($this, 'fix_brizy_editor_screen')); + add_filter('wu_should_redirect_to_primary_domain', [$this, 'fix_brizy_editor_screen']); /** * Divi Page Builder. * * @see https://www.elegantthemes.com/ */ - add_filter('wu_should_redirect_to_primary_domain', array($this, 'fix_divi_editor_screen')); + add_filter('wu_should_redirect_to_primary_domain', [$this, 'fix_divi_editor_screen']); /** * WP Hide Pro * * @see https://wp-hide.com/ */ - add_filter('wu_append_preview_parameter', array($this, 'fix_wp_hide_preview_url')); + add_filter('wu_append_preview_parameter', [$this, 'fix_wp_hide_preview_url']); /** * Frontend Admin. * * @see https://wpfrontendadmin.com/ */ - add_filter('wp_frontend_admin/shortcode/admin_page_final_url', array($this, 'fix_frontend_admin_loading_url'), 10, 3); + add_filter('wp_frontend_admin/shortcode/admin_page_final_url', [$this, 'fix_frontend_admin_loading_url'], 10, 3); /** * Oxygen Builder. @@ -87,16 +87,16 @@ class General_Compat { * * @see https://oxygenbuilder.com/ */ - add_filter('wu_element_should_enqueue_scripts', array($this, 'maybe_parse_oxygen_content'), 10, 3); + add_filter('wu_element_should_enqueue_scripts', [$this, 'maybe_parse_oxygen_content'], 10, 3); - add_action('wu_template_previewer', array($this, 'prevent_oxygen_cleanup_on_template_previewer')); + add_action('wu_template_previewer', [$this, 'prevent_oxygen_cleanup_on_template_previewer']); /** * WP Maintenance Mode. Adds SSO to WPMM, if enabled. * * @see https://wordpress.org/plugins/wp-maintenance-mode/ */ - add_filter('wu_sso_loaded_on_init', array($this, 'add_sso_to_maintenance_mode')); + add_filter('wu_sso_loaded_on_init', [$this, 'add_sso_to_maintenance_mode']); /** * Avada Theme. @@ -106,8 +106,8 @@ class General_Compat { * * @see https://themeforest.net/item/avada-responsive-multipurpose-theme/ */ - add_filter('wu_template_previewer_before', array($this, 'run_wp_on_template_previewer')); - add_filter('wu_domain_post_save', array($this, 'clear_avada_cache')); + add_filter('wu_template_previewer_before', [$this, 'run_wp_on_template_previewer']); + add_filter('wu_domain_post_save', [$this, 'clear_avada_cache']); /** * FluentCRM Pro @@ -116,7 +116,7 @@ class General_Compat { * * @see https://fluentcrm.com/ */ - add_action('wp_insert_site', array($this, 'fix_fluent_pro_site_duplication')); + add_action('wp_insert_site', [$this, 'fix_fluent_pro_site_duplication']); /** * Rank Math (Free and Pro) @@ -125,7 +125,7 @@ class General_Compat { * * @see https://rankmath.com/ */ - add_action('wp_initialize_site', array($this, 'fix_rank_math_site_creation'), 1); + add_action('wp_initialize_site', [$this, 'fix_rank_math_site_creation'], 1); /** * WP E-Signature and WP E-Signature Business add-ons @@ -134,7 +134,7 @@ class General_Compat { * * @see https://www.approveme.com/ */ - add_action('wp_initialize_site', array($this, 'fix_wp_e_signature_site_creation'), 1); + add_action('wp_initialize_site', [$this, 'fix_wp_e_signature_site_creation'], 1); /** * KeyPress DSN Manager backwards compatibility. @@ -161,7 +161,7 @@ class General_Compat { * @since 2.1.1 * @see https://perfmatters.io/ */ - add_filter('wp_print_scripts', array($this, 'remove_perfmatters_checkout_dep'), 99); + add_filter('wp_print_scripts', [$this, 'remove_perfmatters_checkout_dep'], 99); /** * Adds the setup preview for elements on DIVI. @@ -189,20 +189,20 @@ class General_Compat { * @see https://wordpress.org/plugins/woocommerce/ * @since 2.0.14 */ - public function replace_wc_wpdb_table_fix() { + public function replace_wc_wpdb_table_fix(): void { global $wpdb; - remove_action('switch_blog', array(WC(), 'wpdb_table_fix'), 0); + remove_action('switch_blog', [WC(), 'wpdb_table_fix'], 0); // List of tables without prefixes. - $tables = array( + $tables = [ 'payment_tokenmeta' => 'woocommerce_payment_tokenmeta', 'order_itemmeta' => 'woocommerce_order_itemmeta', 'wc_product_meta_lookup' => 'wc_product_meta_lookup', 'wc_tax_rate_classes' => 'wc_tax_rate_classes', 'wc_reserved_stock' => 'wc_reserved_stock', - ); + ]; foreach ( $tables as $name => $table ) { $wpdb->tables[] = $table; @@ -250,7 +250,7 @@ class General_Compat { * @since 2.0.0 * @return void */ - public function add_wp_typography_warning_message() { + public function add_wp_typography_warning_message(): void { WP_Ultimo()->notices->add(__('WP Typography "Smart Quotes" replacement is not compatible with WP Multisite WaaS and will be automatically disabled.', 'wp-ultimo'), 'warning'); } @@ -381,7 +381,7 @@ class General_Compat { * @since 2.0.4 * @return void */ - public function prevent_oxygen_cleanup_on_template_previewer() { + public function prevent_oxygen_cleanup_on_template_previewer(): void { add_action( 'wp_head', @@ -401,9 +401,9 @@ class General_Compat { * @param \WP_Ultimo\Domain_Mapping\SSO $sso The SSO class instance. * @return void */ - public function add_sso_to_maintenance_mode($sso) { + public function add_sso_to_maintenance_mode($sso): void { - add_action('wpmm_head', array($sso, 'enqueue_script')); + add_action('wpmm_head', [$sso, 'enqueue_script']); } /** @@ -412,7 +412,7 @@ class General_Compat { * * @since 2.0.11 */ - public function run_wp_on_template_previewer() { + public function run_wp_on_template_previewer(): void { if (class_exists('Avada')) { do_action('wp'); //phpcs:disable @@ -427,7 +427,7 @@ class General_Compat { * * @since 2.0.11 */ - public function clear_avada_cache($data) { + public function clear_avada_cache($data): void { switch_to_blog($data['blog_id']); @@ -462,14 +462,14 @@ class General_Compat { * * @since 2.0.11 */ - public function fix_fluent_pro_site_duplication() { + public function fix_fluent_pro_site_duplication(): void { $class_name = 'FluentCampaign\App\Hooks\Handlers\IntegrationHandler'; if (class_exists($class_name)) { // Here we use this function due FluentCrm($class_name) returns an instance not working with remove_action - $this->hard_remove_action('set_user_role', array($class_name, 'maybeAutoAlterTags'), 11); + $this->hard_remove_action('set_user_role', [$class_name, 'maybeAutoAlterTags'], 11); } @@ -482,20 +482,20 @@ class General_Compat { * * @since 2.0.20 */ - public function fix_rank_math_site_creation() { + public function fix_rank_math_site_creation(): void { - $class_names = array( + $class_names = [ 'RankMath\Installer', 'RankMathPro\Installer', - ); + ]; foreach ($class_names as $class_name) { if (class_exists($class_name)) { // HankMath does not provide a instance of the activation class - $this->hard_remove_action('wpmu_new_blog', array($class_name, 'activate_blog'), 10); - $this->hard_remove_action('wp_initialize_site', array($class_name, 'initialize_site'), 10); + $this->hard_remove_action('wpmu_new_blog', [$class_name, 'activate_blog'], 10); + $this->hard_remove_action('wp_initialize_site', [$class_name, 'initialize_site'], 10); } @@ -511,19 +511,19 @@ class General_Compat { * * @since 2.1 */ - public function fix_wp_e_signature_site_creation() { + public function fix_wp_e_signature_site_creation(): void { - $class_names = array( + $class_names = [ 'ESIG_SAD', 'ESIG_SIF', - ); + ]; foreach ($class_names as $class_name) { if (class_exists($class_name)) { // WP E-Signature does not provide a instance of the activation class - $this->hard_remove_action('wpmu_new_blog', array($class_name, 'activate_new_site'), 10); + $this->hard_remove_action('wpmu_new_blog', [$class_name, 'activate_new_site'], 10); } @@ -541,7 +541,7 @@ class General_Compat { * @param int $priority The The action priority. * @return void */ - public function hard_remove_action($tag, $handler, $priority) { + public function hard_remove_action($tag, $handler, $priority): void { global $wp_filter; @@ -555,7 +555,7 @@ class General_Compat { foreach($wp_filter[$tag][$priority] as $handler_key => $filter_handler) { - if(strpos((string) $handler_key, (string) $handler[1]) !== false && is_array($filter_handler['function']) && is_a($filter_handler['function'][0], $handler[0]) && $filter_handler['function'][1] === $handler[1]) { + if(str_contains((string) $handler_key, (string) $handler[1]) && is_array($filter_handler['function']) && is_a($filter_handler['function'][0], $handler[0]) && $filter_handler['function'][1] === $handler[1]) { $handler_id = $handler_key; @@ -579,7 +579,7 @@ class General_Compat { * @since 2.1.1 * @return void */ - public function remove_perfmatters_checkout_dep() { + public function remove_perfmatters_checkout_dep(): void { if (is_main_site() || is_admin()) { diff --git a/inc/compat/class-gutenberg-support.php b/inc/compat/class-gutenberg-support.php index 8906292..de356b3 100644 --- a/inc/compat/class-gutenberg-support.php +++ b/inc/compat/class-gutenberg-support.php @@ -47,10 +47,10 @@ class Gutenberg_Support { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { if ($this->should_load()) { - add_action('admin_enqueue_scripts', array($this, 'add_scripts')); + add_action('admin_enqueue_scripts', [$this, 'add_scripts']); } } @@ -60,9 +60,9 @@ class Gutenberg_Support { * @since 1.9.14 * @return void */ - public function add_scripts() { + public function add_scripts(): void { - wp_register_script('wu-gutenberg-support', wu_get_asset('gutenberg-support.js', 'js'), array('jquery'), wu_get_version(), true); + wp_register_script('wu-gutenberg-support', wu_get_asset('gutenberg-support.js', 'js'), ['jquery'], wu_get_version(), true); // translators: the placeholder is replaced with the network name. $preview_message = apply_filters('wu_gutenberg_support_preview_message', sprintf(__('%s is generating the preview...', 'wp-ultimo'), get_network_option(null, 'site_name'))); @@ -70,10 +70,10 @@ class Gutenberg_Support { wp_localize_script( 'wu-gutenberg-support', 'wu_gutenberg', - array( + [ 'logo' => esc_url(wu_get_network_logo()), 'replacement_message' => $preview_message, - ) + ] ); wp_enqueue_script('wu-gutenberg-support'); diff --git a/inc/compat/class-legacy-shortcodes.php b/inc/compat/class-legacy-shortcodes.php index bfcdd0f..619a807 100644 --- a/inc/compat/class-legacy-shortcodes.php +++ b/inc/compat/class-legacy-shortcodes.php @@ -44,19 +44,19 @@ class Legacy_Shortcodes { * * @return void */ - public function init() { + public function init(): void { - add_shortcode('wu_paying_users', array($this, 'paying_users')); + add_shortcode('wu_paying_users', [$this, 'paying_users']); - add_shortcode('wu_user_meta', array($this, 'user_meta')); + add_shortcode('wu_user_meta', [$this, 'user_meta']); - add_shortcode('wu_plan_link', array($this, 'plan_link')); + add_shortcode('wu_plan_link', [$this, 'plan_link']); - add_shortcode('wu_restricted_content', array($this, 'restricted_content')); + add_shortcode('wu_restricted_content', [$this, 'restricted_content']); - add_shortcode('wu_pricing_table', array($this, 'pricing_table')); + add_shortcode('wu_pricing_table', [$this, 'pricing_table']); - add_shortcode('wu_templates_list', array($this, 'templates_list')); + add_shortcode('wu_templates_list', [$this, 'templates_list']); } /** @@ -86,12 +86,12 @@ class Legacy_Shortcodes { } $atts = shortcode_atts( - array( + [ 'user_id' => $user_id, 'meta_name' => 'first_name', 'default' => false, 'unique' => true, - ), + ], $atts, 'wu_user_meta' ); @@ -106,7 +106,7 @@ class Legacy_Shortcodes { $value = implode(', ', $value); } - return $value ? $value : '--'; + return $value ?: '--'; } /** @@ -121,12 +121,12 @@ class Legacy_Shortcodes { global $wpdb; - $atts = shortcode_atts(array(), $atts, 'wu_paying_users'); + $atts = shortcode_atts([], $atts, 'wu_paying_users'); $paying_customers = wu_get_customers( - array( + [ 'count' => true, - ) + ] ); return $paying_customers; @@ -143,11 +143,11 @@ class Legacy_Shortcodes { public function plan_link($atts) { $atts = shortcode_atts( - array( + [ 'plan_id' => 0, 'plan_freq' => 1, 'skip_plan' => 1, - ), + ], $atts, 'wu_plan_link' ); @@ -157,7 +157,7 @@ class Legacy_Shortcodes { * * @since 1.5.1 */ - foreach (array('plan_id', 'plan_freq') as $att) { + foreach (['plan_id', 'plan_freq'] as $att) { $atts[ $att ] = wu_extract_number($atts[ $att ]); } @@ -200,14 +200,14 @@ class Legacy_Shortcodes { public function restricted_content($atts, $content) { $atts = shortcode_atts( - array( + [ 'plan_id' => false, 'product_id' => false, 'only_active' => true, 'only_logged' => false, 'exclude_trials' => false, 'from_request' => false, - ), + ], $atts, 'wu_restricted_content' ); @@ -218,9 +218,9 @@ class Legacy_Shortcodes { return __('You need to pass a valid plan ID.', 'wp-ultimo'); } - $query_products = get_query_var('products', array()); + $query_products = get_query_var('products', []); - $request_products = array(); + $request_products = []; foreach ($query_products as $product) { $product = wu_get_product($product); @@ -238,8 +238,8 @@ class Legacy_Shortcodes { $else = '[wu_default_content]'; - if (strpos($content, $else) !== false) { - list($if, $else) = explode($else, $content, 2); + if (str_contains($content, $else)) { + [$if, $else] = explode($else, $content, 2); } else { $if = $content; @@ -258,7 +258,7 @@ class Legacy_Shortcodes { if ($membership && $should_check && ! $from_request) { $membership_products = array_merge( - array($membership->get_plan_id()), + [$membership->get_plan_id()], $membership->get_addon_ids() ); @@ -297,7 +297,7 @@ class Legacy_Shortcodes { global $post; $atts = shortcode_atts( - array( + [ 'primary_color' => wu_get_setting('primary_color', '#00a1ff'), 'accent_color' => wu_get_setting('accent_color', '#78b336'), 'default_pricing_option' => wu_get_setting('default_pricing_option', 1), @@ -306,7 +306,7 @@ class Legacy_Shortcodes { // New Options 'layout' => 'legacy', 'period_selector_layout' => 'legacy', - ), + ], $atts, 'wu_pricing_table' ); @@ -328,46 +328,46 @@ class Legacy_Shortcodes { $checkout_form = new \WP_Ultimo\Models\Checkout_Form(); - $fields = array(); + $fields = []; - $search_arguments = array( + $search_arguments = [ 'fields' => 'ids', - ); + ]; if ($atts['plan_id']) { $search_arguments['id__in'] = $atts['plan_id']; } if ($atts['show_selector']) { - $fields[] = array( + $fields[] = [ 'step' => 'checkout', 'name' => '', 'type' => 'period_selection', 'id' => 'period_selection', 'period_selection_template' => $atts['period_selector_layout'], - 'period_options' => array( - array( + 'period_options' => [ + [ 'duration' => 1, 'duration_unit' => 'month', 'label' => __('Monthly', 'wp-ultimo'), - ), - array( + ], + [ 'duration' => 3, 'duration_unit' => 'month', 'label' => __('Quarterly', 'wp-ultimo'), - ), - array( + ], + [ 'duration' => 1, 'duration_unit' => 'year', 'label' => __('Yearly', 'wp-ultimo'), - ), - ), - ); + ], + ], + ]; } $layout = $atts['layout']; - $fields[] = array( + $fields[] = [ 'step' => 'checkout', 'name' => __('Plans', 'wp-ultimo'), 'type' => 'pricing_table', @@ -376,29 +376,29 @@ class Legacy_Shortcodes { 'pricing_table_products' => implode(',', wu_get_plans($search_arguments)), 'pricing_table_template' => $layout, 'element_classes' => $layout === 'legacy' ? 'wu-content-plan' : '', - ); + ]; /** * If not using the legacy checkout, * we'll need a submit field. */ if ($layout !== 'legacy') { - $fields[] = array( + $fields[] = [ 'step' => 'checkout', 'name' => __('Get Started →', 'wp-ultimo'), 'type' => 'submit_button', 'id' => 'checkout', - ); + ]; } - $steps = array( - array( + $steps = [ + [ 'id' => 'checkout', 'name' => __('Checkout', 'wp-ultimo'), 'desc' => '', 'fields' => $fields, - ), - ); + ], + ]; $checkout = \WP_Ultimo\Checkout\Checkout::get_instance(); @@ -433,30 +433,30 @@ class Legacy_Shortcodes { /* * Adds the product fields to keep them. */ - $final_fields['products[]'] = array( + $final_fields['products[]'] = [ 'type' => 'hidden', - 'html_attr' => array( + 'html_attr' => [ 'v-for' => '(product, index) in unique_products', 'v-model' => 'products[index]', 'v-bind:id' => '"products-" + index', - ), - ); + ], + ]; - $final_fields['pre-flight'] = array( + $final_fields['pre-flight'] = [ 'type' => 'hidden', 'value' => 1, - ); + ]; return wu_get_template_contents( 'checkout/form', - array( + [ 'step' => $checkout_form->get_step('checkout', true), 'step_name' => 'checkout', 'checkout_form_name' => 'wu_pricing_table', 'checkout_form_action' => add_query_arg('pre-flight', 1, wu_get_registration_url()), 'display_title' => '', 'final_fields' => $final_fields, - ) + ] ); } @@ -477,14 +477,14 @@ class Legacy_Shortcodes { global $post; $atts = shortcode_atts( - array( + [ 'show_filters' => true, 'show_title' => true, 'templates' => false, 'cols' => 3, 'layout' => 'legacy', 'checkout_page' => wu_guess_registration_page(), - ), + ], $atts, 'wu_templates_list' ); @@ -512,33 +512,33 @@ class Legacy_Shortcodes { $checkout_form = new \WP_Ultimo\Models\Checkout_Form(); - $fields = array(); + $fields = []; - $search_arguments = array( + $search_arguments = [ 'fields' => 'ids', - ); + ]; $layout = $atts['layout']; - $fields[] = array( + $fields[] = [ 'step' => 'checkout', 'name' => __('Templates', 'wp-ultimo'), 'type' => 'template_selection', 'id' => 'template_selection', - 'template_selection_sites' => implode(',', $templates ? $templates : wu_get_site_templates($search_arguments)), + 'template_selection_sites' => implode(',', $templates ?: wu_get_site_templates($search_arguments)), 'template_selection_template' => $layout, 'cols' => $atts['cols'], 'element_classes' => $layout === 'legacy' ? 'wu-content-templates' : '', - ); + ]; - $steps = array( - array( + $steps = [ + [ 'id' => 'checkout', 'name' => __('Checkout', 'wp-ultimo'), 'desc' => '', 'fields' => $fields, - ), - ); + ], + ]; $checkout = \WP_Ultimo\Checkout\Checkout::get_instance(); @@ -570,23 +570,23 @@ class Legacy_Shortcodes { 'after' ); - $final_fields['pre-flight'] = array( + $final_fields['pre-flight'] = [ 'type' => 'hidden', 'value' => 1, - ); + ]; $page_url = wu_switch_blog_and_run(fn() => get_permalink($atts['checkout_page'])); return wu_get_template_contents( 'checkout/form', - array( + [ 'step' => $checkout_form->get_step('checkout', true), 'step_name' => 'checkout', 'checkout_form_name' => 'wu_templates_list', 'checkout_form_action' => add_query_arg('pre-flight', 1, $page_url), 'display_title' => '', 'final_fields' => $final_fields, - ) + ] ); } /** diff --git a/inc/compat/class-multiple-accounts-compat.php b/inc/compat/class-multiple-accounts-compat.php index 350bb26..a65a587 100644 --- a/inc/compat/class-multiple-accounts-compat.php +++ b/inc/compat/class-multiple-accounts-compat.php @@ -49,10 +49,10 @@ class Multiple_Accounts_Compat { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { // Add the settings to enable or disable this feature. - add_action('wu_settings_login', array($this, 'add_settings'), 10); + add_action('wu_settings_login', [$this, 'add_settings'], 10); if ($this->should_load()) { @@ -60,28 +60,28 @@ class Multiple_Accounts_Compat { $this->fix_object_cache_on_multiple_accounts(); // Unset user, if the current one is not part of the site. - add_action('plugins_loaded', array($this, 'maybe_unset_current_user'), -10); + add_action('plugins_loaded', [$this, 'maybe_unset_current_user'], -10); // prevents woocommerce from adding customers to sites without our knowledge - add_action('woocommerce_process_login_errors', array($this, 'prevent_woo_from_adding_to_blog'), -10); + add_action('woocommerce_process_login_errors', [$this, 'prevent_woo_from_adding_to_blog'], -10); // Add the filter to prevent email blocking - add_filter('email_exists', array($this, 'allow_duplicate_emails'), 10, 2); + add_filter('email_exists', [$this, 'allow_duplicate_emails'], 10, 2); // Add the filter to prevent email blocking - add_filter('query', array($this, 'fix_user_query'), -999); + add_filter('query', [$this, 'fix_user_query'], -999); // Action in the login to debug the login info - add_filter('authenticate', array($this, 'fix_login'), 50000, 3); + add_filter('authenticate', [$this, 'fix_login'], 50000, 3); // Now we handle the password thing - add_action('init', array($this, 'handle_reset_password'), 2000); + add_action('init', [$this, 'handle_reset_password'], 2000); // Now we add a custom column in that table to allow the admin to control them - add_filter('wpmu_users_columns', array($this, 'add_multiple_account_column')); + add_filter('wpmu_users_columns', [$this, 'add_multiple_account_column']); // Adds the number of additional accounts. - add_filter('manage_users_custom_column', array($this, 'add_column_content'), 10, 3); + add_filter('manage_users_custom_column', [$this, 'add_column_content'], 10, 3); } } @@ -95,9 +95,9 @@ class Multiple_Accounts_Compat { */ public function fix_object_cache_on_multiple_accounts(): void { - $to_remove = array( + $to_remove = [ 'useremail', - ); + ]; if (function_exists('wp_cache_add_non_persistent_groups')) { wp_cache_add_non_persistent_groups($to_remove); @@ -118,7 +118,7 @@ class Multiple_Accounts_Compat { $search = "\$db->get_row(\"SELECT * FROM $wpdb->users WHERE user_email"; - if ( strpos($wpdb->func_call, $search) === 0) { + if ( str_starts_with($wpdb->func_call, $search)) { $prefix = "SELECT * FROM $wpdb->users WHERE user_email"; $last = substr($query, strlen($prefix)); @@ -187,7 +187,7 @@ class Multiple_Accounts_Compat { * @since 2.0.0 * @return void */ - public function maybe_unset_current_user() { + public function maybe_unset_current_user(): void { global $current_user; @@ -254,27 +254,27 @@ class Multiple_Accounts_Compat { * * @return void. */ - public function add_settings() { + public function add_settings(): void { wu_register_settings_field( 'login-and-registration', 'multiple_accounts_header', - array( + [ 'title' => __('Multiple Accounts', 'wp-ultimo'), 'desc' => __('Options related to the Multiple Accounts feature.', 'wp-ultimo'), 'type' => 'header', - ) + ] ); wu_register_settings_field( 'login-and-registration', 'enable_multiple_accounts', - array( + [ 'title' => __('Enable Multiple Accounts', 'wp-ultimo'), 'desc' => __('Allow users to have accounts in different sites with the same email address. This is useful when running stores with WooCommerce and other plugins, for example.', 'wp-ultimo') . ' ' . sprintf('%s', wu_get_documentation_url('multiple-accounts'), __('Read More', 'wp-ultimo')), 'type' => 'toggle', 'default' => 0, - ) + ] ); } @@ -303,7 +303,7 @@ class Multiple_Accounts_Compat { * @param int $user_id The ID of the user. * @return void */ - public function add_column_content($null, $column, $user_id) { + public function add_column_content($null, $column, $user_id): void { if ($column === 'multiple_accounts') { @@ -312,11 +312,11 @@ class Multiple_Accounts_Compat { // Get all the accounts with the same email $users = new \WP_User_Query( - array( + [ 'blog_id' => 0, 'search' => $user->user_email, - 'fields' => array('ID', 'user_login'), - ) + 'fields' => ['ID', 'user_login'], + ] ); // translators: the %d is the account count for that email address. @@ -334,7 +334,7 @@ class Multiple_Accounts_Compat { * @since 2.0.0 * @return void */ - public function handle_reset_password() { + public function handle_reset_password(): void { // Only run in the right case if (wu_request('action') === 'retrievepassword' || wu_request('wc_reset_password')) { @@ -364,9 +364,9 @@ class Multiple_Accounts_Compat { // Sets the right user to be returned; $has_user = false; - $query = array( + $query = [ 'search' => $email, - ); + ]; /** * When the user id is present, we use it @@ -377,9 +377,9 @@ class Multiple_Accounts_Compat { * @since 2.0.11 */ if ($user_id) { - $query['include'] = array( + $query['include'] = [ absint($user_id), - ); + ]; } // Now we search for the correct user based on the password and the blog information @@ -418,7 +418,7 @@ class Multiple_Accounts_Compat { // Sets the right user to be returned; $user = $this->get_right_user($username, $password); - return $user ? $user : null; + return $user ?: null; } /** @@ -447,9 +447,9 @@ class Multiple_Accounts_Compat { $args = array_slice(func_get_args(), 2); - $args = array_merge(array($capability), $args); + $args = array_merge([$capability], $args); - $can = call_user_func_array(\Closure::fromCallable(array($current_user, 'has_cap')), $args); + $can = call_user_func_array(\Closure::fromCallable([$current_user, 'has_cap']), $args); if ($switched) { restore_current_blog(); @@ -473,7 +473,7 @@ class Multiple_Accounts_Compat { // $hash = wp_hash_password($password); // Now we search for the correct user based on the password and the blog information - $users = new \WP_User_Query(array('search' => $email)); + $users = new \WP_User_Query(['search' => $email]); // Loop the results and check which one is in this group foreach ($users->results as $user_with_email) { diff --git a/inc/compat/class-product-compat.php b/inc/compat/class-product-compat.php index e2f3e63..c37a3d0 100644 --- a/inc/compat/class-product-compat.php +++ b/inc/compat/class-product-compat.php @@ -29,11 +29,11 @@ class Product_Compat { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - add_filter('wu_product_options_sections', array($this, 'add_legacy_section'), 100, 2); + add_filter('wu_product_options_sections', [$this, 'add_legacy_section'], 100, 2); - add_filter('update_post_metadata', array($this, 'check_update_plan'), 10, 5); + add_filter('update_post_metadata', [$this, 'check_update_plan'], 10, 5); } /** @@ -93,47 +93,47 @@ class Product_Compat { */ public function add_legacy_section($sections, $object) { - $sections['legacy_options_core'] = array( + $sections['legacy_options_core'] = [ 'title' => __('Legacy Options', 'wp-ultimo'), 'desc' => __('Options used by old 1.X versions. ', 'wp-ultimo'), 'icon' => 'dashicons-wu-spreadsheet', - 'state' => array( + 'state' => [ 'legacy_options' => $object->get_legacy_options(), - ), - 'fields' => array( - 'legacy_options' => array( + ], + 'fields' => [ + 'legacy_options' => [ 'type' => 'toggle', 'value' => $object->get_legacy_options(), 'title' => __('Toggle Legacy Options', 'wp-ultimo'), 'desc' => __('Toggle this option to edit legacy options.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'legacy_options', - ), - ), - 'featured_plan' => array( + ], + ], + 'featured_plan' => [ 'type' => 'toggle', 'value' => $object->is_featured_plan(), 'title' => __('Featured Plan', 'wp-ultimo'), 'desc' => __('Toggle this option to mark this product as featured on the legacy pricing tables.', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'legacy_options', - ), - ), - 'feature_list' => array( + ], + ], + 'feature_list' => [ 'type' => 'textarea', 'title' => __('Features List', 'wp-ultimo'), 'placeholder' => __('E.g. Feature 1', 'wp-ultimo') . PHP_EOL . __('Feature 2', 'wp-ultimo'), 'desc' => __('Add a feature per line. These will be shown on the pricing tables.', 'wp-ultimo'), 'value' => $object->get_feature_list(), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'legacy_options', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'rows' => 6, - ), - ), - ), - ); + ], + ], + ], + ]; return $sections; } diff --git a/inc/country/class-country-br.php b/inc/country/class-country-br.php index bf1037e..e8c3cec 100644 --- a/inc/country/class-country-br.php +++ b/inc/country/class-country-br.php @@ -68,11 +68,11 @@ class Country_BR extends Country { * @since 2.0.11 * @var array */ - protected $attributes = array( + protected $attributes = [ 'country_code' => 'BR', 'currency' => 'BRL', 'phone_code' => 55, - ); + ]; /** * The type of nomenclature used to refer to the country sub-divisions. @@ -101,7 +101,7 @@ class Country_BR extends Country { */ protected function states() { - return array( + return [ 'AC' => __('Acre', 'wp-ultimo'), 'AL' => __('Alagoas', 'wp-ultimo'), 'AP' => __('Amapá', 'wp-ultimo'), @@ -129,6 +129,6 @@ class Country_BR extends Country { 'SE' => __('Sergipe', 'wp-ultimo'), 'SP' => __('São Paulo', 'wp-ultimo'), 'TO' => __('Tocantins', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/country/class-country-ca.php b/inc/country/class-country-ca.php index 89be7b6..b69c96a 100644 --- a/inc/country/class-country-ca.php +++ b/inc/country/class-country-ca.php @@ -54,11 +54,11 @@ class Country_CA extends Country { * @since 2.0.11 * @var array */ - protected $attributes = array( + protected $attributes = [ 'country_code' => 'CA', 'currency' => 'CAD', 'phone_code' => 1, - ); + ]; /** * The type of nomenclature used to refer to the country sub-divisions. @@ -87,7 +87,7 @@ class Country_CA extends Country { */ protected function states() { - return array( + return [ 'AB' => __('Alberta', 'wp-ultimo'), 'BC' => __('British Columbia', 'wp-ultimo'), 'MB' => __('Manitoba', 'wp-ultimo'), @@ -101,6 +101,6 @@ class Country_CA extends Country { 'QC' => __('Quebec', 'wp-ultimo'), 'SK' => __('Saskatchewan', 'wp-ultimo'), 'YT' => __('Yukon', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/country/class-country-cn.php b/inc/country/class-country-cn.php index 04d5c77..2d81556 100644 --- a/inc/country/class-country-cn.php +++ b/inc/country/class-country-cn.php @@ -73,11 +73,11 @@ class Country_CN extends Country { * @since 2.0.11 * @var array */ - protected $attributes = array( + protected $attributes = [ 'country_code' => 'CN', 'currency' => 'CNY', 'phone_code' => 86, - ); + ]; /** * The type of nomenclature used to refer to the country sub-divisions. @@ -106,7 +106,7 @@ class Country_CN extends Country { */ protected function states() { - return array( + return [ 'AH' => __('Anhui', 'wp-ultimo'), 'BJ' => __('Beijing', 'wp-ultimo'), 'CQ' => __('Chongqing', 'wp-ultimo'), @@ -141,6 +141,6 @@ class Country_CN extends Country { 'XZ' => __('Xizang', 'wp-ultimo'), 'YN' => __('Yunnan', 'wp-ultimo'), 'ZJ' => __('Zhejiang', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/country/class-country-de.php b/inc/country/class-country-de.php index 8cde140..9b0a05f 100644 --- a/inc/country/class-country-de.php +++ b/inc/country/class-country-de.php @@ -57,11 +57,11 @@ class Country_DE extends Country { * @since 2.0.11 * @var array */ - protected $attributes = array( + protected $attributes = [ 'country_code' => 'DE', 'currency' => 'EUR', 'phone_code' => 49, - ); + ]; /** * The type of nomenclature used to refer to the country sub-divisions. @@ -90,7 +90,7 @@ class Country_DE extends Country { */ protected function states() { - return array( + return [ 'BW' => __('Baden-Württemberg', 'wp-ultimo'), 'BY' => __('Bavaria', 'wp-ultimo'), 'BE' => __('Berlin', 'wp-ultimo'), @@ -107,6 +107,6 @@ class Country_DE extends Country { 'ST' => __('Saxony-Anhalt', 'wp-ultimo'), 'SH' => __('Schleswig-Holstein', 'wp-ultimo'), 'TH' => __('Thuringia', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/country/class-country-default.php b/inc/country/class-country-default.php index 4452171..5863eaa 100644 --- a/inc/country/class-country-default.php +++ b/inc/country/class-country-default.php @@ -52,19 +52,19 @@ class Country_Default extends Country { * @param array $attributes The country attributes. * @return \WP_Ultimo\Country\Country */ - public static function build($code, $name = null, $attributes = array()) { + public static function build($code, $name = null, $attributes = []) { $instance = new self(); - $instance->name = $name ? $name : wu_get_country_name($code); + $instance->name = $name ?: wu_get_country_name($code); $instance->attributes = wp_parse_args( $attributes, - array( + [ 'country_code' => strtoupper($code), 'currency' => strtoupper($code), 'phone_code' => 00, - ) + ] ); return $instance; diff --git a/inc/country/class-country-es.php b/inc/country/class-country-es.php index c604591..5e5c3cf 100644 --- a/inc/country/class-country-es.php +++ b/inc/country/class-country-es.php @@ -59,11 +59,11 @@ class Country_ES extends Country { * @since 2.0.11 * @var array */ - protected $attributes = array( + protected $attributes = [ 'country_code' => 'ES', 'currency' => 'EUR', 'phone_code' => 34, - ); + ]; /** * The type of nomenclature used to refer to the country sub-divisions. @@ -92,7 +92,7 @@ class Country_ES extends Country { */ protected function states() { - return array( + return [ 'AN' => __('Andalusia', 'wp-ultimo'), 'AR' => __('Aragon', 'wp-ultimo'), 'AS' => __('Asturias', 'wp-ultimo'), @@ -121,6 +121,6 @@ class Country_ES extends Country { 'VA' => __('Valladolid Province', 'wp-ultimo'), 'ZA' => __('Zamora Province', 'wp-ultimo'), 'AV' => __('Ávila', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/country/class-country-fr.php b/inc/country/class-country-fr.php index 9d6abdf..41faa0e 100644 --- a/inc/country/class-country-fr.php +++ b/inc/country/class-country-fr.php @@ -54,11 +54,11 @@ class Country_FR extends Country { * @since 2.0.11 * @var array */ - protected $attributes = array( + protected $attributes = [ 'country_code' => 'FR', 'currency' => 'EUR', 'phone_code' => 33, - ); + ]; /** * The type of nomenclature used to refer to the country sub-divisions. @@ -87,7 +87,7 @@ class Country_FR extends Country { */ protected function states() { - return array( + return [ '10' => __('Aube', 'wp-ultimo'), '11' => __('Aude', 'wp-ultimo'), '12' => __('Aveyron', 'wp-ultimo'), @@ -211,6 +211,6 @@ class Country_FR extends Country { 'MF' => __('Saint-Martin', 'wp-ultimo'), 'WF' => __('Wallis and Futuna', 'wp-ultimo'), 'IDF' => __('Île-de-France', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/country/class-country-gb.php b/inc/country/class-country-gb.php index 7d7edb9..e35d084 100644 --- a/inc/country/class-country-gb.php +++ b/inc/country/class-country-gb.php @@ -45,11 +45,11 @@ class Country_GB extends Country { * @since 2.0.11 * @var array */ - protected $attributes = array( + protected $attributes = [ 'country_code' => 'GB', 'currency' => 'GBP', 'phone_code' => 44, - ); + ]; /** * The type of nomenclature used to refer to the country sub-divisions. @@ -78,7 +78,7 @@ class Country_GB extends Country { */ protected function states() { - return array( + return [ 'ABE' => __('Aberdeen', 'wp-ultimo'), 'ABD' => __('Aberdeenshire', 'wp-ultimo'), 'ANS' => __('Angus', 'wp-ultimo'), @@ -326,6 +326,6 @@ class Country_GB extends Country { 'WOK' => __('Wokingham', 'wp-ultimo'), 'WOR' => __('Worcestershire', 'wp-ultimo'), 'WRX' => __('Wrexham County Borough', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/country/class-country-in.php b/inc/country/class-country-in.php index a9ba678..4eacb54 100644 --- a/inc/country/class-country-in.php +++ b/inc/country/class-country-in.php @@ -77,11 +77,11 @@ class Country_IN extends Country { * @since 2.0.11 * @var array */ - protected $attributes = array( + protected $attributes = [ 'country_code' => 'IN', 'currency' => 'INR', 'phone_code' => 91, - ); + ]; /** * The type of nomenclature used to refer to the country sub-divisions. @@ -110,7 +110,7 @@ class Country_IN extends Country { */ protected function states() { - return array( + return [ 'AN' => __('Andaman and Nicobar Islands', 'wp-ultimo'), 'AP' => __('Andhra Pradesh', 'wp-ultimo'), 'AR' => __('Arunachal Pradesh', 'wp-ultimo'), @@ -147,6 +147,6 @@ class Country_IN extends Country { 'UP' => __('Uttar Pradesh', 'wp-ultimo'), 'UT' => __('Uttarakhand', 'wp-ultimo'), 'WB' => __('West Bengal', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/country/class-country-jp.php b/inc/country/class-country-jp.php index befe19c..8f2b36d 100644 --- a/inc/country/class-country-jp.php +++ b/inc/country/class-country-jp.php @@ -88,11 +88,11 @@ class Country_JP extends Country { * @since 2.0.11 * @var array */ - protected $attributes = array( + protected $attributes = [ 'country_code' => 'JP', 'currency' => 'JPY', 'phone_code' => 81, - ); + ]; /** * The type of nomenclature used to refer to the country sub-divisions. @@ -121,7 +121,7 @@ class Country_JP extends Country { */ protected function states() { - return array( + return [ '10' => __('Gunma Prefecture', 'wp-ultimo'), '11' => __('Saitama Prefecture', 'wp-ultimo'), '12' => __('Chiba Prefecture', 'wp-ultimo'), @@ -169,6 +169,6 @@ class Country_JP extends Country { '04' => __('Miyagi Prefecture', 'wp-ultimo'), '09' => __('Tochigi Prefecture', 'wp-ultimo'), '06' => __('Yamagata Prefecture', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/country/class-country-mx.php b/inc/country/class-country-mx.php index 63dc373..7fa12e1 100644 --- a/inc/country/class-country-mx.php +++ b/inc/country/class-country-mx.php @@ -73,11 +73,11 @@ class Country_MX extends Country { * @since 2.0.11 * @var array */ - protected $attributes = array( + protected $attributes = [ 'country_code' => 'MX', 'currency' => 'MXN', 'phone_code' => 52, - ); + ]; /** * The type of nomenclature used to refer to the country sub-divisions. @@ -106,7 +106,7 @@ class Country_MX extends Country { */ protected function states() { - return array( + return [ 'AGU' => __('Aguascalientes', 'wp-ultimo'), 'BCN' => __('Baja California', 'wp-ultimo'), 'BCS' => __('Baja California Sur', 'wp-ultimo'), @@ -139,6 +139,6 @@ class Country_MX extends Country { 'VER' => __('Veracruz de Ignacio de la Llave', 'wp-ultimo'), 'YUC' => __('Yucatán', 'wp-ultimo'), 'ZAC' => __('Zacatecas', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/country/class-country-my.php b/inc/country/class-country-my.php index 5f1a830..97666df 100644 --- a/inc/country/class-country-my.php +++ b/inc/country/class-country-my.php @@ -57,11 +57,11 @@ class Country_MY extends Country { * @since 2.0.11 * @var array */ - protected $attributes = array( + protected $attributes = [ 'country_code' => 'MY', 'currency' => 'MYR', 'phone_code' => 60, - ); + ]; /** * The type of nomenclature used to refer to the country sub-divisions. @@ -90,7 +90,7 @@ class Country_MY extends Country { */ protected function states() { - return array( + return [ '10' => __('Selangor', 'wp-ultimo'), '11' => __('Terengganu', 'wp-ultimo'), '12' => __('Sabah', 'wp-ultimo'), @@ -107,6 +107,6 @@ class Country_MY extends Country { '07' => __('Penang', 'wp-ultimo'), '08' => __('Perak', 'wp-ultimo'), '09' => __('Perlis', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/country/class-country-ne.php b/inc/country/class-country-ne.php index 3236092..4003995 100644 --- a/inc/country/class-country-ne.php +++ b/inc/country/class-country-ne.php @@ -48,11 +48,11 @@ class Country_NE extends Country { * @since 2.0.11 * @var array */ - protected $attributes = array( + protected $attributes = [ 'country_code' => 'NE', 'currency' => 'XOF', 'phone_code' => 227, - ); + ]; /** * The type of nomenclature used to refer to the country sub-divisions. @@ -81,7 +81,7 @@ class Country_NE extends Country { */ protected function states() { - return array( + return [ '1' => __('Agadez Region', 'wp-ultimo'), '2' => __('Diffa Region', 'wp-ultimo'), '3' => __('Dosso Region', 'wp-ultimo'), @@ -89,6 +89,6 @@ class Country_NE extends Country { '5' => __('Tahoua Region', 'wp-ultimo'), '6' => __('Tillabéri Region', 'wp-ultimo'), '7' => __('Zinder Region', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/country/class-country-nl.php b/inc/country/class-country-nl.php index c6587da..80cf8fb 100644 --- a/inc/country/class-country-nl.php +++ b/inc/country/class-country-nl.php @@ -53,11 +53,11 @@ class Country_NL extends Country { * @since 2.0.11 * @var array */ - protected $attributes = array( + protected $attributes = [ 'country_code' => 'NL', 'currency' => 'EUR', 'phone_code' => 31, - ); + ]; /** * The type of nomenclature used to refer to the country sub-divisions. @@ -86,7 +86,7 @@ class Country_NL extends Country { */ protected function states() { - return array( + return [ 'BQ1' => __('Bonaire', 'wp-ultimo'), 'DR' => __('Drenthe', 'wp-ultimo'), 'FL' => __('Flevoland', 'wp-ultimo'), @@ -102,6 +102,6 @@ class Country_NL extends Country { 'ZH' => __('South Holland', 'wp-ultimo'), 'UT' => __('Utrecht', 'wp-ultimo'), 'ZE' => __('Zeeland', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/country/class-country-ru.php b/inc/country/class-country-ru.php index 449566b..1302b22 100644 --- a/inc/country/class-country-ru.php +++ b/inc/country/class-country-ru.php @@ -124,11 +124,11 @@ class Country_RU extends Country { * @since 2.0.11 * @var array */ - protected $attributes = array( + protected $attributes = [ 'country_code' => 'RU', 'currency' => 'RUB', 'phone_code' => 7, - ); + ]; /** * The type of nomenclature used to refer to the country sub-divisions. @@ -157,7 +157,7 @@ class Country_RU extends Country { */ protected function states() { - return array( + return [ 'ALT' => __('Altai Krai', 'wp-ultimo'), 'AL' => __('Altai Republic', 'wp-ultimo'), 'AMU' => __('Amur Oblast', 'wp-ultimo'), @@ -242,6 +242,6 @@ class Country_RU extends Country { 'YAN' => __('Yamalo-Nenets Autonomous Okrug', 'wp-ultimo'), 'YAR' => __('Yaroslavl Oblast', 'wp-ultimo'), 'ZAB' => __('Zabaykalsky Krai', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/country/class-country-sg.php b/inc/country/class-country-sg.php index 2d2444f..6bb993b 100644 --- a/inc/country/class-country-sg.php +++ b/inc/country/class-country-sg.php @@ -43,11 +43,11 @@ class Country_SG extends Country { * @since 2.0.11 * @var array */ - protected $attributes = array( + protected $attributes = [ 'country_code' => 'SG', 'currency' => 'SGD', 'phone_code' => 65, - ); + ]; /** * The type of nomenclature used to refer to the country sub-divisions. @@ -76,12 +76,12 @@ class Country_SG extends Country { */ protected function states() { - return array( + return [ '01' => __('Central Singapore Community Development Council', 'wp-ultimo'), '02' => __('North East Community Development Council', 'wp-ultimo'), '03' => __('North West Community Development Council', 'wp-ultimo'), '04' => __('South East Community Development Council', 'wp-ultimo'), '05' => __('South West Community Development Council', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/country/class-country-tr.php b/inc/country/class-country-tr.php index de0c51a..7a93b00 100644 --- a/inc/country/class-country-tr.php +++ b/inc/country/class-country-tr.php @@ -122,11 +122,11 @@ class Country_TR extends Country { * @since 2.0.11 * @var array */ - protected $attributes = array( + protected $attributes = [ 'country_code' => 'TR', 'currency' => 'TRY', 'phone_code' => 90, - ); + ]; /** * The type of nomenclature used to refer to the country sub-divisions. @@ -155,7 +155,7 @@ class Country_TR extends Country { */ protected function states() { - return array( + return [ '10' => __('Balıkesir', 'wp-ultimo'), '11' => __('Bilecik', 'wp-ultimo'), '12' => __('Bingöl', 'wp-ultimo'), @@ -237,6 +237,6 @@ class Country_TR extends Country { '08' => __('Artvin', 'wp-ultimo'), '09' => __('Aydın', 'wp-ultimo'), '04' => __('Ağrı', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/country/class-country-us.php b/inc/country/class-country-us.php index 768add8..238883c 100644 --- a/inc/country/class-country-us.php +++ b/inc/country/class-country-us.php @@ -93,11 +93,11 @@ class Country_US extends Country { * @since 2.0.11 * @var array */ - protected $attributes = array( + protected $attributes = [ 'country_code' => 'US', 'currency' => 'USD', 'phone_code' => 1, - ); + ]; /** * The type of nomenclature used to refer to the country sub-divisions. @@ -126,7 +126,7 @@ class Country_US extends Country { */ protected function states() { - return array( + return [ 'AL' => __('Alabama', 'wp-ultimo'), 'AK' => __('Alaska', 'wp-ultimo'), 'AS' => __('American Samoa', 'wp-ultimo'), @@ -193,6 +193,6 @@ class Country_US extends Country { 'WV' => __('West Virginia', 'wp-ultimo'), 'WI' => __('Wisconsin', 'wp-ultimo'), 'WY' => __('Wyoming', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/country/class-country-za.php b/inc/country/class-country-za.php index 693df94..ac7a90c 100644 --- a/inc/country/class-country-za.php +++ b/inc/country/class-country-za.php @@ -50,11 +50,11 @@ class Country_ZA extends Country { * @since 2.0.11 * @var array */ - protected $attributes = array( + protected $attributes = [ 'country_code' => 'ZA', 'currency' => 'ZAR', 'phone_code' => 27, - ); + ]; /** * The type of nomenclature used to refer to the country sub-divisions. @@ -83,7 +83,7 @@ class Country_ZA extends Country { */ protected function states() { - return array( + return [ 'EC' => __('Eastern Cape', 'wp-ultimo'), 'FS' => __('Free State', 'wp-ultimo'), 'GP' => __('Gauteng', 'wp-ultimo'), @@ -93,6 +93,6 @@ class Country_ZA extends Country { 'NW' => __('North West', 'wp-ultimo'), 'NC' => __('Northern Cape', 'wp-ultimo'), 'WC' => __('Western Cape', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/country/class-country.php b/inc/country/class-country.php index d776ba4..e8b4250 100644 --- a/inc/country/class-country.php +++ b/inc/country/class-country.php @@ -30,7 +30,7 @@ abstract class Country { * @since 2.0.11 * @var array */ - protected $attributes = array(); + protected $attributes = []; /** * The type of nomenclature used to refer to the country sub-divisions. @@ -98,7 +98,7 @@ abstract class Country { $options = $this->get_states(); - $placeholder_option = array(); + $placeholder_option = []; if ($placeholder !== false && $options) { $division_name = $this->get_administrative_division_name(); @@ -121,13 +121,13 @@ abstract class Country { public function get_cities($state_code = '') { if (empty($state_code)) { - return array(); + return []; } $repository_file = wu_path("inc/country/{$this->country_code}/{$state_code}.php"); if (file_exists($repository_file) === false) { - return array(); + return []; } $cities = include $repository_file; @@ -159,7 +159,7 @@ abstract class Country { $options = $this->get_cities($state_code); - $placeholder_option = array(); + $placeholder_option = []; if ($placeholder !== false && $options) { $placeholder_option[''] = $placeholder !== '' ? $placeholder : __('Select your city', 'wp-ultimo'); @@ -178,7 +178,7 @@ abstract class Country { */ protected function states() { - return array(); + return []; } /** @@ -216,7 +216,7 @@ abstract class Country { */ public function get_administrative_division_name($state_code = null, $ucwords = false) { - $denominations = array( + $denominations = [ 'province' => __('province', 'wp-ultimo'), 'state' => __('state', 'wp-ultimo'), 'territory' => __('territory', 'wp-ultimo'), @@ -229,7 +229,7 @@ abstract class Country { 'county' => __('county', 'wp-ultimo'), 'division' => __('division', 'wp-ultimo'), 'unknown' => __('state / province', 'wp-ultimo'), - ); + ]; $name = wu_get_isset($denominations, $this->state_type, $denominations['unknown']); diff --git a/inc/database/broadcasts/class-broadcast-query.php b/inc/database/broadcasts/class-broadcast-query.php index ea48f15..69a05a2 100644 --- a/inc/database/broadcasts/class-broadcast-query.php +++ b/inc/database/broadcasts/class-broadcast-query.php @@ -46,7 +46,7 @@ class Broadcast_Query extends Post_Query { * @access public * @var mixed */ - protected $item_shape = '\\WP_Ultimo\\Models\\Broadcast'; + protected $item_shape = \WP_Ultimo\Models\Broadcast::class; /** * Group to cache queries and queried items in. @@ -73,9 +73,9 @@ class Broadcast_Query extends Post_Query { * @param array $query Query parameters being passed. * @return array */ - public function query($query = array()) { + public function query($query = []) { - $query['type__in'] = array('broadcast_email', 'broadcast_notice'); + $query['type__in'] = ['broadcast_email', 'broadcast_notice']; return parent::query($query); } diff --git a/inc/database/checkout-forms/class-checkout-form-query.php b/inc/database/checkout-forms/class-checkout-form-query.php index 6355810..8dd9b82 100644 --- a/inc/database/checkout-forms/class-checkout-form-query.php +++ b/inc/database/checkout-forms/class-checkout-form-query.php @@ -48,7 +48,7 @@ class Checkout_Form_Query extends Query { * @access public * @var string */ - protected $table_schema = '\\WP_Ultimo\\Database\\Checkout_Forms\\Checkout_Forms_Schema'; + protected $table_schema = \WP_Ultimo\Database\Checkout_Forms\Checkout_Forms_Schema::class; /** Item ******************************************************************/ @@ -77,7 +77,7 @@ class Checkout_Form_Query extends Query { * @access public * @var mixed */ - protected $item_shape = '\\WP_Ultimo\\Models\\Checkout_Form'; + protected $item_shape = \WP_Ultimo\Models\Checkout_Form::class; /** * Group to cache queries and queried items in. @@ -104,7 +104,7 @@ class Checkout_Form_Query extends Query { * * @param string|array $query Array of query arguments. */ - public function __construct($query = array()) { + public function __construct($query = []) { parent::__construct($query); } diff --git a/inc/database/checkout-forms/class-checkout-forms-meta-table.php b/inc/database/checkout-forms/class-checkout-forms-meta-table.php index 21e40ef..d4ef9df 100644 --- a/inc/database/checkout-forms/class-checkout-forms-meta-table.php +++ b/inc/database/checkout-forms/class-checkout-forms-meta-table.php @@ -64,7 +64,7 @@ final class Checkout_Forms_Meta_Table extends Table { * @since 2.0.0 * @return void */ - protected function set_schema() { + protected function set_schema(): void { $max_index_length = 191; diff --git a/inc/database/checkout-forms/class-checkout-forms-schema.php b/inc/database/checkout-forms/class-checkout-forms-schema.php index a789c1f..0981aef 100644 --- a/inc/database/checkout-forms/class-checkout-forms-schema.php +++ b/inc/database/checkout-forms/class-checkout-forms-schema.php @@ -28,9 +28,9 @@ class Checkout_Forms_Schema extends Schema { * @access public * @var array */ - public $columns = array( + public $columns = [ - array( + [ 'name' => 'id', 'type' => 'bigint', 'length' => '20', @@ -38,26 +38,26 @@ class Checkout_Forms_Schema extends Schema { 'extra' => 'auto_increment', 'primary' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'name', 'type' => 'varchar', 'searchable' => true, 'sortable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'slug', 'type' => 'tinytext', 'default' => '', 'searchable' => true, 'sortable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'active', 'type' => 'tinyint', 'length' => '4', @@ -65,31 +65,31 @@ class Checkout_Forms_Schema extends Schema { 'default' => 1, 'transition' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'settings', 'type' => 'longtext', 'default' => '', 'transition' => true, 'allow_null' => false, - ), + ], - array( + [ 'name' => 'custom_css', 'type' => 'longtext', 'default' => '', 'allow_null' => true, - ), + ], - array( + [ 'name' => 'allowed_countries', 'type' => 'text', 'default' => '', 'allow_null' => true, - ), + ], - array( + [ 'name' => 'date_created', 'type' => 'datetime', 'default' => null, @@ -97,9 +97,9 @@ class Checkout_Forms_Schema extends Schema { 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], - array( + [ 'name' => 'date_modified', 'type' => 'datetime', 'default' => null, @@ -107,7 +107,7 @@ class Checkout_Forms_Schema extends Schema { 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], - ); + ]; } diff --git a/inc/database/checkout-forms/class-checkout-forms-table.php b/inc/database/checkout-forms/class-checkout-forms-table.php index 0112763..59d775d 100644 --- a/inc/database/checkout-forms/class-checkout-forms-table.php +++ b/inc/database/checkout-forms/class-checkout-forms-table.php @@ -50,9 +50,9 @@ final class Checkout_Forms_Table extends Table { * * @var array */ - protected $upgrades = array( + protected $upgrades = [ '2.0.1-revision.20230601' => 20_230_601, - ); + ]; /** * Event constructor. @@ -73,7 +73,7 @@ final class Checkout_Forms_Table extends Table { * @since 2.0.0 * @return void */ - protected function set_schema() { + protected function set_schema(): void { $this->schema = "id bigint(20) NOT NULL auto_increment, name tinytext NOT NULL DEFAULT '', @@ -93,10 +93,10 @@ final class Checkout_Forms_Table extends Table { */ protected function __20230601(): bool { - $null_columns = array( + $null_columns = [ 'date_created', 'date_modified', - ); + ]; foreach ($null_columns as $column) { $query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;"; diff --git a/inc/database/customers/class-customer-query.php b/inc/database/customers/class-customer-query.php index fd68874..fdf152c 100644 --- a/inc/database/customers/class-customer-query.php +++ b/inc/database/customers/class-customer-query.php @@ -48,7 +48,7 @@ class Customer_Query extends Query { * @access public * @var string */ - protected $table_schema = '\\WP_Ultimo\\Database\\Customers\\Customers_Schema'; + protected $table_schema = \WP_Ultimo\Database\Customers\Customers_Schema::class; /** Item ******************************************************************/ @@ -77,7 +77,7 @@ class Customer_Query extends Query { * @access public * @var mixed */ - protected $item_shape = '\\WP_Ultimo\\Models\\Customer'; + protected $item_shape = \WP_Ultimo\Models\Customer::class; /** * Group to cache queries and queried items in. @@ -104,7 +104,7 @@ class Customer_Query extends Query { * * @param string|array $query Array of query arguments. */ - public function __construct($query = array()) { + public function __construct($query = []) { // $query['type'] = 'customer'; diff --git a/inc/database/customers/class-customers-meta-table.php b/inc/database/customers/class-customers-meta-table.php index 08d1769..baae54d 100644 --- a/inc/database/customers/class-customers-meta-table.php +++ b/inc/database/customers/class-customers-meta-table.php @@ -64,7 +64,7 @@ final class Customers_Meta_Table extends Table { * @since 2.0.0 * @return void */ - protected function set_schema() { + protected function set_schema(): void { $max_index_length = 191; diff --git a/inc/database/customers/class-customers-schema.php b/inc/database/customers/class-customers-schema.php index 34b2295..c264602 100644 --- a/inc/database/customers/class-customers-schema.php +++ b/inc/database/customers/class-customers-schema.php @@ -28,10 +28,10 @@ class Customers_Schema extends Schema { * @access public * @var array */ - public $columns = array( + public $columns = [ // id - array( + [ 'name' => 'id', 'type' => 'bigint', 'length' => '20', @@ -40,27 +40,27 @@ class Customers_Schema extends Schema { 'primary' => true, 'sortable' => true, 'searchable' => true, - ), + ], // user_id - array( + [ 'name' => 'user_id', 'type' => 'bigint', 'length' => '20', 'unsigned' => true, 'searchable' => true, - ), + ], - array( + [ 'name' => 'type', 'type' => 'varchar', 'default' => 'customer', 'searchable' => true, 'sortable' => true, - ), + ], // date_registered - array( + [ 'name' => 'date_registered', 'type' => 'datetime', 'default' => null, @@ -68,28 +68,28 @@ class Customers_Schema extends Schema { 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], // email_verification - array( + [ 'name' => 'email_verification', 'type' => 'enum(\'verified\', \'pending\', \'none\')', 'default' => 'none', 'transition' => true, - ), + ], // last_login - array( + [ 'name' => 'last_login', 'type' => 'datetime', 'default' => null, 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], // has_trialed - array( + [ 'name' => 'has_trialed', 'type' => 'smallint', 'length' => '', @@ -97,10 +97,10 @@ class Customers_Schema extends Schema { 'default' => null, 'transition' => true, 'allow_null' => true, - ), + ], // vip - array( + [ 'name' => 'vip', 'type' => 'smallint', 'length' => '', @@ -108,25 +108,25 @@ class Customers_Schema extends Schema { 'default' => 0, 'transition' => true, 'sortable' => true, - ), + ], // ips - array( + [ 'name' => 'ips', 'type' => 'longtext', 'default' => '', 'searchable' => true, 'allow_null' => true, - ), + ], // Added on 2.0 beta 7 - array( + [ 'name' => 'signup_form', 'type' => 'varchar', 'default' => 'by-admin', 'searchable' => true, 'sortable' => true, - ), + ], - ); + ]; } diff --git a/inc/database/customers/class-customers-table.php b/inc/database/customers/class-customers-table.php index fc7a535..c1fe701 100644 --- a/inc/database/customers/class-customers-table.php +++ b/inc/database/customers/class-customers-table.php @@ -50,11 +50,11 @@ final class Customers_Table extends Table { * * @var array */ - protected $upgrades = array( + protected $upgrades = [ '2.0.1-revision.20210508' => 20_210_508, '2.0.1-revision.20210607' => 20_210_607, '2.0.1-revision.20230601' => 20_230_601, - ); + ]; /** * Customer constructor. @@ -75,7 +75,7 @@ final class Customers_Table extends Table { * @since 2.0.0 * @return void */ - protected function set_schema() { + protected function set_schema(): void { $this->schema = "id bigint(20) unsigned NOT NULL AUTO_INCREMENT, user_id bigint(20) unsigned NOT NULL DEFAULT '0', @@ -152,11 +152,11 @@ final class Customers_Table extends Table { */ protected function __20230601(): bool { - $null_columns = array( + $null_columns = [ 'date_modified', 'date_registered', 'last_login', - ); + ]; foreach ($null_columns as $column) { $query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;"; diff --git a/inc/database/discount-codes/class-discount-code-query.php b/inc/database/discount-codes/class-discount-code-query.php index 4a5f938..d1c09e9 100644 --- a/inc/database/discount-codes/class-discount-code-query.php +++ b/inc/database/discount-codes/class-discount-code-query.php @@ -48,7 +48,7 @@ class Discount_Code_Query extends Query { * @access public * @var string */ - protected $table_schema = '\\WP_Ultimo\\Database\\Discount_Codes\\Discount_Codes_Schema'; + protected $table_schema = \WP_Ultimo\Database\Discount_Codes\Discount_Codes_Schema::class; /** Item ******************************************************************/ @@ -77,7 +77,7 @@ class Discount_Code_Query extends Query { * @access public * @var mixed */ - protected $item_shape = '\\WP_Ultimo\\Models\\Discount_Code'; + protected $item_shape = \WP_Ultimo\Models\Discount_Code::class; /** * Group to cache queries and queried items in. @@ -104,7 +104,7 @@ class Discount_Code_Query extends Query { * * @param string|array $query Array of query arguments. */ - public function __construct($query = array()) { + public function __construct($query = []) { parent::__construct($query); } diff --git a/inc/database/discount-codes/class-discount-codes-meta-table.php b/inc/database/discount-codes/class-discount-codes-meta-table.php index 88a1635..45e2139 100644 --- a/inc/database/discount-codes/class-discount-codes-meta-table.php +++ b/inc/database/discount-codes/class-discount-codes-meta-table.php @@ -64,7 +64,7 @@ final class Discount_Codes_Meta_Table extends Table { * @since 2.0.0 * @return void */ - protected function set_schema() { + protected function set_schema(): void { $max_index_length = 191; diff --git a/inc/database/discount-codes/class-discount-codes-schema.php b/inc/database/discount-codes/class-discount-codes-schema.php index 6915726..62cdaff 100644 --- a/inc/database/discount-codes/class-discount-codes-schema.php +++ b/inc/database/discount-codes/class-discount-codes-schema.php @@ -28,9 +28,9 @@ class Discount_Codes_Schema extends Schema { * @access public * @var array */ - public $columns = array( + public $columns = [ - array( + [ 'name' => 'id', 'type' => 'bigint', 'length' => '20', @@ -38,40 +38,40 @@ class Discount_Codes_Schema extends Schema { 'extra' => 'auto_increment', 'primary' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'name', 'type' => 'varchar', 'searchable' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'code', 'type' => 'varchar', 'length' => '20', 'sortable' => true, 'searchable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'description', 'type' => 'longtext', 'default' => '', 'searchable' => true, - ), + ], - array( + [ 'name' => 'uses', 'type' => 'int', 'unsigned' => true, 'sortable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'max_uses', 'type' => 'int', 'unsigned' => true, @@ -79,9 +79,9 @@ class Discount_Codes_Schema extends Schema { 'transition' => true, 'allow_null' => true, 'default' => 0, - ), + ], - array( + [ 'name' => 'apply_to_renewals', 'type' => 'tinyint', 'length' => '4', @@ -89,39 +89,39 @@ class Discount_Codes_Schema extends Schema { 'default' => 0, 'transition' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'type', 'type' => 'enum(\'percentage\', \'absolute\')', 'default' => 'percentage', 'transition' => true, - ), + ], - array( + [ 'name' => 'value', 'type' => 'decimal(13,4)', 'default' => '', 'sortable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'setup_fee_type', 'type' => 'enum(\'percentage\', \'absolute\')', 'default' => 'percentage', 'transition' => true, - ), + ], - array( + [ 'name' => 'setup_fee_value', 'type' => 'decimal(13,4)', 'default' => '', 'sortable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'active', 'type' => 'tinyint', 'length' => '4', @@ -129,9 +129,9 @@ class Discount_Codes_Schema extends Schema { 'default' => 1, 'transition' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'date_start', 'type' => 'datetime', 'default' => null, @@ -139,9 +139,9 @@ class Discount_Codes_Schema extends Schema { 'sortable' => true, 'transition' => true, 'allow_null' => true, - ), + ], - array( + [ 'name' => 'date_expiration', 'type' => 'datetime', 'default' => null, @@ -149,9 +149,9 @@ class Discount_Codes_Schema extends Schema { 'sortable' => true, 'transition' => true, 'allow_null' => true, - ), + ], - array( + [ 'name' => 'date_created', 'type' => 'datetime', 'default' => null, @@ -159,9 +159,9 @@ class Discount_Codes_Schema extends Schema { 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], - array( + [ 'name' => 'date_modified', 'type' => 'datetime', 'default' => null, @@ -169,7 +169,7 @@ class Discount_Codes_Schema extends Schema { 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], - ); + ]; } diff --git a/inc/database/discount-codes/class-discount-codes-table.php b/inc/database/discount-codes/class-discount-codes-table.php index 1f532b9..3c354b4 100644 --- a/inc/database/discount-codes/class-discount-codes-table.php +++ b/inc/database/discount-codes/class-discount-codes-table.php @@ -50,9 +50,9 @@ final class Discount_Codes_Table extends Table { * * @var array */ - protected $upgrades = array( + protected $upgrades = [ '2.0.1-revision.20230601' => 20_230_601, - ); + ]; /** * Discount_Code constructor. @@ -73,7 +73,7 @@ final class Discount_Codes_Table extends Table { * @since 2.0.0 * @return void */ - protected function set_schema() { + protected function set_schema(): void { $this->schema = "id bigint(20) NOT NULL auto_increment, name tinytext NOT NULL DEFAULT '', @@ -100,10 +100,10 @@ final class Discount_Codes_Table extends Table { */ protected function __20230601(): bool { - $null_columns = array( + $null_columns = [ 'date_created', 'date_modified', - ); + ]; foreach ($null_columns as $column) { $query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;"; diff --git a/inc/database/domains/class-domain-query.php b/inc/database/domains/class-domain-query.php index f74f1e6..59af4e7 100644 --- a/inc/database/domains/class-domain-query.php +++ b/inc/database/domains/class-domain-query.php @@ -48,7 +48,7 @@ class Domain_Query extends Query { * @access public * @var string */ - protected $table_schema = '\\WP_Ultimo\\Database\\Domains\\Domains_Schema'; + protected $table_schema = \WP_Ultimo\Database\Domains\Domains_Schema::class; /** Item ******************************************************************/ @@ -77,7 +77,7 @@ class Domain_Query extends Query { * @access public * @var mixed */ - protected $item_shape = '\\WP_Ultimo\\Models\\Domain'; + protected $item_shape = \WP_Ultimo\Models\Domain::class; /** * Group to cache queries and queried items in. @@ -104,7 +104,7 @@ class Domain_Query extends Query { * * @param string|array $query Array of query arguments. */ - public function __construct($query = array()) { + public function __construct($query = []) { parent::__construct($query); } diff --git a/inc/database/domains/class-domain-stage.php b/inc/database/domains/class-domain-stage.php index 2b84b96..2e4bf3a 100644 --- a/inc/database/domains/class-domain-stage.php +++ b/inc/database/domains/class-domain-stage.php @@ -40,13 +40,13 @@ class Domain_Stage extends Enum { */ protected function classes() { - return array( + return [ static::FAILED => 'wu-bg-red-200 wu-text-red-700', static::CHECKING_DNS => 'wu-bg-blue-200 wu-text-blue-700', static::CHECKING_SSL => 'wu-bg-yellow-200 wu-text-yellow-700', static::DONE => 'wu-bg-green-200 wu-text-green-700', static::DONE_WITHOUT_SSL => 'wu-bg-gray-800 wu-text-white', - ); + ]; } /** @@ -57,12 +57,12 @@ class Domain_Stage extends Enum { */ protected function labels() { - return array( + return [ static::FAILED => __('DNS Failed', 'wp-ultimo'), static::CHECKING_DNS => __('Checking DNS', 'wp-ultimo'), static::CHECKING_SSL => __('Checking SSL', 'wp-ultimo'), static::DONE => __('Ready', 'wp-ultimo'), static::DONE_WITHOUT_SSL => __('Ready (without SSL)', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/database/domains/class-domains-schema.php b/inc/database/domains/class-domains-schema.php index 05be786..4d6b19d 100644 --- a/inc/database/domains/class-domains-schema.php +++ b/inc/database/domains/class-domains-schema.php @@ -28,9 +28,9 @@ class Domains_Schema extends Schema { * @access public * @var array */ - public $columns = array( + public $columns = [ - array( + [ 'name' => 'id', 'type' => 'bigint', 'length' => '20', @@ -38,27 +38,27 @@ class Domains_Schema extends Schema { 'extra' => 'auto_increment', 'primary' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'blog_id', 'type' => 'bigint', 'length' => '20', 'unsigned' => true, - 'aliases' => array('site_id', 'site'), + 'aliases' => ['site_id', 'site'], 'searchable' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'domain', 'type' => 'varchar', 'searchable' => true, 'sortable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'active', 'type' => 'tinyint', 'length' => '4', @@ -66,9 +66,9 @@ class Domains_Schema extends Schema { 'default' => 1, 'transition' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'primary_domain', 'type' => 'tinyint', 'length' => '4', @@ -76,9 +76,9 @@ class Domains_Schema extends Schema { 'default' => 0, 'transition' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'secure', 'type' => 'tinyint', 'length' => '4', @@ -86,17 +86,17 @@ class Domains_Schema extends Schema { 'default' => 0, 'transition' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'stage', 'type' => 'enum(\'checking-dns\', \'checking-ssl-cert\', \'done-without-ssl\', \'done\', \'failed\')', 'default' => 'checking-dns', 'transition' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'date_created', 'type' => 'datetime', 'default' => null, @@ -104,9 +104,9 @@ class Domains_Schema extends Schema { 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], - array( + [ 'name' => 'date_modified', 'type' => 'datetime', 'default' => null, @@ -114,7 +114,7 @@ class Domains_Schema extends Schema { 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], - ); + ]; } diff --git a/inc/database/domains/class-domains-table.php b/inc/database/domains/class-domains-table.php index fe441b3..015b0ae 100644 --- a/inc/database/domains/class-domains-table.php +++ b/inc/database/domains/class-domains-table.php @@ -50,9 +50,9 @@ final class Domains_Table extends Table { * * @var array */ - protected $upgrades = array( + protected $upgrades = [ '2.0.1-revision.20230601' => 20_230_601, - ); + ]; /** * Domains constructor. @@ -73,7 +73,7 @@ final class Domains_Table extends Table { * @since 2.0.0 * @return void */ - protected function set_schema() { + protected function set_schema(): void { $this->schema = "id bigint(20) NOT NULL auto_increment, blog_id bigint(20) NOT NULL, @@ -95,10 +95,10 @@ final class Domains_Table extends Table { */ protected function __20230601(): bool { - $null_columns = array( + $null_columns = [ 'date_created', 'date_modified', - ); + ]; foreach ($null_columns as $column) { $query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;"; diff --git a/inc/database/emails/class-email-query.php b/inc/database/emails/class-email-query.php index afa316e..af2e3d3 100644 --- a/inc/database/emails/class-email-query.php +++ b/inc/database/emails/class-email-query.php @@ -46,7 +46,7 @@ class Email_Query extends Post_Query { * @access public * @var mixed */ - protected $item_shape = '\\WP_Ultimo\\Models\\Email'; + protected $item_shape = \WP_Ultimo\Models\Email::class; /** * Group to cache queries and queried items in. @@ -73,9 +73,9 @@ class Email_Query extends Post_Query { * @param array $query Query parameters being passed. * @return array */ - public function query($query = array()) { + public function query($query = []) { - $query['type__in'] = array('system_email'); + $query['type__in'] = ['system_email']; return parent::query($query); } diff --git a/inc/database/engine/class-enum.php b/inc/database/engine/class-enum.php index 663ad54..e175d3f 100644 --- a/inc/database/engine/class-enum.php +++ b/inc/database/engine/class-enum.php @@ -30,7 +30,7 @@ abstract class Enum { * @since 2.0.0 * @var array */ - static $options = array(); + static $options = []; /** * @var string */ @@ -69,7 +69,7 @@ abstract class Enum { */ protected function icon_classes() { - return array(); + return []; } /** @@ -223,10 +223,10 @@ abstract class Enum { public function exists_or_default($array, $key, $default = '') { if (empty($default)) { - $default = isset($array[ static::__default ]) ? $array[ static::__default ] : ''; + $default = $array[ static::__default ] ?? ''; } - return isset($array[ $key ]) ? $array[ $key ] : $default; + return $array[ $key ] ?? $default; } /** diff --git a/inc/database/engine/class-query.php b/inc/database/engine/class-query.php index 9f2cb4a..71da897 100644 --- a/inc/database/engine/class-query.php +++ b/inc/database/engine/class-query.php @@ -42,7 +42,7 @@ class Query extends \BerlinDB\Database\Query { * @since 2.1.2 * @var array */ - protected static $added_globals = array(); + protected static $added_globals = []; /** * Plural version for a group of items. @@ -69,12 +69,12 @@ class Query extends \BerlinDB\Database\Query { * @param string|array $query Optional. An array or string of Query parameters. * @return void */ - public function __construct($query = array()) { + public function __construct($query = []) { $cache_group = $this->apply_prefix($this->cache_group, '-'); if ($this->global_cache && ! in_array($cache_group, self::$added_globals, true)) { - wp_cache_add_global_groups(array($cache_group)); + wp_cache_add_global_groups([$cache_group]); self::$added_globals[] = $cache_group; } diff --git a/inc/database/events/class-event-query.php b/inc/database/events/class-event-query.php index 2b67f55..405ea03 100644 --- a/inc/database/events/class-event-query.php +++ b/inc/database/events/class-event-query.php @@ -48,7 +48,7 @@ class Event_Query extends Query { * @access public * @var string */ - protected $table_schema = '\\WP_Ultimo\\Database\\Events\\Events_Schema'; + protected $table_schema = \WP_Ultimo\Database\Events\Events_Schema::class; /** Item ******************************************************************/ @@ -77,7 +77,7 @@ class Event_Query extends Query { * @access public * @var mixed */ - protected $item_shape = '\\WP_Ultimo\\Models\\Event'; + protected $item_shape = \WP_Ultimo\Models\Event::class; /** * Group to cache queries and queried items in. @@ -104,7 +104,7 @@ class Event_Query extends Query { * * @param string|array $query Array of query arguments. */ - public function __construct($query = array()) { + public function __construct($query = []) { parent::__construct($query); } diff --git a/inc/database/events/class-events-schema.php b/inc/database/events/class-events-schema.php index b9680e3..d1664e5 100644 --- a/inc/database/events/class-events-schema.php +++ b/inc/database/events/class-events-schema.php @@ -28,9 +28,9 @@ class Events_Schema extends Schema { * @access public * @var array */ - public $columns = array( + public $columns = [ - array( + [ 'name' => 'id', 'type' => 'bigint', 'length' => '20', @@ -38,62 +38,62 @@ class Events_Schema extends Schema { 'extra' => 'auto_increment', 'primary' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'severity', 'type' => 'tinyint', 'length' => '1', 'unsigned' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'initiator', 'type' => 'enum(\'system\', \'manual\')', 'default' => 'none', - ), + ], - array( + [ 'name' => 'author_id', 'type' => 'bigint', 'length' => '20', 'unsigned' => true, 'sortable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'object_type', 'type' => 'varchar', 'length' => 20, 'default' => 'network', 'sortable' => true, 'searchable' => true, - ), + ], - array( + [ 'name' => 'object_id', 'type' => 'bigint', 'length' => '20', 'unsigned' => true, 'sortable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'slug', 'type' => 'longtext', 'default' => '', - ), + ], - array( + [ 'name' => 'payload', 'type' => 'longtext', 'default' => '', - ), + ], - array( + [ 'name' => 'date_created', 'type' => 'datetime', 'default' => null, @@ -101,7 +101,7 @@ class Events_Schema extends Schema { 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], - ); + ]; } diff --git a/inc/database/events/class-events-table.php b/inc/database/events/class-events-table.php index 6d1d9ed..fcb5f1b 100644 --- a/inc/database/events/class-events-table.php +++ b/inc/database/events/class-events-table.php @@ -50,9 +50,9 @@ final class Events_Table extends Table { * * @var array */ - protected $upgrades = array( + protected $upgrades = [ '2.0.1-revision.20230601' => 20_230_601, - ); + ]; /** * Event constructor. @@ -73,7 +73,7 @@ final class Events_Table extends Table { * @since 2.0.0 * @return void */ - protected function set_schema() { + protected function set_schema(): void { $this->schema = "id bigint(20) NOT NULL auto_increment, severity tinyint(4), @@ -96,9 +96,9 @@ final class Events_Table extends Table { */ protected function __20230601(): bool { - $null_columns = array( + $null_columns = [ 'date_created', - ); + ]; foreach ($null_columns as $column) { $query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;"; diff --git a/inc/database/memberships/class-membership-query.php b/inc/database/memberships/class-membership-query.php index 4035294..bc9f95d 100644 --- a/inc/database/memberships/class-membership-query.php +++ b/inc/database/memberships/class-membership-query.php @@ -48,7 +48,7 @@ class Membership_Query extends Query { * @access public * @var string */ - protected $table_schema = '\\WP_Ultimo\\Database\\Memberships\\Memberships_Schema'; + protected $table_schema = \WP_Ultimo\Database\Memberships\Memberships_Schema::class; /** Item ******************************************************************/ @@ -77,7 +77,7 @@ class Membership_Query extends Query { * @access public * @var mixed */ - protected $item_shape = '\\WP_Ultimo\\Models\\Membership'; + protected $item_shape = \WP_Ultimo\Models\Membership::class; /** * Group to cache queries and queried items in. @@ -104,7 +104,7 @@ class Membership_Query extends Query { * * @param string|array $query Array of query arguments. */ - public function __construct($query = array()) { + public function __construct($query = []) { parent::__construct($query); } diff --git a/inc/database/memberships/class-membership-status.php b/inc/database/memberships/class-membership-status.php index 92f3492..ab0d073 100644 --- a/inc/database/memberships/class-membership-status.php +++ b/inc/database/memberships/class-membership-status.php @@ -41,14 +41,14 @@ class Membership_Status extends Enum { */ protected function classes() { - return array( + return [ static::PENDING => 'wu-bg-gray-200 wu-text-gray-700', static::ACTIVE => 'wu-bg-green-200 wu-text-green-700', static::TRIALING => 'wu-bg-orange-200 wu-text-orange-700', static::ON_HOLD => 'wu-bg-blue-200 wu-text-blue-700', static::EXPIRED => 'wu-bg-yellow-200 wu-text-yellow-700', static::CANCELLED => 'wu-bg-red-200 wu-text-red-700', - ); + ]; } /** @@ -59,13 +59,13 @@ class Membership_Status extends Enum { */ protected function labels() { - return array( + return [ static::PENDING => __('Pending', 'wp-ultimo'), static::ACTIVE => __('Active', 'wp-ultimo'), static::TRIALING => __('Trialing', 'wp-ultimo'), static::ON_HOLD => __('On Hold', 'wp-ultimo'), static::EXPIRED => __('Expired', 'wp-ultimo'), static::CANCELLED => __('Cancelled', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/database/memberships/class-memberships-meta-table.php b/inc/database/memberships/class-memberships-meta-table.php index 0a0cabc..cdd6bcb 100644 --- a/inc/database/memberships/class-memberships-meta-table.php +++ b/inc/database/memberships/class-memberships-meta-table.php @@ -64,7 +64,7 @@ final class Memberships_Meta_Table extends Table { * @since 2.0.0 * @return void */ - protected function set_schema() { + protected function set_schema(): void { $max_index_length = 191; diff --git a/inc/database/memberships/class-memberships-schema.php b/inc/database/memberships/class-memberships-schema.php index c9c985d..d6ba0e0 100644 --- a/inc/database/memberships/class-memberships-schema.php +++ b/inc/database/memberships/class-memberships-schema.php @@ -28,10 +28,10 @@ class Memberships_Schema extends Schema { * @access public * @var array */ - public $columns = array( + public $columns = [ // id - array( + [ 'name' => 'id', 'type' => 'bigint', 'length' => '20', @@ -40,69 +40,69 @@ class Memberships_Schema extends Schema { 'primary' => true, 'sortable' => true, 'searchable' => true, - ), + ], // customer_id - array( + [ 'name' => 'customer_id', 'type' => 'bigint', 'length' => '20', 'unsigned' => true, - ), + ], // user_id - array( + [ 'name' => 'user_id', 'type' => 'bigint', 'length' => '20', 'unsigned' => true, 'default' => null, 'allow_null' => true, - ), + ], - array( + [ 'name' => 'migrated_from_id', 'type' => 'bigint', 'length' => '20', 'unsigned' => true, 'sortable' => true, 'allow_null' => true, - ), + ], // object_id - array( + [ 'name' => 'plan_id', 'type' => 'bigint', 'length' => '20', 'unsigned' => true, 'sortable' => true, 'transition' => true, - ), + ], // addons - array( + [ 'name' => 'addon_products', 'type' => 'longtext', - ), + ], // currency - array( + [ 'name' => 'currency', 'type' => 'varchar', 'length' => '20', 'default' => 'USD', 'sortable' => true, - ), + ], - array( + [ 'name' => 'initial_amount', 'type' => 'decimal(13,4)', 'default' => '', 'sortable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'recurring', 'type' => 'tinyint', 'length' => '4', @@ -110,9 +110,9 @@ class Memberships_Schema extends Schema { 'default' => 1, 'transition' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'auto_renew', 'type' => 'tinyint', 'length' => '4', @@ -120,33 +120,33 @@ class Memberships_Schema extends Schema { 'default' => 0, 'transition' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'duration', 'type' => 'smallint', 'unsigned' => true, 'default' => '0', 'sortable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'duration_unit', 'type' => 'enum(\'day\', \'month\', \'week\', \'year\')', 'default' => 'none', - ), + ], - array( + [ 'name' => 'amount', 'type' => 'decimal(13,4)', 'default' => '', 'sortable' => true, 'transition' => true, - ), + ], // date_created - array( + [ 'name' => 'date_created', 'type' => 'datetime', 'default' => null, @@ -154,50 +154,50 @@ class Memberships_Schema extends Schema { 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], // date_activated - array( + [ 'name' => 'date_activated', 'type' => 'datetime', 'default' => null, 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], // date_trial_end - array( + [ 'name' => 'date_trial_end', 'type' => 'datetime', 'default' => null, 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], // date_renewed - array( + [ 'name' => 'date_renewed', 'type' => 'datetime', 'default' => null, 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], // date_cancellation - array( + [ 'name' => 'date_cancellation', 'type' => 'datetime', 'default' => null, 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], // date_expiration - array( + [ 'name' => 'date_expiration', 'type' => 'datetime', 'default' => null, @@ -205,10 +205,10 @@ class Memberships_Schema extends Schema { 'sortable' => true, 'transition' => true, 'allow_null' => true, - ), + ], // date_payment_plan_completed - array( + [ 'name' => 'date_payment_plan_completed', 'type' => 'datetime', 'default' => null, @@ -216,118 +216,118 @@ class Memberships_Schema extends Schema { 'sortable' => true, 'transition' => true, 'allow_null' => true, - ), + ], // auto_renew - array( + [ 'name' => 'auto_renew', 'type' => 'smallint', 'unsigned' => true, 'default' => '0', 'transition' => true, - ), + ], // times_billed - array( + [ 'name' => 'times_billed', 'type' => 'smallint', 'unsigned' => true, 'default' => '0', 'sortable' => true, 'transition' => true, - ), + ], // billing_cycles - array( + [ 'name' => 'billing_cycles', 'type' => 'smallint', 'unsigned' => true, 'default' => '0', 'sortable' => true, - ), + ], // status - array( + [ 'name' => 'status', 'type' => 'varchar', 'length' => '12', 'default' => 'pending', 'sortable' => true, 'transition' => true, - ), + ], // gateway_customer_id - array( + [ 'name' => 'gateway_customer_id', 'type' => 'tinytext', 'default' => '', 'searchable' => true, 'sortable' => true, 'transition' => true, - ), + ], // gateway_subscription_id - array( + [ 'name' => 'gateway_subscription_id', 'type' => 'tinytext', 'default' => '', 'searchable' => true, 'sortable' => true, 'transition' => true, - ), + ], // gateway - array( + [ 'name' => 'gateway', 'type' => 'tinytext', 'default' => '', 'searchable' => true, - ), + ], // signup_method - array( + [ 'name' => 'signup_method', 'type' => 'tinytext', 'default' => '', - ), + ], // subscription_key - array( + [ 'name' => 'subscription_key', 'type' => 'varchar', 'length' => '32', 'default' => '', 'searchable' => true, 'sortable' => true, - ), + ], // upgraded_from - array( + [ 'name' => 'upgraded_from', 'type' => 'bigint', 'length' => '20', 'unsigned' => true, 'default' => '', - ), + ], // date_modified - array( + [ 'name' => 'date_modified', 'type' => 'datetime', 'default' => null, 'modified' => true, 'date_query' => true, 'sortable' => true, - ), + ], // disabled - array( + [ 'name' => 'disabled', 'type' => 'smallint', 'unsigned' => true, 'default' => '', 'pattern' => '%d', - ), + ], - ); + ]; } diff --git a/inc/database/memberships/class-memberships-table.php b/inc/database/memberships/class-memberships-table.php index 77447b6..a51e300 100644 --- a/inc/database/memberships/class-memberships-table.php +++ b/inc/database/memberships/class-memberships-table.php @@ -50,9 +50,9 @@ final class Memberships_Table extends Table { * * @var array */ - protected $upgrades = array( + protected $upgrades = [ '2.0.1-revision.20230601' => 20_230_601, - ); + ]; /** * Memberships constructor. @@ -73,7 +73,7 @@ final class Memberships_Table extends Table { * @since 2.0.0 * @return void */ - protected function set_schema() { + protected function set_schema(): void { $this->schema = "id bigint(20) unsigned NOT NULL AUTO_INCREMENT, customer_id bigint(20) unsigned NOT NULL default '0', @@ -119,7 +119,7 @@ final class Memberships_Table extends Table { */ protected function __20230601(): bool { - $null_columns = array( + $null_columns = [ 'date_created', 'date_activated', 'date_trial_end', @@ -128,7 +128,7 @@ final class Memberships_Table extends Table { 'date_expiration', 'date_payment_plan_completed', 'date_modified', - ); + ]; foreach ($null_columns as $column) { $query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;"; diff --git a/inc/database/payments/class-payment-query.php b/inc/database/payments/class-payment-query.php index b058387..3daf5b0 100644 --- a/inc/database/payments/class-payment-query.php +++ b/inc/database/payments/class-payment-query.php @@ -48,7 +48,7 @@ class Payment_Query extends Query { * @access public * @var string */ - protected $table_schema = '\\WP_Ultimo\\Database\\Payments\\Payments_Schema'; + protected $table_schema = \WP_Ultimo\Database\Payments\Payments_Schema::class; /** Item ******************************************************************/ @@ -77,7 +77,7 @@ class Payment_Query extends Query { * @access public * @var mixed */ - protected $item_shape = '\\WP_Ultimo\\Models\\Payment'; + protected $item_shape = \WP_Ultimo\Models\Payment::class; /** * Group to cache queries and queried items in. @@ -104,7 +104,7 @@ class Payment_Query extends Query { * * @param string|array $query Array of query arguments. */ - public function __construct($query = array()) { + public function __construct($query = []) { parent::__construct($query); } diff --git a/inc/database/payments/class-payment-status.php b/inc/database/payments/class-payment-status.php index 7acbc14..810838d 100644 --- a/inc/database/payments/class-payment-status.php +++ b/inc/database/payments/class-payment-status.php @@ -42,7 +42,7 @@ class Payment_Status extends Enum { */ protected function classes() { - return array( + return [ static::PENDING => 'wu-bg-gray-200 wu-text-gray-700', static::COMPLETED => 'wu-bg-green-200 wu-text-green-700', static::REFUND => 'wu-bg-blue-200 wu-text-gray-700', @@ -50,7 +50,7 @@ class Payment_Status extends Enum { static::PARTIAL => 'wu-bg-yellow-200 wu-text-yellow-700', static::FAILED => 'wu-bg-red-200 wu-text-red-700', static::CANCELLED => 'wu-bg-orange-200 wu-text-orange-700', - ); + ]; } /** @@ -61,7 +61,7 @@ class Payment_Status extends Enum { */ protected function icon_classes() { - return array( + return [ static::PENDING => 'wu-align-middle dashicons-wu-clock wu-text-gray-700', static::COMPLETED => 'wu-align-middle dashicons-wu-check wu-text-green-700', static::REFUND => 'wu-align-middle dashicons-wu-cw wu-text-gray-700', @@ -69,7 +69,7 @@ class Payment_Status extends Enum { static::PARTIAL => 'wu-align-middle dashicons-wu-cw wu-text-yellow-700', static::FAILED => 'wu-align-middle dashicons-wu-circle-with-cross wu-text-red-700', static::CANCELLED => 'wu-align-middle dashicons-wu-circle-with-cross wu-text-orange-700', - ); + ]; } /** @@ -80,7 +80,7 @@ class Payment_Status extends Enum { */ protected function labels() { - return array( + return [ static::PENDING => __('Pending', 'wp-ultimo'), static::COMPLETED => __('Completed', 'wp-ultimo'), static::REFUND => __('Refunded', 'wp-ultimo'), @@ -88,6 +88,6 @@ class Payment_Status extends Enum { static::PARTIAL => __('Partially Paid', 'wp-ultimo'), static::FAILED => __('Failed', 'wp-ultimo'), static::CANCELLED => __('Cancelled', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/database/payments/class-payments-meta-table.php b/inc/database/payments/class-payments-meta-table.php index 2f1c6eb..d9ce168 100644 --- a/inc/database/payments/class-payments-meta-table.php +++ b/inc/database/payments/class-payments-meta-table.php @@ -64,7 +64,7 @@ final class Payments_Meta_Table extends Table { * @since 2.0.0 * @return void */ - protected function set_schema() { + protected function set_schema(): void { $max_index_length = 191; diff --git a/inc/database/payments/class-payments-schema.php b/inc/database/payments/class-payments-schema.php index eb47fe9..c8b4dcb 100644 --- a/inc/database/payments/class-payments-schema.php +++ b/inc/database/payments/class-payments-schema.php @@ -28,10 +28,10 @@ class Payments_Schema extends Schema { * @access public * @var array */ - public $columns = array( + public $columns = [ // id - array( + [ 'name' => 'id', 'type' => 'bigint', 'length' => '20', @@ -40,152 +40,152 @@ class Payments_Schema extends Schema { 'primary' => true, 'sortable' => true, 'searchable' => true, - ), + ], - array( + [ 'name' => 'status', 'type' => 'varchar', 'length' => '12', 'default' => 'pending', 'sortable' => true, 'transition' => true, - ), + ], // customer_id - array( + [ 'name' => 'customer_id', 'type' => 'bigint', 'length' => '20', 'unsigned' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'membership_id', 'type' => 'bigint', 'length' => '20', 'unsigned' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'parent_id', 'type' => 'bigint', 'length' => '20', 'unsigned' => true, 'transition' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'product_id', 'type' => 'bigint', 'length' => '20', 'unsigned' => true, 'sortable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'migrated_from_id', 'type' => 'bigint', 'length' => '20', 'unsigned' => true, 'sortable' => true, 'allow_null' => true, - ), + ], // currency - array( + [ 'name' => 'currency', 'type' => 'varchar', 'length' => '20', 'default' => 'USD', 'sortable' => true, - ), + ], - array( + [ 'name' => 'discount_code', 'type' => 'tinytext', 'default' => '', 'searchable' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'discount_total', 'type' => 'decimal(13,4)', 'default' => '', 'sortable' => true, - ), + ], - array( + [ 'name' => 'subtotal', 'type' => 'decimal(13,4)', 'default' => '', 'sortable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'refund_total', 'type' => 'decimal(13,4)', 'default' => '', 'sortable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'tax_total', 'type' => 'decimal(13,4)', 'default' => '', 'sortable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'total', 'type' => 'decimal(13,4)', 'default' => '', 'sortable' => true, 'transition' => true, - ), + ], // gateway - array( + [ 'name' => 'gateway', 'type' => 'tinytext', 'default' => '', 'searchable' => true, - ), + ], // gateway - array( + [ 'name' => 'gateway_payment_id', 'type' => 'tinytext', 'default' => '', 'searchable' => true, - ), + ], // date_created - array( + [ 'name' => 'date_created', 'type' => 'datetime', 'created' => true, 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], // date_modified - array( + [ 'name' => 'date_modified', 'type' => 'datetime', 'modified' => true, 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], - ); + ]; } diff --git a/inc/database/payments/class-payments-table.php b/inc/database/payments/class-payments-table.php index 50e8c76..910a752 100644 --- a/inc/database/payments/class-payments-table.php +++ b/inc/database/payments/class-payments-table.php @@ -50,11 +50,11 @@ final class Payments_Table extends Table { * * @var array */ - protected $upgrades = array( + protected $upgrades = [ '2.0.1-revision.20210417' => 20_210_417, '2.0.1-revision.20210607' => 20_210_607, '2.0.1-revision.20230601' => 20_230_601, - ); + ]; /** * Payments constructor. @@ -75,7 +75,7 @@ final class Payments_Table extends Table { * @since 2.0.0 * @return void */ - protected function set_schema() { + protected function set_schema(): void { $this->schema = "id bigint(20) unsigned NOT NULL AUTO_INCREMENT, status varchar(20) NOT NULL DEFAULT 'pending', @@ -162,10 +162,10 @@ final class Payments_Table extends Table { */ protected function __20230601(): bool { - $null_columns = array( + $null_columns = [ 'date_created', 'date_modified', - ); + ]; foreach ($null_columns as $column) { $query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;"; diff --git a/inc/database/posts/class-post-query.php b/inc/database/posts/class-post-query.php index e2a057e..2209e47 100644 --- a/inc/database/posts/class-post-query.php +++ b/inc/database/posts/class-post-query.php @@ -48,7 +48,7 @@ class Post_Query extends Query { * @access public * @var string */ - protected $table_schema = '\\WP_Ultimo\\Database\\Posts\\Posts_Schema'; + protected $table_schema = \WP_Ultimo\Database\Posts\Posts_Schema::class; /** Item ******************************************************************/ @@ -77,7 +77,7 @@ class Post_Query extends Query { * @access public * @var mixed */ - protected $item_shape = '\\WP_Ultimo\\Models\\Post_Base_Model'; + protected $item_shape = \WP_Ultimo\Models\Post_Base_Model::class; /** * Group to cache queries and queried items in. @@ -96,7 +96,7 @@ class Post_Query extends Query { * * @param string|array $query Array of query arguments. */ - public function query($query = array()) { + public function query($query = []) { if ( ! isset($query['type__in'])) { $query['type'] = $this->item_name; diff --git a/inc/database/posts/class-posts-meta-table.php b/inc/database/posts/class-posts-meta-table.php index 8e65e6d..107301a 100644 --- a/inc/database/posts/class-posts-meta-table.php +++ b/inc/database/posts/class-posts-meta-table.php @@ -64,7 +64,7 @@ final class Posts_Meta_Table extends Table { * @since 2.0.0 * @return void */ - protected function set_schema() { + protected function set_schema(): void { $max_index_length = 191; diff --git a/inc/database/posts/class-posts-schema.php b/inc/database/posts/class-posts-schema.php index e9ae0ca..d921b00 100644 --- a/inc/database/posts/class-posts-schema.php +++ b/inc/database/posts/class-posts-schema.php @@ -28,9 +28,9 @@ class Posts_Schema extends Schema { * @access public * @var array */ - public $columns = array( + public $columns = [ - array( + [ 'name' => 'id', 'type' => 'bigint', 'length' => '20', @@ -38,51 +38,51 @@ class Posts_Schema extends Schema { 'extra' => 'auto_increment', 'primary' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'author_id', 'type' => 'bigint', 'length' => '20', 'unsigned' => true, - ), + ], - array( + [ 'name' => 'type', 'type' => 'varchar', 'searchable' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'slug', 'type' => 'varchar', 'searchable' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'title', 'type' => 'varchar', 'searchable' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'content', 'type' => 'longtext', 'default' => '', 'searchable' => true, - ), + ], - array( + [ 'name' => 'excerpt', 'type' => 'longtext', 'default' => '', 'searchable' => true, - ), + ], - array( + [ 'name' => 'list_order', 'type' => 'tinyint', 'length' => '4', @@ -90,17 +90,17 @@ class Posts_Schema extends Schema { 'default' => 10, 'transition' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'status', 'type' => 'varchar', // An "enum" here would possibly limit custom post status. 'default' => 'draft', 'transition' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'date_created', 'type' => 'datetime', 'default' => null, @@ -108,9 +108,9 @@ class Posts_Schema extends Schema { 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], - array( + [ 'name' => 'date_modified', 'type' => 'datetime', 'default' => null, @@ -118,7 +118,7 @@ class Posts_Schema extends Schema { 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], - ); + ]; } diff --git a/inc/database/posts/class-posts-table.php b/inc/database/posts/class-posts-table.php index 1aeff3c..d58455c 100644 --- a/inc/database/posts/class-posts-table.php +++ b/inc/database/posts/class-posts-table.php @@ -50,9 +50,9 @@ final class Posts_Table extends Table { * * @var array */ - protected $upgrades = array( + protected $upgrades = [ '2.0.1-revision.20230601' => 20_230_601, - ); + ]; /** * Posts constructor. @@ -73,7 +73,7 @@ final class Posts_Table extends Table { * @since 2.0.0 * @return void */ - protected function set_schema() { + protected function set_schema(): void { $this->schema = "id bigint(20) NOT NULL AUTO_INCREMENT, author_id bigint(20) NOT NULL, @@ -95,10 +95,10 @@ final class Posts_Table extends Table { */ protected function __20230601(): bool { - $null_columns = array( + $null_columns = [ 'date_created', 'date_modified', - ); + ]; foreach ($null_columns as $column) { $query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;"; diff --git a/inc/database/products/class-product-query.php b/inc/database/products/class-product-query.php index af3da9b..f246efd 100644 --- a/inc/database/products/class-product-query.php +++ b/inc/database/products/class-product-query.php @@ -48,7 +48,7 @@ class Product_Query extends Query { * @access public * @var string */ - protected $table_schema = '\\WP_Ultimo\\Database\\Products\\Products_Schema'; + protected $table_schema = \WP_Ultimo\Database\Products\Products_Schema::class; /** Item ******************************************************************/ @@ -77,7 +77,7 @@ class Product_Query extends Query { * @access public * @var mixed */ - protected $item_shape = '\\WP_Ultimo\\Models\\Product'; + protected $item_shape = \WP_Ultimo\Models\Product::class; /** * Group to cache queries and queried items in. @@ -104,7 +104,7 @@ class Product_Query extends Query { * * @param string|array $query Array of query arguments. */ - public function __construct($query = array()) { + public function __construct($query = []) { parent::__construct($query); } diff --git a/inc/database/products/class-product-type.php b/inc/database/products/class-product-type.php index 079aacc..73111cc 100644 --- a/inc/database/products/class-product-type.php +++ b/inc/database/products/class-product-type.php @@ -38,11 +38,11 @@ class Product_Type extends Enum { */ protected function classes() { - return array( + return [ static::PLAN => 'wu-bg-green-200 wu-text-green-700', static::PACKAGE => 'wu-bg-gray-200 wu-text-blue-700', static::SERVICE => 'wu-bg-yellow-200 wu-text-yellow-700', - ); + ]; } /** @@ -53,10 +53,10 @@ class Product_Type extends Enum { */ protected function labels() { - return array( + return [ static::PLAN => __('Plan', 'wp-ultimo'), static::PACKAGE => __('Package', 'wp-ultimo'), static::SERVICE => __('Service', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/database/products/class-products-meta-table.php b/inc/database/products/class-products-meta-table.php index 0a529ab..9f1b8a7 100644 --- a/inc/database/products/class-products-meta-table.php +++ b/inc/database/products/class-products-meta-table.php @@ -64,7 +64,7 @@ final class Products_Meta_Table extends Table { * @since 2.0.0 * @return void */ - protected function set_schema() { + protected function set_schema(): void { $max_index_length = 191; diff --git a/inc/database/products/class-products-schema.php b/inc/database/products/class-products-schema.php index 9e062b0..29b86e1 100644 --- a/inc/database/products/class-products-schema.php +++ b/inc/database/products/class-products-schema.php @@ -28,9 +28,9 @@ class Products_Schema extends Schema { * @access public * @var array */ - public $columns = array( + public $columns = [ - array( + [ 'name' => 'id', 'type' => 'bigint', 'length' => '20', @@ -38,16 +38,16 @@ class Products_Schema extends Schema { 'extra' => 'auto_increment', 'primary' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'slug', 'type' => 'varchar', 'searchable' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'parent_id', 'type' => 'bigint', 'length' => '20', @@ -55,72 +55,72 @@ class Products_Schema extends Schema { 'sortable' => true, 'transition' => true, 'allow_null' => true, - ), + ], - array( + [ 'name' => 'migrated_from_id', 'type' => 'bigint', 'length' => '20', 'unsigned' => true, 'sortable' => true, 'allow_null' => true, - ), + ], - array( + [ 'name' => 'name', 'type' => 'varchar', 'searchable' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'description', 'type' => 'longtext', 'default' => '', 'searchable' => true, - ), + ], - array( + [ 'name' => 'product_group', 'type' => 'varchar', 'searchable' => true, 'sortable' => true, 'allow_null' => true, - ), + ], - array( + [ 'name' => 'currency', 'type' => 'varchar', 'length' => '10', 'default' => 'USD', 'sortable' => true, - ), + ], - array( + [ 'name' => 'pricing_type', 'type' => 'varchar', 'length' => '10', 'default' => 'paid', 'sortable' => true, - ), + ], - array( + [ 'name' => 'amount', 'type' => 'decimal(13,4)', 'default' => '', 'sortable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'setup_fee', 'type' => 'decimal(13,4)', 'default' => '', 'sortable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'recurring', 'type' => 'tinyint', 'length' => '4', @@ -128,48 +128,48 @@ class Products_Schema extends Schema { 'default' => 1, 'transition' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'trial_duration', 'type' => 'smallint', 'unsigned' => true, 'default' => '0', 'sortable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'trial_duration_unit', 'type' => 'enum(\'day\', \'month\', \'week\', \'year\')', 'default' => 'none', - ), + ], - array( + [ 'name' => 'duration', 'type' => 'smallint', 'unsigned' => true, 'default' => '0', 'sortable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'duration_unit', 'type' => 'enum(\'day\', \'month\', \'week\', \'year\')', 'default' => 'none', - ), + ], - array( + [ 'name' => 'billing_cycles', 'type' => 'smallint', 'unsigned' => true, 'default' => '0', 'sortable' => true, 'transition' => true, - ), + ], - array( + [ 'name' => 'list_order', 'type' => 'tinyint', 'length' => '4', @@ -177,9 +177,9 @@ class Products_Schema extends Schema { 'default' => 10, 'transition' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'active', 'type' => 'tinyint', 'length' => '4', @@ -187,9 +187,9 @@ class Products_Schema extends Schema { 'default' => 1, 'transition' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'date_created', 'type' => 'datetime', 'default' => null, @@ -197,9 +197,9 @@ class Products_Schema extends Schema { 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], - array( + [ 'name' => 'date_modified', 'type' => 'datetime', 'default' => null, @@ -207,14 +207,14 @@ class Products_Schema extends Schema { 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], - array( + [ 'name' => 'type', 'type' => 'varchar', 'searchable' => true, 'sortable' => true, - ), + ], - ); + ]; } diff --git a/inc/database/products/class-products-table.php b/inc/database/products/class-products-table.php index b310fc2..68cc2ea 100644 --- a/inc/database/products/class-products-table.php +++ b/inc/database/products/class-products-table.php @@ -50,11 +50,11 @@ final class Products_Table extends Table { * * @var array */ - protected $upgrades = array( + protected $upgrades = [ '2.0.1-revision.20210419' => 20_210_419, '2.0.1-revision.20210607' => 20_210_607, '2.0.1-revision.20230601' => 20_230_601, - ); + ]; /** * Products constructor. @@ -75,7 +75,7 @@ final class Products_Table extends Table { * @since 2.0.0 * @return void */ - protected function set_schema() { + protected function set_schema(): void { $this->schema = "id bigint(20) NOT NULL AUTO_INCREMENT, name tinytext NOT NULL DEFAULT '', @@ -161,10 +161,10 @@ final class Products_Table extends Table { */ protected function __20230601(): bool { - $null_columns = array( + $null_columns = [ 'date_created', 'date_modified', - ); + ]; foreach ($null_columns as $column) { $query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;"; diff --git a/inc/database/sites/class-site-query.php b/inc/database/sites/class-site-query.php index 746aff0..8617977 100644 --- a/inc/database/sites/class-site-query.php +++ b/inc/database/sites/class-site-query.php @@ -56,7 +56,7 @@ class Site_Query extends Query { * @access public * @var string */ - protected $table_schema = '\\WP_Ultimo\\Database\\Sites\\Sites_Schema'; + protected $table_schema = \WP_Ultimo\Database\Sites\Sites_Schema::class; /** Item ******************************************************************/ @@ -85,7 +85,7 @@ class Site_Query extends Query { * @access public * @var mixed */ - protected $item_shape = '\\WP_Ultimo\\Models\\Site'; + protected $item_shape = \WP_Ultimo\Models\Site::class; /** * Group to cache queries and queried items in. @@ -112,7 +112,7 @@ class Site_Query extends Query { * * @param string|array $query Array of query arguments. */ - public function __construct($query = array()) { + public function __construct($query = []) { parent::__construct($query); } diff --git a/inc/database/sites/class-site-type.php b/inc/database/sites/class-site-type.php index c93bff7..65914be 100644 --- a/inc/database/sites/class-site-type.php +++ b/inc/database/sites/class-site-type.php @@ -41,14 +41,14 @@ class Site_Type extends Enum { */ protected function classes() { - return array( + return [ static::REGULAR => 'wu-bg-gray-700 wu-text-gray-200', static::SITE_TEMPLATE => 'wu-bg-yellow-200 wu-text-yellow-700', static::CUSTOMER_OWNED => 'wu-bg-green-200 wu-text-green-700', static::PENDING => 'wu-bg-purple-200 wu-text-purple-700', static::EXTERNAL => 'wu-bg-blue-200 wu-text-blue-700', static::MAIN => 'wu-bg-pink-200 wu-text-pink-700', - ); + ]; } /** @@ -59,12 +59,12 @@ class Site_Type extends Enum { */ protected function labels() { - return array( + return [ static::REGULAR => __('Regular Site', 'wp-ultimo'), static::SITE_TEMPLATE => __('Site Template', 'wp-ultimo'), static::CUSTOMER_OWNED => __('Customer-Owned', 'wp-ultimo'), static::PENDING => __('Pending', 'wp-ultimo'), static::MAIN => __('Main Site', 'wp-ultimo'), - ); + ]; } } diff --git a/inc/database/sites/class-sites-meta-table.php b/inc/database/sites/class-sites-meta-table.php index 49960ec..48de19d 100644 --- a/inc/database/sites/class-sites-meta-table.php +++ b/inc/database/sites/class-sites-meta-table.php @@ -72,7 +72,7 @@ final class Sites_Meta_Table extends Table { * @since 2.0.0 * @return void */ - protected function set_schema() { + protected function set_schema(): void { $this->schema = false; } diff --git a/inc/database/sites/class-sites-schema.php b/inc/database/sites/class-sites-schema.php index a89a4ed..415399a 100644 --- a/inc/database/sites/class-sites-schema.php +++ b/inc/database/sites/class-sites-schema.php @@ -36,9 +36,9 @@ class Sites_Schema extends Schema { * @access public * @var array */ - public $columns = array( + public $columns = [ - array( + [ 'name' => 'blog_id', 'type' => 'bigint', 'length' => '20', @@ -46,33 +46,33 @@ class Sites_Schema extends Schema { 'extra' => 'auto_increment', 'primary' => true, 'sortable' => true, - 'aliases' => array('id', 'ID'), + 'aliases' => ['id', 'ID'], 'searchable' => true, - ), + ], - array( + [ 'name' => 'site_id', 'type' => 'bigint', 'length' => '20', 'unsigned' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'domain', 'type' => 'varchar', 'searchable' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'path', 'type' => 'varchar', 'searchable' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'registered', 'type' => 'datetime', 'default' => '0000-00-00 00:00:00', @@ -80,9 +80,9 @@ class Sites_Schema extends Schema { 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], - array( + [ 'name' => 'last_updated', 'type' => 'datetime', 'default' => '0000-00-00 00:00:00', @@ -90,61 +90,61 @@ class Sites_Schema extends Schema { 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], - array( + [ 'name' => 'public', 'type' => 'tinyint', 'length' => '2', 'unsigned' => true, 'default' => 1, 'sortable' => true, - ), + ], - array( + [ 'name' => 'archived', 'type' => 'tinyint', 'length' => '2', 'unsigned' => true, 'default' => 0, 'sortable' => true, - ), + ], - array( + [ 'name' => 'mature', 'type' => 'tinyint', 'length' => '2', 'unsigned' => true, 'default' => 0, 'sortable' => true, - ), + ], - array( + [ 'name' => 'spam', 'type' => 'tinyint', 'length' => '2', 'unsigned' => true, 'default' => 0, 'sortable' => true, - ), + ], - array( + [ 'name' => 'deleted', 'type' => 'tinyint', 'length' => '2', 'unsigned' => true, 'default' => 0, 'sortable' => true, - ), + ], - array( + [ 'name' => 'lang_id', 'type' => 'int', 'length' => '11', 'unsigned' => true, 'default' => 0, 'sortable' => true, - ), + ], - ); + ]; } diff --git a/inc/database/sites/class-sites-table.php b/inc/database/sites/class-sites-table.php index fe39e11..1a390af 100644 --- a/inc/database/sites/class-sites-table.php +++ b/inc/database/sites/class-sites-table.php @@ -72,7 +72,7 @@ final class Sites_Table extends Table { * @since 2.0.0 * @return void */ - protected function set_schema() { + protected function set_schema(): void { $this->schema = false; } @@ -82,5 +82,5 @@ final class Sites_Table extends Table { * * @since 2.0.0 */ - public function install() {} + public function install(): void {} } diff --git a/inc/database/webhooks/class-webhook-query.php b/inc/database/webhooks/class-webhook-query.php index 8983048..a23bafc 100644 --- a/inc/database/webhooks/class-webhook-query.php +++ b/inc/database/webhooks/class-webhook-query.php @@ -48,7 +48,7 @@ class Webhook_Query extends Query { * @access public * @var string */ - protected $table_schema = '\\WP_Ultimo\\Database\\Webhooks\\Webhooks_Schema'; + protected $table_schema = \WP_Ultimo\Database\Webhooks\Webhooks_Schema::class; /** Item ******************************************************************/ @@ -77,7 +77,7 @@ class Webhook_Query extends Query { * @access public * @var mixed */ - protected $item_shape = '\\WP_Ultimo\\Models\\Webhook'; + protected $item_shape = \WP_Ultimo\Models\Webhook::class; /** * Group to cache queries and queried items in. @@ -104,7 +104,7 @@ class Webhook_Query extends Query { * * @param string|array $query Array of query arguments. */ - public function __construct($query = array()) { + public function __construct($query = []) { parent::__construct($query); } diff --git a/inc/database/webhooks/class-webhooks-schema.php b/inc/database/webhooks/class-webhooks-schema.php index 69bfe64..81f1a6f 100644 --- a/inc/database/webhooks/class-webhooks-schema.php +++ b/inc/database/webhooks/class-webhooks-schema.php @@ -28,9 +28,9 @@ class Webhooks_Schema extends Schema { * @access public * @var array */ - public $columns = array( + public $columns = [ - array( + [ 'name' => 'id', 'type' => 'bigint', 'length' => '20', @@ -38,48 +38,48 @@ class Webhooks_Schema extends Schema { 'extra' => 'auto_increment', 'primary' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'migrated_from_id', 'type' => 'bigint', 'length' => '20', 'unsigned' => true, 'sortable' => true, 'allow_null' => true, - ), + ], - array( + [ 'name' => 'name', 'type' => 'varchar', 'searchable' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'webhook_url', 'type' => 'varchar', 'searchable' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'event', 'type' => 'varchar', 'searchable' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'event_count', 'type' => 'int', 'length' => '10', 'default' => 0, 'sortable' => true, - 'aliases' => array('sent_events_count'), - ), + 'aliases' => ['sent_events_count'], + ], - array( + [ 'name' => 'active', 'type' => 'tinyint', 'length' => '4', @@ -87,9 +87,9 @@ class Webhooks_Schema extends Schema { 'default' => 1, 'transition' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'hidden', 'type' => 'tinyint', 'length' => '4', @@ -97,31 +97,31 @@ class Webhooks_Schema extends Schema { 'default' => 0, 'transition' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'integration', 'type' => 'varchar', 'searchable' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'date_last_failed', 'type' => 'datetime', 'date_query' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'date_created', 'type' => 'datetime', 'created' => true, 'date_query' => true, 'sortable' => true, - ), + ], - array( + [ 'name' => 'date_modified', 'type' => 'datetime', 'default' => null, @@ -129,7 +129,7 @@ class Webhooks_Schema extends Schema { 'date_query' => true, 'sortable' => true, 'allow_null' => true, - ), + ], - ); + ]; } diff --git a/inc/database/webhooks/class-webhooks-table.php b/inc/database/webhooks/class-webhooks-table.php index 8a68090..ca946db 100644 --- a/inc/database/webhooks/class-webhooks-table.php +++ b/inc/database/webhooks/class-webhooks-table.php @@ -50,9 +50,9 @@ final class Webhooks_Table extends Table { * * @var array */ - protected $upgrades = array( + protected $upgrades = [ '2.0.1-revision.20230601' => 20_230_601, - ); + ]; /** * Webhook constructor. @@ -73,7 +73,7 @@ final class Webhooks_Table extends Table { * @since 2.0.0 * @return void */ - protected function set_schema() { + protected function set_schema(): void { // phpcs:disable @@ -101,10 +101,10 @@ final class Webhooks_Table extends Table { */ protected function __20230601(): bool { - $null_columns = array( + $null_columns = [ 'date_created', 'date_modified', - ); + ]; foreach ($null_columns as $column) { $query = "ALTER TABLE {$this->table_name} MODIFY COLUMN `{$column}` datetime DEFAULT NULL;"; diff --git a/inc/debug/class-debug.php b/inc/debug/class-debug.php index ba89738..c7a7662 100644 --- a/inc/debug/class-debug.php +++ b/inc/debug/class-debug.php @@ -29,7 +29,7 @@ class Debug { * @since 2.0.0 * @var array */ - private array $pages = array(); + private array $pages = []; /** * Initializes main hooks. @@ -37,15 +37,15 @@ class Debug { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { $this->load(); - add_action('wp_ultimo_debug', array($this, 'add_main_debug_menu')); + add_action('wp_ultimo_debug', [$this, 'add_main_debug_menu']); - add_action('wp_ultimo_debug', array($this, 'add_additional_hooks')); + add_action('wp_ultimo_debug', [$this, 'add_additional_hooks']); - add_action('wp_ultimo_debug', array($this, 'register_forms')); + add_action('wp_ultimo_debug', [$this, 'register_forms']); } /** @@ -54,9 +54,9 @@ class Debug { * @since 2.0.0 * @return void */ - public function add_additional_hooks() { + public function add_additional_hooks(): void { - add_action('wu_header_left', array($this, 'add_debug_links')); + add_action('wu_header_left', [$this, 'add_debug_links']); } // phpcs:disable @@ -67,7 +67,7 @@ class Debug { * @since 2.0.0 * @return void */ - public function add_debug_links() { ?> + public function add_debug_links(): void { ?> array($this, 'render_debug_generator_form'), - 'handler' => array($this, 'handle_debug_generator_form'), - ) + [ + 'render' => [$this, 'render_debug_generator_form'], + 'handler' => [$this, 'handle_debug_generator_form'], + ] ); /* @@ -134,10 +134,10 @@ class Debug { */ wu_register_form( 'add_debug_reset_database_form', - array( - 'render' => array($this, 'render_debug_reset_database_form'), - 'handler' => array($this, 'handle_debug_reset_database_form'), - ) + [ + 'render' => [$this, 'render_debug_reset_database_form'], + 'handler' => [$this, 'handle_debug_reset_database_form'], + ] ); /* @@ -145,10 +145,10 @@ class Debug { */ wu_register_form( 'add_debug_drop_database_form', - array( - 'render' => array($this, 'render_debug_drop_database_form'), - 'handler' => array($this, 'handle_debug_drop_database_form'), - ) + [ + 'render' => [$this, 'render_debug_drop_database_form'], + 'handler' => [$this, 'handle_debug_drop_database_form'], + ] ); } @@ -158,148 +158,148 @@ class Debug { * @since 2.0.0 * @return void */ - public function render_debug_generator_form() { + public function render_debug_generator_form(): void { - $fields = array( - 'customers' => array( + $fields = [ + 'customers' => [ 'title' => __('Customers', 'wp-ultimo'), 'desc' => __('Toggle to generate customers.', 'wp-ultimo'), 'type' => 'toggle', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'customers', - ), - ), - 'customers_number' => array( + ], + ], + 'customers_number' => [ 'title' => __('Number of Customers', 'wp-ultimo'), 'type' => 'number', 'value' => 10, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'customers', 'v-cloak' => '1', - ), - ), - 'products' => array( + ], + ], + 'products' => [ 'title' => __('Products', 'wp-ultimo'), 'desc' => __('Toggle to generate products.', 'wp-ultimo'), 'type' => 'toggle', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'products', - ), - ), - 'products_number' => array( + ], + ], + 'products_number' => [ 'title' => __('Number of Products', 'wp-ultimo'), 'type' => 'number', 'value' => 10, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'products', 'v-cloak' => '1', - ), - ), - 'memberships' => array( + ], + ], + 'memberships' => [ 'title' => __('Memberships', 'wp-ultimo'), 'desc' => __('Toggle to generate memberships.', 'wp-ultimo'), 'type' => 'toggle', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'memberships', - ), - ), - 'memberships_number' => array( + ], + ], + 'memberships_number' => [ 'title' => __('Number of Memberships', 'wp-ultimo'), 'type' => 'number', 'value' => 10, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'memberships', 'v-cloak' => '1', - ), - ), - 'sites' => array( + ], + ], + 'sites' => [ 'title' => __('Sites', 'wp-ultimo'), 'desc' => __('Toggle to generate sites.', 'wp-ultimo'), 'type' => 'toggle', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'sites', - ), - ), - 'sites_number' => array( + ], + ], + 'sites_number' => [ 'title' => __('Number of Sites', 'wp-ultimo'), 'type' => 'number', 'value' => 10, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'sites', 'v-cloak' => '1', - ), - ), - 'domains' => array( + ], + ], + 'domains' => [ 'title' => __('Domains', 'wp-ultimo'), 'desc' => __('Toggle to generate domains.', 'wp-ultimo'), 'type' => 'toggle', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'domains', - ), - ), - 'domains_number' => array( + ], + ], + 'domains_number' => [ 'title' => __('Number of Domains', 'wp-ultimo'), 'type' => 'number', 'value' => 10, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'domains', 'v-cloak' => '1', - ), - ), - 'discount_codes' => array( + ], + ], + 'discount_codes' => [ 'title' => __('Discount Codes', 'wp-ultimo'), 'desc' => __('Toggle to generate discount codes.', 'wp-ultimo'), 'type' => 'toggle', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'discount_codes', - ), - ), - 'discount_codes_number' => array( + ], + ], + 'discount_codes_number' => [ 'title' => __('Number of Discount Codes', 'wp-ultimo'), 'type' => 'number', 'value' => 10, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'discount_codes', 'v-cloak' => '1', - ), - ), - 'payments' => array( + ], + ], + 'payments' => [ 'title' => __('Payments', 'wp-ultimo'), 'desc' => __('Toggle to generate payments.', 'wp-ultimo'), 'type' => 'toggle', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'payments', - ), - ), - 'payments_number' => array( + ], + ], + 'payments_number' => [ 'title' => __('Number of Payments', 'wp-ultimo'), 'type' => 'number', 'value' => 30, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'payments', 'v-cloak' => '1', - ), - ), - 'submit_button' => array( + ], + ], + 'submit_button' => [ 'title' => __('Generate Data →', 'wp-ultimo'), 'type' => 'submit', 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'add_debug_generator_form', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'debug_generator', 'data-state' => json_encode( - array( + [ 'customers' => false, 'products' => false, 'memberships' => false, @@ -308,10 +308,10 @@ class Debug { 'discount_codes' => false, 'webhooks' => false, 'payments' => false, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -323,7 +323,7 @@ class Debug { * @since 2.0.0 * @return void */ - public function handle_debug_generator_form() { + public function handle_debug_generator_form(): void { ignore_user_abort(true); // You and I are gonna live forever! @@ -373,7 +373,7 @@ class Debug { $fake_data_generated = $faker->get_fake_data_generated(); - $fake_ids_generated = array(); + $fake_ids_generated = []; foreach ($fake_data_generated as $key => $model) { foreach ($model as $object) { @@ -388,9 +388,9 @@ class Debug { $wpdb->query('COMMIT'); wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url('wp-ultimo'), - ) + ] ); } @@ -400,43 +400,43 @@ class Debug { * @since 2.0.0 * @return void */ - public function render_debug_reset_database_form() { + public function render_debug_reset_database_form(): void { - $fields = array( - 'reset_only_fake_data' => array( + $fields = [ + 'reset_only_fake_data' => [ 'title' => __('Only reset generated data.', 'wp-ultimo'), 'desc' => __('Toggle this option to only remove data that was added by the generator previously. Untoggling this option will reset ALL data in WP Multisite WaaS tables.', 'wp-ultimo'), 'type' => 'toggle', 'value' => true, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'reset_only', - ), - ), - 'submit_button' => array( + ], + ], + 'submit_button' => [ 'title' => __('Reset Database →', 'wp-ultimo'), 'type' => 'submit', 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'debug_reset_database_form', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'debug_reset_database_form', 'data-state' => json_encode( - array( + [ 'reset_only' => true, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -448,7 +448,7 @@ class Debug { * @since 2.0.0 * @return void */ - public function handle_debug_reset_database_form() { + public function handle_debug_reset_database_form(): void { global $wpdb; @@ -473,9 +473,9 @@ class Debug { wu_delete_option('debug_faker'); wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url('wp-ultimo-setup'), - ) + ] ); } @@ -485,38 +485,38 @@ class Debug { * @since 2.0.0 * @return void */ - public function render_debug_drop_database_form() { + public function render_debug_drop_database_form(): void { - $fields = array( - 'reset_note' => array( + $fields = [ + 'reset_note' => [ 'type' => 'note', 'desc' => __('This action will drop the WP Multisite WaaS database tables and is irreversable.', 'wp-ultimo'), - ), - 'submit_button' => array( + ], + 'submit_button' => [ 'title' => __('Drop Database Tables →', 'wp-ultimo'), 'type' => 'submit', 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'debug_drop_database_form', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'debug_drop_database_form', 'data-state' => json_encode( - array( + [ 'reset_only' => true, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -528,26 +528,22 @@ class Debug { * @since 2.0.0 * @return void */ - public function handle_debug_drop_database_form() { + public function handle_debug_drop_database_form(): void { global $wpdb; try { wu_drop_tables(); - } catch (\Throwable $e) { - $error = new \WP_Error($e->getCode(), $e->getMessage()); - - wp_send_json_error($error); - } catch (\Exception $e) { + } catch (\Throwable| \Exception $e) { $error = new \WP_Error($e->getCode(), $e->getMessage()); wp_send_json_error($error); } wp_send_json_success( - array( + [ 'redirect_url' => wu_network_admin_url('wp-ultimo-setup&step=installation'), - ) + ] ); } @@ -571,10 +567,10 @@ class Debug { * @since 2.0.0 * @return void */ - public function load() { + public function load(): void { if ($this->should_load()) { - add_action('wu_page_added', array($this, 'add_page')); + add_action('wu_page_added', [$this, 'add_page']); add_filter('wu_tour_finished', '__return_false'); @@ -596,7 +592,7 @@ class Debug { * @param string $page_id The page ID. e.g. wp-ultimo. * @return void */ - public function add_page($page_id) { + public function add_page($page_id): void { $this->pages[ $page_id ] = wu_network_admin_url($page_id); } @@ -618,7 +614,7 @@ class Debug { * @since 2.0.0 * @return void */ - public function add_main_debug_menu() { + public function add_main_debug_menu(): void { new \WP_Ultimo\Admin_Pages\Debug\Debug_Admin_Page(); } @@ -629,9 +625,9 @@ class Debug { * @since 2.0.0 * @return void */ - private function reset_fake_data() { + private function reset_fake_data(): void { - $fake_data_generated = wu_get_option('debug_faker', array()); + $fake_data_generated = wu_get_option('debug_faker', []); $customers_id = wu_get_isset($fake_data_generated, 'customers'); @@ -668,7 +664,7 @@ class Debug { * @since 2.0.0 * @return void */ - private function reset_all_data() { + private function reset_all_data(): void { $this->reset_customers(); @@ -703,7 +699,7 @@ class Debug { * @return void * @throws \Exception In case of failures, an exception is thrown. */ - private function reset_table($table, $ids = array(), $field = 'ID') { + private function reset_table($table, $ids = [], $field = 'ID'): void { global $wpdb; @@ -736,7 +732,7 @@ class Debug { * @return void * @throws \Exception In case of failures, an exception is thrown. */ - private function reset_customers($ids = array()) { + private function reset_customers($ids = []): void { global $wpdb; $customers_table = "{$wpdb->base_prefix}wu_customers"; @@ -770,7 +766,7 @@ class Debug { * @return void * @throws \Exception In case of failures, an exception is thrown. */ - private function reset_sites($ids = array()) { + private function reset_sites($ids = []): void { if ( ! empty($ids)) { foreach ($ids as $id) { @@ -790,7 +786,7 @@ class Debug { * @param array $ids The ids to delete. * @return void */ - private function reset_products($ids = array()) { + private function reset_products($ids = []): void { global $wpdb; @@ -810,7 +806,7 @@ class Debug { * @param array $ids The ids to delete. * @return void */ - private function reset_memberships($ids = array()) { + private function reset_memberships($ids = []): void { global $wpdb; @@ -830,7 +826,7 @@ class Debug { * @param array $ids The ids to delete. * @return void */ - private function reset_domains($ids = array()) { + private function reset_domains($ids = []): void { global $wpdb; @@ -846,7 +842,7 @@ class Debug { * @param array $ids The ids to delete. * @return void */ - private function reset_discount_codes($ids = array()) { + private function reset_discount_codes($ids = []): void { global $wpdb; @@ -862,7 +858,7 @@ class Debug { * @param array $ids The ids to delete. * @return void */ - private function reset_webhooks($ids = array()) { + private function reset_webhooks($ids = []): void { global $wpdb; @@ -878,7 +874,7 @@ class Debug { * @param array $ids The ids to delete. * @return void */ - private function reset_payments($ids = array()) { + private function reset_payments($ids = []): void { global $wpdb; @@ -894,7 +890,7 @@ class Debug { * @param array $ids The ids to delete. * @return void */ - private function reset_checkout_forms($ids = array()) { + private function reset_checkout_forms($ids = []): void { global $wpdb; @@ -914,7 +910,7 @@ class Debug { * @param array $ids The ids to delete. * @return void */ - private function reset_post_like_models($ids = array()) { + private function reset_post_like_models($ids = []): void { global $wpdb; @@ -934,7 +930,7 @@ class Debug { * @param array $ids The ids to delete. * @return void */ - private function reset_events($ids = array()) { + private function reset_events($ids = []): void { global $wpdb; @@ -949,7 +945,7 @@ class Debug { * @since 2.0.7 * @return void */ - private function reset_settings() { + private function reset_settings(): void { $the_prefix = 'wp-ultimo_'; @@ -957,7 +953,7 @@ class Debug { * List of WP Multisite WaaS options. * Format: $option_name => $should_use_prefix */ - $options = array( + $options = [ 'v2_settings' => true, 'debug_faker' => true, 'finished' => true, @@ -970,7 +966,7 @@ class Debug { 'wu_default_email_template' => false, 'wu_is_migration_done' => false, 'wu_host_integrations_enabled' => false, - ); + ]; foreach ($options as $option_name => $should_use_prefix) { $prefix = $should_use_prefix ? $the_prefix : ''; diff --git a/inc/deprecated/deprecated.php b/inc/deprecated/deprecated.php index bea5499..f391157 100644 --- a/inc/deprecated/deprecated.php +++ b/inc/deprecated/deprecated.php @@ -63,7 +63,7 @@ class WU_Settings { _deprecated_function(__METHOD__, '2.0.0', 'WP_Ultimo()->settings->save_settings()'); - return WP_Ultimo()->settings->save_settings(array(), $reset); + return WP_Ultimo()->settings->save_settings([], $reset); } /** @@ -145,7 +145,7 @@ class WU_Page extends \WP_Ultimo\Admin_Pages\Base_Admin_Page { * @since 2.0.0 * @var array */ - protected $attributes = array(); + protected $attributes = []; /** * Deprecated: Creates the page with the necessary hooks @@ -156,13 +156,13 @@ class WU_Page extends \WP_Ultimo\Admin_Pages\Base_Admin_Page { * @param boolean $network If this is a network page. * @param array $atts The page attributes. */ - public function __construct($network = true, $atts = array()) { + public function __construct($network = true, $atts = []) { _deprecated_function(__METHOD__, '2.0.0', 'wu_send_mail()'); $this->attributes = wp_parse_args( $atts, - array( + [ 'badge_count' => 0, 'position' => 10, 'submenu_title' => false, @@ -173,7 +173,7 @@ class WU_Page extends \WP_Ultimo\Admin_Pages\Base_Admin_Page { 'menu_icon' => 'dashicons-menu', 'title' => __('Admin Page', 'wp-ultimo'), 'menu_title' => __('Admin Page', 'wp-ultimo'), - ) + ] ); /* @@ -266,19 +266,19 @@ class WU_Mail { * @param array $bcc Bcc. * @return boolean */ - public function send_mail($to, $subject, $content, $html = true, $shortcodes = array(), $attachments = array(), $bcc = '') { + public function send_mail($to, $subject, $content, $html = true, $shortcodes = [], $attachments = [], $bcc = '') { _deprecated_function(__METHOD__, '2.0.0', 'wu_send_mail()'); - $from = array( + $from = [ 'name' => wu_get_setting('from_name'), 'email' => wu_get_setting('from_email'), - ); + ]; /* * Constructs the backwards compatible array. */ - $args = array( + $args = [ 'payload' => $shortcodes, 'subject' => $subject, 'content' => $content, @@ -287,7 +287,7 @@ class WU_Mail { 'attachments' => $attachments, 'type' => $html ? 'html' : 'plain', 'bcc' => $bcc, - ); + ]; return wu_send_mail($from, $to, $args); } @@ -303,7 +303,7 @@ class WU_Mail { * @param array $attachments Attachments. * @return void */ - public function send_template($slug, $to, $shortcodes, $attachments = array()) { + public function send_template($slug, $to, $shortcodes, $attachments = []): void { _deprecated_function(__METHOD__, '2.0.0'); } @@ -317,7 +317,7 @@ class WU_Mail { * @param string $args Array with the arguments. * @return void */ - public function register_template($slug, $args) { + public function register_template($slug, $args): void { _deprecated_function(__METHOD__, '2.0.0'); } @@ -413,7 +413,7 @@ class WU_Multi_Network { */ public static function __callStatic($method_name, $args) { - _deprecated_function(__CLASS__ . "::$method_name()", '2.0.0'); + _deprecated_function(self::class . "::$method_name()", '2.0.0'); return false; } @@ -437,9 +437,9 @@ class WU_Help_Pointers { * @since 2.0.0 * @param array $pntrs The pointers to add. */ - public function __construct($pntrs = array()) { + public function __construct($pntrs = []) { - _deprecated_function(__CLASS__, '2.0.0'); + _deprecated_function(self::class, '2.0.0'); } } @@ -524,7 +524,7 @@ class WU_Util { * @param array $args Arguments to pass down to wp_die. * @return void */ - public static function wp_die($message, $title, $redirect = false, $time = 5000, $args = array()) { + public static function wp_die($message, $title, $redirect = false, $time = 5000, $args = []): void { _deprecated_function(__METHOD__, '2.0.0', 'wp_die()'); @@ -542,7 +542,7 @@ class WU_Util { * @param boolean $arguments Deprecated argument. * @return void */ - public static function display_alert($title, $message, $type = 'success', $arguments = false) { + public static function display_alert($title, $message, $type = 'success', $arguments = false): void { _deprecated_function(__METHOD__, '2.0.0'); } @@ -558,14 +558,14 @@ class WU_Util { _deprecated_function(__METHOD__, '2.0.0', 'wu_get_customers() w/ count = true'); $signups = wu_get_customers( - array( + [ 'count' => true, - 'date_query' => array( + 'date_query' => [ 'column' => 'date_registered', 'after' => 'today', 'inclusive' => true, - ), - ) + ], + ] ); return $signups; @@ -610,7 +610,7 @@ class WU_Util { * @param array $data Data to save. First column being the headers. * @return void */ - public static function generate_csv($file_name, $data = array()) { + public static function generate_csv($file_name, $data = []): void { _deprecated_function(__METHOD__, '2.0.0', 'wu_generate_csv()'); @@ -662,7 +662,7 @@ class WU_Logger { $alternative = 'wu_log_clear'; } - _deprecated_function(__CLASS__ . "::$method_name()", '2.0.0', "$alternative()"); + _deprecated_function(self::class . "::$method_name()", '2.0.0', "$alternative()"); return call_user_func_array($alternative, $args); } @@ -713,7 +713,7 @@ class WU_Site extends \WP_Ultimo\Models\Site { */ public function __construct($object = null) { - _deprecated_function(__CLASS__, '2.0.0', '\WP_Ultimo\Models\Site'); + _deprecated_function(self::class, '2.0.0', \WP_Ultimo\Models\Site::class); if (is_numeric($object)) { $object = wu_get_site($object); @@ -743,7 +743,7 @@ class WU_Site_Template extends \WP_Ultimo\Models\Site { */ public function __construct($object = null) { - _deprecated_function(__CLASS__, '2.0.0', '\WP_Ultimo\Models\Site'); + _deprecated_function(self::class, '2.0.0', \WP_Ultimo\Models\Site::class); if (is_numeric($object)) { $object = wu_get_site($object); @@ -771,7 +771,7 @@ class WU_Site_Owner { */ public function __construct() { - _deprecated_function(__CLASS__, '2.0.0'); + _deprecated_function(self::class, '2.0.0'); } } @@ -793,7 +793,7 @@ trait WU_Deprecated_Model { public function __set($key, $value) { if (method_exists($this, "set_$key")) { - call_user_func(array($this, "set_$key"), $value); + call_user_func([$this, "set_$key"], $value); } $this->{$key} = $value; @@ -811,7 +811,7 @@ trait WU_Deprecated_Model { public function __get($key) { if (method_exists($this, "get_$key")) { - return call_user_func(array($this, "get_$key")); + return call_user_func([$this, "get_$key"]); } return false; @@ -846,7 +846,7 @@ class WU_Coupon extends \WP_Ultimo\Models\Discount_Code { */ public function __construct($object = null) { - _deprecated_function(__CLASS__, '2.0.0', '\WP_Ultimo\Models\Discount_Code'); + _deprecated_function(self::class, '2.0.0', \WP_Ultimo\Models\Discount_Code::class); if (is_numeric($object)) { $object = wu_get_discount_code($object); @@ -871,7 +871,7 @@ class WU_Coupon extends \WP_Ultimo\Models\Discount_Code { * @param string $key The key to set. * @param mixed $value The value to set. */ - public function after_set($key, $value) { + public function after_set($key, $value): void { if ($key === 'title') { $this->set_code($value); @@ -901,7 +901,7 @@ class WU_Plan extends \WP_Ultimo\Models\Product { */ public function __construct($object = null) { - _deprecated_function(__CLASS__, '2.0.0', '\WP_Ultimo\Models\Product'); + _deprecated_function(self::class, '2.0.0', \WP_Ultimo\Models\Product::class); if (is_numeric($object)) { $object = wu_get_product($object); @@ -936,7 +936,7 @@ class WU_Plan extends \WP_Ultimo\Models\Product { } if (method_exists($this, "get_$key")) { - return call_user_func(array($this, "get_$key")); + return call_user_func([$this, "get_$key"]); } return $this->get_meta('wpu_' . $key, false); @@ -950,7 +950,7 @@ class WU_Plan extends \WP_Ultimo\Models\Product { * @param string $key The key to set. * @param mixed $value The value to set. */ - public function after_set($key, $value) { + public function after_set($key, $value): void { if ($key === 'price_1') { $this->set_amount($value); @@ -976,7 +976,7 @@ class WU_Subscription extends \WP_Ultimo\Models\Membership { */ public function __construct($object = null) { - _deprecated_function(__CLASS__, '2.0.0', '\WP_Ultimo\Models\Membership'); + _deprecated_function(self::class, '2.0.0', \WP_Ultimo\Models\Membership::class); if (is_numeric($object)) { $object = wu_get_membership($object); @@ -1005,7 +1005,7 @@ class WU_Subscription extends \WP_Ultimo\Models\Membership { * @deprecated 2.0.0 * @param null $coupon_code Deprecated Argument. */ - public function apply_coupon_code($coupon_code = null) { + public function apply_coupon_code($coupon_code = null): void { _deprecated_function(__METHOD__, '2.0.0'); } @@ -1015,7 +1015,7 @@ class WU_Subscription extends \WP_Ultimo\Models\Membership { * * @deprecated 2.0.0 */ - public function get_price_after_coupon_code() { + public function get_price_after_coupon_code(): void { _deprecated_function(__METHOD__, '2.0.0'); } @@ -1033,7 +1033,7 @@ class WU_Signup extends \WP_Ultimo\Checkout\Legacy_Checkout { */ public function __construct() { - _deprecated_function(__CLASS__, '2.0.0', '\WP_Ultimo\Checkout\Legacy_Checkout'); + _deprecated_function(self::class, '2.0.0', \WP_Ultimo\Checkout\Legacy_Checkout::class); } } @@ -1067,9 +1067,9 @@ class WU_Site_Hooks { */ public static function get_available_templates($include_wp = true) { - _deprecated_function(__CLASS__, '2.0.0'); + _deprecated_function(self::class, '2.0.0'); - return array(); + return []; } /** @@ -1091,15 +1091,15 @@ class WU_Site_Hooks { global $current_site; - _deprecated_function(__CLASS__, '2.0.0', '\WP_Ultimo\Helpers\Site_Duplicator::duplicate_site()'); + _deprecated_function(self::class, '2.0.0', '\WP_Ultimo\Helpers\Site_Duplicator::duplicate_site()'); - $arguments = array( + $arguments = [ 'email' => $email, 'path' => $domain, 'copy_files' => $copy_files, - 'domain' => $site_domain ? $site_domain : $current_site->domain, + 'domain' => $site_domain ?: $current_site->domain, 'user_id' => $user_id, - ); + ]; return \WP_Ultimo\Helpers\Site_Duplicator::duplicate_site($site_to_duplicate, $title, $arguments); } @@ -1114,7 +1114,7 @@ class WU_Site_Hooks { */ public static function get_template_preview_url($site_id = '') { - _deprecated_function(__CLASS__, '2.0.0', '\WP_Ultimo\Models\Site::get_featured_image()'); + _deprecated_function(self::class, '2.0.0', '\WP_Ultimo\Models\Site::get_featured_image()'); $site = wu_get_site($site_id); @@ -1143,7 +1143,7 @@ class WU_Transactions { */ public static function get_current_time($type = 'mysql') { - _deprecated_function(__CLASS__, '2.0.0', 'wu_date()'); + _deprecated_function(self::class, '2.0.0', 'wu_date()'); $date = new \DateTime(); diff --git a/inc/development/assets/development.css b/inc/development/assets/development.css index 5c4a3be..b0e169c 100644 --- a/inc/development/assets/development.css +++ b/inc/development/assets/development.css @@ -10,7 +10,7 @@ body { content: " "; position: absolute; top: 30; - background: url("../../../assets/img/logo.png"); + background: url("../../../assets/img/logo.webp"); background-size: contain; height: 40px; background-position: left center; diff --git a/inc/development/assets/development.scss b/inc/development/assets/development.scss index a18768f..29a5d83 100644 --- a/inc/development/assets/development.scss +++ b/inc/development/assets/development.scss @@ -21,7 +21,7 @@ body { content: " "; position: absolute; top: 30; - background: url("../../../assets/img/logo.png"); + background: url("../../../assets/img/logo.webp"); background-size: contain; height: 40px; background-position: left center; diff --git a/inc/development/class-toolkit.php b/inc/development/class-toolkit.php index 5548ea0..cfed71a 100644 --- a/inc/development/class-toolkit.php +++ b/inc/development/class-toolkit.php @@ -32,7 +32,7 @@ class Toolkit { * @since 2.0.11 * @var array */ - protected $wp_hooks = array(); + protected $wp_hooks = []; /** * Listeners registered. @@ -40,7 +40,7 @@ class Toolkit { * @since 2.0.11 * @var array */ - protected $listeners = array(); + protected $listeners = []; /** * Keeps track of number of listeners run. @@ -72,15 +72,15 @@ class Toolkit { * @since 2.0.11 * @return void */ - public function init() { + public function init(): void { $this->register_default_listeners(); $this->load_sandbox(); - add_filter('qm/collectors', array($this, 'register_collector_overview'), 1, 2); + add_filter('qm/collectors', [$this, 'register_collector_overview'], 1, 2); - add_filter('qm/outputter/html', array($this, 'add_overview_panel'), 50, 2); + add_filter('qm/outputter/html', [$this, 'add_overview_panel'], 50, 2); } /** @@ -95,7 +95,7 @@ class Toolkit { * In the case of an empty listener name (?development) * adds the listener link. */ - $this->listen('index', array($this, 'render_listeners_menu'), 'init'); + $this->listen('index', [$this, 'render_listeners_menu'], 'init'); /** * Saves the rest endpoints to the mpb data folder @@ -103,9 +103,9 @@ class Toolkit { */ $this->listen('save-rest-arguments', '__return_false', 'wu_rest_get_endpoint_schema_use_cache'); - $this->listen('save-rest-arguments', array($this, 'save_route_arguments'), 'wu_rest_register_routes_general'); + $this->listen('save-rest-arguments', [$this, 'save_route_arguments'], 'wu_rest_register_routes_general'); - $this->listen('save-rest-arguments', array($this, 'save_route_arguments'), 'wu_rest_register_routes_with_id'); + $this->listen('save-rest-arguments', [$this, 'save_route_arguments'], 'wu_rest_register_routes_with_id'); } /** @@ -119,7 +119,7 @@ class Toolkit { * @param \WP_Ultimo\Traits\Rest_Api $manager The model manager instance. * @return void */ - public function save_route_arguments($routes, $path, $context, $manager) { + public function save_route_arguments($routes, $path, $context, $manager): void { $class_name = str_replace('_', '-', strtolower($path)); @@ -182,9 +182,9 @@ class Toolkit { * @param array $configs The config constants. * @return void */ - public function config($configs = array()) { + public function config($configs = []): void { - $allowed_configs = array( + $allowed_configs = [ 'QM_DARK_MODE', 'QM_DB_EXPENSIVE', 'QM_DISABLED', @@ -194,7 +194,7 @@ class Toolkit { 'QM_HIDE_SELF', 'QM_NO_JQUERY', 'QM_SHOW_ALL_HOOKS', - ); + ]; foreach ($configs as $constant_name => $constant_value) { if (in_array($constant_name, $allowed_configs, true)) { @@ -212,7 +212,7 @@ class Toolkit { * @param string|bool $should_die False to prevent it from dying, or a WordPress hook to wait before dying. * @return void */ - public function die($should_die = true) { + public function die($should_die = true): void { if ($should_die === true) { $should_die = is_admin() ? 'admin_enqueue_scripts' : 'wp_enqueue_scripts'; @@ -230,7 +230,7 @@ class Toolkit { * @param array $arguments The arguments passed to the WordPress hook. * @return mixed */ - public function run_listener($wp_hook, $arguments = array()) { + public function run_listener($wp_hook, $arguments = []) { $listener = wu_request(self::LISTENER_PARAM, 'no-dev-param'); @@ -275,7 +275,7 @@ class Toolkit { add_action($wp_hook, fn(...$arguments) => $this->run_listener($wp_hook, $arguments), 0, 100); } - add_action('shutdown', array($this, 'setup_query_monitor')); + add_action('shutdown', [$this, 'setup_query_monitor']); if ($this->should_die) { $this->dump_and_die(end($wp_hooks)); @@ -288,7 +288,7 @@ class Toolkit { * @since 2.0.11 * @return void */ - public function setup_query_monitor() { + public function setup_query_monitor(): void { if (class_exists('\QM_Dispatchers')) { // phpcs:ignore @@ -358,9 +358,9 @@ class Toolkit { printf('', wu_url('inc/development/assets/development.css')); wp_print_styles( - array( + [ 'wu-admin', - ) + ] ); $dispatcher->manually_print_assets(); // phpcs:ignore @@ -457,7 +457,7 @@ class Toolkit { * @since 2.0.11 * @return void */ - public function render_listeners_menu() { + public function render_listeners_menu(): void { /** * Make sure we display it only once. diff --git a/inc/development/query-monitor/collectors/class-collector-overview.php b/inc/development/query-monitor/collectors/class-collector-overview.php index c7b92a1..f709ddc 100644 --- a/inc/development/query-monitor/collectors/class-collector-overview.php +++ b/inc/development/query-monitor/collectors/class-collector-overview.php @@ -32,7 +32,7 @@ class Collector_Overview extends \QM_Collector { * @since 2.0.11 * @return void */ - public function set_up() { + public function set_up(): void { parent::set_up(); } @@ -43,7 +43,7 @@ class Collector_Overview extends \QM_Collector { * @since 2.0.11 * @return void */ - public function tear_down() { + public function tear_down(): void { parent::tear_down(); } @@ -57,7 +57,7 @@ class Collector_Overview extends \QM_Collector { * @since 2.0.11 * @return void */ - public function process() { + public function process(): void { $this->data = $_REQUEST; } diff --git a/inc/development/query-monitor/panel/class-overview.php b/inc/development/query-monitor/panel/class-overview.php index c62affa..7ce5798 100644 --- a/inc/development/query-monitor/panel/class-overview.php +++ b/inc/development/query-monitor/panel/class-overview.php @@ -30,9 +30,9 @@ class Overview extends \QM_Output_Html { parent::__construct($collector); - add_filter('qm/output/menus', array($this, 'admin_menu'), 1000); + add_filter('qm/output/menus', [$this, 'admin_menu'], 1000); - add_filter('qm/output/panel_menus', array($this, 'panel_menu'), 1000); + add_filter('qm/output/panel_menus', [$this, 'panel_menu'], 1000); } /** @@ -52,7 +52,7 @@ class Overview extends \QM_Output_Html { * @since 2.0.11 * @return void */ - public function output() { + public function output(): void { $data = $this->collector->get_data(); @@ -102,14 +102,14 @@ class Overview extends \QM_Output_Html { */ public function panel_menu(array $menu) { - $new_menu = array( + $new_menu = [ 'wp-ultimo' => $this->menu( - array( + [ 'title' => esc_html__('WP Multisite WaaS', 'wp-ultimo'), 'id' => 'wp-ultimo', - ) + ] ), - ); + ]; return $new_menu + $menu; } diff --git a/inc/domain-mapping/class-helper.php b/inc/domain-mapping/class-helper.php index 119bf25..8b65d47 100644 --- a/inc/domain-mapping/class-helper.php +++ b/inc/domain-mapping/class-helper.php @@ -26,11 +26,11 @@ class Helper { * * @var array */ - static $providers = array( + static $providers = [ 'https://ipv4.canihazip.com/s', 'https://ipv4.icanhazip.com/', 'https://api.ipify.org/', - ); + ]; /** * Static-only class. @@ -72,7 +72,7 @@ class Helper { */ public static function get_local_network_ip() { - return isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : false; + return $_SERVER['SERVER_ADDR'] ?? false; } /** @@ -104,9 +104,9 @@ class Helper { foreach ( self::$providers as $provider_url ) { $response = wp_remote_get( $provider_url, - array( + [ 'timeout' => 5, - ) + ] ); if ( ! is_wp_error($response) ) { @@ -154,16 +154,16 @@ class Helper { } // Add 'https://' if not already present to use SSL context properly. - $domain = strpos($domain, 'https://') === 0 ? $domain : 'https://' . $domain; + $domain = str_starts_with($domain, 'https://') ? $domain : 'https://' . $domain; try { // Create SSL context to fetch the certificate. $context = stream_context_create( - array( - 'ssl' => array( + [ + 'ssl' => [ 'capture_peer_cert' => true, - ), - ) + ], + ] ); // Open a stream to the domain over SSL. @@ -212,7 +212,7 @@ class Helper { $is_valid = true; } else { foreach ($alt_names_array as $alt_name) { - if ( strpos($alt_name, '*.') === 0 && str_ends_with($host, substr($alt_name, 1))) { + if ( str_starts_with($alt_name, '*.') && str_ends_with($host, substr($alt_name, 1))) { $is_valid = true; break; } diff --git a/inc/domain-mapping/class-primary-domain.php b/inc/domain-mapping/class-primary-domain.php index ea9150b..a5f381f 100644 --- a/inc/domain-mapping/class-primary-domain.php +++ b/inc/domain-mapping/class-primary-domain.php @@ -29,9 +29,9 @@ class Primary_Domain { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - add_action('wu_domain_mapping_load', array($this, 'add_hooks'), -20); + add_action('wu_domain_mapping_load', [$this, 'add_hooks'], -20); } /** @@ -40,13 +40,13 @@ class Primary_Domain { * @since 2.0.0 * @return void */ - public function add_hooks() { + public function add_hooks(): void { - add_action('template_redirect', array($this, 'redirect_to_primary_domain')); + add_action('template_redirect', [$this, 'redirect_to_primary_domain']); - add_action('admin_init', array($this, 'maybe_redirect_to_mapped_or_network_domain')); + add_action('admin_init', [$this, 'maybe_redirect_to_mapped_or_network_domain']); - add_action('login_init', array($this, 'maybe_redirect_to_mapped_or_network_domain')); + add_action('login_init', [$this, 'maybe_redirect_to_mapped_or_network_domain']); } /** @@ -55,7 +55,7 @@ class Primary_Domain { * @since 2.0.0 * @return void */ - public function redirect_to_primary_domain() { + public function redirect_to_primary_domain(): void { $should_redirect = true; @@ -85,12 +85,12 @@ class Primary_Domain { } $domains = wu_get_domains( - array( + [ 'blog_id' => get_current_blog_id(), 'primary_domain' => 1, 'active' => 1, - 'domain__not_in' => array($_SERVER['HTTP_HOST']), - ) + 'domain__not_in' => [$_SERVER['HTTP_HOST']], + ] ); if (empty($domains)) { @@ -116,7 +116,7 @@ class Primary_Domain { * @since 2.0.0 * @return void */ - public function maybe_redirect_to_mapped_or_network_domain() { + public function maybe_redirect_to_mapped_or_network_domain(): void { if ($_SERVER['REQUEST_METHOD'] !== 'GET' || wp_doing_ajax()) { return; @@ -151,7 +151,7 @@ class Primary_Domain { $mapped_url_to_compare = $mapped_url['host']; - $query_args = array(); + $query_args = []; if (wu_get_isset($current_url, 'query')) { wp_parse_str($current_url['query'], $query_args); diff --git a/inc/duplication/data.php b/inc/duplication/data.php index 8d67b43..be5b81c 100644 --- a/inc/duplication/data.php +++ b/inc/duplication/data.php @@ -15,7 +15,7 @@ if ( ! class_exists('MUCD_Data') ) { * @param int $from_site_id duplicated site id * @param int $to_site_id new site id */ - public static function copy_data($from_site_id, $to_site_id) { + public static function copy_data($from_site_id, $to_site_id): void { self::$to_site_id = $to_site_id; // Copy @@ -25,16 +25,16 @@ if ( ! class_exists('MUCD_Data') ) { self::db_update_data($from_site_id, $to_site_id, $saved_options); } - public static function db_copy_blog_meta($from_site_id, $to_site_id) { + public static function db_copy_blog_meta($from_site_id, $to_site_id): void { global $wpdb; // Delete everything $wpdb->delete( _get_meta_table('blog'), - array( + [ 'blog_id' => $to_site_id, - ) + ] ); $meta = get_site_meta($from_site_id); @@ -96,12 +96,12 @@ if ( ! class_exists('MUCD_Data') ) { // die; - $tables_to_ignore = array( + $tables_to_ignore = [ 'actionscheduler_actions', 'actionscheduler_claims', 'actionscheduler_groups', 'actionscheduler_logs', - ); + ]; foreach ($from_site_table as $table) { $table_base_name = substr((string) $table, $from_site_prefix_length); @@ -169,7 +169,7 @@ if ( ! class_exists('MUCD_Data') ) { * @param int $from_site_id duplicated site id * @param int $to_site_id new site id */ - public static function db_update_data($from_site_id, $to_site_id, $saved_options) { + public static function db_update_data($from_site_id, $to_site_id, $saved_options): void { global $wpdb; @@ -192,7 +192,7 @@ if ( ! class_exists('MUCD_Data') ) { restore_current_blog(); - $tables = array(); + $tables = []; // Bugfix : escape '_' , '%' and '/' character for mysql 'like' queries $to_blog_prefix_like = $wpdb->esc_like($to_blog_prefix); @@ -200,13 +200,13 @@ if ( ! class_exists('MUCD_Data') ) { $results = self::do_sql_query('SHOW TABLES LIKE \'' . $to_blog_prefix_like . '%\'', 'col', false); foreach ( $results as $k => $v ) { - $tables[ str_replace($to_blog_prefix, '', (string) $v) ] = array(); + $tables[ str_replace($to_blog_prefix, '', (string) $v) ] = []; } foreach ( $tables as $table => $col) { $results = self::do_sql_query('SHOW COLUMNS FROM `' . $to_blog_prefix . $table . '`', 'col', false); - $columns = array(); + $columns = []; foreach ( $results as $k => $v ) { $columns[] = $v; @@ -224,11 +224,11 @@ if ( ! class_exists('MUCD_Data') ) { $from_site_prefix = $wpdb->get_blog_prefix($from_site_id); $to_site_prefix = $wpdb->get_blog_prefix($to_site_id); - $string_to_replace = array( + $string_to_replace = [ wu_replace_scheme($from_upload_url) => wu_replace_scheme($to_upload_url), wu_replace_scheme($from_blog_url) => wu_replace_scheme($to_blog_url), $from_site_prefix => $to_site_prefix, - ); + ]; $string_to_replace = apply_filters('mucd_string_to_replace', $string_to_replace, $from_site_id, $to_site_id); @@ -248,7 +248,7 @@ if ( ! class_exists('MUCD_Data') ) { * @param int $from_site_id duplicated site id * @param int $to_site_id new site id */ - public static function db_restore_data($to_site_id, $saved_options) { + public static function db_restore_data($to_site_id, $saved_options): void { switch_to_blog($to_site_id); @@ -272,7 +272,7 @@ if ( ! class_exists('MUCD_Data') ) { * @param string $from_string original string to replace * @param string $to_string new string */ - public static function update($table, $fields, $from_string, $to_string) { + public static function update($table, $fields, $from_string, $to_string): void { if (is_array($fields) || ! empty($fields)) { global $wpdb; @@ -336,7 +336,7 @@ if ( ! class_exists('MUCD_Data') ) { * @return string the new string */ public static function replace_recursive($val, $from_string, $to_string) { - $unset = array(); + $unset = []; if (is_array($val)) { foreach ($val as $k => $v) { $val[ $k ] = self::try_replace($val, $k, $from_string, $to_string); @@ -457,7 +457,7 @@ if ( ! class_exists('MUCD_Data') ) { * @param string $sql_query the query * @param string $sql_error the error */ - public static function sql_error($sql_query, $sql_error) { + public static function sql_error($sql_query, $sql_error): void { wu_log_add('site-duplication-errors', sprintf('Got error "%s" while running: %s', $sql_error, $sql_query), LogLevel::ERROR); } } diff --git a/inc/duplication/duplicate.php b/inc/duplication/duplicate.php index 0a43c95..397cf81 100644 --- a/inc/duplication/duplicate.php +++ b/inc/duplication/duplicate.php @@ -16,7 +16,7 @@ if ( ! class_exists('MUCD_Duplicate') ) { * * @since 0.2.0 */ - public static function init() { + public static function init(): void { self::$log = false; } @@ -30,7 +30,7 @@ if ( ! class_exists('MUCD_Duplicate') ) { public static function duplicate_site($data) { global $wpdb; - $form_message = array(); + $form_message = []; $wpdb->hide_errors(); self::init_log($data); @@ -61,7 +61,7 @@ if ( ! class_exists('MUCD_Duplicate') ) { // Create new site switch_to_blog(1); - $to_site_id = wpmu_create_blog($newdomain, $path, $title, $user_id, array('public' => $public), $network_id); + $to_site_id = wpmu_create_blog($newdomain, $path, $title, $user_id, ['public' => $public], $network_id); $wpdb->show_errors(); if ( is_wp_error($to_site_id) ) { @@ -140,7 +140,7 @@ if ( ! class_exists('MUCD_Duplicate') ) { * @param int $from_site_id duplicated site id * @param int $to_site_id new site id */ - public static function copy_users($from_site_id, $to_site_id) { + public static function copy_users($from_site_id, $to_site_id): void { global $wpdb; @@ -151,7 +151,7 @@ if ( ! class_exists('MUCD_Duplicate') ) { if (is_main_site($from_site_id)) { $is_from_main_site = true; - $args = array('fields' => 'ids'); + $args = ['fields' => 'ids']; $all_sites_ids = MUCD_Functions::get_sites($args); if ( ! empty($all_sites_ids)) { $all_sites_ids = array_map('user_array_map', $all_sites_ids); @@ -205,12 +205,12 @@ if ( ! class_exists('MUCD_Duplicate') ) { * @since 0.2.0 * @param array $data data from FORM */ - public static function init_log($data) { + public static function init_log($data): void { // INIT LOG AND SAVE OPTION if (isset($data['log']) && $data['log'] == 'yes' ) { if (isset($data['log-path']) && ! empty($data['log-path'])) { $log_name = @date('Y_m_d_His') . '-' . $data['domain'] . '.log'; - if (substr_compare((string) $data['log-path'], '/', -strlen('/')) !== 0) { + if (! str_ends_with((string) $data['log-path'], '/')) { $data['log-path'] = $data['log-path'] . '/'; } self::$log = new MUCD_Log(true, $data['log-path'], $log_name); @@ -246,7 +246,7 @@ if ( ! class_exists('MUCD_Duplicate') ) { * @since 0.2.0 * @param string $msg the message */ - public static function write_log($msg) { + public static function write_log($msg): void { if (self::log() !== false) { self::$log->write_log($msg); } @@ -257,7 +257,7 @@ if ( ! class_exists('MUCD_Duplicate') ) { * * @since 0.2.0 */ - public static function close_log() { + public static function close_log(): void { if (self::log() !== false) { self::$log->close_log(); } @@ -291,7 +291,7 @@ if ( ! class_exists('MUCD_Duplicate') ) { * * @since 0.2.0 */ - public static function bypass_server_limit() { + public static function bypass_server_limit(): void { @ini_set('memory_limit', '1024M'); @ini_set('max_execution_time', '0'); } diff --git a/inc/duplication/files.php b/inc/duplication/files.php index 7136da7..a585053 100644 --- a/inc/duplication/files.php +++ b/inc/duplication/files.php @@ -16,7 +16,7 @@ if ( ! class_exists('MUCD_Files') ) { switch_to_blog($from_site_id); $wp_upload_info = wp_upload_dir(); $from_dir['path'] = $wp_upload_info['basedir']; - $from_site_id == MUCD_PRIMARY_SITE_ID ? $from_dir['exclude'] = MUCD_Option::get_primary_dir_exclude() : $from_dir['exclude'] = array(); + $from_site_id == MUCD_PRIMARY_SITE_ID ? $from_dir['exclude'] = MUCD_Option::get_primary_dir_exclude() : $from_dir['exclude'] = []; // Switch to Destination site and get uploads info switch_to_blog($to_site_id); @@ -25,12 +25,12 @@ if ( ! class_exists('MUCD_Files') ) { restore_current_blog(); - $dirs = array(); - $dirs[] = array( + $dirs = []; + $dirs[] = [ 'from_dir_path' => $from_dir['path'], 'to_dir_path' => $to_dir, 'exclude_dirs' => $from_dir['exclude'], - ); + ]; $dirs = apply_filters('mucd_copy_dirs', $dirs, $from_site_id, $to_site_id); @@ -53,7 +53,7 @@ if ( ! class_exists('MUCD_Files') ) { * @param string $dst destination directory path * @param array $exclude_dirs directories to ignore */ - public static function recurse_copy($src, $dst, $exclude_dirs = array()) { + public static function recurse_copy($src, $dst, $exclude_dirs = []): void { $src = rtrim($src, '/'); $dst = rtrim($dst, '/'); $dir = opendir($src); @@ -102,7 +102,7 @@ if ( ! class_exists('MUCD_Files') ) { * @since 0.2.0 * @param string $dir the path */ - public static function rrmdir($dir) { + public static function rrmdir($dir): void { if (is_dir($dir)) { $objects = scandir($dir); foreach ($objects as $object) { @@ -125,7 +125,7 @@ if ( ! class_exists('MUCD_Files') ) { * @since 0.2.0 * @param string $dir_path the path */ - public static function mkdir_error($dir_path) { + public static function mkdir_error($dir_path): void { $error_1 = 'ERROR DURING FILE COPY : CANNOT CREATE ' . $dir_path; MUCD_Duplicate::write_log($error_1); $error_2 = sprintf(MUCD_NETWORK_PAGE_DUPLICATE_COPY_FILE_ERROR, MUCD_Functions::get_primary_upload_dir()); diff --git a/inc/duplication/functions.php b/inc/duplication/functions.php index 04185d1..6b48bc4 100644 --- a/inc/duplication/functions.php +++ b/inc/duplication/functions.php @@ -50,7 +50,7 @@ if ( ! class_exists('MUCD_Functions') ) { * @since 0.2.0 * @param int $blog_id the blog id */ - public static function remove_blog($blog_id) { + public static function remove_blog($blog_id): void { switch_to_blog($blog_id); $wp_upload_info = wp_upload_dir(); $dir = str_replace(' ', '\\ ', trailingslashit($wp_upload_info['basedir'])); @@ -87,8 +87,8 @@ if ( ! class_exists('MUCD_Functions') ) { * @return array of blog data */ public static function get_site_list() { - $site_list = array(); - $network_blogs = self::get_sites(apply_filters('mucd_get_site_list_args', array())); + $site_list = []; + $network_blogs = self::get_sites(apply_filters('mucd_get_site_list_args', [])); foreach ( $network_blogs as $blog ) { if (self::is_duplicable($blog['blog_id']) && MUCD_SITE_DUPLICATION_EXCLUDE != $blog['blog_id']) { $site_list[] = $blog; @@ -147,7 +147,7 @@ if ( ! class_exists('MUCD_Functions') ) { * * @since 1.3.1 */ - public static function set_locale_to_en_US() { + public static function set_locale_to_en_US(): void { // Bugfix Pierre Dargham : relocating this declaration outside of the call to add_filter // PHP < 5.3 does not accept anonymous functions @@ -185,9 +185,9 @@ if ( ! class_exists('MUCD_Functions') ) { return false; } - public static function get_sites($args = array()) { + public static function get_sites($args = []) { if (version_compare(get_bloginfo('version'), '4.6', '>=')) { - $defaults = array('number' => MUCD_MAX_NUMBER_OF_SITE); + $defaults = ['number' => MUCD_MAX_NUMBER_OF_SITE]; $args = wp_parse_args($args, $defaults); $args = apply_filters('mucd_get_sites_args', $args); $sites = get_sites($args); @@ -196,7 +196,7 @@ if ( ! class_exists('MUCD_Functions') ) { } return $sites; } else { - $defaults = array('limit' => MUCD_MAX_NUMBER_OF_SITE); + $defaults = ['limit' => MUCD_MAX_NUMBER_OF_SITE]; $args = apply_filters('mucd_get_sites_args', $args); $args = wp_parse_args($args, $defaults); return wp_get_sites($args); @@ -208,7 +208,7 @@ if ( ! class_exists('MUCD_Functions') ) { * * @since 0.2.0 */ - public static function check_if_multisite() { + public static function check_if_multisite(): void { if ( ! function_exists('is_multisite') || ! is_multisite()) { deactivate_plugins(plugin_basename(__FILE__)); wp_die('multisite-clone-duplicator works only for multisite installation'); @@ -220,7 +220,7 @@ if ( ! class_exists('MUCD_Functions') ) { * * @since 1.4.0 */ - public static function check_if_network_admin() { + public static function check_if_network_admin(): void { if ( ! is_network_admin() ) { deactivate_plugins(plugin_basename(__FILE__)); wp_die('multisite-clone-duplicator works only as multisite network-wide plugin'); diff --git a/inc/duplication/log.php b/inc/duplication/log.php index a49a6ca..67819e6 100644 --- a/inc/duplication/log.php +++ b/inc/duplication/log.php @@ -146,7 +146,7 @@ if ( ! class_exists('MUCD_Log') ) { * * @since 0.2.0 */ - public function close_log() { + public function close_log(): void { @fclose($this->fp); } } diff --git a/inc/duplication/option.php b/inc/duplication/option.php index 7ad345a..5e6f20d 100644 --- a/inc/duplication/option.php +++ b/inc/duplication/option.php @@ -13,7 +13,7 @@ if ( ! class_exists('MUCD_Option') ) { * @param string $network_value the value for site option * @since 0.2.0 */ - public static function init_duplicable_option($blogs_value = 'no', $network_value = 'all') { + public static function init_duplicable_option($blogs_value = 'no', $network_value = 'all'): void { $network_blogs = MUCD_Functions::get_sites(); foreach ( $network_blogs as $blog ) { $blog_id = $blog['blog_id']; @@ -28,7 +28,7 @@ if ( ! class_exists('MUCD_Option') ) { * * @since 0.2.0 */ - public static function delete_duplicable_option() { + public static function delete_duplicable_option(): void { $network_blogs = MUCD_Functions::get_sites(); foreach ( $network_blogs as $blog ) { $blog_id = $blog['blog_id']; @@ -44,7 +44,7 @@ if ( ! class_exists('MUCD_Option') ) { * @since 0.2.0 * @param array $blogs list of blogs we want the option set to "yes" */ - public static function set_duplicable_option($blogs) { + public static function set_duplicable_option($blogs): void { $network_blogs = MUCD_Functions::get_sites(); foreach ( $network_blogs as $blog ) { if (in_array($blog['blog_id'], $blogs)) { @@ -61,7 +61,7 @@ if ( ! class_exists('MUCD_Option') ) { * * @since 1.3.0 */ - public static function init_options() { + public static function init_options(): void { add_site_option('mucd_copy_files', 'yes'); add_site_option('mucd_keep_users', 'yes'); add_site_option('mucd_log', 'no'); @@ -77,7 +77,7 @@ if ( ! class_exists('MUCD_Option') ) { * * @since 1.3.0 */ - public static function delete_options() { + public static function delete_options(): void { delete_site_option('mucd_copy_files'); delete_site_option('mucd_keep_users'); delete_site_option('mucd_log'); @@ -106,9 +106,9 @@ if ( ! class_exists('MUCD_Option') ) { * @return array of string */ public static function get_primary_dir_exclude() { - return array( + return [ 'sites', - ); + ]; } @@ -119,7 +119,7 @@ if ( ! class_exists('MUCD_Option') ) { * @return array of string */ public static function get_default_saved_option() { - return array( + return [ 'siteurl' => '', 'home' => '', 'upload_path' => '', @@ -132,7 +132,7 @@ if ( ! class_exists('MUCD_Option') ) { 'schema-ActionScheduler_StoreSchema' => '', 'schema-ActionScheduler_LoggerSchema' => '', 'action_scheduler_lock_async-request-runner' => '', - ); + ]; } @@ -154,17 +154,17 @@ if ( ! class_exists('MUCD_Option') ) { * @return array '%table_name' => array('%field_name_1','%field_name_2','%field_name_3', ...) */ public static function get_default_fields_to_update() { - return array( - 'commentmeta' => array(), - 'comments' => array(), - 'links' => array('link_url', 'link_image'), - 'options' => array('option_name', 'option_value'), - 'postmeta' => array('meta_value'), - 'posts' => array('post_content', 'guid', 'post_title', 'post_name'), - 'terms' => array(), - 'term_relationships' => array(), - 'term_taxonomy' => array(), - ); + return [ + 'commentmeta' => [], + 'comments' => [], + 'links' => ['link_url', 'link_image'], + 'options' => ['option_name', 'option_value'], + 'postmeta' => ['meta_value'], + 'posts' => ['post_content', 'guid', 'post_title', 'post_name'], + 'terms' => [], + 'term_relationships' => [], + 'term_taxonomy' => [], + ]; } @@ -186,7 +186,7 @@ if ( ! class_exists('MUCD_Option') ) { * @return array of string */ public static function get_default_primary_tables_to_copy() { - return array( + return [ 'commentmeta', 'comments', 'links', @@ -197,7 +197,7 @@ if ( ! class_exists('MUCD_Option') ) { 'term_relationships', 'term_taxonomy', 'termmeta', - ); + ]; } diff --git a/inc/functions/admin.php b/inc/functions/admin.php index ea5d21d..950807a 100644 --- a/inc/functions/admin.php +++ b/inc/functions/admin.php @@ -17,11 +17,11 @@ defined('ABSPATH') || exit; * @param array $args List of the page arguments. * @return string */ -function wu_render_empty_state($args = array()) { +function wu_render_empty_state($args = []) { $args = wp_parse_args( $args, - array( + [ 'message' => __('This is not yet available...'), 'sub_message' => __('We\'re still working on this part of the product.'), 'link_label' => __('← Go Back', 'wp-ultimo'), @@ -29,7 +29,7 @@ function wu_render_empty_state($args = array()) { 'link_classes' => '', 'link_icon' => '', 'display_background_image' => true, - ) + ] ); return wu_get_template_contents('base/empty-state', $args); @@ -55,17 +55,17 @@ function wu_wrap_use_container() { * @param array $second_row The second row, on the right. * @return string */ -function wu_responsive_table_row($args = array(), $first_row = array(), $second_row = array()) { +function wu_responsive_table_row($args = [], $first_row = [], $second_row = []) { $args = wp_parse_args( $args, - array( + [ 'id' => '', 'title' => __('No Title', 'wp-ultimo'), 'url' => '#', 'status' => '', 'image' => '', - ) + ] ); return wu_get_template_contents('base/responsive-table-row', compact('args', 'first_row', 'second_row')); diff --git a/inc/functions/array-helpers.php b/inc/functions/array-helpers.php index 17e4ea6..46c561f 100644 --- a/inc/functions/array-helpers.php +++ b/inc/functions/array-helpers.php @@ -22,7 +22,7 @@ use WP_Ultimo\Helpers\Arr; */ function wu_array_flatten($array, $indexes = false) { - $return = array(); + $return = []; array_walk_recursive( $array, @@ -99,9 +99,9 @@ function wu_array_merge_recursive_distinct(array &$array1, array &$array2, $shou * @param array $to_keep List of keys to keep regardless of diff status. * @return array */ -function wu_array_recursive_diff($array1, $array2, $to_keep = array()) { +function wu_array_recursive_diff($array1, $array2, $to_keep = []) { - $arr_return = array(); + $arr_return = []; $array1 = (array) $array1; $array2 = (array) $array2; @@ -175,13 +175,13 @@ function wu_array_map_keys($callable, $array): array { */ function wu_key_map_to_array($assoc_array, $key_name = 'id', $value_name = 'value') { - $results = array(); + $results = []; foreach ($assoc_array as $key => &$value) { - $results[] = array( + $results[] = [ $key_name => $key, $value_name => $value, - ); + ]; } return $results; diff --git a/inc/functions/broadcast.php b/inc/functions/broadcast.php index 7b9cfb4..f97ff27 100644 --- a/inc/functions/broadcast.php +++ b/inc/functions/broadcast.php @@ -19,10 +19,10 @@ use WP_Ultimo\Models\Broadcast; * @param array $query Query arguments. * @return \WP_Ultimo\Models\Broadcast[] */ -function wu_get_broadcasts($query = array()) { +function wu_get_broadcasts($query = []) { if ( ! isset($query['type__in'])) { - $query['type__in'] = array('broadcast_email', 'broadcast_notice'); + $query['type__in'] = ['broadcast_email', 'broadcast_notice']; } return \WP_Ultimo\Models\Broadcast::query($query); @@ -45,17 +45,17 @@ function wu_get_broadcast_by($column, $value) { return $first_attempt; } - $query = array( + $query = [ 'number' => 1, - 'type__in' => array('broadcast_email', 'broadcast_notice'), - ); + 'type__in' => ['broadcast_email', 'broadcast_notice'], + ]; - $query['meta_query'] = array( - array( + $query['meta_query'] = [ + [ 'key' => $column, 'value' => $value, - ), - ); + ], + ]; $results = \WP_Ultimo\Models\Broadcast::query($query); @@ -96,7 +96,7 @@ function wu_get_broadcast_targets($broadcast_id, $type) { return explode(',', $targets[ $type ]); } - return array(); + return []; } /** @@ -113,18 +113,18 @@ function wu_create_broadcast($broadcast_data) { $broadcast_data = wp_parse_args( $broadcast_data, - array( + [ 'type' => 'broadcast_notice', 'notice_type' => 'success', 'date_created' => wu_get_current_time('mysql', true), 'date_modified' => wu_get_current_time('mysql', true), 'migrated_from_id' => 0, 'skip_validation' => false, - 'message_targets' => array( - 'customers' => array(), - 'products' => array(), - ), - ) + 'message_targets' => [ + 'customers' => [], + 'products' => [], + ], + ] ); $broadcast = new Broadcast($broadcast_data); diff --git a/inc/functions/checkout-form.php b/inc/functions/checkout-form.php index 91818d0..b2f1129 100644 --- a/inc/functions/checkout-form.php +++ b/inc/functions/checkout-form.php @@ -33,7 +33,7 @@ function wu_get_checkout_form($checkout_form_id) { * @param array $query Query arguments. * @return \WP_Ultimo\Models\Checkout_Form[] */ -function wu_get_checkout_forms($query = array()) { +function wu_get_checkout_forms($query = []) { return \WP_Ultimo\Models\Checkout_Form::query($query); } @@ -96,14 +96,14 @@ function wu_create_checkout_form($checkout_form_data) { $checkout_form_data = wp_parse_args( $checkout_form_data, - array( + [ 'name' => false, 'slug' => false, - 'settings' => array(), - 'allowed_countries' => array(), + 'settings' => [], + 'allowed_countries' => [], 'date_created' => wu_get_current_time('mysql', true), 'date_modified' => wu_get_current_time('mysql', true), - ) + ] ); $checkout_form = new Checkout_Form($checkout_form_data); @@ -121,7 +121,7 @@ function wu_create_checkout_form($checkout_form_data) { */ function wu_get_available_domain_options() { - $fields = array(); + $fields = []; $main_form = wu_get_checkout_form_by_slug('main-form'); @@ -129,9 +129,9 @@ function wu_get_available_domain_options() { $fields = $main_form->get_all_fields_by_type('site_url'); } else { $forms = wu_get_checkout_forms( - array( + [ 'number' => 1, - ) + ] ); if ($forms) { @@ -139,11 +139,11 @@ function wu_get_available_domain_options() { } } - $domain_options = array(); + $domain_options = []; if ($fields) { foreach ($fields as $field) { - $available_domains = isset($field['available_domains']) ? $field['available_domains'] : ''; + $available_domains = $field['available_domains'] ?? ''; $field_domain_options = explode(PHP_EOL, (string) $available_domains); @@ -167,7 +167,7 @@ function wu_is_form_field_pre_selected($field_slug) { $checkout = Checkout::get_instance(); - $pre_selected = $checkout->request_or_session('pre_selected', array()); + $pre_selected = $checkout->request_or_session('pre_selected', []); $from_request = stripslashes_deep(wu_get_isset($_GET, $field_slug)) || isset($pre_selected[ $field_slug ]); diff --git a/inc/functions/checkout.php b/inc/functions/checkout.php index 166089a..3d41371 100644 --- a/inc/functions/checkout.php +++ b/inc/functions/checkout.php @@ -64,15 +64,15 @@ function wu_stripe_generate_idempotency_key($args, $context = 'new') { * @param array $fields List of signup field types. * @return array */ -function wu_create_checkout_fields($fields = array()) { +function wu_create_checkout_fields($fields = []) { $field_types = Signup_Fields_Manager::get_instance()->get_field_types(); - $actual_fields = array(); + $actual_fields = []; // Extra check to prevent error messages from being displayed. if ( ! is_array($fields)) { - $fields = array(); + $fields = []; } foreach ($fields as $field) { @@ -117,10 +117,10 @@ function wu_create_checkout_fields($fields = array()) { */ $field = wp_parse_args( $field, - array( + [ 'element_classes' => '', 'classes' => '', - ) + ] ); $field_array = $field_class->to_fields_array($field); @@ -290,7 +290,7 @@ function wu_register_field_template($field_type, $field_template_id, $field_temp 'wu_checkout_field_templates', function ($field_templates) use ($field_type, $field_template_id, $field_template_class_name) { - $field_templates_for_field_type = wu_get_isset($field_templates, $field_type, array()); + $field_templates_for_field_type = wu_get_isset($field_templates, $field_type, []); $field_templates_for_field_type[ $field_template_id ] = $field_template_class_name; diff --git a/inc/functions/color.php b/inc/functions/color.php index 5c964f1..1eeb93d 100644 --- a/inc/functions/color.php +++ b/inc/functions/color.php @@ -45,7 +45,7 @@ function wu_color($hex) { */ function wu_get_random_color($index) { - $colors = array( + $colors = [ 'wu-bg-red-500', 'wu-bg-green-500', 'wu-bg-blue-500', @@ -53,7 +53,7 @@ function wu_get_random_color($index) { 'wu-bg-orange-500', 'wu-bg-purple-500', 'wu-bg-pink-500', - ); + ]; - return wu_get_isset($colors, $index, $colors[ rand(0, count($colors) - 1) ]); + return wu_get_isset($colors, $index, $colors[ random_int(0, count($colors) - 1) ]); } diff --git a/inc/functions/countries.php b/inc/functions/countries.php index 8905a56..8c03251 100644 --- a/inc/functions/countries.php +++ b/inc/functions/countries.php @@ -19,7 +19,7 @@ function wu_get_countries() { return apply_filters( 'wu_get_countries', - array( + [ 'AF' => __('Afghanistan', 'wp-ultimo'), 'AX' => __('Åland Islands', 'wp-ultimo'), 'AL' => __('Albania', 'wp-ultimo'), @@ -269,7 +269,7 @@ function wu_get_countries() { 'YE' => __('Yemen', 'wp-ultimo'), 'ZM' => __('Zambia', 'wp-ultimo'), 'ZW' => __('Zimbabwe', 'wp-ultimo'), - ) + ] ); } @@ -282,9 +282,9 @@ function wu_get_countries() { function wu_get_countries_as_options() { return array_merge( - array( + [ '' => __('Select Country', 'wp-ultimo'), - ), + ], wu_get_countries() ); } @@ -299,7 +299,7 @@ function wu_get_countries_as_options() { * @param array $fallback_attributes Fallback attributes if the country class is not present. * @return \WP_Ultimo\Country\Country */ -function wu_get_country($country_code, $name = null, $fallback_attributes = array()) { +function wu_get_country($country_code, $name = null, $fallback_attributes = []) { $country_code = strtoupper($country_code); @@ -324,9 +324,9 @@ function wu_get_country($country_code, $name = null, $fallback_attributes = arra */ function wu_get_country_states($country_code, $key_name = 'id', $value_name = 'value') { - static $state_options = array(); + static $state_options = []; - $options = array(); + $options = []; $cache = wu_get_isset($state_options, $country_code, false); @@ -360,11 +360,11 @@ function wu_get_country_states($country_code, $key_name = 'id', $value_name = 'v */ function wu_get_country_cities($country_code, $states, $key_name = 'id', $value_name = 'value') { - static $city_options = array(); + static $city_options = []; $states = (array) $states; - $options = array(); + $options = []; foreach ($states as $state_code) { $cache = wu_get_isset($city_options, $state_code, false); @@ -441,7 +441,7 @@ function wu_get_countries_of_customers($count = 10, $start_date = false, $end_da $results = $wpdb->get_results($query); // phpcs:ignore - $countries = array(); + $countries = []; foreach ($results as $result) { $countries[ $result->country ] = $result->count; @@ -464,7 +464,7 @@ function wu_get_states_of_customers($country_code, $count = 100, $start_date = f global $wpdb; - static $states = array(); + static $states = []; $table_name = "{$wpdb->base_prefix}wu_customermeta"; $customer_table_name = "{$wpdb->base_prefix}wu_customers"; @@ -480,7 +480,7 @@ function wu_get_states_of_customers($country_code, $count = 100, $start_date = f $states = wu_get_country_states('BR', false); if (empty($states)) { - return array(); + return []; } $states_in = implode("','", array_keys($states)); @@ -501,10 +501,10 @@ function wu_get_states_of_customers($country_code, $count = 100, $start_date = f $results = $wpdb->get_results($query); // phpcs:ignore if (empty($results)) { - return array(); + return []; } - $_states = array(); + $_states = []; foreach ($results as $result) { $final_label = sprintf('%s (%s)', $states[ $result->state ], $result->state); diff --git a/inc/functions/currency.php b/inc/functions/currency.php index d5f9da8..4adfffe 100644 --- a/inc/functions/currency.php +++ b/inc/functions/currency.php @@ -18,7 +18,7 @@ function wu_get_currencies(): array { $currencies = apply_filters( 'wu_currencies', - array( + [ 'AED' => __('United Arab Emirates Dirham', 'wp-ultimo'), 'ARS' => __('Argentine Peso', 'wp-ultimo'), 'AUD' => __('Australian Dollars', 'wp-ultimo'), @@ -68,7 +68,7 @@ function wu_get_currencies(): array { 'USD' => __('US Dollars', 'wp-ultimo'), 'VND' => __('Vietnamese Dong', 'wp-ultimo'), 'EGP' => __('Egyptian Pound', 'wp-ultimo'), - ) + ] ); return array_unique($currencies); @@ -238,26 +238,26 @@ function wu_format_currency($value, $currency = null, $format = null, $thousands $value = wu_to_float($value); - $args = array( + $args = [ 'currency' => $currency, 'format' => $format, 'thousands_sep' => $thousands_sep, 'decimal_sep' => $decimal_sep, 'precision' => $precision, - ); + ]; // Remove invalid args $args = array_filter($args); $atts = wp_parse_args( $args, - array( + [ 'currency' => wu_get_setting('currency_symbol'), 'format' => wu_get_setting('currency_position'), 'thousands_sep' => wu_get_setting('thousand_separator'), 'decimal_sep' => wu_get_setting('decimal_separator'), 'precision' => (int) wu_get_setting('precision', 2), - ) + ] ); $currency_symbol = wu_get_currency_symbol($atts['currency']); @@ -280,7 +280,7 @@ function wu_format_currency($value, $currency = null, $format = null, $thousands */ function wu_is_zero_decimal_currency($currency = 'USD') { - $zero_dec_currencies = array( + $zero_dec_currencies = [ 'BIF', // Burundian Franc 'CLP', // Chilean Peso 'DJF', // Djiboutian Franc @@ -296,7 +296,7 @@ function wu_is_zero_decimal_currency($currency = 'USD') { 'XAF', // Central African CFA Franc 'XOF', // West African CFA Franc 'XPF', // CFP Franc - ); + ]; return apply_filters('wu_is_zero_decimal_currency', in_array($currency, $zero_dec_currencies, true)); } diff --git a/inc/functions/customer.php b/inc/functions/customer.php index b235d39..bc4f6ca 100644 --- a/inc/functions/customer.php +++ b/inc/functions/customer.php @@ -57,16 +57,16 @@ function wu_get_customer_by_hash($hash) { * @param array $query Query arguments. * @return \WP_Ultimo\Models\Customer[] */ -function wu_get_customers($query = array()) { +function wu_get_customers($query = []) { if ( ! empty($query['search'])) { $user_ids = get_users( - array( + [ 'blog_id' => 0, 'number' => -1, 'search' => '*' . $query['search'] . '*', 'fields' => 'ids', - ) + ] ); if ( ! empty($user_ids)) { @@ -120,7 +120,7 @@ function wu_create_customer($customer_data) { $customer_data = wp_parse_args( $customer_data, - array( + [ 'user_id' => false, 'email' => false, 'username' => false, @@ -128,13 +128,13 @@ function wu_create_customer($customer_data) { 'vip' => false, 'ip' => false, 'email_verification' => 'none', - 'meta' => array(), + 'meta' => [], 'date_registered' => wu_get_current_time('mysql', true), 'date_modified' => wu_get_current_time('mysql', true), 'last_login' => wu_get_current_time('mysql', true), 'signup_form' => 'by-admin', - 'billing_address' => array(), - ) + 'billing_address' => [], + ] ); $user = get_user_by('email', $customer_data['email']); @@ -166,7 +166,7 @@ function wu_create_customer($customer_data) { } $customer = new Customer( - array( + [ 'user_id' => $user_id, 'email_verification' => $customer_data['email_verification'], 'meta' => $customer_data['meta'], @@ -175,7 +175,7 @@ function wu_create_customer($customer_data) { 'billing_address' => $customer_data['billing_address'], 'last_login' => $customer_data['last_login'], 'type' => 'customer', - ) + ] ); $saved = $customer->save(); @@ -196,11 +196,11 @@ function wu_create_customer($customer_data) { */ function wu_get_customer_meta_types($form_slugs = false) { - $meta_keys = array(); + $meta_keys = []; - $query = array( + $query = [ 'number' => 99999, - ); + ]; if (is_array($form_slugs)) { $query['slug__in'] = (array) $form_slugs; @@ -212,7 +212,7 @@ function wu_get_customer_meta_types($form_slugs = false) { $customer_meta_fields = $form->get_all_meta_fields('customer_meta'); foreach ($customer_meta_fields as $customer_meta_field) { - $meta_keys[ $customer_meta_field['id'] ] = array( + $meta_keys[ $customer_meta_field['id'] ] = [ 'type' => $customer_meta_field['type'], 'title' => $customer_meta_field['name'], 'description' => wu_get_isset($customer_meta_field, 'description', ''), @@ -220,11 +220,11 @@ function wu_get_customer_meta_types($form_slugs = false) { 'default' => wu_get_isset($customer_meta_field, 'default', ''), 'id' => wu_get_isset($customer_meta_field, 'id', ''), 'step' => wu_get_isset($customer_meta_field, 'step', ''), - 'options' => wu_get_isset($customer_meta_field, 'options', array()), + 'options' => wu_get_isset($customer_meta_field, 'options', []), 'form' => $form->get_slug(), 'value' => '', 'exists' => false, - ); + ]; } } @@ -243,12 +243,12 @@ function wu_get_customer_meta_types($form_slugs = false) { */ function wu_get_all_customer_meta($customer_id, $include_unset = true) { - $all_meta = array(); + $all_meta = []; $customer = wu_get_customer($customer_id); if ($include_unset) { - $form_slugs = $customer ? array($customer->get_signup_form()) : false; + $form_slugs = $customer ? [$customer->get_signup_form()] : false; $all_meta = array_merge($all_meta, wu_get_customer_meta_types($form_slugs)); } @@ -323,16 +323,16 @@ function wu_update_customer_meta($customer_id, $key, $value, $type = null, $titl } if ($type) { - $custom_keys = $customer->get_meta('wu_custom_meta_keys', array()); + $custom_keys = $customer->get_meta('wu_custom_meta_keys', []); $custom_keys = array_merge( $custom_keys, - array( - $key => array( + [ + $key => [ 'type' => $type, 'title' => $title, - ), - ) + ], + ] ); $customer->update_meta('wu_custom_meta_keys', $custom_keys); @@ -358,7 +358,7 @@ function wu_delete_customer_meta($customer_id, $meta_key) { return false; } - $custom_keys = $customer->get_meta('wu_custom_meta_keys', array()); + $custom_keys = $customer->get_meta('wu_custom_meta_keys', []); if (isset($custom_keys[ $meta_key ])) { unset($custom_keys[ $meta_key ]); @@ -378,15 +378,15 @@ function wu_delete_customer_meta($customer_id, $meta_key) { * @param array $allowed_gateways The list of allowed gateways to search. * @return string */ -function wu_get_customer_gateway_id($customer_id, $allowed_gateways = array()) { +function wu_get_customer_gateway_id($customer_id, $allowed_gateways = []) { $memberships = wu_get_memberships( - array( + [ 'customer_id' => absint($customer_id), 'gateway__in' => $allowed_gateways, 'number' => 1, - 'gateway_customer_id__not_in' => array(''), - ) + 'gateway_customer_id__not_in' => [''], + ] ); return ! empty($memberships) ? $memberships[0]->get_gateway_customer_id() : ''; @@ -406,9 +406,9 @@ function wu_get_customer_gateway_id($customer_id, $allowed_gateways = array()) { * @param string $suffix Append string to username to make it unique. * @return string Generated username. */ -function wu_username_from_email($email, $new_user_args = array(), $suffix = '') { +function wu_username_from_email($email, $new_user_args = [], $suffix = '') { - $username_parts = array(); + $username_parts = []; if (isset($new_user_args['first_name'])) { $username_parts[] = sanitize_user($new_user_args['first_name'], true); @@ -426,13 +426,13 @@ function wu_username_from_email($email, $new_user_args = array(), $suffix = '') $email_parts = explode('@', $email); $email_username = $email_parts[0]; - $common_emails = array( + $common_emails = [ 'sales', 'hello', 'mail', 'contact', 'info', - ); + ]; // Exclude common prefixes. if (in_array($email_username, $common_emails, true)) { @@ -450,11 +450,11 @@ function wu_username_from_email($email, $new_user_args = array(), $suffix = '') $username .= $suffix; } - $illegal_logins = (array) apply_filters('illegal_user_logins', array()); // phpcs:ignore + $illegal_logins = (array) apply_filters('illegal_user_logins', []); // phpcs:ignore // Stop illegal logins and generate a new random username. if (in_array(strtolower($username), array_map('strtolower', $illegal_logins), true)) { - $new_args = array(); + $new_args = []; /** * Filter generated customer username. diff --git a/inc/functions/danger.php b/inc/functions/danger.php index 93f8b08..acc39ae 100644 --- a/inc/functions/danger.php +++ b/inc/functions/danger.php @@ -20,10 +20,10 @@ function wu_drop_tables() { $tables = apply_filters('wu_drop_tables', \WP_Ultimo\Loaders\Table_Loader::get_instance()->get_tables()); - $except = array( + $except = [ 'blogs', 'blogmeta', - ); + ]; $except = apply_filters('wu_drop_tables_except', $except); diff --git a/inc/functions/date.php b/inc/functions/date.php index 973d705..cd55995 100644 --- a/inc/functions/date.php +++ b/inc/functions/date.php @@ -167,7 +167,7 @@ function wu_human_time_diff($from, $limit = '-5 days', $to = false): string { */ function wu_convert_php_date_format_to_moment_js_format($php_date_format): string { - $replacements = array( + $replacements = [ 'A' => 'A', // for the sake of escaping below 'a' => 'a', // for the sake of escaping below 'B' => '', // Swatch internet time (.beats), no equivalent @@ -206,7 +206,7 @@ function wu_convert_php_date_format_to_moment_js_format($php_date_format): strin 'y' => 'YY', 'Z' => '', // time zone offset in minutes => moment().zone(); 'z' => 'DDD', - ); + ]; // Converts escaped characters. foreach ($replacements as $from => $to) { diff --git a/inc/functions/discount-code.php b/inc/functions/discount-code.php index 5f81ff8..abe0d6c 100644 --- a/inc/functions/discount-code.php +++ b/inc/functions/discount-code.php @@ -44,7 +44,7 @@ function wu_get_discount_code($discount_code_id) { * @param array $query Query arguments. * @return \WP_Ultimo\Models\Discount_Code[] */ -function wu_get_discount_codes($query = array()) { +function wu_get_discount_codes($query = []) { return \WP_Ultimo\Models\Discount_Code::query($query); } @@ -87,7 +87,7 @@ function wu_create_discount_code($discount_code_data) { $discount_code_data = wp_parse_args( $discount_code_data, - array( + [ 'max_uses' => true, 'name' => false, 'code' => false, @@ -99,7 +99,7 @@ function wu_create_discount_code($discount_code_data) { 'date_created' => wu_get_current_time('mysql', true), 'date_modified' => wu_get_current_time('mysql', true), 'skip_validation' => false, - ) + ] ); $discount_code = new Discount_Code($discount_code_data); diff --git a/inc/functions/domain.php b/inc/functions/domain.php index 60370e3..4afae31 100644 --- a/inc/functions/domain.php +++ b/inc/functions/domain.php @@ -32,7 +32,7 @@ function wu_get_domain($domain_id) { * @param array $query Query arguments. * @return \WP_Ultimo\Models\Domain[] */ -function wu_get_domains($query = array()) { +function wu_get_domains($query = []) { return \WP_Ultimo\Models\Domain::query($query); } @@ -62,7 +62,7 @@ function wu_create_domain($domain_data) { $domain_data = wp_parse_args( $domain_data, - array( + [ 'blog_id' => false, 'domain' => false, 'active' => true, @@ -71,7 +71,7 @@ function wu_create_domain($domain_data) { 'stage' => 'checking-dns', 'date_created' => wu_get_current_time('mysql', true), 'date_modified' => wu_get_current_time('mysql', true), - ) + ] ); $domain = new Domain($domain_data); @@ -85,7 +85,7 @@ function wu_create_domain($domain_data) { /* * Add the processing. */ - wu_enqueue_async_action('wu_async_process_domain_stage', array('domain_id' => $domain->get_id()), 'domain'); + wu_enqueue_async_action('wu_async_process_domain_stage', ['domain_id' => $domain->get_id()], 'domain'); return $domain; } diff --git a/inc/functions/email.php b/inc/functions/email.php index 9d24729..b916dd5 100644 --- a/inc/functions/email.php +++ b/inc/functions/email.php @@ -48,17 +48,17 @@ function wu_get_email_by($column, $value) { * @param array $query Query arguments. * @return Email[] */ -function wu_get_emails($query = array()) { +function wu_get_emails($query = []) { - $query['type__in'] = array('system_email'); + $query['type__in'] = ['system_email']; if (wu_get_isset($query, 'event')) { - $query['meta_query'] = array( - 'event_query' => array( + $query['meta_query'] = [ + 'event_query' => [ 'key' => 'wu_system_email_event', 'value' => wu_get_isset($query, 'event'), - ), - ); + ], + ]; } return Email::query($query); @@ -74,10 +74,10 @@ function wu_get_emails($query = array()) { function wu_get_all_system_emails() { return Email::query( - array( - 'status__in' => array('draft', 'publish'), - 'type__in' => array('system_email'), - ) + [ + 'status__in' => ['draft', 'publish'], + 'type__in' => ['system_email'], + ] ); } @@ -119,7 +119,7 @@ function wu_create_default_system_email($slug) { * @param array $args With content, subject and other arguments, has shortcodes, mail type. * @return array */ -function wu_send_mail($from = array(), $to = array(), $args = array()) { +function wu_send_mail($from = [], $to = [], $args = []) { return Sender::send_mail($from, $to, $args); } @@ -154,7 +154,7 @@ function wu_create_email($email_data) { $email_data = wp_parse_args( $email_data, - array( + [ 'type' => 'system_email', 'event' => 'Laborum consectetur', 'title' => 'Lorem Ipsum', @@ -162,7 +162,7 @@ function wu_create_email($email_data) { 'target' => 'admin', 'date_created' => wu_get_current_time('mysql', true), 'date_modified' => wu_get_current_time('mysql', true), - ) + ] ); $email = new Email($email_data); diff --git a/inc/functions/event.php b/inc/functions/event.php index 5c0812b..e3ae64e 100644 --- a/inc/functions/event.php +++ b/inc/functions/event.php @@ -91,7 +91,7 @@ function wu_get_event_type($slug) { * @param array $query Query arguments. * @return \WP_Ultimo\Models\Event[] */ -function wu_get_events($query = array()) { +function wu_get_events($query = []) { return \WP_Ultimo\Models\Event::query($query); } @@ -135,19 +135,19 @@ function wu_create_event($event_data) { $event_data = wp_parse_args( $event_data, - array( + [ 'severity' => Event::SEVERITY_NEUTRAL, 'initiator' => 'system', 'author_id' => $author_id, 'object_type' => 'network', 'object_id' => 0, 'date_created' => wu_get_current_time('mysql', true), - 'payload' => array( + 'payload' => [ 'key' => 'None', 'old_value' => 'None', 'new_value' => 'None', - ), - ) + ], + ] ); $event = new Event($event_data); @@ -170,7 +170,7 @@ function wu_create_event($event_data) { */ function wu_generate_event_payload($model_name, $model = false): array { - $payload = array(); + $payload = []; if ( ! $model) { switch ($model_name) { @@ -195,14 +195,14 @@ function wu_generate_event_payload($model_name, $model = false): array { } if ( ! $model) { - return array(); + return []; } } if ($model_name === 'customer') { $payload = $model->to_search_results(); - $payload = array( + $payload = [ 'customer_id' => $payload['id'], 'customer_name' => $payload['display_name'], 'customer_user_id' => $payload['user_id'], @@ -212,17 +212,17 @@ function wu_generate_event_payload($model_name, $model = false): array { 'customer_billing_address' => $payload['billing_address'], 'customer_manage_url' => wu_network_admin_url( 'wp-ultimo-edit-customer', - array( + [ 'id' => $model->get_id(), - ) + ] ), - ); + ]; } elseif ($model_name === 'membership') { $payload = $model->to_search_results(); $p = $payload; - $payload = array( + $payload = [ 'membership_id' => $p['id'], 'membership_status' => $p['status'], 'membership_reference_code' => $p['reference_code'], @@ -236,15 +236,15 @@ function wu_generate_event_payload($model_name, $model = false): array { 'membership_date_expiration' => $p['date_expiration'], 'membership_manage_url' => wu_network_admin_url( 'wp-ultimo-edit-membership', - array( + [ 'id' => $model->get_id(), - ) + ] ), - ); + ]; } elseif ($model_name === 'product') { $payload = $model->to_search_results(); - $payload = array( + $payload = [ 'product_id' => $payload['id'], 'product_amount' => wu_format_currency($payload['amount'], $payload['currency']), 'product_amount_raw' => $payload['amount'], @@ -255,15 +255,15 @@ function wu_generate_event_payload($model_name, $model = false): array { 'product_image' => $payload['image'], 'product_manage_url' => wu_network_admin_url( 'wp-ultimo-edit-payment', - array( + [ 'id' => $model->get_id(), - ) + ] ), - ); + ]; } elseif ($model_name === 'payment') { $payload = $model->to_search_results(); - $payload = array( + $payload = [ 'payment_id' => $payload['id'], 'payment_status' => $payload['status'], 'payment_reference_code' => $payload['reference_code'], @@ -280,15 +280,15 @@ function wu_generate_event_payload($model_name, $model = false): array { 'payment_invoice_url' => $model->get_invoice_url(), 'payment_manage_url' => wu_network_admin_url( 'wp-ultimo-edit-payment', - array( + [ 'id' => $model->get_id(), - ) + ] ), - ); + ]; } elseif ($model_name === 'site') { $payload = $model->to_search_results(); - $payload = array( + $payload = [ 'site_id' => $payload['blog_id'], 'site_title' => $payload['title'], 'site_description' => $payload['description'], @@ -296,15 +296,15 @@ function wu_generate_event_payload($model_name, $model = false): array { 'site_admin_url' => get_admin_url($model->get_id()), 'site_manage_url' => wu_network_admin_url( 'wp-ultimo-edit-site', - array( + [ 'id' => $model->get_id(), - ) + ] ), - ); + ]; } elseif ($model_name === 'domain') { $payload = $model->to_search_results(); - $payload = array( + $payload = [ 'domain_id' => $payload['id'], 'domain_domain' => $payload['domain'], 'domain_site_id' => $payload['blog_id'], @@ -315,11 +315,11 @@ function wu_generate_event_payload($model_name, $model = false): array { 'domain_date_created' => $payload['date_created'], 'domain_manage_url' => wu_network_admin_url( 'wp-ultimo-edit-domain', - array( + [ 'id' => $model->get_id(), - ) + ] ), - ); + ]; } return $payload; diff --git a/inc/functions/financial.php b/inc/functions/financial.php index 7c4907a..f300ca5 100644 --- a/inc/functions/financial.php +++ b/inc/functions/financial.php @@ -23,12 +23,12 @@ function wu_calculate_mrr() { $total_mrr = 0; $memberships = wu_get_memberships( - array( + [ 'recurring' => true, - 'status__in' => array( + 'status__in' => [ Membership_Status::ACTIVE, - ), - ) + ], + ] ); foreach ($memberships as $membership) { @@ -38,7 +38,7 @@ function wu_calculate_mrr() { continue; } - $duration = $membership->get_duration() ? $membership->get_duration() : 1; + $duration = $membership->get_duration() ?: 1; $duration_unit = $membership->get_duration_unit(); @@ -113,14 +113,14 @@ function wu_calculate_revenue($start_date = false, $end_date = false, $inclusive $total_revenue = 0; - $query_args = array( - 'fields' => array('total'), - 'date_query' => array(), - 'status__in' => array( + $query_args = [ + 'fields' => ['total'], + 'date_query' => [], + 'status__in' => [ Payment_Status::COMPLETED, Payment_Status::PARTIAL, - ), - ); + ], + ]; if ($start_date) { $query_args['date_query']['column'] = 'date_created'; @@ -157,14 +157,14 @@ function wu_calculate_refunds($start_date = false, $end_date = false, $inclusive $total_revenue = 0; - $query_args = array( - 'fields' => array('refund_total'), - 'date_query' => array(), - 'status__in' => array( + $query_args = [ + 'fields' => ['refund_total'], + 'date_query' => [], + 'status__in' => [ Payment_Status::REFUND, Payment_Status::PARTIAL_REFUND, - ), - ); + ], + ]; if ($start_date) { $query_args['date_query']['column'] = 'date_created'; @@ -199,9 +199,9 @@ function wu_calculate_refunds($start_date = false, $end_date = false, $inclusive */ function wu_calculate_taxes_by_rate($start_date = false, $end_date = false, $inclusive = true) { - $query_args = array( - 'date_query' => array(), - ); + $query_args = [ + 'date_query' => [], + ]; if ($start_date) { $query_args['date_query']['after'] = $start_date; @@ -215,7 +215,7 @@ function wu_calculate_taxes_by_rate($start_date = false, $end_date = false, $inc $order = 0; - $taxes_paid_list = array(); + $taxes_paid_list = []; $line_items_groups = \WP_Ultimo\Checkout\Line_Item::get_line_items($query_args); @@ -230,14 +230,14 @@ function wu_calculate_taxes_by_rate($start_date = false, $end_date = false, $inc } if ( ! wu_get_isset($taxes_paid_list, $tax_name)) { - $taxes_paid_list[ $tax_name ] = array( + $taxes_paid_list[ $tax_name ] = [ 'title' => $tax_name, 'country' => '', 'state' => '', 'order_count' => $order, 'tax_rate' => $line_item->get_tax_rate(), 'tax_total' => $line_item->get_tax_total(), - ); + ]; } else { $taxes_paid_list[ $tax_name ]['tax_total'] += $line_item->get_tax_total(); $taxes_paid_list[ $tax_name ]['order_count'] += $order; @@ -260,10 +260,10 @@ function wu_calculate_taxes_by_rate($start_date = false, $end_date = false, $inc */ function wu_calculate_financial_data_by_product($start_date = false, $end_date = false, $inclusive = true) { - $query_args = array( - 'date_query' => array(), + $query_args = [ + 'date_query' => [], 'payment_status' => Payment_Status::COMPLETED, - ); + ]; if ($start_date) { $query_args['date_query']['after'] = $start_date; @@ -277,15 +277,15 @@ function wu_calculate_financial_data_by_product($start_date = false, $end_date = $line_items_groups = \WP_Ultimo\Checkout\Line_Item::get_line_items($query_args); - $data = array(); + $data = []; $products = wu_get_products(); foreach ($products as $product) { - $data[ $product->get_id() ] = array( + $data[ $product->get_id() ] = [ 'label' => $product->get_name(), 'revenue' => 0, - ); + ]; } foreach ($line_items_groups as $line_items_group) { @@ -321,9 +321,9 @@ function wu_calculate_financial_data_by_product($start_date = false, $end_date = */ function wu_calculate_taxes_by_day($start_date = false, $end_date = false, $inclusive = true) { - $query_args = array( - 'date_query' => array(), - ); + $query_args = [ + 'date_query' => [], + ]; if ($start_date) { $query_args['date_query']['after'] = $start_date; @@ -337,7 +337,7 @@ function wu_calculate_taxes_by_day($start_date = false, $end_date = false, $incl $line_items_groups = \WP_Ultimo\Checkout\Line_Item::get_line_items($query_args); - $data = array(); + $data = []; $period = new \DatePeriod( new \DateTime($start_date), @@ -348,12 +348,12 @@ function wu_calculate_taxes_by_day($start_date = false, $end_date = false, $incl $days = array_reverse(iterator_to_array($period)); foreach ($days as $day_datetime) { - $data[ $day_datetime->format('Y-m-d') ] = array( + $data[ $day_datetime->format('Y-m-d') ] = [ 'order_count' => 0, 'total' => 0, 'tax_total' => 0, 'net_profit' => 0, - ); + ]; } foreach ($line_items_groups as $line_items_group) { @@ -361,12 +361,12 @@ function wu_calculate_taxes_by_day($start_date = false, $end_date = false, $incl $date = gmdate('Y-m-d', strtotime((string) $line_item->date_created)); if ( ! wu_get_isset($data, $date)) { - $data[ $date ] = array( + $data[ $date ] = [ 'order_count' => 0, 'total' => $line_item->get_total(), 'tax_total' => $line_item->get_tax_total(), 'net_profit' => $line_item->get_total() - $line_item->get_tax_total(), - ); + ]; } else { $data[ $date ]['order_count'] += 1; $data[ $date ]['total'] += $line_item->get_total(); @@ -393,17 +393,17 @@ function wu_calculate_taxes_by_month() { return $cache; } - $query_args = array( - 'date_query' => array( + $query_args = [ + 'date_query' => [ 'after' => 'first day of January this year', 'before' => 'last day of December this year', 'inclusive' => true, - ), - ); + ], + ]; $line_items_groups = \WP_Ultimo\Checkout\Line_Item::get_line_items($query_args); - $data = array(); + $data = []; $period = new \DatePeriod( new \DateTime($query_args['date_query']['after']), @@ -414,12 +414,12 @@ function wu_calculate_taxes_by_month() { $months = iterator_to_array($period); foreach ($months as $month_datetime) { - $data[ $month_datetime->format('n') ] = array( + $data[ $month_datetime->format('n') ] = [ 'order_count' => 0, 'total' => 0, 'tax_total' => 0, 'net_profit' => 0, - ); + ]; } foreach ($line_items_groups as $line_items_group) { @@ -427,12 +427,12 @@ function wu_calculate_taxes_by_month() { $date = gmdate('n', strtotime((string) $line_item->date_created)); if ( ! wu_get_isset($data, $date)) { - $data[ $date ] = array( + $data[ $date ] = [ 'order_count' => 0, 'total' => $line_item->get_total(), 'tax_total' => $line_item->get_tax_total(), 'net_profit' => $line_item->get_total() - $line_item->get_tax_total(), - ); + ]; } else { $data[ $date ]['order_count'] += 1; $data[ $date ]['total'] += $line_item->get_total(); @@ -461,9 +461,9 @@ function wu_calculate_signups_by_form($start_date = false, $end_date = false, $i global $wpdb; - $query = array( - 'date_query' => array(), - ); + $query = [ + 'date_query' => [], + ]; if ($start_date) { $query['date_query']['after'] = $start_date; diff --git a/inc/functions/form.php b/inc/functions/form.php index 8b21080..60572af 100644 --- a/inc/functions/form.php +++ b/inc/functions/form.php @@ -25,7 +25,7 @@ use WP_Ultimo\Managers\Form_Manager; * @param array $atts Form attributes, check wp_parse_atts call below. * @return mixed */ -function wu_register_form($form_id, $atts = array()) { +function wu_register_form($form_id, $atts = []) { return Form_Manager::get_instance()->register_form($form_id, $atts); } @@ -41,16 +41,16 @@ function wu_register_form($form_id, $atts = array()) { * @param boolean $inline If this form is has content. * @return string */ -function wu_get_form_url($form_id, $atts = array(), $inline = false) { +function wu_get_form_url($form_id, $atts = [], $inline = false) { if ($inline) { $atts = wp_parse_args( $atts, - array( + [ 'inlineId' => $form_id, 'width' => '400', 'height' => '360', - ) + ] ); // TB_inline?height=300&width=300&inlineId=wu-add-field diff --git a/inc/functions/gateway.php b/inc/functions/gateway.php index 675cf99..24cdacc 100644 --- a/inc/functions/gateway.php +++ b/inc/functions/gateway.php @@ -52,9 +52,9 @@ function wu_get_gateways() { */ function wu_get_active_gateways() { - $gateways = array(); + $gateways = []; - $active_gateways = (array) wu_get_setting('active_gateways', array()); + $active_gateways = (array) wu_get_setting('active_gateways', []); foreach ($active_gateways as $active_gateway) { if (Gateway_Manager::get_instance()->is_gateway_registered($active_gateway)) { @@ -95,7 +95,7 @@ function wu_get_gateway($id, $subscription = null) { */ function wu_get_gateway_as_options() { - $options = array(); + $options = []; foreach (wu_get_gateways() as $gateway_slug => $gateway) { $instance = class_exists($gateway['class_name']) ? new $gateway['class_name']() : false; @@ -118,7 +118,7 @@ function wu_get_gateway_as_options() { */ function wu_get_active_gateway_as_options() { - $options = array(); + $options = []; foreach (wu_get_active_gateways() as $gateway_slug => $gateway) { $instance = class_exists($gateway['class_name']) ? new $gateway['class_name']() : false; diff --git a/inc/functions/generator.php b/inc/functions/generator.php index 81f533e..3c70fbf 100644 --- a/inc/functions/generator.php +++ b/inc/functions/generator.php @@ -16,7 +16,7 @@ defined('ABSPATH') || exit; * @param array $data Content. * @return void */ -function wu_generate_csv($file_name, $data = array()) { +function wu_generate_csv($file_name, $data = []) { $fp = fopen('php://output', 'w'); diff --git a/inc/functions/helper.php b/inc/functions/helper.php index 57093fc..96f8b5c 100644 --- a/inc/functions/helper.php +++ b/inc/functions/helper.php @@ -69,7 +69,7 @@ function wu_get_isset($array, $key, $default = false) { $array = (array) $array; } - return isset($array[ $key ]) ? $array[ $key ] : $default; + return $array[ $key ] ?? $default; } /** @@ -251,7 +251,7 @@ function wu_get_function_caller($depth = 1) { $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, $depth + 1); - $caller = isset($backtrace[ $depth ]['function']) ? $backtrace[ $depth ]['function'] : null; + $caller = $backtrace[ $depth ]['function'] ?? null; return $caller; } diff --git a/inc/functions/legacy.php b/inc/functions/legacy.php index e51cc40..3dc9c17 100644 --- a/inc/functions/legacy.php +++ b/inc/functions/legacy.php @@ -54,7 +54,7 @@ if (!function_exists('validate_user_form')) { * @param array $attributes * @return void */ -function wu_create_html_attributes_from_array($attributes = array()) { +function wu_create_html_attributes_from_array($attributes = []) { $output = ''; @@ -80,7 +80,7 @@ function wu_create_html_attributes_from_array($attributes = array()) { * @param string $option_label * @return void */ -function wu_print_signup_field_option($option_value, $option_label, $field = array()) { ?> +function wu_print_signup_field_option($option_value, $option_label, $field = []) { ?> @@ -94,7 +94,7 @@ function wu_print_signup_field_option($option_value, $option_label, $field = arr * @param array $options * @return void */ -function wu_print_signup_field_options($options, $field = array()) { +function wu_print_signup_field_options($options, $field = []) { foreach ($options as $option_value => $option_label) { @@ -246,7 +246,7 @@ function wu_print_signup_field($field_slug, $field, $results) {

id="-field" style="" > + type="" name="" id="" class="input" value="" size="20"> min; - wp_enqueue_script('wu-password-verify', WP_Ultimo()->get_asset("wu-password-verify$suffix.js", 'js'), array('jquery'), true); + wp_enqueue_script('wu-password-verify', WP_Ultimo()->get_asset("wu-password-verify$suffix.js", 'js'), ['jquery'], true); ?> @@ -296,7 +296,7 @@ function wu_print_signup_field($field_slug, $field, $results) { + type="" name="" id="" class="input" value="" size="20"> @@ -356,7 +356,7 @@ function wu_print_signup_field($field_slug, $field, $results) {

\s*<(div|aside|section|article|header|footer)#', '#\s*

#', '#\s*
#', '#<(div|aside|section|article|header|footer)(.*?)>\s*

#', '#

\s*', '', '<$1$2>', ' $key . '="' . htmlspecialchars((string) $value) . '"', array_keys($attributes), $attributes); @@ -148,9 +148,9 @@ function wu_preview_image($image_url, $label = false): string { */ function wu_get_icons_list() { - $all_icons = array(); + $all_icons = []; - $all_icons['WP Ultimo Icons'] = array( + $all_icons['WP Ultimo Icons'] = [ 'dashicons-wu-add_task', 'dashicons-wu-address', 'dashicons-wu-add-to-list', @@ -487,9 +487,9 @@ function wu_get_icons_list() { 'dashicons-wu-wallet', 'dashicons-wu-warning', 'dashicons-wu-wp-ultimo', - ); + ]; - $all_icons['Dashicons'] = array( + $all_icons['Dashicons'] = [ 'dashicons-before dashicons-admin-appearance', 'dashicons-before dashicons-admin-collapse', 'dashicons-before dashicons-admin-comments', @@ -744,7 +744,7 @@ function wu_get_icons_list() { 'dashicons-before dashicons-wordpress', 'dashicons-before dashicons-yes-alt', 'dashicons-before dashicons-yes', - ); + ]; return apply_filters('wu_icons_list', $all_icons); } diff --git a/inc/functions/membership.php b/inc/functions/membership.php index 1e0961d..ca32deb 100644 --- a/inc/functions/membership.php +++ b/inc/functions/membership.php @@ -60,14 +60,14 @@ function wu_get_membership_by_hash($hash) { * @param array $query Query arguments. * @return Membership[] */ -function wu_get_memberships($query = array()) { +function wu_get_memberships($query = []) { if ( ! empty($query['search'])) { $customer_ids = wu_get_customers( - array( + [ 'search' => $query['search'], 'fields' => 'ids', - ) + ] ); if ( ! empty($customer_ids)) { @@ -93,7 +93,7 @@ function wu_create_membership($membership_data) { * Shortcode atts clean the array from not-allowed keys, so we don't need to worry much. */ $membership_data = shortcode_atts( - array( + [ 'customer_id' => false, 'user_id' => false, 'migrated_from_id' => 0, @@ -122,7 +122,7 @@ function wu_create_membership($membership_data) { 'date_modified' => wu_get_current_time('mysql', true), 'date_expiration' => wu_get_current_time('mysql', true), 'skip_validation' => false, - ), + ], $membership_data ); @@ -184,16 +184,16 @@ function wu_get_membership_customers($product_id) { * @param boolean $amount The amount. Increases accuracy. * @return \WP_Ultimo\Models\Membership|false */ -function wu_get_membership_by_customer_gateway_id($customer_gateway_id, $allowed_gateways = array(), $amount = false) { +function wu_get_membership_by_customer_gateway_id($customer_gateway_id, $allowed_gateways = [], $amount = false) { - $search_data = array( + $search_data = [ 'gateway__in' => $allowed_gateways, 'number' => 1, - 'gateway_customer_id__in' => array($customer_gateway_id), - 'status__in' => array('pending'), + 'gateway_customer_id__in' => [$customer_gateway_id], + 'status__in' => ['pending'], 'orderby' => 'id', 'order' => 'DESC', - ); + ]; if ( ! empty($amount)) { $search_data['initial_amount'] = $amount; @@ -222,13 +222,13 @@ function wu_get_membership_product_price($membership, $product_id, $quantity, $o // Create a Cart with this product $cart = new Cart( - array( + [ 'duration' => $membership->get_duration(), 'duration_unit' => $membership->get_duration_unit(), 'country' => $address->billing_country, 'state' => $address->billing_state, 'city' => $address->billing_city, - ) + ] ); $discount_code = $membership->get_discount_code(); @@ -245,11 +245,11 @@ function wu_get_membership_product_price($membership, $product_id, $quantity, $o $payment_data = array_merge( $cart->to_payment_data(), - array( + [ 'customer_id' => $membership->get_customer_id(), 'membership_id' => $membership->get_id(), 'gateway' => $membership->get_gateway(), - ) + ] ); // create a temporary payment to see the price. @@ -301,11 +301,11 @@ function wu_membership_create_new_payment($membership, $should_cancel_pending_pa $payment_data = array_merge( $cart->to_payment_data(), - array( + [ 'customer_id' => $membership->get_customer_id(), 'membership_id' => $membership->get_id(), 'gateway' => $membership->get_gateway(), - ) + ] ); // We will save the payment after we recalculate the totals. @@ -347,13 +347,13 @@ function wu_get_membership_new_cart($membership) { $address = $membership->get_billing_address(); $cart = new Cart( - array( + [ 'duration' => $membership->get_duration(), 'duration_unit' => $membership->get_duration_unit(), 'country' => $address->billing_country, 'state' => $address->billing_state, 'city' => $address->billing_city, - ) + ] ); $discount_code = $membership->get_discount_code(); @@ -371,7 +371,7 @@ function wu_get_membership_new_cart($membership) { if (round(abs($difference), wu_currency_decimal_filter()) > 0) { $type_translate = $difference < 0 ? __('credit', 'wp-ultimo') : __('debit', 'wp-ultimo'); - $line_item_params = array( + $line_item_params = [ 'hash' => 'ADJUSTMENT', 'type' => $difference < 0 ? 'credit' : 'fee', // translators: %s is the type of adjustment (credit or debit). @@ -384,7 +384,7 @@ function wu_get_membership_new_cart($membership) { 'quantity' => 1, 'duration' => $membership->get_duration(), 'duration_unit' => $membership->get_duration_unit(), - ); + ]; $adjustment_line_item = new \WP_Ultimo\Checkout\Line_Item($line_item_params); @@ -398,7 +398,7 @@ function wu_get_membership_new_cart($membership) { $difference = $membership->get_initial_amount() - $cart->get_total(); $type_translate = $difference < 0 ? __('credit', 'wp-ultimo') : __('debit', 'wp-ultimo'); - $line_item_params = array( + $line_item_params = [ 'hash' => 'INITADJUSTMENT', 'type' => $difference < 0 ? 'credit' : 'fee', // translators: %s is the type of adjustment (credit or debit). @@ -409,7 +409,7 @@ function wu_get_membership_new_cart($membership) { 'taxable' => false, 'recurring' => false, 'quantity' => 1, - ); + ]; $adjustment_line_item = new \WP_Ultimo\Checkout\Line_Item($line_item_params); @@ -440,9 +440,9 @@ function wu_get_membership_update_url($membership) { if ($url) { return add_query_arg( - array( + [ 'membership' => $membership_hash, - ), + ], $url ); } @@ -455,10 +455,10 @@ function wu_get_membership_update_url($membership) { if (count($sites) > 0) { return add_query_arg( - array( + [ 'page' => 'wu-checkout', 'membership' => $membership_hash, - ), + ], get_admin_url($sites[0]->get_id()) ); } @@ -467,10 +467,10 @@ function wu_get_membership_update_url($membership) { $url = $checkout_pages->get_page_url('register'); return add_query_arg( - array( + [ 'membership' => $membership_hash, 'wu_form' => 'wu-checkout', - ), + ], $url ); } diff --git a/inc/functions/mock.php b/inc/functions/mock.php index 5bb8f15..6213d40 100644 --- a/inc/functions/mock.php +++ b/inc/functions/mock.php @@ -20,12 +20,12 @@ function wu_mock_site($seed = false) { $atts = apply_filters( 'wu_mock_site', - array( + [ 'title' => __('Example Site', 'wp-ultimo'), 'description' => __('This is an example of a site description.', 'wp-ultimo'), 'domain' => __('examplesite.dev', 'wp-ultimo'), 'path' => '/', - ) + ] ); if ($seed) { @@ -45,14 +45,14 @@ function wu_mock_site($seed = false) { function wu_mock_membership() { return new \WP_Ultimo\Models\Membership( - array( + [ 'billing_address' => new \WP_Ultimo\Objects\Billing_Address( - array( + [ 'company_name' => 'Company Co.', 'billing_email' => 'company@co.dev', - ) + ] ), - ) + ] ); } @@ -65,9 +65,9 @@ function wu_mock_membership() { function wu_mock_product() { $product = new \WP_Ultimo\Models\Product( - array( + [ 'name' => __('Test Product', 'wp-ultimo'), - ) + ] ); $product->_mocked = true; @@ -84,18 +84,18 @@ function wu_mock_product() { function wu_mock_customer() { $customer = new \WP_Ultimo\Models\Customer( - array( + [ 'billing_address' => new \WP_Ultimo\Objects\Billing_Address( - array( + [ 'company_name' => 'Company Co.', 'billing_email' => 'company@co.dev', - ) + ] ), - ) + ] ); - $customer->_user = (object) array( - 'data' => (object) array( + $customer->_user = (object) [ + 'data' => (object) [ 'ID' => '1', 'user_login' => 'mockeduser', 'user_pass' => 'passwordhash', @@ -108,8 +108,8 @@ function wu_mock_customer() { 'display_name' => 'John McMocked', 'spam' => '0', 'deleted' => '0', - ), - ); + ], + ]; return $customer; } @@ -125,15 +125,15 @@ function wu_mock_payment() { $payment = new \WP_Ultimo\Models\Payment(); $line_item = new \WP_Ultimo\Checkout\Line_Item( - array( + [ 'product' => wu_mock_product(), - ) + ] ); $payment->set_line_items( - array( + [ $line_item, - ) + ] ); return $payment; @@ -148,14 +148,14 @@ function wu_mock_payment() { function wu_mock_domain() { $domain = new \WP_Ultimo\Models\Domain( - array( + [ 'blog_id' => 1, 'domain' => 'example.com', 'active' => true, 'primary_domain' => true, 'secure' => true, 'stage' => 'checking-dns', - ) + ] ); return $domain; diff --git a/inc/functions/model.php b/inc/functions/model.php index f996268..bfac1dd 100644 --- a/inc/functions/model.php +++ b/inc/functions/model.php @@ -37,10 +37,10 @@ function wu_cast_model_to_array($model) { */ function wu_models_to_options($models, $label_field = 'name') { - $options_list = array(); + $options_list = []; foreach ($models as $model) { - $options_list[ $model->get_id() ] = call_user_func(array($model, "get_{$label_field}")); + $options_list[ $model->get_id() ] = call_user_func([$model, "get_{$label_field}"]); } return $options_list; @@ -56,7 +56,7 @@ function wu_models_to_options($models, $label_field = 'name') { */ function wu_model_get_schema($class_name) { - $schema = array(); + $schema = []; if (method_exists($class_name, 'get_schema')) { $schema = $class_name::get_schema(); @@ -75,13 +75,13 @@ function wu_model_get_schema($class_name) { */ function wu_model_get_required_fields($class_name) { - $required_fields = array(); + $required_fields = []; if (method_exists($class_name, 'validation_rules')) { $validation_rules = (new $class_name())->validation_rules(); foreach ($validation_rules as $field => $validation_rule) { - if (strpos((string) $validation_rule, 'required|') !== false || $validation_rule === 'required') { + if (str_contains((string) $validation_rule, 'required|') || $validation_rule === 'required') { $required_fields[] = $field; } } diff --git a/inc/functions/number-helpers.php b/inc/functions/number-helpers.php index 7702442..f8d83f0 100644 --- a/inc/functions/number-helpers.php +++ b/inc/functions/number-helpers.php @@ -19,7 +19,7 @@ defined('ABSPATH') || exit; */ function wu_extract_number($str) { - $matches = array(); + $matches = []; preg_match_all('/\d+/', $str, $matches); diff --git a/inc/functions/options.php b/inc/functions/options.php index ad36182..870ddab 100644 --- a/inc/functions/options.php +++ b/inc/functions/options.php @@ -17,7 +17,7 @@ defined('ABSPATH') || exit; * @param mixed $default The default value. * @return mixed */ -function wu_get_option($option_name = 'settings', $default = array()) { +function wu_get_option($option_name = 'settings', $default = []) { $option_value = get_network_option(null, wu_slugify($option_name), $default); diff --git a/inc/functions/payment.php b/inc/functions/payment.php index 7e34752..96946b5 100644 --- a/inc/functions/payment.php +++ b/inc/functions/payment.php @@ -33,7 +33,7 @@ function wu_get_payment($payment_id) { * @param array $query Query arguments. * @return \WP_Ultimo\Models\Payment[] */ -function wu_get_payments($query = array()) { +function wu_get_payments($query = []) { return \WP_Ultimo\Models\Payment::query($query); } @@ -99,9 +99,9 @@ function wu_create_payment($payment_data, $save = true) { * Shortcode atts clean the array from not-allowed keys, so we don't need to worry much. */ $payment_data = shortcode_atts( - array( - 'line_items' => array(), - 'meta' => array(), + [ + 'line_items' => [], + 'meta' => [], 'customer_id' => false, 'membership_id' => false, 'parent_id' => '', @@ -119,7 +119,7 @@ function wu_create_payment($payment_data, $save = true) { 'date_modified' => wu_get_current_time('mysql', true), 'migrated_from_id' => 0, 'skip_validation' => false, - ), + ], $payment_data ); @@ -145,10 +145,10 @@ function wu_create_payment($payment_data, $save = true) { */ function wu_get_refundable_payment_types() { - $refundable_payment_types = array( + $refundable_payment_types = [ Payment_Status::COMPLETED, Payment_Status::PARTIAL_REFUND, - ); + ]; return apply_filters('wu_get_refundable_payment_type', $refundable_payment_types); } diff --git a/inc/functions/product.php b/inc/functions/product.php index 8d5757b..fe7c25b 100644 --- a/inc/functions/product.php +++ b/inc/functions/product.php @@ -36,7 +36,7 @@ function wu_get_product($product_id_or_slug) { * @param array $query Query arguments. * @return Product[] */ -function wu_get_products($query = array()) { +function wu_get_products($query = []) { return Product::query($query); } @@ -49,7 +49,7 @@ function wu_get_products($query = array()) { * @param array $query Query arguments. * @return Product[] */ -function wu_get_plans($query = array()) { +function wu_get_plans($query = []) { $query['type'] = 'plan'; @@ -70,7 +70,7 @@ function wu_get_plans($query = array()) { */ function wu_get_plans_as_options() { - $options = array(); + $options = []; foreach (wu_get_plans() as $plan) { $options[ $plan->get_id() ] = $plan->get_name(); @@ -117,7 +117,7 @@ function wu_create_product($product_data) { $product_data = wp_parse_args( $product_data, - array( + [ 'name' => false, 'description' => false, 'currency' => false, @@ -139,10 +139,10 @@ function wu_create_product($product_data) { 'date_created' => wu_get_current_time('mysql', true), 'date_modified' => wu_get_current_time('mysql', true), 'migrated_from_id' => 0, - 'meta' => array(), - 'available_addons' => array(), + 'meta' => [], + 'available_addons' => [], 'group' => '', - ) + ] ); $product = new Product($product_data); @@ -177,7 +177,7 @@ function wu_get_product_groups(): array { */ function wu_segregate_products($products) { - $results = array(false, array()); + $results = [false, []]; foreach ($products as $product) { if (is_a($product, Product::class) === false) { diff --git a/inc/functions/reflection.php b/inc/functions/reflection.php index 82c0b70..0b33d11 100644 --- a/inc/functions/reflection.php +++ b/inc/functions/reflection.php @@ -34,7 +34,7 @@ function wu_reflection_parse_object_arguments($class_name) { $doc_block_factory = DocBlockFactory::createInstance(); - $arguments = array(); + $arguments = []; /** * Tries to fetch the database schema, if one exists. @@ -55,11 +55,11 @@ function wu_reflection_parse_object_arguments($class_name) { $param = $doc_block->getTagsByName('param'); if (isset($param[0]) && is_object($param[0])) { - $arguments[ $column['name'] ] = array( + $arguments[ $column['name'] ] = [ 'description' => (string) $param[0]->getDescription(), 'type' => (string) $param[0]->getType(), 'required' => false, // Actual value set later - ); + ]; if ($db_schema) { $db_column = wu_array_find_first_by($db_schema, 'name', $column['name']); @@ -78,7 +78,7 @@ function wu_reflection_parse_object_arguments($class_name) { if (isset($option[0])) { $description = (string) $option[0]->getDescription(); - if (strpos($description, '\\WP_Ultimo\\') !== false) { + if (str_contains($description, '\\WP_Ultimo\\')) { $enum_options = new $description(); $arguments[ $column['name'] ]['enum'] = array_map('strtolower', array_keys(array_flip($enum_options->get_options()))); @@ -103,17 +103,17 @@ function wu_reflection_parse_object_arguments($class_name) { */ function wu_reflection_parse_arguments_from_setters($class_name, $return_schema = true) { - $arguments = array(); + $arguments = []; foreach (get_class_methods($class_name) as $setter_name) { if (preg_match('/^set_/', $setter_name)) { $argument = str_replace('set_', '', $setter_name); if ($return_schema) { - $arguments[] = array( + $arguments[] = [ 'name' => $argument, 'type' => '', - ); + ]; } else { $arguments[] = $argument; } diff --git a/inc/functions/rest.php b/inc/functions/rest.php index 32efac6..8f4de91 100644 --- a/inc/functions/rest.php +++ b/inc/functions/rest.php @@ -46,7 +46,7 @@ function wu_rest_get_endpoint_schema($class_name, $context = 'create', $force_ge $from_cache = false; - $schema = array(); + $schema = []; $endpoint = wu_rest_get_endpoint_from_class_name($class_name); diff --git a/inc/functions/scheduler.php b/inc/functions/scheduler.php index eb5eb80..c8db9b0 100644 --- a/inc/functions/scheduler.php +++ b/inc/functions/scheduler.php @@ -34,7 +34,7 @@ function wu_get_next_queue_run() { * @param string $group The group to assign this job to. * @return int The action ID. */ -function wu_enqueue_async_action($hook, $args = array(), $group = '') { +function wu_enqueue_async_action($hook, $args = [], $group = '') { return wu_switch_blog_and_run(fn() => as_enqueue_async_action($hook, $args, $group)); } @@ -51,7 +51,7 @@ function wu_enqueue_async_action($hook, $args = array(), $group = '') { * * @return int The action ID. */ -function wu_schedule_single_action($timestamp, $hook, $args = array(), $group = '') { +function wu_schedule_single_action($timestamp, $hook, $args = [], $group = '') { return wu_switch_blog_and_run(fn() => as_schedule_single_action($timestamp, $hook, $args, $group)); } @@ -69,7 +69,7 @@ function wu_schedule_single_action($timestamp, $hook, $args = array(), $group = * * @return int The action ID. */ -function wu_schedule_recurring_action($timestamp, $interval_in_seconds, $hook, $args = array(), $group = '') { +function wu_schedule_recurring_action($timestamp, $interval_in_seconds, $hook, $args = [], $group = '') { return wu_switch_blog_and_run(fn() => as_schedule_recurring_action($timestamp, $interval_in_seconds, $hook, $args, $group)); } @@ -99,7 +99,7 @@ function wu_schedule_recurring_action($timestamp, $interval_in_seconds, $hook, $ * * @return int The action ID. */ -function wu_schedule_cron_action($timestamp, $schedule, $hook, $args = array(), $group = '') { +function wu_schedule_cron_action($timestamp, $schedule, $hook, $args = [], $group = '') { return wu_switch_blog_and_run(fn() => as_schedule_cron_action($timestamp, $schedule, $hook, $args, $group)); } @@ -115,7 +115,7 @@ function wu_schedule_cron_action($timestamp, $schedule, $hook, $args = array(), * * @return string|null The scheduled action ID if a scheduled action was found, or null if no matching action found. */ -function wu_unschedule_action($hook, $args = array(), $group = '') { +function wu_unschedule_action($hook, $args = [], $group = '') { return wu_switch_blog_and_run(fn() => as_unschedule_action($hook, $args, $group)); } @@ -129,7 +129,7 @@ function wu_unschedule_action($hook, $args = array(), $group = '') { * @param array $args Args that would have been passed to the job. * @param string $group The group the job is assigned to. */ -function wu_unschedule_all_actions($hook, $args = array(), $group = '') { +function wu_unschedule_all_actions($hook, $args = [], $group = '') { return wu_switch_blog_and_run(fn() => as_unschedule_all_actions($hook, $args, $group)); } @@ -166,7 +166,7 @@ function wu_next_scheduled_action($hook, $args = null, $group = '') { * * @return array */ -function wu_get_scheduled_actions($args = array(), $return_format = OBJECT) { +function wu_get_scheduled_actions($args = [], $return_format = OBJECT) { return wu_switch_blog_and_run(fn() => as_get_scheduled_actions($args, $return_format)); } diff --git a/inc/functions/settings.php b/inc/functions/settings.php index 95fe326..7406e90 100644 --- a/inc/functions/settings.php +++ b/inc/functions/settings.php @@ -106,11 +106,11 @@ function wu_register_settings_side_panel($section_slug, $atts) { $atts = wp_parse_args( $atts, - array( + [ 'title' => __('Side Panel', 'wp-ultimo'), 'render' => '__return_false', 'show' => '__return_true', - ) + ] ); $callback = wu_get_isset($atts, 'show', '__return_true'); @@ -154,7 +154,7 @@ function wu_get_network_logo($size = 'full') { return $settings_logo[0]; } - $logo = wu_get_asset('logo.png', 'img'); + $logo = wu_get_asset('logo.webp', 'img'); $custom_logo = wp_get_attachment_image_src(get_theme_mod('custom_logo'), $size); @@ -173,7 +173,7 @@ function wu_get_network_logo($size = 'full') { */ function wu_get_network_favicon($size = '48') { - $custom_icon = get_site_icon_url($size, wu_get_asset('badge.png', 'img'), wu_get_main_site_id()); + $custom_icon = get_site_icon_url($size, wu_get_asset('badge.webp', 'img'), wu_get_main_site_id()); return $custom_icon; } diff --git a/inc/functions/site.php b/inc/functions/site.php index e68843a..2c5d0ed 100644 --- a/inc/functions/site.php +++ b/inc/functions/site.php @@ -53,15 +53,15 @@ function wu_get_site_by_hash($hash) { * @param array $query Query arguments. * @return \WP_Ultimo\Models\Site[] */ -function wu_get_sites($query = array()) { +function wu_get_sites($query = []) { if ( ! empty($query['search'])) { $domain_ids = wu_get_domains( - array( + [ 'number' => -1, 'search' => '*' . $query['search'] . '*', - 'fields' => array('blog_id'), - ) + 'fields' => ['blog_id'], + ] ); $domain_ids = array_column($domain_ids, 'blog_id'); @@ -84,13 +84,13 @@ function wu_get_sites($query = array()) { * @param array $query Query arguments. * @return array */ -function wu_get_site_templates($query = array()) { +function wu_get_site_templates($query = []) { $query = wp_parse_args( $query, - array( + [ 'number' => 9999, // By default, we try to get ALL available templates. - ) + ] ); return \WP_Ultimo\Models\Site::get_all_by_type('site_template', $query); @@ -108,7 +108,7 @@ function wu_handle_site_domain($domain) { global $current_site; - if (strpos($domain, 'http') === false) { + if (! str_contains($domain, 'http')) { $domain = "https://{$domain}"; } @@ -130,7 +130,7 @@ function wu_create_site($site_data) { $site_data = wp_parse_args( $site_data, - array( + [ 'domain' => $current_site->domain, 'path' => '/', 'title' => false, @@ -139,7 +139,7 @@ function wu_create_site($site_data) { 'featured_image_id' => 0, 'duplication_arguments' => false, 'public' => true, - ) + ] ); $site = new \WP_Ultimo\Models\Site($site_data); @@ -166,7 +166,7 @@ function wu_get_site_domain_and_path($path_or_subdomain = '/', $base_domain = fa $path_or_subdomain = trim($path_or_subdomain, '/'); - $domain = $base_domain ? $base_domain : $current_site->domain; + $domain = $base_domain ?: $current_site->domain; $d = new \stdClass(); diff --git a/inc/functions/sort.php b/inc/functions/sort.php index 423c2c3..45db4d2 100644 --- a/inc/functions/sort.php +++ b/inc/functions/sort.php @@ -55,7 +55,7 @@ function wu_set_order_from_index($list, $order_key = 'order') { foreach ($list as &$item) { if (isset($item[ $order_key ]) === false) { - $index = $index ? $index : 1; // phpcs:ignore + $index = $index ?: 1; // phpcs:ignore $item[ $order_key ] = $index * 10; diff --git a/inc/functions/string-helpers.php b/inc/functions/string-helpers.php index 517bb2a..a320330 100644 --- a/inc/functions/string-helpers.php +++ b/inc/functions/string-helpers.php @@ -34,7 +34,7 @@ function wu_string_to_bool($string) { */ function wu_slug_to_name($slug) { - $slug = str_replace(array('-', '_'), ' ', $slug); + $slug = str_replace(['-', '_'], ' ', $slug); return ucwords($slug); } diff --git a/inc/functions/tax.php b/inc/functions/tax.php index 1d65092..223026e 100644 --- a/inc/functions/tax.php +++ b/inc/functions/tax.php @@ -47,9 +47,9 @@ function wu_get_tax_category($tax_category = 'default') { return wu_get_isset( $tax_categories, $tax_category, - array( - 'rates' => array(), - ) + [ + 'rates' => [], + ] ); } /** @@ -128,12 +128,12 @@ function wu_get_tax_amount($base_price, $amount, $type, $format = true, $inclusi function wu_get_applicable_tax_rates($country, $tax_category = 'default', $state = '*', $city = '*') { if ( ! $country) { - return array(); + return []; } $tax_category = wu_get_tax_category($tax_category); - $results = array(); + $results = []; foreach ($tax_category['rates'] as &$rate) { /* @@ -144,11 +144,11 @@ function wu_get_applicable_tax_rates($country, $tax_category = 'default', $state $keys_of_interest = array_intersect_key( $rate, - array( + [ 'country' => 1, 'state' => 1, 'city' => 1, - ) + ] ); $priority = 0; diff --git a/inc/functions/template.php b/inc/functions/template.php index 1bf7646..3f70296 100644 --- a/inc/functions/template.php +++ b/inc/functions/template.php @@ -17,7 +17,7 @@ defined('ABSPATH') || exit; * @param string|false $default_view View to be used if the view passed is not found. Used as fallback. * @return void */ -function wu_get_template($view, $args = array(), $default_view = false) { +function wu_get_template($view, $args = [], $default_view = false) { /** * Allow plugin developers to add extra variable to the render context globally. @@ -49,12 +49,12 @@ function wu_get_template($view, $args = array(), $default_view = false) { */ $replaceable_views = apply_filters( 'wu_view_override_replaceable_views', - array( + [ 'signup', 'emails', 'forms', 'checkout', - ) + ] ); /* @@ -81,7 +81,7 @@ function wu_get_template($view, $args = array(), $default_view = false) { * @param string|false $default_view View to be used if the view passed is not found. Used as fallback. * @return string */ -function wu_get_template_contents($view, $args = array(), $default_view = false) { +function wu_get_template_contents($view, $args = [], $default_view = false) { ob_start(); diff --git a/inc/functions/url.php b/inc/functions/url.php index 9b30269..1c55d45 100644 --- a/inc/functions/url.php +++ b/inc/functions/url.php @@ -50,7 +50,7 @@ function wu_replace_scheme($url, $new_scheme = '') { * @param array $query URL query parameters. * @return string */ -function wu_network_admin_url($path, $query = array()) { +function wu_network_admin_url($path, $query = []) { $path = sprintf('admin.php?page=%s', $path); @@ -70,7 +70,7 @@ function wu_network_admin_url($path, $query = array()) { * @param null|string $scheme URL scheme. Follows the same rules as the scheme param of get_home_url. * @return string */ -function wu_ajax_url($when = null, $query_args = array(), $site_id = false, $scheme = null) { +function wu_ajax_url($when = null, $query_args = [], $site_id = false, $scheme = null) { if (empty($site_id)) { $site_id = get_current_blog_id(); @@ -79,7 +79,7 @@ function wu_ajax_url($when = null, $query_args = array(), $site_id = false, $sch $base_url = get_home_url($site_id, '', $scheme); if ( ! is_array($query_args)) { - $query_args = array(); + $query_args = []; } $query_args['wu-ajax'] = 1; diff --git a/inc/functions/user.php b/inc/functions/user.php index ec5bc66..129e322 100644 --- a/inc/functions/user.php +++ b/inc/functions/user.php @@ -22,7 +22,7 @@ function wu_get_roles_as_options($add_default_option = false) { require_once ABSPATH . 'wp-admin/includes/user.php'; } - $roles = array(); + $roles = []; if ($add_default_option) { $roles['default'] = __('Use WP Multisite WaaS default', 'wp-ultimo'); diff --git a/inc/functions/webhook.php b/inc/functions/webhook.php index 732c17a..dfbaf83 100644 --- a/inc/functions/webhook.php +++ b/inc/functions/webhook.php @@ -19,7 +19,7 @@ use WP_Ultimo\Models\Webhook; * @param array $query Query arguments. * @return \WP_Ultimo\Models\Webhook[] */ -function wu_get_webhooks($query = array()) { +function wu_get_webhooks($query = []) { return \WP_Ultimo\Models\Webhook::query($query); } @@ -51,7 +51,7 @@ function wu_create_webhook($webhook_data) { $webhook_data = wp_parse_args( $webhook_data, - array( + [ 'name' => false, 'webhook_url' => false, 'event' => false, @@ -60,7 +60,7 @@ function wu_create_webhook($webhook_data) { 'date_created' => wu_get_current_time('mysql', true), 'date_modified' => wu_get_current_time('mysql', true), 'migrated_from_id' => 0, - ) + ] ); $webhook = new Webhook($webhook_data); diff --git a/inc/gateways/class-base-gateway.php b/inc/gateways/class-base-gateway.php index 46bf0d2..a004bbd 100644 --- a/inc/gateways/class-base-gateway.php +++ b/inc/gateways/class-base-gateway.php @@ -61,7 +61,7 @@ abstract class Base_Gateway { * @since 2.0.7 * @var array */ - protected $other_ids = array(); + protected $other_ids = []; /** * The order cart object. @@ -165,7 +165,7 @@ abstract class Base_Gateway { * @param \WP_Ultimo\Checkout\Cart $order The order. * @return void */ - public function set_order($order) { + public function set_order($order): void { if ($order === null) { return; @@ -643,16 +643,16 @@ abstract class Base_Gateway { $return_url = is_admin() ? admin_url('admin.php') : $this->return_url; $return_url = remove_query_arg( - array( + [ 'wu-confirm', 'token', 'PayerID', - ), + ], $return_url ); if (is_admin()) { - $args = array('page' => 'account'); + $args = ['page' => 'account']; if ($this->order) { $args['updated'] = $this->order->get_cart_type(); @@ -661,10 +661,10 @@ abstract class Base_Gateway { $return_url = add_query_arg($args, $return_url); } else { $return_url = add_query_arg( - array( + [ 'payment' => $this->payment->get_hash(), 'status' => 'done', - ), + ], $return_url ); } @@ -696,9 +696,9 @@ abstract class Base_Gateway { } return add_query_arg( - array( + [ 'payment' => $this->payment->get_hash(), - ), + ], $this->cancel_url ); } @@ -716,10 +716,10 @@ abstract class Base_Gateway { } return add_query_arg( - array( + [ 'payment' => $this->payment->get_hash(), 'wu-confirm' => $this->get_id(), - ), + ], $this->confirm_url ); } @@ -744,7 +744,7 @@ abstract class Base_Gateway { * @param \WP_Ultimo\Models\Payment $payment The payment. * @return void */ - public function set_payment($payment) { + public function set_payment($payment): void { $this->payment = $payment; } @@ -756,7 +756,7 @@ abstract class Base_Gateway { * @param \WP_Ultimo\Models\Membership $membership The membership. * @return void */ - public function set_membership($membership) { + public function set_membership($membership): void { $this->membership = $membership; } @@ -768,7 +768,7 @@ abstract class Base_Gateway { * @param \WP_Ultimo\Models\Payment $customer The customer. * @return void */ - public function set_customer($customer) { + public function set_customer($customer): void { $this->customer = $customer; } @@ -782,7 +782,7 @@ abstract class Base_Gateway { * @param \WP_Ultimo\Models\Membership $membership The membership object. * @return void */ - public function trigger_payment_processed($payment, $membership = null) { + public function trigger_payment_processed($payment, $membership = null): void { if ($membership === null) { $membership = $payment->get_membership(); @@ -829,7 +829,7 @@ abstract class Base_Gateway { */ public function get_all_ids() { - $all_ids = array_merge(array($this->get_id()), (array) $this->other_ids); + $all_ids = array_merge([$this->get_id()], (array) $this->other_ids); return array_unique($all_ids); } diff --git a/inc/gateways/class-base-stripe-gateway.php b/inc/gateways/class-base-stripe-gateway.php index 6cb7df4..5ffd5ca 100644 --- a/inc/gateways/class-base-stripe-gateway.php +++ b/inc/gateways/class-base-stripe-gateway.php @@ -40,7 +40,7 @@ class Base_Stripe_Gateway extends Base_Gateway { * @since 2.0.7 * @var array */ - protected $other_ids = array('stripe', 'stripe-checkout'); + protected $other_ids = ['stripe', 'stripe-checkout']; /** * Backwards compatibility for the old notify ajax url. @@ -119,7 +119,7 @@ class Base_Stripe_Gateway extends Base_Gateway { * @since 2.1 * @return void */ - public function init() { + public function init(): void { $id = wu_replace_dashes($this->get_id()); @@ -146,9 +146,9 @@ class Base_Stripe_Gateway extends Base_Gateway { * @param string $id The gateway stripe id. * @return void */ - public function setup_api_keys($id = false) { + public function setup_api_keys($id = false): void { - $id = $id ? $id : wu_replace_dashes($this->get_id()); + $id = $id ?: wu_replace_dashes($this->get_id()); if ($this->test_mode) { $this->publishable_key = wu_get_setting("{$id}_test_pk_key", ''); @@ -171,21 +171,21 @@ class Base_Stripe_Gateway extends Base_Gateway { * @since 2.0.0 * @return void */ - public function hooks() { + public function hooks(): void { - add_action('wu_after_save_settings', array($this, 'install_webhook'), 10, 3); + add_action('wu_after_save_settings', [$this, 'install_webhook'], 10, 3); - add_action('wu_after_save_settings', array($this, 'check_keys_status'), 10, 3); + add_action('wu_after_save_settings', [$this, 'check_keys_status'], 10, 3); - add_filter('wu_pre_save_settings', array($this, 'fix_saving_settings'), 10, 3); + add_filter('wu_pre_save_settings', [$this, 'fix_saving_settings'], 10, 3); - add_filter('wu_element_get_site_actions', array($this, 'add_site_actions'), 10, 4); + add_filter('wu_element_get_site_actions', [$this, 'add_site_actions'], 10, 4); /** * We need to check if we should redirect after instantiate the Currents */ - add_action('init', array($this, 'maybe_redirect_to_portal'), 11); - add_action('wp', array($this, 'maybe_redirect_to_portal'), 11); + add_action('init', [$this, 'maybe_redirect_to_portal'], 11); + add_action('wp', [$this, 'maybe_redirect_to_portal'], 11); } /** @@ -213,16 +213,16 @@ class Base_Stripe_Gateway extends Base_Gateway { $s_subscription_id = $membership->get_gateway_subscription_id(); if ( ! empty($s_subscription_id)) { - $actions['change_payment_method'] = array( + $actions['change_payment_method'] = [ 'label' => __('Change Payment Method', 'wp-ultimo'), 'icon_classes' => 'dashicons-wu-edit wu-align-middle', 'href' => add_query_arg( - array( + [ 'wu-stripe-portal' => true, 'membership' => $membership->get_hash(), - ) + ] ), - ); + ]; } } @@ -235,7 +235,7 @@ class Base_Stripe_Gateway extends Base_Gateway { * @since 2.1.2 * @return void */ - public function maybe_redirect_to_portal() { + public function maybe_redirect_to_portal(): void { if ( ! wu_request('wu-stripe-portal')) { return; @@ -259,9 +259,9 @@ class Base_Stripe_Gateway extends Base_Gateway { $allowed_payment_method_types = apply_filters( 'wu_stripe_checkout_allowed_payment_method_types', - array( + [ 'card', - ), + ], $gateway ); @@ -271,7 +271,7 @@ class Base_Stripe_Gateway extends Base_Gateway { // If customer is not set, get from checkout session if (empty($s_customer_id)) { - $subscription_data = array( + $subscription_data = [ 'payment_method_types' => $allowed_payment_method_types, 'mode' => 'setup', 'success_url' => $return_url, @@ -279,7 +279,7 @@ class Base_Stripe_Gateway extends Base_Gateway { 'billing_address_collection' => 'required', 'client_reference_id' => $customer_id, 'customer' => $s_customer_id, - ); + ]; $session = Stripe\Checkout\Session::create($subscription_data); $s_customer_id = $session->subscript_ion_data['customer']; @@ -289,20 +289,20 @@ class Base_Stripe_Gateway extends Base_Gateway { if ( ! $portal_config_id) { $portal_config = Stripe\BillingPortal\Configuration::create( - array( - 'features' => array( - 'invoice_history' => array( + [ + 'features' => [ + 'invoice_history' => [ 'enabled' => true, - ), - 'payment_method_update' => array( + ], + 'payment_method_update' => [ 'enabled' => true, - ), - 'subscription_cancel' => array( + ], + 'subscription_cancel' => [ 'enabled' => true, 'mode' => 'at_period_end', - 'cancellation_reason' => array( + 'cancellation_reason' => [ 'enabled' => true, - 'options' => array( + 'options' => [ 'too_expensive', 'missing_features', 'switched_service', @@ -310,14 +310,14 @@ class Base_Stripe_Gateway extends Base_Gateway { 'customer_service', 'too_complex', 'other', - ), - ), - ), - ), - 'business_profile' => array( + ], + ], + ], + ], + 'business_profile' => [ 'headline' => __('Manage your membership payment methods.', 'wp-ultimo'), - ), - ) + ], + ] ); $portal_config_id = $portal_config->id; @@ -325,11 +325,11 @@ class Base_Stripe_Gateway extends Base_Gateway { update_site_option('wu_stripe_portal_config_id', $portal_config_id); } - $subscription_data = array( + $subscription_data = [ 'return_url' => $return_url, 'customer' => $s_customer_id, 'configuration' => $portal_config_id, - ); + ]; $session = Stripe\BillingPortal\Session::create($subscription_data); @@ -357,23 +357,23 @@ class Base_Stripe_Gateway extends Base_Gateway { * @since 2.0.0 * @return void */ - public function settings() { + public function settings(): void { $gateway_id = wu_replace_dashes($this->id); wu_register_settings_field( 'payment-gateways', "{$gateway_id}_enable_portal", - array( + [ 'title' => __('Use Stripe Billing Portal', 'wp-ultimo'), 'desc' => 'Add a link to the Billing Portal in the site actions widget so your customer can change the payment method used in Stripe (additional charges from Stripe could be applied).', 'type' => 'toggle', 'default' => 0, 'capability' => 'manage_api_keys', - 'require' => array( + 'require' => [ 'active_gateways' => $this->get_id(), - ), - ) + ], + ] ); } @@ -391,9 +391,9 @@ class Base_Stripe_Gateway extends Base_Gateway { $this->setup_api_keys(); $search_webhook = Stripe\WebhookEndpoint::all( - array( + [ 'limit' => 100, - ) + ] ); $set_webhook_endpoint = false; @@ -435,7 +435,7 @@ class Base_Stripe_Gateway extends Base_Gateway { $id = wu_replace_dashes($this->get_id()); - $active_gateways = (array) wu_get_isset($settings_to_save, 'active_gateways', array()); + $active_gateways = (array) wu_get_isset($settings_to_save, 'active_gateways', []); if ( ! in_array($this->get_id(), $active_gateways, true)) { return $settings; @@ -461,11 +461,11 @@ class Base_Stripe_Gateway extends Base_Gateway { * @param array $saved_settings Array containing the original settings. * @return void */ - public function check_keys_status($settings, $settings_to_save, $saved_settings) { + public function check_keys_status($settings, $settings_to_save, $saved_settings): void { $id = wu_replace_dashes($this->get_id()); - $active_gateways = (array) wu_get_isset($settings_to_save, 'active_gateways', array()); + $active_gateways = (array) wu_get_isset($settings_to_save, 'active_gateways', []); if ( ! in_array($this->get_id(), $active_gateways, true)) { return; @@ -476,17 +476,17 @@ class Base_Stripe_Gateway extends Base_Gateway { /* * Checked if the Stripe Settings changed, so we can install webhooks. */ - $changed_settings = array( + $changed_settings = [ $settings[ "{$id}_sandbox_mode" ], $settings[ "{$id}_{$stripe_mode}_pk_key" ], $settings[ "{$id}_{$stripe_mode}_sk_key" ], - ); + ]; - $original_settings = array( + $original_settings = [ $saved_settings[ "{$id}_sandbox_mode" ], $saved_settings[ "{$id}_{$stripe_mode}_pk_key" ], $saved_settings[ "{$id}_{$stripe_mode}_sk_key" ], - ); + ]; if ($changed_settings == $original_settings) { // phpcs:ignore @@ -497,19 +497,19 @@ class Base_Stripe_Gateway extends Base_Gateway { Stripe\Stripe::setApiKey($settings[ "{$id}_{$stripe_mode}_sk_key" ]); Stripe\Token::create( - array( - 'card' => array( + [ + 'card' => [ 'number' => '4242424242424242', 'exp_month' => 7, 'exp_year' => 2028, 'cvc' => '314', - ), - ) + ], + ] ); wu_save_setting("{$id}_{$stripe_mode}_sk_key_status", ''); } catch (\Throwable $e) { - if (strncmp($e->getMessage(), 'Invalid API Key provided', strlen('Invalid API Key provided')) === 0) { + if (str_starts_with($e->getMessage(), 'Invalid API Key provided')) { /** * The secret key is invalid; */ @@ -522,19 +522,19 @@ class Base_Stripe_Gateway extends Base_Gateway { Stripe\Stripe::setApiKey($settings[ "{$id}_{$stripe_mode}_pk_key" ]); Stripe\Token::create( - array( - 'card' => array( + [ + 'card' => [ 'number' => '4242424242424242', 'exp_month' => 7, 'exp_year' => 2028, 'cvc' => '314', - ), - ) + ], + ] ); wu_save_setting("{$id}_{$stripe_mode}_pk_key_status", ''); } catch (\Throwable $e) { - if (strncmp($e->getMessage(), 'Invalid API Key provided', strlen('Invalid API Key provided')) === 0) { + if (str_starts_with($e->getMessage(), 'Invalid API Key provided')) { /** * The public key is invalid; */ @@ -563,7 +563,7 @@ class Base_Stripe_Gateway extends Base_Gateway { $id = wu_replace_dashes($this->get_id()); - $active_gateways = (array) wu_get_isset($settings_to_save, 'active_gateways', array()); + $active_gateways = (array) wu_get_isset($settings_to_save, 'active_gateways', []); if ( ! in_array($this->get_id(), $active_gateways, true)) { return false; @@ -572,21 +572,21 @@ class Base_Stripe_Gateway extends Base_Gateway { /* * Checked if the Stripe Settings changed, so we can install webhooks. */ - $changed_settings = array( + $changed_settings = [ $settings[ "{$id}_sandbox_mode" ], $settings[ "{$id}_test_pk_key" ], $settings[ "{$id}_test_sk_key" ], $settings[ "{$id}_live_pk_key" ], $settings[ "{$id}_live_sk_key" ], - ); + ]; - $original_settings = array( + $original_settings = [ $saved_settings[ "{$id}_sandbox_mode" ], $saved_settings[ "{$id}_test_pk_key" ], $saved_settings[ "{$id}_test_sk_key" ], $saved_settings[ "{$id}_live_pk_key" ], $saved_settings[ "{$id}_live_sk_key" ], - ); + ]; if ($changed_settings == $original_settings) { // phpcs:ignore @@ -611,9 +611,9 @@ class Base_Stripe_Gateway extends Base_Gateway { if ($existing_webhook->status === 'disabled') { $status = Stripe\WebhookEndpoint::update( $existing_webhook->id, - array( + [ 'status' => 'enabled', - ) + ] ); } @@ -624,11 +624,11 @@ class Base_Stripe_Gateway extends Base_Gateway { * Otherwise, create it. */ Stripe\WebhookEndpoint::create( - array( - 'enabled_events' => array('*'), + [ + 'enabled_events' => ['*'], 'url' => $webhook_url, 'description' => 'Added by WP Multisite WaaS. Required to correctly handle changes in subscription status.', - ) + ] ); return true; @@ -680,18 +680,18 @@ class Base_Stripe_Gateway extends Base_Gateway { $line_items = $temp_payment->get_line_items(); - $recurring_items = array(); + $recurring_items = []; - $credits = array(); + $credits = []; $s_coupon = ''; foreach ($line_items as $line_item) { if ($line_item->get_total() < 0) { - $credits[] = array( + $credits[] = [ 'amount' => $line_item->get_total(), 'description' => $line_item->get_title(), - ); + ]; continue; } @@ -712,13 +712,13 @@ class Base_Stripe_Gateway extends Base_Gateway { if ($line_item->is_taxable() && ! empty($line_item->get_tax_rate())) { $tax_behavior = $line_item->get_tax_inclusive() ? 'inclusive' : 'exclusive'; - $tax_args = array( + $tax_args = [ 'country' => $membership->get_billing_address()->billing_country, 'tax_rate' => $line_item->get_tax_rate(), 'type' => $line_item->get_tax_type(), 'title' => $line_item->get_tax_label(), 'inclusive' => $line_item->get_tax_inclusive(), - ); + ]; $s_tax_rate = $this->maybe_create_tax_rate($tax_args); } @@ -733,12 +733,12 @@ class Base_Stripe_Gateway extends Base_Gateway { $tax_behavior ); - $recurring_item = array( + $recurring_item = [ 'price' => $s_price, - ); + ]; if ($s_tax_rate) { - $recurring_item['tax_rates'] = array($s_tax_rate); + $recurring_item['tax_rates'] = [$s_tax_rate]; } $recurring_items[] = $recurring_item; @@ -746,10 +746,10 @@ class Base_Stripe_Gateway extends Base_Gateway { if ( ! empty($credits)) { if (count($credits) > 1) { - $credit = array( + $credit = [ 'amount' => array_sum(wp_list_pluck($credits, 'amount')), 'description' => __('Amount adjustment based on custom deal.', 'wp-ultimo'), - ); + ]; } else { $credit = $credits[0]; } @@ -759,31 +759,31 @@ class Base_Stripe_Gateway extends Base_Gateway { if ($s_amount >= 1) { $currency = strtolower($membership->get_currency()); - $coupon_data = array( + $coupon_data = [ 'id' => sprintf('%s-%s-%s', $s_amount, $currency, 'forever'), 'name' => $credit['description'], 'amount_off' => $s_amount, 'duration' => 'forever', 'currency' => $currency, - ); + ]; $s_coupon = $this->get_stripe_coupon($coupon_data); } } $existing_items = array_map( - fn($item) => array( + fn($item) => [ 'id' => $item->id, 'deleted' => true, - ), + ], $subscription->items->data ); - $update_data = array( + $update_data = [ 'items' => array_merge($recurring_items, $existing_items), 'proration_behavior' => 'none', 'coupon' => $s_coupon, - ); + ]; $subscription = Stripe\Subscription::update($gateway_subscription_id, $update_data); @@ -840,7 +840,7 @@ class Base_Stripe_Gateway extends Base_Gateway { * database for an existing Stripe customer id. */ if (empty($stripe_customer_id)) { - $stripe_customer_id = wu_get_customer_gateway_id($customer_id, array('stripe', 'stripe-checkout')); + $stripe_customer_id = wu_get_customer_gateway_id($customer_id, ['stripe', 'stripe-checkout']); } /** @@ -883,11 +883,11 @@ class Base_Stripe_Gateway extends Base_Gateway { /* * Pass the name and email to stripe. */ - $customer_args = array( + $customer_args = [ 'email' => $this->customer->get_email_address(), 'name' => $this->customer->get_display_name(), 'address' => $this->convert_to_stripe_address($this->customer->get_billing_address()), - ); + ]; /* * Filters the customer creation arguments. @@ -927,14 +927,14 @@ class Base_Stripe_Gateway extends Base_Gateway { */ public function convert_to_stripe_address($billing_address) { - return array( + return [ 'city' => $billing_address->billing_city, 'country' => $billing_address->billing_country, 'line1' => $billing_address->billing_address_line_1, 'line2' => $billing_address->billing_address_line_2, 'postal_code' => $billing_address->billing_zip_code, 'state' => $billing_address->billing_state, - ); + ]; } /** @@ -945,13 +945,13 @@ class Base_Stripe_Gateway extends Base_Gateway { */ protected function get_customer_metadata() { - $meta_data = array( + $meta_data = [ 'key' => $this->membership->get_id(), 'email' => $this->customer->get_email_address(), 'membership_id' => $this->membership->get_id(), 'customer_id' => $this->customer->get_id(), 'payment_id' => $this->payment->get_id(), - ); + ]; return $meta_data; } @@ -1024,7 +1024,7 @@ class Base_Stripe_Gateway extends Base_Gateway { // Otherwise, use the calculated expiration date of the membership, modified to current time instead of 23:59. $billing_date = $cart->get_billing_start_date(); - $base_date = $billing_date ? $billing_date : $cart->get_billing_next_charge_date(); + $base_date = $billing_date ?: $cart->get_billing_next_charge_date(); $datetime = \DateTime::createFromFormat('U', $base_date); $current_time = getdate(); @@ -1039,12 +1039,12 @@ class Base_Stripe_Gateway extends Base_Gateway { /* * Subscription arguments for Stripe */ - $sub_args = array( + $sub_args = [ 'items' => array_values($stripe_cart), 'default_payment_method' => $payment_method->id, 'prorate' => false, 'metadata' => $this->get_customer_metadata(), - ); + ]; /* * Now determine if we use `trial_end` or `billing_cycle_anchor` to schedule the start of the @@ -1117,9 +1117,9 @@ class Base_Stripe_Gateway extends Base_Gateway { $sub_options = apply_filters( 'wu_stripe_create_subscription_options', - array( + [ 'idempotency_key' => wu_stripe_generate_idempotency_key($sub_args), - ) + ] ); try { @@ -1141,7 +1141,7 @@ class Base_Stripe_Gateway extends Base_Gateway { $fees = array_filter($cart->get_line_items_by_type('fee'), fn($fee) => ! $fee->is_recurring()); - $s_fees = array(); + $s_fees = []; foreach ($fees as $fee) { $amount = $fee->get_quantity() * $fee->get_unit_price(); @@ -1152,13 +1152,13 @@ class Base_Stripe_Gateway extends Base_Gateway { if ($fee->is_taxable() && ! empty($fee->get_tax_rate())) { $tax_behavior = $fee->get_tax_inclusive() ? 'inclusive' : 'exclusive'; - $tax_args = array( + $tax_args = [ 'country' => $membership->get_billing_address()->billing_country, 'tax_rate' => $fee->get_tax_rate(), 'type' => $fee->get_tax_type(), 'title' => $fee->get_tax_label(), 'inclusive' => $fee->get_tax_inclusive(), - ); + ]; $s_tax_rate = $this->maybe_create_tax_rate($tax_args); } @@ -1173,25 +1173,25 @@ class Base_Stripe_Gateway extends Base_Gateway { $tax_behavior, ); - $s_fee = array( + $s_fee = [ 'price' => $s_price, - ); + ]; if ($s_tax_rate) { - $s_fee['tax_rates'] = array($s_tax_rate); + $s_fee['tax_rates'] = [$s_tax_rate]; } $s_fees[] = $s_fee; } if ( ! empty($s_fees)) { - $options = array( + $options = [ 'add_invoice_items' => $s_fees, - ); + ]; - $sub_options = array( - 'idempotency_key' => wu_stripe_generate_idempotency_key(array_merge(array('s_subscription' => $subscription->id), $options)), - ); + $sub_options = [ + 'idempotency_key' => wu_stripe_generate_idempotency_key(array_merge(['s_subscription' => $subscription->id], $options)), + ]; try { $subscription = Stripe\Subscription::update($subscription->id, $options, $sub_options); @@ -1236,13 +1236,13 @@ class Base_Stripe_Gateway extends Base_Gateway { $s_amount = - round($amount * wu_stripe_get_currency_multiplier()); $currency = strtolower($cart->get_currency()); - $coupon_data = array( + $coupon_data = [ 'id' => sprintf('%s-%s-%s', $s_amount, $currency, 'once'), 'name' => __('Account credit and other discounts', 'wp-ultimo'), 'amount_off' => $s_amount, 'duration' => 'once', 'currency' => $currency, - ); + ]; return $this->get_stripe_coupon($coupon_data); } @@ -1264,9 +1264,9 @@ class Base_Stripe_Gateway extends Base_Gateway { Stripe\Coupon::update( $coupon->id, - array( + [ 'name' => $coupon_data['name'], - ) + ] ); return $coupon->id; @@ -1307,7 +1307,7 @@ class Base_Stripe_Gateway extends Base_Gateway { */ protected function build_non_recurring_cart($cart, $include_recurring_products = false): array { - $cart_items = array(); + $cart_items = []; foreach ($cart->get_line_items() as $line_item) { /* @@ -1325,12 +1325,12 @@ class Base_Stripe_Gateway extends Base_Gateway { continue; } - $cart_items[ $line_item->get_id() ] = array( + $cart_items[ $line_item->get_id() ] = [ 'name' => $line_item->get_title(), 'quantity' => $line_item->get_quantity(), 'amount' => $line_item->get_unit_price() * wu_stripe_get_currency_multiplier(), 'currency' => strtolower($cart->get_currency()), - ); + ]; $description = $line_item->get_description(); @@ -1346,15 +1346,15 @@ class Base_Stripe_Gateway extends Base_Gateway { * Stripe and apply it on the subscription cart. */ if ($line_item->is_taxable() && ! empty($line_item->get_tax_rate())) { - $tax_args = array( + $tax_args = [ 'country' => $this->membership->get_billing_address()->billing_country, 'tax_rate' => $line_item->get_tax_rate(), 'type' => $line_item->get_tax_type(), 'title' => $line_item->get_tax_label(), 'inclusive' => $line_item->get_tax_inclusive(), - ); + ]; - $cart_items[ $line_item->get_id() ]['tax_rates'] = array($this->maybe_create_tax_rate($tax_args)); + $cart_items[ $line_item->get_id() ]['tax_rates'] = [$this->maybe_create_tax_rate($tax_args)]; } } @@ -1377,7 +1377,7 @@ class Base_Stripe_Gateway extends Base_Gateway { * All start dates are delayed one cycle because we use a * one-time payment for the first charge. */ - $plans = array(); + $plans = []; $all_products = $cart->get_all_products(); @@ -1411,12 +1411,12 @@ class Base_Stripe_Gateway extends Base_Gateway { * Otherwise, we'll get the stripe plan id in here. */ $plan_id = $this->maybe_create_plan( - array( + [ 'name' => $product->get_name(), 'price' => $amount, 'interval' => $product->get_duration_unit(), 'interval_count' => $product->get_duration(), - ) + ] ); if (is_wp_error($plan_id)) { @@ -1426,9 +1426,9 @@ class Base_Stripe_Gateway extends Base_Gateway { /* * Adds the new plan ID to the subscription cart. */ - $plans[ $plan_id ] = array( + $plans[ $plan_id ] = [ 'plan' => $plan_id, - ); + ]; } catch (\Exception $e) { $error_message = sprintf('Failed to create subscription for membership #%d. Message: %s', $this->membership->get_id(), $e->getMessage()); @@ -1443,15 +1443,15 @@ class Base_Stripe_Gateway extends Base_Gateway { * Stripe and apply it on the subscription cart. */ if ($line_item->is_taxable() && ! empty($line_item->get_tax_rate())) { - $tax_args = array( + $tax_args = [ 'country' => $this->membership->get_billing_address()->billing_country, 'tax_rate' => $line_item->get_tax_rate(), 'type' => $line_item->get_tax_type(), 'title' => $line_item->get_tax_label(), 'inclusive' => $line_item->get_tax_inclusive(), - ); + ]; - $plans[ $plan_id ]['tax_rates'] = array($this->maybe_create_tax_rate($tax_args)); + $plans[ $plan_id ]['tax_rates'] = [$this->maybe_create_tax_rate($tax_args)]; } } @@ -1468,9 +1468,9 @@ class Base_Stripe_Gateway extends Base_Gateway { */ protected function get_ultimo_line_items_from_invoice($invoice_line_items) { - $line_items = array(); + $line_items = []; - $membership_products = array(); + $membership_products = []; if ($this->membership) { $m_products = $this->membership->get_all_products(); @@ -1491,13 +1491,13 @@ class Base_Stripe_Gateway extends Base_Gateway { $title = preg_replace($description_pattern, '$1', (string) $s_line_item->description); - $line_item_data = array( + $line_item_data = [ 'title' => $title, 'description' => $s_line_item->description, 'tax_inclusive' => $s_line_item->amount !== $s_line_item->amount_excluding_tax, 'unit_price' => $s_line_item->unit_amount_excluding_tax / $currency_multiplier, 'quantity' => $quantity, - ); + ]; if (wu_get_isset($membership_products, $title)) { $line_item_data['product'] = wu_get_isset($membership_products, $title); @@ -1511,12 +1511,12 @@ class Base_Stripe_Gateway extends Base_Gateway { // Set this values after generate the line item to bypass the recalculate_totals $line_item->attributes( - array( + [ 'discount_total' => 0, 'subtotal' => $subtotal, 'tax_total' => $tax_total, 'total' => $total, - ) + ] ); $line_items[] = $line_item; @@ -1543,9 +1543,9 @@ class Base_Stripe_Gateway extends Base_Gateway { if (empty($payment_method->customer)) { $payment_method->attach( - array( + [ 'customer' => $s_customer->id, - ) + ] ); } @@ -1554,11 +1554,11 @@ class Base_Stripe_Gateway extends Base_Gateway { */ Stripe\Customer::update( $s_customer->id, - array( - 'invoice_settings' => array( + [ + 'invoice_settings' => [ 'default_payment_method' => $payment_intent->payment_method, - ), - ) + ], + ] ); /* @@ -1572,10 +1572,10 @@ class Base_Stripe_Gateway extends Base_Gateway { * in the future. */ $customer_payment_methods = Stripe\PaymentMethod::all( - array( + [ 'customer' => $s_customer->id, 'type' => 'card', - ) + ] ); if ( ! empty($customer_payment_methods->data)) { @@ -1605,14 +1605,14 @@ class Base_Stripe_Gateway extends Base_Gateway { * @param Stripe\Customer $s_customer The stripe customer. * @return void */ - public function maybe_cancel_old_subscriptions($s_customer) { + public function maybe_cancel_old_subscriptions($s_customer): void { $allow_multiple_membership = wu_multiple_memberships_enabled(); try { // Set up array of subscriptions we cancel below so we don't try to cancel the same one twice. - $cancelled_subscriptions = array(); + $cancelled_subscriptions = []; // Clean up any past due or unpaid subscriptions. We do this to ensure we don't end up with duplicates. $subscriptions = $s_customer->subscriptions->all(); @@ -1719,9 +1719,9 @@ class Base_Stripe_Gateway extends Base_Gateway { * Check if we have an invoice, * or a charge at hand. */ - if (strncmp((string) $gateway_payment_id, 'ch_', strlen('ch_')) === 0) { + if (str_starts_with((string) $gateway_payment_id, 'ch_')) { $charge_id = $gateway_payment_id; - } elseif (strncmp((string) $gateway_payment_id, 'in_', strlen('in_')) === 0) { + } elseif (str_starts_with((string) $gateway_payment_id, 'in_')) { $invoice = Stripe\Invoice::retrieve($gateway_payment_id); $gateway_payment_id = $invoice->charge; @@ -1737,10 +1737,10 @@ class Base_Stripe_Gateway extends Base_Gateway { $normalize_amount = $amount * wu_stripe_get_currency_multiplier(); Stripe\Refund::create( - array( + [ 'charge' => $charge_id, 'amount' => $normalize_amount, - ) + ] ); /* @@ -1896,7 +1896,7 @@ class Base_Stripe_Gateway extends Base_Gateway { * @since 2.0.8 * @return void */ - public function before_backwards_compatible_webhook() { + public function before_backwards_compatible_webhook(): void { if (empty($this->secret_key)) { $other_id = $this->get_id() === 'stripe' ? 'stripe-checkout' : 'stripe'; @@ -1979,7 +1979,7 @@ class Base_Stripe_Gateway extends Base_Gateway { * We can also get the subscription by the * object ID in some circumstances. */ - if (empty($subscription) && strpos((string) $payment_event->id, 'sub_') !== false) { + if (empty($subscription) && str_contains((string) $payment_event->id, 'sub_')) { $subscription = Stripe\Subscription::retrieve($payment_event->id); } @@ -2001,7 +2001,7 @@ class Base_Stripe_Gateway extends Base_Gateway { if (empty($membership) && ! empty($invoice)) { $amount = $invoice->amount_paid / wu_stripe_get_currency_multiplier(); - $membership = wu_get_membership_by_customer_gateway_id($payment_event->customer, array('stripe', 'stripe-checkout'), $amount); + $membership = wu_get_membership_by_customer_gateway_id($payment_event->customer, ['stripe', 'stripe-checkout'], $amount); } /** @@ -2087,10 +2087,10 @@ class Base_Stripe_Gateway extends Base_Gateway { * stripe invoices. */ - $payment_data = array( + $payment_data = [ 'status' => Payment_Status::COMPLETED, 'gateway' => $this->get_id(), - ); + ]; if ($event->type === 'charge.succeeded') { /* @@ -2254,7 +2254,7 @@ class Base_Stripe_Gateway extends Base_Gateway { $payment_intent_id = (string) $payment->get_meta('stripe_payment_intent_id'); // We handle setup intents from process_checkout. - $is_setup_intent = strncmp($payment_intent_id, 'seti_', strlen('seti_')) === 0; + $is_setup_intent = str_starts_with($payment_intent_id, 'seti_'); if ($cart && $cart->should_auto_renew() && $cart->has_recurring() && ! $is_setup_intent) { $s_customer = Stripe\Customer::retrieve($payment_event->customer); @@ -2317,9 +2317,9 @@ class Base_Stripe_Gateway extends Base_Gateway { * Next, let's deal with charges that went through! */ if ($event->type === 'charge.refunded') { - $payment_data = array( + $payment_data = [ 'gateway' => 'stripe', - ); + ]; $payment_id = $payment_event->metadata->payment_id; @@ -2404,14 +2404,14 @@ class Base_Stripe_Gateway extends Base_Gateway { public function get_saved_card_options() { if ( ! is_user_logged_in()) { - return array(); + return []; } - $options = array(); + $options = []; $user_id = isset($this->customer) && $this->customer ? $this->customer->get_user_id() : false; - $saved_payment_methods = $this->get_user_saved_payment_methods($user_id); + $saved_payment_methods = $this->get_user_saved_payment_methods(); foreach ($saved_payment_methods as $saved_payment_method) { $options[ $saved_payment_method->id ] = sprintf( @@ -2440,7 +2440,7 @@ class Base_Stripe_Gateway extends Base_Gateway { * @since 2.0.0 * @return void */ - public function update_card_fields() { // phpcs:disable ?> + public function update_card_fields(): void { // phpcs:disable ?>

@@ -2470,9 +2470,9 @@ class Base_Stripe_Gateway extends Base_Gateway { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { - $active_gateways = (array) wu_get_setting('active_gateways', array()); + $active_gateways = (array) wu_get_setting('active_gateways', []); if (empty($this->publishable_key) || ! in_array($this->get_id(), $active_gateways, true)) { return; @@ -2480,7 +2480,7 @@ class Base_Stripe_Gateway extends Base_Gateway { wp_register_script('wu-stripe-sdk', 'https://js.stripe.com/v3/', false, 'v3'); - wp_register_script("wu-{$this->get_id()}", wu_get_asset("gateways/{$this->get_id()}.js", 'js'), array('wu-checkout', 'wu-stripe-sdk'), wu_get_version(), true); + wp_register_script("wu-{$this->get_id()}", wu_get_asset("gateways/{$this->get_id()}.js", 'js'), ['wu-checkout', 'wu-stripe-sdk'], wu_get_version(), true); $saved_cards = $this->get_saved_card_options(); @@ -2489,12 +2489,12 @@ class Base_Stripe_Gateway extends Base_Gateway { wp_localize_script( "wu-{$this->get_id()}", $obj_name, - array( + [ 'pk_key' => $this->publishable_key, 'request_billing_address' => $this->request_billing_address, 'add_new_card' => empty($saved_cards), 'payment_method' => empty($saved_cards) ? 'add-new' : current(array_keys($saved_cards)), - ) + ] ); wp_enqueue_script("wu-{$this->get_id()}"); @@ -2516,7 +2516,7 @@ class Base_Stripe_Gateway extends Base_Gateway { $slug .= '-inclusive'; } - static $cache = array(); + static $cache = []; if (wu_get_isset($cache, $slug)) { return wu_get_isset($cache, $slug); @@ -2532,16 +2532,16 @@ class Base_Stripe_Gateway extends Base_Gateway { } } - $args = array( + $args = [ 'display_name' => $args['title'], 'description' => $args['title'], 'jurisdiction' => $args['country'], 'percentage' => absint($args['tax_rate']), 'inclusive' => wu_get_isset($args, 'inclusive'), - 'metadata' => array( + 'metadata' => [ 'tax_rate_id' => $slug, - ), - ); + ], + ]; try { $tax_rate = Stripe\TaxRate::create($args); @@ -2580,14 +2580,14 @@ class Base_Stripe_Gateway extends Base_Gateway { $args = wp_parse_args( $args, - array( + [ 'name' => '', 'price' => 0.00, 'interval' => 'month', 'interval_count' => 1, 'currency' => strtolower((string) wu_get_setting('currency_symbol', 'USD')), 'id' => '', - ) + ] ); // Name and price are required. @@ -2621,7 +2621,7 @@ class Base_Stripe_Gateway extends Base_Gateway { // First check to see if a plan exists with this ID. If so, return that. try { - $membership_level = isset($plan_level) ? $plan_level : new \stdClass(); + $membership_level = $plan_level ?? new \stdClass(); /** * Filters the ID of the plan to check for. If this exists, the new subscription will @@ -2643,21 +2643,21 @@ class Base_Stripe_Gateway extends Base_Gateway { // Otherwise, create a new plan. try { $product = Stripe\Product::create( - array( + [ 'name' => $args['name'] . ' - ' . $args['currency'], 'type' => 'service', - ) + ] ); $plan = Stripe\Plan::create( - array( + [ 'amount' => $price, 'interval' => $args['interval'], 'interval_count' => $args['interval_count'], 'currency' => $args['currency'], 'id' => $plan_id, 'product' => $product->id, - ) + ] ); // plan successfully created @@ -2731,10 +2731,10 @@ class Base_Stripe_Gateway extends Base_Gateway { // Otherwise, create a new product. try { $product = Stripe\Product::create( - array( + [ 'id' => $product_id, 'name' => $name, - ) + ] ); // product successfully created @@ -2780,18 +2780,18 @@ class Base_Stripe_Gateway extends Base_Gateway { $s_product = $this->maybe_create_product($name); - $s_price_data = array( + $s_price_data = [ 'lookup_key' => "$s_product-$s_amount-$currency", 'unit_amount' => $s_amount, 'currency' => $currency, 'product' => $s_product, - ); + ]; if ($duration && $duration_unit) { - $s_price_data['recurring'] = array( + $s_price_data['recurring'] = [ 'interval' => $duration_unit, 'interval_count' => $duration, - ); + ]; $s_price_data['lookup_key'] .= "-$duration-$duration_unit"; } @@ -2803,10 +2803,10 @@ class Base_Stripe_Gateway extends Base_Gateway { // check if price already exists $existing = Stripe\Price::all( - array( - 'lookup_keys' => array($s_price_data['lookup_key']), + [ + 'lookup_keys' => [$s_price_data['lookup_key']], 'limit' => 1, - ) + ] ); if ( ! empty($existing->data)) { @@ -2855,7 +2855,7 @@ class Base_Stripe_Gateway extends Base_Gateway { $customer = wu_get_current_customer(); if ( ! $customer) { - return array(); + return []; } $customer_id = $customer->get_id(); @@ -2875,23 +2875,23 @@ class Base_Stripe_Gateway extends Base_Gateway { return $existing_payment_methods[ $customer_id ]; } - $customer_payment_methods = array(); + $customer_payment_methods = []; $stripe_customer_id = \WP_Ultimo\Models\Membership::query( - array( + [ 'customer_id' => $customer_id, 'search' => 'cus_*', - 'fields' => array('gateway_customer_id'), - ) + 'fields' => ['gateway_customer_id'], + ] ); $stripe_customer_id = current(array_column($stripe_customer_id, 'gateway_customer_id')); $payment_methods = Stripe\PaymentMethod::all( - array( + [ 'customer' => $stripe_customer_id, 'type' => 'card', - ) + ] ); foreach ($payment_methods->data as $payment_method) { @@ -2902,7 +2902,7 @@ class Base_Stripe_Gateway extends Base_Gateway { return $existing_payment_methods[ $customer_id ]; } catch (\Throwable $exception) { - return array(); + return []; } } @@ -2922,7 +2922,7 @@ class Base_Stripe_Gateway extends Base_Gateway { $path = 'payments'; - if (strncmp($gateway_payment_id, 'in_', strlen('in_')) === 0) { + if (str_starts_with($gateway_payment_id, 'in_')) { $path = 'invoices'; } diff --git a/inc/gateways/class-free-gateway.php b/inc/gateways/class-free-gateway.php index 0aa63cb..677f6ed 100644 --- a/inc/gateways/class-free-gateway.php +++ b/inc/gateways/class-free-gateway.php @@ -56,7 +56,7 @@ class Free_Gateway extends Base_Gateway { * @param string $type The checkout type. Can be 'new', 'retry', 'upgrade', 'downgrade', 'addon'. * @return void */ - public function process_checkout($payment, $membership, $customer, $cart, $type) { + public function process_checkout($payment, $membership, $customer, $cart, $type): void { $membership_status = $membership->get_status(); diff --git a/inc/gateways/class-manual-gateway.php b/inc/gateways/class-manual-gateway.php index 614884c..d010167 100644 --- a/inc/gateways/class-manual-gateway.php +++ b/inc/gateways/class-manual-gateway.php @@ -43,11 +43,11 @@ class Manual_Gateway extends Base_Gateway { * @since 2.0.0 * @return void */ - public function hooks() { + public function hooks(): void { /* * Adds payment instructions to the thank you page. */ - add_action('wu_thank_you_before_info_blocks', array($this, 'add_payment_instructions_block'), 10, 3); + add_action('wu_thank_you_before_info_blocks', [$this, 'add_payment_instructions_block'], 10, 3); } /** @@ -81,35 +81,35 @@ class Manual_Gateway extends Base_Gateway { * @since 2.0.0 * @return void */ - public function settings() { + public function settings(): void { wu_register_settings_field( 'payment-gateways', 'manual_header', - array( + [ 'title' => __('Manual', 'wp-ultimo'), 'desc' => __('Use the settings section below to configure the manual payment method. This method allows your customers to manually pay for their memberships, but those payments require manual confirmation on your part.', 'wp-ultimo'), 'type' => 'header', 'show_as_submenu' => true, - 'require' => array( + 'require' => [ 'active_gateways' => 'manual', - ), - ) + ], + ] ); wu_register_settings_field( 'payment-gateways', 'manual_payment_instructions', - array( + [ 'title' => __('Payment Instructions', 'wp-ultimo'), 'desc' => __('This instructions will be shown to the customer on the thank you page, as well as be sent via email.', 'wp-ultimo'), 'type' => 'wp_editor', 'allow_html' => true, 'default' => __('Payment instructions here.', 'wp-ultimo'), - 'require' => array( + 'require' => [ 'active_gateways' => 'manual', - ), - ) + ], + ] ); } @@ -332,7 +332,7 @@ class Manual_Gateway extends Base_Gateway { * @param \WP_Ultimo\Models\Customer $customer The customer checking out. * @return void|bool */ - public function process_refund($amount, $payment, $membership, $customer) { + public function process_refund($amount, $payment, $membership, $customer): void { $status = $payment->refund($amount); @@ -367,7 +367,7 @@ class Manual_Gateway extends Base_Gateway { * @param \WP_Ultimo\Models\Customer $customer the current customer. * @return void */ - public function add_payment_instructions_block($payment, $membership, $customer) { + public function add_payment_instructions_block($payment, $membership, $customer): void { if ($payment->get_gateway() !== $this->id) { return; diff --git a/inc/gateways/class-paypal-gateway.php b/inc/gateways/class-paypal-gateway.php index 2ac1eec..e608191 100644 --- a/inc/gateways/class-paypal-gateway.php +++ b/inc/gateways/class-paypal-gateway.php @@ -138,7 +138,7 @@ class PayPal_Gateway extends Base_Gateway { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { /* * Checks if we are in test mode or not, * based on the PayPal Setting. @@ -180,43 +180,43 @@ class PayPal_Gateway extends Base_Gateway { * @since 2.0.0 * @return void */ - public function settings() { + public function settings(): void { wu_register_settings_field( 'payment-gateways', 'paypal_header', - array( + [ 'title' => __('PayPal', 'wp-ultimo'), 'desc' => __('Use the settings section below to configure PayPal Express as a payment method.', 'wp-ultimo'), 'type' => 'header', 'show_as_submenu' => true, - 'require' => array( + 'require' => [ 'active_gateways' => 'paypal', - ), - ) + ], + ] ); wu_register_settings_field( 'payment-gateways', 'paypal_sandbox_mode', - array( + [ 'title' => __('PayPal Sandbox Mode', 'wp-ultimo'), 'desc' => __('Toggle this to put PayPal on sandbox mode. This is useful for testing and making sure PayPal is correctly setup to handle your payments.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'paypal_sandbox_mode', - ), - 'require' => array( + ], + 'require' => [ 'active_gateways' => 'paypal', - ), - ) + ], + ] ); wu_register_settings_field( 'payment-gateways', 'paypal_test_username', - array( + [ 'title' => __('PayPal Test Username', 'wp-ultimo'), 'desc' => '', 'tooltip' => __('Make sure you are placing the TEST username, not the live one.', 'wp-ultimo'), @@ -224,17 +224,17 @@ class PayPal_Gateway extends Base_Gateway { 'type' => 'text', 'default' => '', 'capability' => 'manage_api_keys', - 'require' => array( + 'require' => [ 'active_gateways' => 'paypal', 'paypal_sandbox_mode' => 1, - ), - ) + ], + ] ); wu_register_settings_field( 'payment-gateways', 'paypal_test_password', - array( + [ 'title' => __('PayPal Test Password', 'wp-ultimo'), 'desc' => '', 'tooltip' => __('Make sure you are placing the TEST password, not the live one.', 'wp-ultimo'), @@ -242,17 +242,17 @@ class PayPal_Gateway extends Base_Gateway { 'type' => 'text', 'default' => '', 'capability' => 'manage_api_keys', - 'require' => array( + 'require' => [ 'active_gateways' => 'paypal', 'paypal_sandbox_mode' => 1, - ), - ) + ], + ] ); wu_register_settings_field( 'payment-gateways', 'paypal_test_signature', - array( + [ 'title' => __('PayPal Test Signature', 'wp-ultimo'), 'desc' => '', 'tooltip' => __('Make sure you are placing the TEST signature, not the live one.', 'wp-ultimo'), @@ -260,17 +260,17 @@ class PayPal_Gateway extends Base_Gateway { 'type' => 'text', 'default' => '', 'capability' => 'manage_api_keys', - 'require' => array( + 'require' => [ 'active_gateways' => 'paypal', 'paypal_sandbox_mode' => 1, - ), - ) + ], + ] ); wu_register_settings_field( 'payment-gateways', 'paypal_live_username', - array( + [ 'title' => __('PayPal Live Username', 'wp-ultimo'), 'desc' => '', 'tooltip' => __('Make sure you are placing the LIVE username, not the test one.', 'wp-ultimo'), @@ -278,17 +278,17 @@ class PayPal_Gateway extends Base_Gateway { 'type' => 'text', 'default' => '', 'capability' => 'manage_api_keys', - 'require' => array( + 'require' => [ 'active_gateways' => 'paypal', 'paypal_sandbox_mode' => 0, - ), - ) + ], + ] ); wu_register_settings_field( 'payment-gateways', 'paypal_live_password', - array( + [ 'title' => __('PayPal Live Password', 'wp-ultimo'), 'desc' => '', 'tooltip' => __('Make sure you are placing the LIVE password, not the test one.', 'wp-ultimo'), @@ -296,17 +296,17 @@ class PayPal_Gateway extends Base_Gateway { 'type' => 'text', 'default' => '', 'capability' => 'manage_api_keys', - 'require' => array( + 'require' => [ 'active_gateways' => 'paypal', 'paypal_sandbox_mode' => 0, - ), - ) + ], + ] ); wu_register_settings_field( 'payment-gateways', 'paypal_live_signature', - array( + [ 'title' => __('PayPal Live Signature', 'wp-ultimo'), 'desc' => '', 'tooltip' => __('Make sure you are placing the LIVE signature, not the test one.', 'wp-ultimo'), @@ -314,11 +314,11 @@ class PayPal_Gateway extends Base_Gateway { 'type' => 'text', 'default' => '', 'capability' => 'manage_api_keys', - 'require' => array( + 'require' => [ 'active_gateways' => 'paypal', 'paypal_sandbox_mode' => 0, - ), - ) + ], + ] ); } @@ -357,7 +357,7 @@ class PayPal_Gateway extends Base_Gateway { $description = wu_get_setting('company_name', __('Subscription', 'wp-ultimo')) . ': ' . implode(', ', array_map(fn($item) => 'x' . $item->get_quantity() . ' ' . $item->get_title(), $temp_payment->get_line_items())); - $args = array( + $args = [ 'USER' => $this->username, 'PWD' => $this->password, 'SIGNATURE' => $this->signature, @@ -368,15 +368,15 @@ class PayPal_Gateway extends Base_Gateway { 'DESC' => $description, 'AMT' => $temp_payment->get_total() - $temp_payment->get_tax_total(), 'TAXAMT' => $temp_payment->get_tax_total(), - ); + ]; $request = wp_remote_post( $this->api_endpoint, - array( + [ 'timeout' => 45, 'httpversion' => '1.1', 'body' => $args, - ) + ] ); /* @@ -417,7 +417,7 @@ class PayPal_Gateway extends Base_Gateway { * @param string $type The checkout type. Can be 'new', 'retry', 'upgrade', 'downgrade', 'addon'. * @return void */ - public function process_checkout($payment, $membership, $customer, $cart, $type) { + public function process_checkout($payment, $membership, $customer, $cart, $type): void { /* * To make our lives easier, let's * set a couple of variables based on the order. @@ -466,7 +466,7 @@ class PayPal_Gateway extends Base_Gateway { * request object, and append the products * later. */ - $args = array( + $args = [ 'USER' => $this->username, 'PWD' => $this->password, 'SIGNATURE' => $this->signature, @@ -492,9 +492,9 @@ class PayPal_Gateway extends Base_Gateway { 'LANDINGPAGE' => 'Billing', 'RETURNURL' => $return_url, 'LOGOIMG' => wu_get_network_logo(), - ); + ]; - $notes = array(); + $notes = []; if ($is_trial_setup) { $desc = $membership->get_recurring_description(); @@ -553,13 +553,13 @@ class PayPal_Gateway extends Base_Gateway { $sub_total = $line_item->get_subtotal(); $tax_amount = $line_item->get_tax_total(); - $product_args = array( + $product_args = [ "L_PAYMENTREQUEST_0_NAME{$product_index}" => $line_item->get_title(), "L_PAYMENTREQUEST_0_DESC{$product_index}" => $line_item->get_description(), "L_PAYMENTREQUEST_0_AMT{$product_index}" => $sub_total, "L_PAYMENTREQUEST_0_QTY{$product_index}" => $line_item->get_quantity(), "L_PAYMENTREQUEST_0_TAXAMT{$product_index}" => $tax_amount, - ); + ]; $args['PAYMENTREQUEST_0_ITEMAMT'] = $args['PAYMENTREQUEST_0_ITEMAMT'] + $sub_total; $args['PAYMENTREQUEST_0_TAXAMT'] = $args['PAYMENTREQUEST_0_TAXAMT'] + $tax_amount; @@ -577,11 +577,11 @@ class PayPal_Gateway extends Base_Gateway { $args = array_merge( $args, - array( + [ "L_PAYMENTREQUEST_0_NAME{$product_index}" => __('Account credit and other discounts', 'wp-ultimo'), "L_PAYMENTREQUEST_0_AMT{$product_index}" => $discounts_total, "L_PAYMENTREQUEST_0_QTY{$product_index}" => 1, - ) + ] ); $args['PAYMENTREQUEST_0_ITEMAMT'] = $args['PAYMENTREQUEST_0_ITEMAMT'] + $discounts_total; @@ -592,11 +592,11 @@ class PayPal_Gateway extends Base_Gateway { $request = wp_remote_post( $this->api_endpoint, - array( + [ 'timeout' => 45, 'httpversion' => '1.1', 'body' => $args, - ) + ] ); $body = wp_remote_retrieve_body($request); @@ -664,11 +664,11 @@ class PayPal_Gateway extends Base_Gateway { * @param \WP_Ultimo\Models\Customer $customer The customer checking out. * @return void|bool */ - public function process_cancellation($membership, $customer) { + public function process_cancellation($membership, $customer): void { $profile_id = $membership->get_gateway_subscription_id(); - $args = array( + $args = [ 'USER' => $this->username, 'PWD' => $this->password, 'SIGNATURE' => $this->signature, @@ -676,15 +676,15 @@ class PayPal_Gateway extends Base_Gateway { 'METHOD' => 'ManageRecurringPaymentsProfileStatus', 'PROFILEID' => $profile_id, 'ACTION' => 'Cancel', - ); + ]; $request = wp_remote_post( $this->api_endpoint, - array( + [ 'timeout' => 45, 'httpversion' => '1.1', 'body' => $args, - ) + ] ); } @@ -720,7 +720,7 @@ class PayPal_Gateway extends Base_Gateway { $amount_formatted = number_format($amount, 2); - $args = array( + $args = [ 'USER' => $this->username, 'PWD' => $this->password, 'SIGNATURE' => $this->signature, @@ -729,7 +729,7 @@ class PayPal_Gateway extends Base_Gateway { 'REFUND_TYPE' => $refund_type, 'TRANSACTIONID' => $gateway_payment_id, 'INVOICEID' => $payment->get_hash(), - ); + ]; if ($refund_type === 'Partial') { $args['AMT'] = $amount_formatted; @@ -737,11 +737,11 @@ class PayPal_Gateway extends Base_Gateway { $request = wp_remote_post( $this->api_endpoint, - array( + [ 'timeout' => 45, 'httpversion' => '1.1', 'body' => $args, - ) + ] ); $body = wp_remote_retrieve_body($request); @@ -802,7 +802,7 @@ class PayPal_Gateway extends Base_Gateway { * @access public * @return void */ - public function process_confirmation() { + public function process_confirmation(): void { /* * Tries to retrieve the nonce, this part is necessary due EU SCA Compliancy. */ @@ -905,7 +905,7 @@ class PayPal_Gateway extends Base_Gateway { $customer = false; $membership = false; - $custom = ! empty($posted['custom']) ? explode('|', (string) $posted['custom']) : array(); + $custom = ! empty($posted['custom']) ? explode('|', (string) $posted['custom']) : []; if (is_array($custom) && ! empty($custom)) { $payment = wu_get_payment(absint($custom[0])); @@ -927,12 +927,12 @@ class PayPal_Gateway extends Base_Gateway { * Base payment data for update * or insertion. */ - $payment_data = array( + $payment_data = [ 'status' => Payment_Status::COMPLETED, 'customer_id' => $membership->get_customer_id(), 'membership_id' => $membership->get_id(), 'gateway' => $this->id, - ); + ]; $amount = isset($posted['mc_gross']) ? wu_to_float($posted['mc_gross']) : false; @@ -1112,7 +1112,7 @@ class PayPal_Gateway extends Base_Gateway { case 'recurring_payment_suspended_due_to_max_failed_payment': // Same case as before wu_log_add('paypal', 'Processing PayPal Express recurring_payment_failed or recurring_payment_suspended_due_to_max_failed_payment IPN.'); - if ( ! in_array($membership->get_status(), array('cancelled', 'expired'), true)) { + if ( ! in_array($membership->get_status(), ['cancelled', 'expired'], true)) { $membership->set_status('expired'); } @@ -1195,7 +1195,7 @@ class PayPal_Gateway extends Base_Gateway { */ protected function create_recurring_profile($details, $cart, $payment, $membership, $customer) { - $args = array( + $args = [ 'USER' => $this->username, 'PWD' => $this->password, 'SIGNATURE' => $this->signature, @@ -1212,7 +1212,7 @@ class PayPal_Gateway extends Base_Gateway { 'L_BILLINGTYPE0' => 'RecurringPayments', 'DESC' => $this->get_subscription_description($cart), 'BUTTONSOURCE' => 'WP_Ultimo', - ); + ]; if ($args['INITAMT'] < 0) { unset($args['INITAMT']); @@ -1236,11 +1236,11 @@ class PayPal_Gateway extends Base_Gateway { $request = wp_remote_post( $this->api_endpoint, - array( + [ 'timeout' => 45, 'httpversion' => '1.1', 'body' => $args, - ) + ] ); $body = wp_remote_retrieve_body($request); @@ -1272,8 +1272,8 @@ class PayPal_Gateway extends Base_Gateway { * First, set the value * and the transaction ID. */ - $transaction_id = isset($body['TRANSACTIONID']) ? $body['TRANSACTIONID'] : ''; - $profile_status = isset($body['PROFILESTATUS']) ? $body['PROFILESTATUS'] : ''; + $transaction_id = $body['TRANSACTIONID'] ?? ''; + $profile_status = $body['PROFILESTATUS'] ?? ''; // If TRANSACTIONID is not passed we need to wait for webhook $payment_status = Payment_Status::PENDING; @@ -1287,10 +1287,10 @@ class PayPal_Gateway extends Base_Gateway { */ $transaction_id = empty($transaction_id) && ! empty($body['PROFILEID']) ? $body['PROFILEID'] : $transaction_id; - $payment_data = array( + $payment_data = [ 'gateway_payment_id' => $transaction_id, 'status' => $payment_status, - ); + ]; /* * Update local payment. @@ -1350,10 +1350,10 @@ class PayPal_Gateway extends Base_Gateway { wp_die( __('Something has gone wrong, please try again', 'wp-ultimo'), __('Error', 'wp-ultimo'), - array( + [ 'back_link' => true, 'response' => '401', - ) + ] ); } } @@ -1390,7 +1390,7 @@ class PayPal_Gateway extends Base_Gateway { protected function complete_single_payment($details, $cart, $payment, $membership, $customer) { // One time payment - $args = array( + $args = [ 'USER' => $this->username, 'PWD' => $this->password, 'SIGNATURE' => $this->signature, @@ -1405,15 +1405,15 @@ class PayPal_Gateway extends Base_Gateway { 'PAYMENTREQUEST_0_TAXAMT' => 0, 'PAYMENTREQUEST_0_CURRENCYCODE' => $details['CURRENCYCODE'], 'BUTTONSOURCE' => 'WP_Ultimo', - ); + ]; $request = wp_remote_post( $this->api_endpoint, - array( + [ 'timeout' => 45, 'httpversion' => '1.1', 'body' => $args, - ) + ] ); /* @@ -1447,10 +1447,10 @@ class PayPal_Gateway extends Base_Gateway { */ $transaction_id = $body['PAYMENTINFO_0_TRANSACTIONID']; - $payment_data = array( + $payment_data = [ 'gateway_payment_id' => $transaction_id, 'status' => Payment_Status::COMPLETED, - ); + ]; /* * Update local payment. @@ -1505,10 +1505,10 @@ class PayPal_Gateway extends Base_Gateway { wp_die( __('Something has gone wrong, please try again', 'wp-ultimo'), __('Error', 'wp-ultimo'), - array( + [ 'back_link' => true, 'response' => '401', - ) + ] ); } } @@ -1539,12 +1539,12 @@ class PayPal_Gateway extends Base_Gateway { wu_get_template( 'checkout/paypal/confirm', - array( + [ 'checkout_details' => $checkout_details, 'customer' => $customer, 'payment' => $checkout_details['pending_payment'], 'membership' => $checkout_details['pending_payment']->get_membership(), - ) + ] ); } /** @@ -1555,22 +1555,22 @@ class PayPal_Gateway extends Base_Gateway { */ public function get_checkout_details($token = '') { - $args = array( + $args = [ 'TOKEN' => $token, 'USER' => $this->username, 'PWD' => $this->password, 'SIGNATURE' => $this->signature, 'VERSION' => '124', 'METHOD' => 'GetExpressCheckoutDetails', - ); + ]; $request = wp_remote_post( $this->api_endpoint, - array( + [ 'timeout' => 45, 'httpversion' => '1.1', 'body' => $args, - ) + ] ); $body = wp_remote_retrieve_body($request); diff --git a/inc/gateways/class-stripe-checkout-gateway.php b/inc/gateways/class-stripe-checkout-gateway.php index 87c920d..946810c 100644 --- a/inc/gateways/class-stripe-checkout-gateway.php +++ b/inc/gateways/class-stripe-checkout-gateway.php @@ -39,53 +39,53 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { * @since 2.0.0 * @return void */ - public function settings() { + public function settings(): void { $error_message_wrap = '%s'; wu_register_settings_field( 'payment-gateways', 'stripe_checkout_header', - array( + [ 'title' => __('Stripe Checkout', 'wp-ultimo'), 'desc' => __('Use the settings section below to configure Stripe Checkout as a payment method.', 'wp-ultimo'), 'type' => 'header', 'show_as_submenu' => true, - 'require' => array( + 'require' => [ 'active_gateways' => 'stripe-checkout', - ), - ) + ], + ] ); wu_register_settings_field( 'payment-gateways', 'stripe_checkout_public_title', - array( + [ 'title' => __('Stripe Public Name', 'wp-ultimo'), 'tooltip' => __('The name to display on the payment method selection field. By default, "Credit Card" is used.', 'wp-ultimo'), 'type' => 'text', 'default' => __('Credit Card', 'wp-ultimo'), - 'require' => array( + 'require' => [ 'active_gateways' => 'stripe-checkout', - ), - ) + ], + ] ); wu_register_settings_field( 'payment-gateways', 'stripe_checkout_sandbox_mode', - array( + [ 'title' => __('Stripe Checkout Sandbox Mode', 'wp-ultimo'), 'desc' => __('Toggle this to put Stripe on sandbox mode. This is useful for testing and making sure Stripe is correctly setup to handle your payments.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 1, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'stripe_checkout_sandbox_mode', - ), - 'require' => array( + ], + 'require' => [ 'active_gateways' => 'stripe-checkout', - ), - ) + ], + ] ); $pk_test_status = wu_get_setting('stripe_checkout_test_pk_key_status', ''); @@ -93,7 +93,7 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { wu_register_settings_field( 'payment-gateways', 'stripe_checkout_test_pk_key', - array( + [ 'title' => __('Stripe Test Publishable Key', 'wp-ultimo'), 'desc' => ! empty($pk_test_status) ? sprintf($error_message_wrap, $pk_test_status) : '', 'tooltip' => __('Make sure you are placing the TEST keys, not the live ones.', 'wp-ultimo'), @@ -101,11 +101,11 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { 'type' => 'text', 'default' => '', 'capability' => 'manage_api_keys', - 'require' => array( + 'require' => [ 'active_gateways' => 'stripe-checkout', 'stripe_checkout_sandbox_mode' => 1, - ), - ) + ], + ] ); $sk_test_status = wu_get_setting('stripe_checkout_test_sk_key_status', ''); @@ -113,7 +113,7 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { wu_register_settings_field( 'payment-gateways', 'stripe_checkout_test_sk_key', - array( + [ 'title' => __('Stripe Test Secret Key', 'wp-ultimo'), 'desc' => ! empty($sk_test_status) ? sprintf($error_message_wrap, $sk_test_status) : '', 'tooltip' => __('Make sure you are placing the TEST keys, not the live ones.', 'wp-ultimo'), @@ -121,11 +121,11 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { 'type' => 'text', 'default' => '', 'capability' => 'manage_api_keys', - 'require' => array( + 'require' => [ 'active_gateways' => 'stripe-checkout', 'stripe_checkout_sandbox_mode' => 1, - ), - ) + ], + ] ); $pk_status = wu_get_setting('stripe_checkout_live_pk_key_status', ''); @@ -133,7 +133,7 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { wu_register_settings_field( 'payment-gateways', 'stripe_checkout_live_pk_key', - array( + [ 'title' => __('Stripe Live Publishable Key', 'wp-ultimo'), 'desc' => ! empty($pk_status) ? sprintf($error_message_wrap, $pk_status) : '', 'tooltip' => __('Make sure you are placing the LIVE keys, not the test ones.', 'wp-ultimo'), @@ -141,11 +141,11 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { 'type' => 'text', 'default' => '', 'capability' => 'manage_api_keys', - 'require' => array( + 'require' => [ 'active_gateways' => 'stripe-checkout', 'stripe_checkout_sandbox_mode' => 0, - ), - ) + ], + ] ); $sk_status = wu_get_setting('stripe_checkout_live_sk_key_status', ''); @@ -153,7 +153,7 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { wu_register_settings_field( 'payment-gateways', 'stripe_checkout_live_sk_key', - array( + [ 'title' => __('Stripe Live Secret Key', 'wp-ultimo'), 'desc' => ! empty($sk_status) ? sprintf($error_message_wrap, $sk_status) : '', 'tooltip' => __('Make sure you are placing the LIVE keys, not the test ones.', 'wp-ultimo'), @@ -161,11 +161,11 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { 'type' => 'text', 'default' => '', 'capability' => 'manage_api_keys', - 'require' => array( + 'require' => [ 'active_gateways' => 'stripe-checkout', 'stripe_checkout_sandbox_mode' => 0, - ), - ) + ], + ] ); $webhook_message = sprintf('%s', __('Whenever you change your Stripe settings, WP Multisite WaaS will automatically check the webhook URLs on your Stripe account to make sure we get notified about changes in subscriptions and payments.', 'wp-ultimo')); @@ -173,7 +173,7 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { wu_register_settings_field( 'payment-gateways', 'stripe_checkout_webhook_listener_explanation', - array( + [ 'title' => __('Webhook Listener URL', 'wp-ultimo'), 'desc' => $webhook_message, 'tooltip' => __('This is the URL Stripe should send webhook calls to.', 'wp-ultimo'), @@ -181,10 +181,10 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { 'copy' => true, 'default' => $this->get_webhook_listener_url(), 'wrapper_classes' => '', - 'require' => array( + 'require' => [ 'active_gateways' => 'stripe-checkout', - ), - ) + ], + ] ); parent::settings(); @@ -244,17 +244,17 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { */ $allowed_payment_method_types = apply_filters( 'wu_stripe_checkout_allowed_payment_method_types', - array( + [ 'card', - ), + ], $this ); - $metadata = array( + $metadata = [ 'payment_id' => $this->payment->get_id(), 'membership_id' => $this->membership->get_id(), 'customer_id' => $this->customer->get_id(), - ); + ]; $this->membership->set_gateway_customer_id($s_customer->id); $this->membership->set_gateway($this->get_id()); @@ -277,7 +277,7 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { $metadata['swap_id'] = $swap_id; } - $subscription_data = array( + $subscription_data = [ 'payment_method_types' => $allowed_payment_method_types, 'success_url' => $redirect_url, 'cancel_url' => $this->get_cancel_url(), @@ -285,7 +285,7 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { 'client_reference_id' => $this->customer->get_id(), 'customer' => $s_customer->id, 'metadata' => $metadata, - ); + ]; if ($this->order->should_auto_renew()) { $stripe_cart = $this->build_stripe_cart($this->order); @@ -294,9 +294,9 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { /* * Adds recurring stuff. */ - $subscription_data['subscription_data'] = array( + $subscription_data['subscription_data'] = [ 'items' => array_values($stripe_cart), - ); + ]; } else { /* * Create non-recurring only cart. @@ -316,9 +316,9 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { $s_coupon = $this->get_credit_coupon($this->order); if ($s_coupon) { - $subscription_data['discounts'] = array( - array('coupon' => $s_coupon), - ); + $subscription_data['discounts'] = [ + ['coupon' => $s_coupon], + ]; } /** @@ -350,9 +350,9 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { $session = Stripe\Checkout\Session::create($subscription_data); // Add the client secret to the JSON success data. - return array( + return [ 'stripe_session_id' => sanitize_text_field($session->id), - ); + ]; } /** @@ -367,7 +367,7 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { * @since 2.0.0 * @return void */ - public function process_confirmation() { + public function process_confirmation(): void { $saved_swap = $this->get_saved_swap(wu_request('swap')); @@ -409,19 +409,19 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { */ public function payment_methods() { - $fields = array(); + $fields = []; $card_options = $this->get_saved_card_options(); if ($card_options) { foreach ($card_options as $payment_method => $card) { - $fields = array( - "payment_method_{$payment_method}" => array( + $fields = [ + "payment_method_{$payment_method}" => [ 'type' => 'text-display', 'title' => __('Saved Cards', 'wp-ultimo'), 'display_value' => $card, - ), - ); + ], + ]; } } @@ -442,7 +442,7 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { $customer = wu_get_current_customer(); if ( ! $customer) { - return array(); + return []; } $customer_id = $customer->get_id(); @@ -457,14 +457,14 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { return $existing_payment_methods[ $customer_id ]; } - $customer_payment_methods = array(); + $customer_payment_methods = []; $stripe_customer_id = \WP_Ultimo\Models\Membership::query( - array( + [ 'customer_id' => $customer_id, 'search' => 'cus_*', - 'fields' => array('gateway_customer_id'), - ) + 'fields' => ['gateway_customer_id'], + ] ); $stripe_customer_id = current(array_column($stripe_customer_id, 'gateway_customer_id')); @@ -475,10 +475,10 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { $this->setup_api_keys(); $payment_methods = Stripe\PaymentMethod::all( - array( + [ 'customer' => $stripe_customer_id, 'type' => 'card', - ) + ] ); foreach ($payment_methods->data as $payment_method) { @@ -489,7 +489,7 @@ class Stripe_Checkout_Gateway extends Base_Stripe_Gateway { return $existing_payment_methods[ $customer_id ]; } catch (\Throwable $exception) { - return array(); + return []; } } } diff --git a/inc/gateways/class-stripe-gateway.php b/inc/gateways/class-stripe-gateway.php index 7e46fbe..c8bf4fe 100644 --- a/inc/gateways/class-stripe-gateway.php +++ b/inc/gateways/class-stripe-gateway.php @@ -40,7 +40,7 @@ class Stripe_Gateway extends Base_Stripe_Gateway { * @since 2.0.0 * @return void */ - public function hooks() { + public function hooks(): void { parent::hooks(); @@ -65,53 +65,53 @@ class Stripe_Gateway extends Base_Stripe_Gateway { * @since 2.0.0 * @return void */ - public function settings() { + public function settings(): void { $error_message_wrap = '%s'; wu_register_settings_field( 'payment-gateways', 'stripe_header', - array( + [ 'title' => __('Stripe', 'wp-ultimo'), 'desc' => __('Use the settings section below to configure Stripe as a payment method.', 'wp-ultimo'), 'type' => 'header', 'show_as_submenu' => true, - 'require' => array( + 'require' => [ 'active_gateways' => 'stripe', - ), - ) + ], + ] ); wu_register_settings_field( 'payment-gateways', 'stripe_public_title', - array( + [ 'title' => __('Stripe Public Name', 'wp-ultimo'), 'tooltip' => __('The name to display on the payment method selection field. By default, "Credit Card" is used.', 'wp-ultimo'), 'type' => 'text', 'default' => __('Credit Card', 'wp-ultimo'), - 'require' => array( + 'require' => [ 'active_gateways' => 'stripe', - ), - ) + ], + ] ); wu_register_settings_field( 'payment-gateways', 'stripe_sandbox_mode', - array( + [ 'title' => __('Stripe Sandbox Mode', 'wp-ultimo'), 'desc' => __('Toggle this to put Stripe on sandbox mode. This is useful for testing and making sure Stripe is correctly setup to handle your payments.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 1, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'stripe_sandbox_mode', - ), - 'require' => array( + ], + 'require' => [ 'active_gateways' => 'stripe', - ), - ) + ], + ] ); $pk_test_status = wu_get_setting('stripe_test_pk_key_status', ''); @@ -119,7 +119,7 @@ class Stripe_Gateway extends Base_Stripe_Gateway { wu_register_settings_field( 'payment-gateways', 'stripe_test_pk_key', - array( + [ 'title' => __('Stripe Test Publishable Key', 'wp-ultimo'), 'desc' => ! empty($pk_test_status) ? sprintf($error_message_wrap, $pk_test_status) : '', 'tooltip' => __('Make sure you are placing the TEST keys, not the live ones.', 'wp-ultimo'), @@ -127,11 +127,11 @@ class Stripe_Gateway extends Base_Stripe_Gateway { 'type' => 'text', 'default' => '', 'capability' => 'manage_api_keys', - 'require' => array( + 'require' => [ 'active_gateways' => 'stripe', 'stripe_sandbox_mode' => 1, - ), - ) + ], + ] ); $sk_test_status = wu_get_setting('stripe_test_sk_key_status', ''); @@ -139,7 +139,7 @@ class Stripe_Gateway extends Base_Stripe_Gateway { wu_register_settings_field( 'payment-gateways', 'stripe_test_sk_key', - array( + [ 'title' => __('Stripe Test Secret Key', 'wp-ultimo'), 'desc' => ! empty($sk_test_status) ? sprintf($error_message_wrap, $sk_test_status) : '', 'tooltip' => __('Make sure you are placing the TEST keys, not the live ones.', 'wp-ultimo'), @@ -147,11 +147,11 @@ class Stripe_Gateway extends Base_Stripe_Gateway { 'type' => 'text', 'default' => '', 'capability' => 'manage_api_keys', - 'require' => array( + 'require' => [ 'active_gateways' => 'stripe', 'stripe_sandbox_mode' => 1, - ), - ) + ], + ] ); $pk_status = wu_get_setting('stripe_live_pk_key_status', ''); @@ -159,7 +159,7 @@ class Stripe_Gateway extends Base_Stripe_Gateway { wu_register_settings_field( 'payment-gateways', 'stripe_live_pk_key', - array( + [ 'title' => __('Stripe Live Publishable Key', 'wp-ultimo'), 'desc' => ! empty($pk_status) ? sprintf($error_message_wrap, $pk_status) : '', 'tooltip' => __('Make sure you are placing the LIVE keys, not the test ones.', 'wp-ultimo'), @@ -167,11 +167,11 @@ class Stripe_Gateway extends Base_Stripe_Gateway { 'type' => 'text', 'default' => '', 'capability' => 'manage_api_keys', - 'require' => array( + 'require' => [ 'active_gateways' => 'stripe', 'stripe_sandbox_mode' => 0, - ), - ) + ], + ] ); $sk_status = wu_get_setting('stripe_live_sk_key_status', ''); @@ -179,7 +179,7 @@ class Stripe_Gateway extends Base_Stripe_Gateway { wu_register_settings_field( 'payment-gateways', 'stripe_live_sk_key', - array( + [ 'title' => __('Stripe Live Secret Key', 'wp-ultimo'), 'desc' => ! empty($sk_status) ? sprintf($error_message_wrap, $sk_status) : '', 'tooltip' => __('Make sure you are placing the LIVE keys, not the test ones.', 'wp-ultimo'), @@ -187,11 +187,11 @@ class Stripe_Gateway extends Base_Stripe_Gateway { 'type' => 'text', 'default' => '', 'capability' => 'manage_api_keys', - 'require' => array( + 'require' => [ 'active_gateways' => 'stripe', 'stripe_sandbox_mode' => 0, - ), - ) + ], + ] ); $webhook_message = sprintf('%s', __('Whenever you change your Stripe settings, WP Multisite WaaS will automatically check the webhook URLs on your Stripe account to make sure we get notified about changes in subscriptions and payments.', 'wp-ultimo')); @@ -199,7 +199,7 @@ class Stripe_Gateway extends Base_Stripe_Gateway { wu_register_settings_field( 'payment-gateways', 'stripe_webhook_listener_explanation', - array( + [ 'title' => __('Webhook Listener URL', 'wp-ultimo'), 'desc' => $webhook_message, 'tooltip' => __('This is the URL Stripe should send webhook calls to.', 'wp-ultimo'), @@ -207,10 +207,10 @@ class Stripe_Gateway extends Base_Stripe_Gateway { 'copy' => true, 'default' => $this->get_webhook_listener_url(), 'wrapper_classes' => '', - 'require' => array( + 'require' => [ 'active_gateways' => 'stripe', - ), - ) + ], + ] ); parent::settings(); @@ -279,11 +279,11 @@ class Stripe_Gateway extends Base_Stripe_Gateway { $this->membership->save(); - $intent_args = array( + $intent_args = [ 'customer' => $s_customer->id, 'metadata' => $this->get_customer_metadata(), 'description' => $this->order->get_cart_descriptor(), - ); + ]; /* * Maybe use an existing payment method. @@ -299,7 +299,7 @@ class Stripe_Gateway extends Base_Stripe_Gateway { * This should also be filterable, to allow support * for Stripe Connect in the future. */ - $intent_options = array(); + $intent_options = []; /* * Tries to retrieve an existing intent id, @@ -325,7 +325,7 @@ class Stripe_Gateway extends Base_Stripe_Gateway { * payment attached to the membership. Those start with a pi_ * id. */ - if ( ! empty($payment_intent_id) && strncmp((string) $payment_intent_id, 'pi_', strlen('pi_')) === 0) { + if ( ! empty($payment_intent_id) && str_starts_with((string) $payment_intent_id, 'pi_')) { $existing_intent = Stripe\PaymentIntent::retrieve($payment_intent_id); /* @@ -334,7 +334,7 @@ class Stripe_Gateway extends Base_Stripe_Gateway { * when we set up a subscription without a * initial amount. */ - } elseif ( ! empty($payment_intent_id) && strncmp((string) $payment_intent_id, 'seti_', strlen('seti_')) === 0) { + } elseif ( ! empty($payment_intent_id) && str_starts_with((string) $payment_intent_id, 'seti_')) { $existing_intent = Stripe\SetupIntent::retrieve($payment_intent_id); } @@ -355,13 +355,13 @@ class Stripe_Gateway extends Base_Stripe_Gateway { if ($this->order->get_total() && $this->order->has_trial() === false) { $intent_args = wp_parse_args( $intent_args, - array( + [ 'amount' => $this->order->get_total() * wu_stripe_get_currency_multiplier(), 'confirmation_method' => 'automatic', 'setup_future_usage' => 'off_session', 'currency' => strtolower((string) wu_get_setting('currency_symbol', 'USD')), 'confirm' => false, - ) + ] ); /** @@ -390,7 +390,7 @@ class Stripe_Gateway extends Base_Stripe_Gateway { $intent_options['idempotency_key'] = wu_stripe_generate_idempotency_key($idempotency_args); // Unset some options we can't update. - $unset_args = array('confirmation_method', 'confirm'); + $unset_args = ['confirmation_method', 'confirm']; foreach ($unset_args as $unset_arg) { if (isset($intent_args[ $unset_arg ])) { @@ -413,9 +413,9 @@ class Stripe_Gateway extends Base_Stripe_Gateway { */ $intent_args = wp_parse_args( $intent_args, - array( + [ 'usage' => 'off_session', - ) + ] ); if (empty($existing_intent) || 'setup_intent' !== $existing_intent->object) { @@ -463,10 +463,10 @@ class Stripe_Gateway extends Base_Stripe_Gateway { * Using this info, we'll be able to process * the Stripe payment on the next step: process_checkout */ - return array( + return [ 'stripe_client_secret' => sanitize_text_field($intent->client_secret), 'stripe_intent_type' => sanitize_text_field($intent->object), - ); + ]; } /** @@ -487,7 +487,7 @@ class Stripe_Gateway extends Base_Stripe_Gateway { * * @return void */ - public function process_checkout($payment, $membership, $customer, $cart, $type) { + public function process_checkout($payment, $membership, $customer, $cart, $type): void { /* * Here's the general idea * of how the Stripe integration works. @@ -529,7 +529,7 @@ class Stripe_Gateway extends Base_Stripe_Gateway { * Get the correct intent * type depending on the intent ID */ - if (strncmp((string) $payment_intent_id, 'seti_', strlen('seti_')) === 0) { + if (str_starts_with((string) $payment_intent_id, 'seti_')) { $is_setup_intent = true; $payment_intent = Stripe\SetupIntent::retrieve($payment_intent_id); @@ -557,15 +557,15 @@ class Stripe_Gateway extends Base_Stripe_Gateway { */ Stripe\Customer::update( $s_customer->id, - array( + [ 'address' => $this->convert_to_stripe_address($customer->get_billing_address()), 'description' => sanitize_text_field($description), - 'metadata' => array( + 'metadata' => [ 'email' => $customer->get_email_address(), 'user_id' => $customer->get_user_id(), 'customer_id' => $customer->get_id(), - ), - ) + ], + ] ); /* @@ -609,7 +609,7 @@ class Stripe_Gateway extends Base_Stripe_Gateway { $membership->set_gateway_customer_id($s_customer->id); $membership->set_gateway_subscription_id($subscription->id); $membership->add_to_times_billed(1); - $membership->should_auto_renew(true); + $membership->should_auto_renew(); if ($type !== 'downgrade') { $membership_status = $cart->has_trial() ? Membership_Status::TRIALING : Membership_Status::ACTIVE; @@ -641,37 +641,37 @@ class Stripe_Gateway extends Base_Stripe_Gateway { */ public function fields(): string { - $fields = array(); + $fields = []; $card_options = $this->get_saved_card_options(); if ($card_options) { $card_options['add-new'] = __('Add new card', 'wp-ultimo'); - $fields = array( - 'payment_method' => array( + $fields = [ + 'payment_method' => [ 'type' => 'radio', 'title' => __('Saved Payment Methods', 'wp-ultimo'), 'value' => wu_request('payment_method'), 'options' => $card_options, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'payment_method', - ), - ), - ); + ], + ], + ]; } $stripe_form = new \WP_Ultimo\UI\Form( 'billing-address-fields', $fields, - array( + [ 'views' => 'checkout/fields', - 'variables' => array( - 'step' => (object) array( + 'variables' => [ + 'step' => (object) [ 'classes' => '', - ), - ), - ) + ], + ], + ] ); ob_start(); @@ -712,19 +712,19 @@ class Stripe_Gateway extends Base_Stripe_Gateway { */ public function payment_methods() { - $fields = array(); + $fields = []; $card_options = $this->get_saved_card_options(); if ($card_options) { foreach ($card_options as $payment_method => $card) { - $fields = array( - "payment_method_{$payment_method}" => array( + $fields = [ + "payment_method_{$payment_method}" => [ 'type' => 'text-display', 'title' => __('Saved Cards', 'wp-ultimo'), 'display_value' => $card, - ), - ); + ], + ]; } } @@ -745,7 +745,7 @@ class Stripe_Gateway extends Base_Stripe_Gateway { $customer = wu_get_current_customer(); if ( ! $customer) { - return array(); + return []; } $customer_id = $customer->get_id(); @@ -760,14 +760,14 @@ class Stripe_Gateway extends Base_Stripe_Gateway { return $existing_payment_methods[ $customer_id ]; } - $customer_payment_methods = array(); + $customer_payment_methods = []; $stripe_customer_id = \WP_Ultimo\Models\Membership::query( - array( + [ 'customer_id' => $customer_id, 'search' => 'cus_*', - 'fields' => array('gateway_customer_id'), - ) + 'fields' => ['gateway_customer_id'], + ] ); $stripe_customer_id = current(array_column($stripe_customer_id, 'gateway_customer_id')); @@ -778,10 +778,10 @@ class Stripe_Gateway extends Base_Stripe_Gateway { $this->setup_api_keys(); $payment_methods = Stripe\PaymentMethod::all( - array( + [ 'customer' => $stripe_customer_id, 'type' => 'card', - ) + ] ); foreach ($payment_methods->data as $payment_method) { @@ -792,7 +792,7 @@ class Stripe_Gateway extends Base_Stripe_Gateway { return $existing_payment_methods[ $customer_id ]; } catch (\Throwable $exception) { - return array(); + return []; } } } diff --git a/inc/helpers/class-arr.php b/inc/helpers/class-arr.php index f444ed3..d8addc1 100644 --- a/inc/helpers/class-arr.php +++ b/inc/helpers/class-arr.php @@ -78,7 +78,7 @@ class Arr { public static function filter($array, $closure) { if ($closure) { - $result = array(); + $result = []; foreach ($array as $key => $value) { if (call_user_func($closure, $value, $key)) { @@ -145,7 +145,7 @@ class Arr { $key = array_shift($keys); if ( ! isset($array[ $key ]) || ! is_array($array[ $key ])) { - $array[ $key ] = array(); + $array[ $key ] = []; } $array =& $array[ $key ]; diff --git a/inc/helpers/class-screenshot.php b/inc/helpers/class-screenshot.php index 625e8f9..96af87d 100644 --- a/inc/helpers/class-screenshot.php +++ b/inc/helpers/class-screenshot.php @@ -60,9 +60,9 @@ class Screenshot { $response = wp_remote_get( $url, - array( + [ 'timeout' => 50, - ) + ] ); if (wp_remote_retrieve_response_code($response) !== 200) { @@ -80,7 +80,7 @@ class Screenshot { /* * Check if the results contain a PNG header. */ - if (strncmp($response['body'], "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a", strlen("\x89\x50\x4e\x47\x0d\x0a\x1a\x0a")) !== 0) { + if (! str_starts_with($response['body'], "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a")) { wu_log_add('screenshot-generator', $log_prefix . __('Result is not a PNG file.', 'wp-ultimo'), LogLevel::ERROR); return false; @@ -100,13 +100,13 @@ class Screenshot { $attachment_title = sanitize_file_name(pathinfo($file_name, PATHINFO_FILENAME)); $wp_upload_dir = wp_upload_dir(); - $post_info = array( + $post_info = [ 'guid' => $wp_upload_dir['url'] . '/' . $file_name, 'post_mime_type' => $file_type['type'], 'post_title' => $attachment_title, 'post_content' => '', 'post_status' => 'inherit', - ); + ]; // Create the attachment $attach_id = wp_insert_attachment($post_info, $file_path); diff --git a/inc/helpers/class-sender.php b/inc/helpers/class-sender.php index b420fdf..8d49a6f 100644 --- a/inc/helpers/class-sender.php +++ b/inc/helpers/class-sender.php @@ -29,20 +29,20 @@ class Sender { * @param array $args The args passed. * @return array */ - public static function parse_args($args = array()) { + public static function parse_args($args = []) { - $default_args = array( - 'from' => array( + $default_args = [ + 'from' => [ 'name' => wu_get_setting('from_name'), 'email' => wu_get_setting('from_email'), - ), + ], 'content' => '', 'subject' => '', - 'bcc' => array(), - 'payload' => array(), - 'attachments' => array(), + 'bcc' => [], + 'payload' => [], + 'attachments' => [], 'style' => wu_get_setting('email_template_type', 'html'), - ); + ]; $args = wp_parse_args($args, $default_args); @@ -59,13 +59,13 @@ class Sender { * @param array $args With content, subject and other arguments, has shortcodes, mail type. * @return array With the send response. */ - public static function send_mail($from = array(), $to = array(), $args = array()) { + public static function send_mail($from = [], $to = [], $args = []) { if ( ! $from) { - $from = array( + $from = [ 'email' => wu_get_setting('from_email'), 'name' => wu_get_setting('from_name'), - ); + ]; } $args = self::parse_args($args); @@ -73,7 +73,7 @@ class Sender { /* * First, replace shortcodes. */ - $payload = wu_get_isset($args, 'payload', array()); + $payload = wu_get_isset($args, 'payload', []); $subject = self::process_shortcodes(wu_get_isset($args, 'subject', ''), $payload); @@ -82,7 +82,7 @@ class Sender { /* * Content type and template */ - $headers = array(); + $headers = []; if (wu_get_isset($args, 'style', 'html') === 'html') { $headers[] = 'Content-Type: text/html; charset=UTF-8'; @@ -95,7 +95,7 @@ class Sender { $template = wu_get_template_contents( 'broadcast/emails/base', - array( + [ 'site_name' => get_network_option(null, 'site_name'), 'site_url' => get_site_url(wu_get_main_site_id()), 'logo_url' => wu_get_network_logo(), @@ -103,7 +103,7 @@ class Sender { 'subject' => $subject, 'content' => $content, 'template_settings' => $template_settings, - ) + ] ); } else { $headers[] = 'Content-Type: text/html; charset=UTF-8'; @@ -151,9 +151,9 @@ class Sender { $to = $main_to; } } else { - $to = array( + $to = [ wu_format_email_string(wu_get_isset($to[0], 'email'), wu_get_isset($to[0], 'name')), - ); + ]; } /* @@ -192,13 +192,13 @@ class Sender { * @param array $payload Payload with the values to render in the content. * @return string */ - public static function process_shortcodes($content, $payload = array()) { + public static function process_shortcodes($content, $payload = []) { if (empty($payload)) { return $content; } - $match = array(); + $match = []; preg_match_all('/{{(.*?)}}/', $content, $match); diff --git a/inc/helpers/class-site-duplicator.php b/inc/helpers/class-site-duplicator.php index c0285b6..25b1da9 100644 --- a/inc/helpers/class-site-duplicator.php +++ b/inc/helpers/class-site-duplicator.php @@ -46,7 +46,7 @@ class Site_Duplicator { * @param array $args List of duplication parameters, check Site_Duplicator::process_duplication for reference. * @return int|\WP_Error ID of the newly created site or error. */ - public static function duplicate_site($from_site_id, $title, $args = array()) { + public static function duplicate_site($from_site_id, $title, $args = []) { $args['from_site_id'] = $from_site_id; $args['title'] = $title; @@ -81,7 +81,7 @@ class Site_Duplicator { * @param array $args List of duplication parameters, check Site_Duplicator::process_duplication for reference. * @return int|false ID of the created site. */ - public static function override_site($from_site_id, $to_site_id, $args = array()) { + public static function override_site($from_site_id, $to_site_id, $args = []) { $to_site = wu_get_site($to_site_id); @@ -93,14 +93,14 @@ class Site_Duplicator { $args = wp_parse_args( $args, - array( + [ 'email' => $to_site_customer->get_email_address(), 'title' => $to_site->get_title(), 'path' => $to_site->get_path(), 'from_site_id' => $from_site_id, 'to_site_id' => $to_site_id, 'meta' => $to_site->meta, - ) + ] ); $duplicate_site_id = self::process_duplication($args); @@ -164,7 +164,7 @@ class Site_Duplicator { $args = wp_parse_args( $args, - array( + [ 'email' => '', // Required arguments. 'title' => '', // Required arguments. 'path' => '/', // Required arguments. @@ -175,9 +175,9 @@ class Site_Duplicator { 'domain' => $current_site->domain, 'copy_files' => wu_get_setting('copy_media', true), 'network_id' => get_current_network_id(), - 'meta' => array(), + 'meta' => [], 'user_id' => 0, - ) + ] ); // Checks @@ -198,7 +198,7 @@ class Site_Duplicator { } if ( ! $args->to_site_id) { - $meta = array_merge($args->meta, array('public' => $args->public)); + $meta = array_merge($args->meta, ['public' => $args->public]); $args->to_site_id = wpmu_create_blog($args->domain, $args->path, $args->title, $user_id, $meta, $args->network_id); @@ -244,9 +244,9 @@ class Site_Duplicator { */ do_action( 'wu_duplicate_site', - array( + [ 'site_id' => $args->to_site_id, - ) + ] ); return $args->to_site_id; diff --git a/inc/helpers/class-validator.php b/inc/helpers/class-validator.php index 181c69f..8d2da8e 100644 --- a/inc/helpers/class-validator.php +++ b/inc/helpers/class-validator.php @@ -68,7 +68,7 @@ class Validator { $validation_error_messages = apply_filters( 'wu_validator_error_messages', - array( + [ 'required' => $field_required_message, 'required_without' => $field_required_message, 'required_with' => $field_required_message, @@ -84,17 +84,17 @@ class Validator { 'lowercase' => sprintf(__('The %s must be lowercase', 'wp-ultimo'), ':attribute'), // translators: %s is the field identifier 'integer' => sprintf(__('The %s must be integer', 'wp-ultimo'), ':attribute'), - ), + ], $this ); $this->validator = new Validator_Helper($validation_error_messages); $this->validator->setTranslations( - array( + [ 'and' => __('and', 'wp-ultimo'), 'or' => __('or', 'wp-ultimo'), - ) + ] ); $this->validator->addValidator('unique', new Unique()); @@ -121,7 +121,7 @@ class Validator { * @param array $aliases List of aliases to be used with the validator. * @return \WP_Ultimo\Helpers\Validator */ - public function validate($data, $rules = array(), $aliases = array()) { + public function validate($data, $rules = [], $aliases = []) { $this->errors = new \WP_Error(); diff --git a/inc/helpers/class-wp-config.php b/inc/helpers/class-wp-config.php index b666390..a698500 100644 --- a/inc/helpers/class-wp-config.php +++ b/inc/helpers/class-wp-config.php @@ -59,7 +59,7 @@ class WP_Config { return file_put_contents($config_path, implode('', $config), LOCK_EX); } else { - list($value, $line) = $line; + [$value, $line] = $line; if ($value !== true) { $config[ $line ] = $content . PHP_EOL; @@ -84,7 +84,7 @@ class WP_Config { public function inject_contents($content_array, $line, $value) { if ( ! is_array($value)) { - $value = array($value); + $value = [$value]; } array_splice($content_array, $line, 0, $value); @@ -142,12 +142,12 @@ class WP_Config { */ $patterns = apply_filters( 'wu_wp_config_reference_hook_line_patterns', - array( + [ '/^\$table_prefix\s*=\s*[\'|\"]' . $wpdb->prefix . '[\'|\"]/' => 0, '/^( ){0,}\$table_prefix\s*=.*[\'|\"]' . $wpdb->prefix . '[\'|\"]/' => 0, '/(\/\* That\'s all, stop editing! Happy publishing\. \*\/)/' => -2, '/<\?php/' => 0, - ) + ] ); $line = 1; @@ -219,7 +219,7 @@ class WP_Config { foreach ($config as $k => $line) { if (preg_match($pattern, (string) $line, $matches)) { - return array(trim($matches[1]), $k); + return [trim($matches[1]), $k]; } } diff --git a/inc/helpers/validation-rules/class-checkout-steps.php b/inc/helpers/validation-rules/class-checkout-steps.php index 19f4f02..37c2ec2 100644 --- a/inc/helpers/validation-rules/class-checkout-steps.php +++ b/inc/helpers/validation-rules/class-checkout-steps.php @@ -36,7 +36,7 @@ class Checkout_Steps extends Rule { * @since 2.0.0 * @var array */ - protected $fillableParams = array(); // phpcs:ignore + protected $fillableParams = []; // phpcs:ignore /** * Performs the actual check. * @@ -90,11 +90,11 @@ class Checkout_Steps extends Rule { */ $submittable_field_types = apply_filters( 'wu_checkout_step_validation_submittable_field_types', - array( + [ 'submit_button', 'pricing_table', 'template_selection', - ) + ] ); /** @@ -103,11 +103,11 @@ class Checkout_Steps extends Rule { foreach ($value as $step) { $found_submittable_field_types = \Arrch\Arrch::find( $step['fields'], - array( - 'where' => array( - array('type', $submittable_field_types), - ), - ) + [ + 'where' => [ + ['type', $submittable_field_types], + ], + ] ); if (empty($found_submittable_field_types)) { diff --git a/inc/helpers/validation-rules/class-city.php b/inc/helpers/validation-rules/class-city.php index 7250b9d..b53758b 100644 --- a/inc/helpers/validation-rules/class-city.php +++ b/inc/helpers/validation-rules/class-city.php @@ -27,7 +27,7 @@ class City extends Rule { * @since 2.0.4 * @var array */ - protected $fillableParams = array('country', 'state'); + protected $fillableParams = ['country', 'state']; /** * Performs the actual check. * @@ -35,7 +35,7 @@ class City extends Rule { * * @param mixed $city The city value detected. */ - public function check($city) : bool { + public function check($city): bool { $check = true; diff --git a/inc/helpers/validation-rules/class-country.php b/inc/helpers/validation-rules/class-country.php index 6744f11..38fed51 100644 --- a/inc/helpers/validation-rules/class-country.php +++ b/inc/helpers/validation-rules/class-country.php @@ -27,7 +27,7 @@ class Country extends Rule { * @since 2.0.4 * @var array */ - protected $fillableParams = array(); // phpcs:ignore + protected $fillableParams = []; // phpcs:ignore /** * Performs the actual check. * diff --git a/inc/helpers/validation-rules/class-domain.php b/inc/helpers/validation-rules/class-domain.php index c5b8436..2713dbf 100644 --- a/inc/helpers/validation-rules/class-domain.php +++ b/inc/helpers/validation-rules/class-domain.php @@ -35,7 +35,7 @@ class Domain extends Rule { * @since 2.0.0 * @var array */ - protected $fillableParams = array(); // phpcs:ignore + protected $fillableParams = []; // phpcs:ignore /** * Performs the actual check. * diff --git a/inc/helpers/validation-rules/class-exists.php b/inc/helpers/validation-rules/class-exists.php index 1fa0102..788ee2e 100644 --- a/inc/helpers/validation-rules/class-exists.php +++ b/inc/helpers/validation-rules/class-exists.php @@ -35,7 +35,7 @@ class Exists extends Rule { * @since 2.0.0 * @var array */ - protected $fillableParams = array('model', 'column', 'except'); // phpcs:ignore + protected $fillableParams = ['model', 'column', 'except']; // phpcs:ignore /** * Performs the actual check. @@ -47,10 +47,10 @@ class Exists extends Rule { public function check($value): bool { $this->requireParameters( - array( + [ 'model', 'column', - ) + ] ); $column = $this->parameter('column'); diff --git a/inc/helpers/validation-rules/class-price-variations.php b/inc/helpers/validation-rules/class-price-variations.php index 9e7cb2d..d8d86ef 100644 --- a/inc/helpers/validation-rules/class-price-variations.php +++ b/inc/helpers/validation-rules/class-price-variations.php @@ -35,7 +35,7 @@ class Price_Variations extends Rule { * @since 2.0.0 * @var array */ - protected $fillableParams = array('duration', 'duration_unit'); // phpcs:ignore + protected $fillableParams = ['duration', 'duration_unit']; // phpcs:ignore /** * Performs the actual check. * @@ -75,12 +75,12 @@ class Price_Variations extends Rule { */ $unit = wu_get_isset($price_variation, 'duration_unit', false); - $allowed_units = array( + $allowed_units = [ 'day', 'week', 'month', 'year', - ); + ]; if (!in_array($unit, $allowed_units, true)) { diff --git a/inc/helpers/validation-rules/class-products.php b/inc/helpers/validation-rules/class-products.php index 20f470c..a3b42db 100644 --- a/inc/helpers/validation-rules/class-products.php +++ b/inc/helpers/validation-rules/class-products.php @@ -35,7 +35,7 @@ class Products extends Rule { * @since 2.0.4 * @var array */ - protected $fillableParams = array(); // phpcs:ignore + protected $fillableParams = []; // phpcs:ignore /** * Performs the actual check. * @@ -49,7 +49,7 @@ class Products extends Rule { $product_objects = array_map('wu_get_product', $products); - list($plan, $additional_products) = wu_segregate_products($product_objects); + [$plan, $additional_products] = wu_segregate_products($product_objects); if ($plan) { return true; diff --git a/inc/helpers/validation-rules/class-site-template.php b/inc/helpers/validation-rules/class-site-template.php index fd09dd7..78847e0 100644 --- a/inc/helpers/validation-rules/class-site-template.php +++ b/inc/helpers/validation-rules/class-site-template.php @@ -37,7 +37,7 @@ class Site_Template extends Rule { * @since 2.0.4 * @var array */ - protected $fillableParams = array(); // phpcs:ignore + protected $fillableParams = []; // phpcs:ignore /** * Performs the actual check. * @@ -81,7 +81,7 @@ class Site_Template extends Rule { $allowed_templates = false; - $product_ids_or_slugs = Checkout::get_instance()->request_or_session('products', array()); + $product_ids_or_slugs = Checkout::get_instance()->request_or_session('products', []); $product_ids_or_slugs = array_unique($product_ids_or_slugs); @@ -90,9 +90,9 @@ class Site_Template extends Rule { $limits = new \WP_Ultimo\Objects\Limitations(); - list($plan, $additional_products) = wu_segregate_products($products); + [$plan, $additional_products] = wu_segregate_products($products); - $products = array_merge(array($plan), $additional_products); + $products = array_merge([$plan], $additional_products); foreach ($products as $product) { $limits = $limits->merge($product->get_limitations()); diff --git a/inc/helpers/validation-rules/class-state.php b/inc/helpers/validation-rules/class-state.php index 4d955a0..4495f65 100644 --- a/inc/helpers/validation-rules/class-state.php +++ b/inc/helpers/validation-rules/class-state.php @@ -27,7 +27,7 @@ class State extends Rule { * @since 2.0.4 * @var array */ - protected $fillableParams = array('country'); // phpcs:ignore + protected $fillableParams = ['country']; // phpcs:ignore /** * Performs the actual check. * diff --git a/inc/helpers/validation-rules/class-unique-site.php b/inc/helpers/validation-rules/class-unique-site.php index 5dbbabc..fdba088 100644 --- a/inc/helpers/validation-rules/class-unique-site.php +++ b/inc/helpers/validation-rules/class-unique-site.php @@ -35,7 +35,7 @@ class Unique_Site extends Rule { * @since 2.0.0 * @var array */ - protected $fillableParams = array('self_id'); // phpcs:ignore + protected $fillableParams = ['self_id']; // phpcs:ignore /** * Performs the actual check. * @@ -45,7 +45,7 @@ class Unique_Site extends Rule { */ public function check($value) : bool { // phpcs:ignore - $this->requireParameters(array()); + $this->requireParameters([]); $self_id = $this->parameter('self_id'); diff --git a/inc/helpers/validation-rules/class-unique.php b/inc/helpers/validation-rules/class-unique.php index 3011c3f..f2d74ad 100644 --- a/inc/helpers/validation-rules/class-unique.php +++ b/inc/helpers/validation-rules/class-unique.php @@ -35,7 +35,7 @@ class Unique extends Rule { * @since 2.0.0 * @var array */ - protected $fillableParams = array('model', 'column', 'self_id'); // phpcs:ignore + protected $fillableParams = ['model', 'column', 'self_id']; // phpcs:ignore /** * Performs the actual check. @@ -47,10 +47,10 @@ class Unique extends Rule { public function check($value): bool { $this->requireParameters( - array( + [ 'model', 'column', - ) + ] ); $column = $this->parameter('column'); @@ -62,17 +62,17 @@ class Unique extends Rule { $callback = 'get_user_by'; break; default: - $callback = array($model, 'get_by'); + $callback = [$model, 'get_by']; break; } // do query $existing = call_user_func($callback, $column, $value); - $user_models = array( + $user_models = [ '\WP_User', - '\WP_Ultimo\Models\Customer', - ); + \WP_Ultimo\Models\Customer::class, + ]; /* * Customize the error message for the customer. diff --git a/inc/installers/class-base-installer.php b/inc/installers/class-base-installer.php index 31188f7..6449d55 100644 --- a/inc/installers/class-base-installer.php +++ b/inc/installers/class-base-installer.php @@ -35,7 +35,7 @@ class Base_Installer { */ public function get_steps() { - return array(); + return []; } /** @@ -75,7 +75,7 @@ class Base_Installer { global $wpdb; - $callable = array($this, "_install_{$installer}"); + $callable = [$this, "_install_{$installer}"]; $callable = apply_filters("wu_installer_{$installer}_callback", $callable, $installer); diff --git a/inc/installers/class-core-installer.php b/inc/installers/class-core-installer.php index 4dd689d..ff2c13f 100644 --- a/inc/installers/class-core-installer.php +++ b/inc/installers/class-core-installer.php @@ -29,7 +29,7 @@ class Core_Installer extends Base_Installer { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { add_filter( 'wu_core_installer_install_sunrise', @@ -64,9 +64,9 @@ class Core_Installer extends Base_Installer { $has_tables_installed = \WP_Ultimo\Loaders\Table_Loader::get_instance()->is_installed(); - $steps = array(); + $steps = []; - $steps['database_tables'] = array( + $steps['database_tables'] = [ 'done' => $has_tables_installed, 'title' => __('Create Database Tables', 'wp-ultimo'), 'description' => __('WP Multisite WaaS uses custom tables for performance reasons. We need to create those tables and make sure they are setup properly before we can activate the plugin.', 'wp-ultimo'), @@ -74,9 +74,9 @@ class Core_Installer extends Base_Installer { 'installing' => __('Creating default tables...', 'wp-ultimo'), 'success' => __('Success!', 'wp-ultimo'), 'help' => wu_get_documentation_url('installation-errors'), - ); + ]; - $steps['sunrise'] = array( + $steps['sunrise'] = [ 'done' => defined('SUNRISE') && SUNRISE && defined('WP_ULTIMO_SUNRISE_VERSION'), 'title' => __('Install sunrise.php File', 'wp-ultimo'), 'description' => __('We need to add our own sunrise.php file to the wp-content folder in order to be able to control access to sites and plugins before anything else happens on WordPress. ', 'wp-ultimo'), @@ -84,7 +84,7 @@ class Core_Installer extends Base_Installer { 'installing' => __('Installing sunrise file...', 'wp-ultimo'), 'success' => __('Success!', 'wp-ultimo'), 'help' => wu_get_documentation_url('installation-errors'), - ); + ]; return $steps; } @@ -96,17 +96,17 @@ class Core_Installer extends Base_Installer { * @throws \Exception When an error occurs during the creation. * @return void */ - public function _install_database_tables() { + public function _install_database_tables(): void { $tables = \WP_Ultimo\Loaders\Table_Loader::get_instance()->get_tables(); foreach ($tables as $table_name => $table) { // Exclude native WP tables, as they already exist. - $exclude_list = array( + $exclude_list = [ 'site_table', 'sitemeta_table', - ); + ]; if (in_array($table_name, $exclude_list, true)) { continue; @@ -131,7 +131,7 @@ class Core_Installer extends Base_Installer { * @throws \Exception When sunrise copying fails. * @return void */ - public function _install_sunrise() { + public function _install_sunrise(): void { $copy = \WP_Ultimo\Sunrise::try_upgrade(); diff --git a/inc/installers/class-default-content-installer.php b/inc/installers/class-default-content-installer.php index 3f7d974..8825fb9 100644 --- a/inc/installers/class-default-content-installer.php +++ b/inc/installers/class-default-content-installer.php @@ -29,7 +29,7 @@ class Default_Content_Installer extends Base_Installer { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { require_once wu_path('inc/functions/email.php'); @@ -143,9 +143,9 @@ class Default_Content_Installer extends Base_Installer { */ public function get_steps() { - $steps = array(); + $steps = []; - $steps['create_template_site'] = array( + $steps['create_template_site'] = [ 'done' => $this->done_creating_template_site(), 'title' => __('Create Example Template Site', 'wp-ultimo'), 'description' => __('This will create a template site on your network that you can use as a starting point.', 'wp-ultimo'), @@ -153,9 +153,9 @@ class Default_Content_Installer extends Base_Installer { 'installing' => __('Creating Template Site...', 'wp-ultimo'), 'success' => __('Success!', 'wp-ultimo'), 'help' => wu_get_documentation_url('installation-errors'), - ); + ]; - $steps['create_products'] = array( + $steps['create_products'] = [ 'done' => $this->done_creating_products(), 'title' => __('Create Example Products', 'wp-ultimo'), 'description' => __('This action will create example products (plans, packages, and services), so you have an starting point.', 'wp-ultimo'), @@ -163,9 +163,9 @@ class Default_Content_Installer extends Base_Installer { 'installing' => __('Creating Products...', 'wp-ultimo'), 'success' => __('Success!', 'wp-ultimo'), 'help' => wu_get_documentation_url('installation-errors'), - ); + ]; - $steps['create_checkout'] = array( + $steps['create_checkout'] = [ 'done' => $this->done_creating_checkout_forms(), 'title' => __('Create a Checkout Form', 'wp-ultimo'), 'description' => __('This action will create a single-step checkout form that your customers will use to place purchases, as well as the page that goes with it.', 'wp-ultimo'), @@ -173,9 +173,9 @@ class Default_Content_Installer extends Base_Installer { 'installing' => __('Creating Checkout Form and Registration Page...', 'wp-ultimo'), 'success' => __('Success!', 'wp-ultimo'), 'help' => wu_get_documentation_url('installation-errors'), - ); + ]; - $steps['create_emails'] = array( + $steps['create_emails'] = [ 'done' => $this->done_creating_emails(), 'title' => __('Create the System Emails', 'wp-ultimo'), 'description' => __('This action will create all emails sent by WP Multisite WaaS.', 'wp-ultimo'), @@ -183,9 +183,9 @@ class Default_Content_Installer extends Base_Installer { 'installing' => __('Creating System Emails...', 'wp-ultimo'), 'success' => __('Success!', 'wp-ultimo'), 'help' => wu_get_documentation_url('installation-errors'), - ); + ]; - $steps['create_login_page'] = array( + $steps['create_login_page'] = [ 'done' => $this->done_creating_login_page(), 'title' => __('Create Custom Login Page', 'wp-ultimo'), 'description' => __('This action will create a custom login page and replace the default one.', 'wp-ultimo'), @@ -193,7 +193,7 @@ class Default_Content_Installer extends Base_Installer { 'installing' => __('Creating Custom Login Page...', 'wp-ultimo'), 'success' => __('Success!', 'wp-ultimo'), 'help' => wu_get_documentation_url('installation-errors'), - ); + ]; return $steps; } @@ -207,16 +207,16 @@ class Default_Content_Installer extends Base_Installer { * @throws \Exception When a site with the /template path already exists. * @return void */ - public function _install_create_template_site() { + public function _install_create_template_site(): void { $d = wu_get_site_domain_and_path('template'); - $template_site = array( + $template_site = [ 'domain' => $d->domain, 'path' => $d->path, 'title' => __('Template Site', 'wp-ultimo'), 'type' => 'site_template', - ); + ]; $status = wu_create_site($template_site); @@ -238,24 +238,24 @@ class Default_Content_Installer extends Base_Installer { * @throws \Exception When the network already has products. * @return void */ - public function _install_create_products() { + public function _install_create_products(): void { /* * Saves Images */ - $images = array( - 'free' => wu_get_asset('free.png', 'img/wizards'), - 'premium' => wu_get_asset('premium.png', 'img/wizards'), - 'seo' => wu_get_asset('seo.png', 'img/wizards'), - ); + $images = [ + 'free' => wu_get_asset('free.webp', 'img/wizards'), + 'premium' => wu_get_asset('premium.webp', 'img/wizards'), + 'seo' => wu_get_asset('seo.webp', 'img/wizards'), + ]; - $images = array_map(array('\\WP_Ultimo\\Helpers\\Screenshot', 'save_image_from_url'), $images); + $images = array_map([\WP_Ultimo\Helpers\Screenshot::class, 'save_image_from_url'], $images); - $products = array(); + $products = []; /* * Free Plan */ - $products[] = array( + $products[] = [ 'name' => __('Free', 'wp-ultimo'), 'description' => __('This is an example of a free plan.', 'wp-ultimo'), 'currency' => wu_get_setting('currency_symbol', 'USD'), @@ -270,12 +270,12 @@ class Default_Content_Installer extends Base_Installer { 'billing_cycles' => false, 'list_order' => false, 'active' => 1, - ); + ]; /* * Premium Plan */ - $products[] = array( + $products[] = [ 'name' => __('Premium', 'wp-ultimo'), 'description' => __('This is an example of a paid plan.', 'wp-ultimo'), 'currency' => wu_get_setting('currency_symbol', 'USD'), @@ -290,12 +290,12 @@ class Default_Content_Installer extends Base_Installer { 'billing_cycles' => false, 'list_order' => false, 'active' => 1, - ); + ]; /* * Service */ - $products[] = array( + $products[] = [ 'name' => __('SEO Consulting', 'wp-ultimo'), 'description' => __('This is an example of a service that you can create and charge customers for.', 'wp-ultimo'), 'currency' => wu_get_setting('currency_symbol', 'USD'), @@ -310,7 +310,7 @@ class Default_Content_Installer extends Base_Installer { 'billing_cycles' => false, 'list_order' => false, 'active' => 1, - ); + ]; foreach ($products as $product_data) { $status = wu_create_product($product_data); @@ -332,13 +332,13 @@ class Default_Content_Installer extends Base_Installer { * @throws \Exception When a checkout form is already present. * @return void */ - public function _install_create_checkout() { + public function _install_create_checkout(): void { - $checkout_form = array( + $checkout_form = [ 'name' => __('Registration Form', 'wp-ultimo'), 'slug' => 'main-form', - 'settings' => array(), - ); + 'settings' => [], + ]; $status = wu_create_checkout_form($checkout_form); @@ -359,14 +359,14 @@ class Default_Content_Installer extends Base_Installer { /* * Create the page on the main site. */ - $post_details = array( + $post_details = [ 'post_name' => 'register', 'post_title' => __('Register', 'wp-ultimo'), 'post_content' => sprintf($post_content, $status->get_slug()), 'post_status' => 'publish', 'post_type' => 'page', 'post_author' => get_current_user_id(), - ); + ]; $page_id = wp_insert_post($post_details); @@ -387,7 +387,7 @@ class Default_Content_Installer extends Base_Installer { * @throws \Exception When the content is already present. * @return void */ - public function _install_create_emails() { + public function _install_create_emails(): void { \WP_Ultimo\Managers\Email_Manager::get_instance()->create_all_system_emails(); } @@ -399,7 +399,7 @@ class Default_Content_Installer extends Base_Installer { * @throws \Exception When the content is already present. * @return void */ - public function _install_create_login_page() { + public function _install_create_login_page(): void { $page_content = ' @@ -407,13 +407,13 @@ class Default_Content_Installer extends Base_Installer { '; - $page_args = array( + $page_args = [ 'post_title' => __('Login', 'wp-ultimo'), 'post_content' => $page_content, 'post_status' => 'publish', 'post_author' => get_current_user_id(), 'post_type' => 'page', - ); + ]; $page_id = wp_insert_post($page_args); diff --git a/inc/installers/class-migrator.php b/inc/installers/class-migrator.php index 0b5616f..6144ee3 100644 --- a/inc/installers/class-migrator.php +++ b/inc/installers/class-migrator.php @@ -88,7 +88,7 @@ class Migrator extends Base_Installer { * @since 2.0.7 * @var array */ - protected $ids_of_interest = array(); + protected $ids_of_interest = []; /** * The status of our attempts to bypass server limitations. @@ -107,7 +107,7 @@ class Migrator extends Base_Installer { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { if ($this->is_migration_screen()) { $this->session = wu_get_session('migrator'); @@ -120,7 +120,7 @@ class Migrator extends Base_Installer { /* * Install the handler for the parallel installer. */ - \WP_Ultimo\Async_Calls::register_listener('parallel_installers', array($this, 'handle_parallel_installers')); + \WP_Ultimo\Async_Calls::register_listener('parallel_installers', [$this, 'handle_parallel_installers']); \WP_Ultimo\Async_Calls::install_listeners(); } @@ -152,7 +152,7 @@ class Migrator extends Base_Installer { * @param string $installer The name of the current installer. * @return void */ - public function on_shutdown($session, $dry_run, $installer) { + public function on_shutdown($session, $dry_run, $installer): void { $message = 'The migrator process exit unexpectedly while running the "%s" migration... You might need to increase server resources to run the migrator. Below, a list of the ids of interest collected thus far:'; @@ -185,10 +185,10 @@ class Migrator extends Base_Installer { public static function is_migration_done() { $plans = get_posts( - array( + [ 'post_type' => 'wpultimo_plan', 'numberposts' => 1, - ) + ] ); if (empty($plans)) { @@ -245,12 +245,12 @@ class Migrator extends Base_Installer { */ public function get_steps($force_all = false) { - $steps = array(); + $steps = []; $dry_run = wu_request('dry-run', true); if ($dry_run && ! $force_all) { - $steps['dry_run_check'] = array( + $steps['dry_run_check'] = [ 'title' => __('Pre-Migration Check', 'wp-ultimo'), 'description' => __('Runs all migrations in a sand-boxed environment to see if it hits an error.', 'wp-ultimo'), 'help' => wu_get_documentation_url('migration-errors'), @@ -258,13 +258,13 @@ class Migrator extends Base_Installer { 'installing' => __('Checking...', 'wp-ultimo'), 'success' => __('Success!', 'wp-ultimo'), 'done' => false, - ); + ]; return $steps; } if ( ! $dry_run) { - $steps['backup'] = array( + $steps['backup'] = [ 'title' => __('Prepare for Migration', 'wp-ultimo'), 'description' => __('Verifies the data before going forward with the migration.', 'wp-ultimo'), 'pending' => __('Pending', 'wp-ultimo'), @@ -272,110 +272,110 @@ class Migrator extends Base_Installer { 'success' => __('Success!', 'wp-ultimo'), 'help' => wu_get_documentation_url('migration-errors'), 'done' => false, - ); + ]; } - $steps['settings'] = array( + $steps['settings'] = [ 'title' => __('Settings', 'wp-ultimo'), 'description' => __('Migrates the settings from the older version.', 'wp-ultimo'), 'help' => wu_get_documentation_url('migration-errors'), 'done' => false, - ); + ]; - $steps['products'] = array( + $steps['products'] = [ 'title' => __('Plans to Products', 'wp-ultimo'), 'description' => __('Converts the old plans into products.', 'wp-ultimo'), 'help' => wu_get_documentation_url('migration-errors'), 'done' => false, - ); + ]; - $steps['customers'] = array( + $steps['customers'] = [ 'title' => __('Users to Customers', 'wp-ultimo'), 'description' => __('Creates customers based on the existing users.', 'wp-ultimo'), 'help' => wu_get_documentation_url('migration-errors'), 'done' => false, - ); + ]; - $steps['memberships'] = array( + $steps['memberships'] = [ 'title' => __('Subscriptions to Memberships', 'wp-ultimo'), 'description' => __('Converts subscriptions into Memberships.', 'wp-ultimo'), 'help' => wu_get_documentation_url('migration-errors'), 'done' => false, - ); + ]; - $steps['transactions'] = array( + $steps['transactions'] = [ 'title' => __('Transactions to Payments & Events', 'wp-ultimo'), 'description' => __('Converts transactions into payments and events.', 'wp-ultimo'), 'help' => wu_get_documentation_url('migration-errors'), 'done' => false, - ); + ]; - $steps['discount_codes'] = array( + $steps['discount_codes'] = [ 'title' => __('Coupons to Discount Codes', 'wp-ultimo'), 'description' => __('Converts coupons into discount codes.', 'wp-ultimo'), 'help' => wu_get_documentation_url('migration-errors'), 'done' => false, - ); + ]; - $steps['sites'] = array( + $steps['sites'] = [ 'title' => __('Customer Sites', 'wp-ultimo'), 'description' => __('Adjusts existing customer sites.', 'wp-ultimo'), 'installing' => __('Making Adjustments...', 'wp-ultimo'), 'help' => wu_get_documentation_url('migration-errors'), 'done' => false, - ); + ]; - $steps['site_templates'] = array( + $steps['site_templates'] = [ 'title' => __('Sites Templates', 'wp-ultimo'), 'description' => __('Adjusts existing site templates.', 'wp-ultimo'), 'installing' => __('Making Adjustments...', 'wp-ultimo'), 'help' => wu_get_documentation_url('migration-errors'), 'done' => false, - ); + ]; - $steps['domains'] = array( + $steps['domains'] = [ 'title' => __('Mapped Domains', 'wp-ultimo'), 'description' => __('Converts mapped domains.', 'wp-ultimo'), 'help' => wu_get_documentation_url('migration-errors'), 'done' => false, - ); + ]; - $steps['forms'] = array( + $steps['forms'] = [ 'title' => __('Checkout Forms', 'wp-ultimo'), 'description' => __('Creates a checkout form based on the existing signup flow.', 'wp-ultimo'), 'help' => wu_get_documentation_url('migration-errors'), 'done' => false, - ); + ]; - $steps['emails'] = array( + $steps['emails'] = [ 'title' => __('Emails & Broadcasts', 'wp-ultimo'), 'description' => __('Converts the emails and broadcasts.', 'wp-ultimo'), 'help' => wu_get_documentation_url('migration-errors'), 'done' => false, - ); + ]; - $steps['webhooks'] = array( + $steps['webhooks'] = [ 'title' => __('Webhooks', 'wp-ultimo'), 'description' => __('Migrates existing webhooks.', 'wp-ultimo'), 'help' => wu_get_documentation_url('migration-errors'), 'done' => false, - ); + ]; - $steps['other'] = array( + $steps['other'] = [ 'title' => __('Other Migrations', 'wp-ultimo'), 'description' => __('Other migrations that don\'t really fit anywhere else.', 'wp-ultimo'), 'help' => wu_get_documentation_url('migration-errors'), 'done' => false, - ); + ]; $steps = array_map( fn($item) => wp_parse_args( $item, - array( + [ 'pending' => __('Pending', 'wp-ultimo'), 'installing' => __('Migrating...', 'wp-ultimo'), 'success' => __('Success!', 'wp-ultimo'), - ) + ] ), $steps ); @@ -465,7 +465,7 @@ class Migrator extends Base_Installer { */ $this->dry_run = wu_request('dry-run', true); - $callable = array($this, "_install_{$installer}"); + $callable = [$this, "_install_{$installer}"]; $callable = apply_filters("wu_installer_{$installer}_callback", $callable, $installer); @@ -550,9 +550,9 @@ class Migrator extends Base_Installer { } if ($session) { - $session->set('errors', array()); + $session->set('errors', []); - $session->set('back_traces', array()); + $session->set('back_traces', []); } return $status; @@ -601,7 +601,7 @@ class Migrator extends Base_Installer { * @since 2.0.7 * @return void */ - public function log_ids_of_interest() { + public function log_ids_of_interest(): void { if ( ! is_array($this->ids_of_interest)) { wu_log_add(self::LOG_FILE_NAME, 'The list of IDs of interested got corrupted, this might indicate problems with one or more migrations', LogLevel::ERROR); @@ -610,7 +610,7 @@ class Migrator extends Base_Installer { } foreach ($this->ids_of_interest as $key => $ids) { - list($installer, $reason) = explode(':', $key); + [$installer, $reason] = explode(':', $key); if (empty($ids)) { continue; @@ -634,11 +634,11 @@ class Migrator extends Base_Installer { * @param string $installer The installer name. * @return void */ - public function add_id_of_interest($id_or_ids, $reason, $installer) { + public function add_id_of_interest($id_or_ids, $reason, $installer): void { $id_list_key = sprintf('%s:%s', $installer, $reason); - $id_list = wu_get_isset($this->ids_of_interest, $id_list_key, array()); + $id_list = wu_get_isset($this->ids_of_interest, $id_list_key, []); $id_or_ids = (array) $id_or_ids; @@ -652,7 +652,7 @@ class Migrator extends Base_Installer { * @throws \Exception Halts the process on error. * @return mixed */ - public function _install_dry_run_check() { + public function _install_dry_run_check(): void { global $wpdb, $wu_migrator_current_installer; @@ -661,7 +661,7 @@ class Migrator extends Base_Installer { foreach ($all_steps as $installer => $step) { $wu_migrator_current_installer = $installer; - $callable = array($this, "_install_{$installer}"); + $callable = [$this, "_install_{$installer}"]; call_user_func($callable); } @@ -674,7 +674,7 @@ class Migrator extends Base_Installer { * @throws \Exception Halts the process on error. * @return mixed */ - public function _install_backup() { + public function _install_backup(): void { global $wpdb; @@ -686,9 +686,9 @@ class Migrator extends Base_Installer { sprintf('mysql:dbname=%s;host=%s', DB_NAME, DB_HOST), DB_USER, DB_PASSWORD, - array( + [ 'compress' => MySQLDump::GZIP, - ) + ] ); $dump->start($file_name); @@ -761,7 +761,7 @@ class Migrator extends Base_Installer { */ wu_save_option("v1_settings_{$random_key}", $settings); - $keys_to_migrate = array( + $keys_to_migrate = [ // General 'currency_symbol', 'currency_position', @@ -826,7 +826,7 @@ class Migrator extends Base_Installer { // Other options we want to keep. 'limits_and_quotas', - ); + ]; $to_migrate = array_intersect_key($settings, array_flip($keys_to_migrate)); @@ -854,13 +854,13 @@ class Migrator extends Base_Installer { /* * Gateway */ - $active_gateways = array_keys($this->get_old_setting('active_gateway', array())); + $active_gateways = array_keys($this->get_old_setting('active_gateway', [])); $to_migrate['active_gateways'] = $active_gateways; /* * Stripe */ - $is_sandbox = strpos((string) $this->get_old_setting('stripe_api_sk', ''), 'test') !== false; + $is_sandbox = str_contains((string) $this->get_old_setting('stripe_api_sk', ''), 'test'); $to_migrate['stripe_sandbox_mode'] = $is_sandbox; @@ -905,7 +905,7 @@ class Migrator extends Base_Installer { /* * Top-bar Settings */ - $top_bar_settings = array( + $top_bar_settings = [ 'enabled' => $this->get_old_setting('allow_template_top_bar', true), 'preview_url_parameter' => 'template-preview', 'bg_color' => $this->get_old_setting('top-bar-bg-color', '#f9f9f9'), @@ -914,7 +914,7 @@ class Migrator extends Base_Installer { 'display_responsive_controls' => $this->get_old_setting('top-bar-enable-resize', true), 'use_custom_logo' => $this->get_old_setting('top-bar-use-logo'), 'custom_logo' => $this->get_old_setting('top-bar-logo'), - ); + ]; $save_settings = Template_Previewer::get_instance()->save_settings($top_bar_settings); @@ -937,7 +937,7 @@ class Migrator extends Base_Installer { * @param array $to_migrate The list of settings to migrate. * @return array */ - public function fake_register_settings($to_migrate = array()) { + public function fake_register_settings($to_migrate = []) { add_filter( 'wu_settings_section_core_fields', @@ -948,11 +948,11 @@ class Migrator extends Base_Installer { $missing_keys = array_diff_key($to_migrate, $all_keys); foreach ($missing_keys as $field_slug => $value) { - $fields[ $field_slug ] = array( + $fields[ $field_slug ] = [ 'type' => 'hidden', 'setting_id' => $field_slug, 'raw' => true, - ); + ]; } return $fields; @@ -988,7 +988,7 @@ class Migrator extends Base_Installer { $product_type_plan = 'plan'; $duration_unit_day = 'month'; $recurring = true; - $currency = isset($settings['currency']) ? $settings['currency'] : 'USD'; + $currency = $settings['currency'] ?? 'USD'; $plans = $wpdb->get_results( " @@ -1016,7 +1016,7 @@ class Migrator extends Base_Installer { continue; } - $product_data = array(); + $product_data = []; $product_data['type'] = 'plan'; $product_data['migrated_from_id'] = $plan->ID; $product_data['name'] = $plan->name; @@ -1042,7 +1042,7 @@ class Migrator extends Base_Installer { */ $default_trial_value = $this->get_old_setting('trial', 0); $plan_trial_value = get_post_meta($plan->ID, 'wpu_trial', true); - $product_data['trial_duration'] = $plan_trial_value ? $plan_trial_value : $default_trial_value; + $product_data['trial_duration'] = $plan_trial_value ?: $default_trial_value; $product_data['trial_duration_unit'] = $duration_unit_day; $active = ! (bool) get_post_meta($plan->ID, 'wpu_hidden', true); @@ -1050,7 +1050,7 @@ class Migrator extends Base_Installer { $is_free = get_post_meta($plan->ID, 'wpu_free', true); - $price_variations = array(); + $price_variations = []; if ($is_free) { $product_data['amount'] = 0; @@ -1064,11 +1064,11 @@ class Migrator extends Base_Installer { $product_data['duration'] = 1; $product_data['duration_unit'] = 'month'; } else { - $price_variations[] = array( + $price_variations[] = [ 'amount' => $price_month, 'duration' => 1, 'duration_unit' => 'month', - ); + ]; } } @@ -1080,11 +1080,11 @@ class Migrator extends Base_Installer { $product_data['duration'] = 3; $product_data['duration_unit'] = 'month'; } else { - $price_variations[] = array( + $price_variations[] = [ 'amount' => $price_3_month, 'duration' => 3, 'duration_unit' => 'month', - ); + ]; } } @@ -1096,11 +1096,11 @@ class Migrator extends Base_Installer { $product_data['duration'] = 1; $product_data['duration_unit'] = 'year'; } else { - $price_variations[] = array( + $price_variations[] = [ 'amount' => $price_12_month, 'duration' => 1, 'duration_unit' => 'year', - ); + ]; } } @@ -1172,7 +1172,7 @@ class Migrator extends Base_Installer { /* * Build template list. */ - $site_templates_limit = array(); + $site_templates_limit = []; $available_site_templates = wu_get_site_templates(); @@ -1188,28 +1188,28 @@ class Migrator extends Base_Installer { $behavior = 'available'; } - $site_templates_limit[ $site_template_id ] = array( + $site_templates_limit[ $site_template_id ] = [ 'behavior' => $behavior, - ); + ]; } /** * Limitation modules. */ - $limitations_modules = array( - 'domain_mapping' => array( + $limitations_modules = [ + 'domain_mapping' => [ 'enabled' => $has_custom_domain, - ), - 'customer_user_role' => array( + ], + 'customer_user_role' => [ 'enabled' => true, 'limit' => $product_data['customer_role'], - ), - 'site_templates' => array( + ], + 'site_templates' => [ 'mode' => $site_template_mode, 'enabled' => $site_template_enabled, 'limit' => $site_templates_limit, - ), - ); + ], + ]; /** * Build the plugins limitations object. @@ -1219,18 +1219,18 @@ class Migrator extends Base_Installer { if (is_array($allowed_plugins)) { $allowed_plugins = $allowed_plugins; - $plugins_limit = array(); + $plugins_limit = []; foreach (Limitation_Manager::get_instance()->get_all_plugins() as $plugin_path => &$plugin_data) { - $plugins_limit[ $plugin_path ] = array( + $plugins_limit[ $plugin_path ] = [ 'visibility' => in_array($plugin_path, $allowed_plugins, true) ? 'visible' : 'hidden', 'behavior' => in_array($plugin_path, $allowed_plugins, true) ? 'available' : 'not_available', - ); + ]; } - $limitations_modules['plugins'] = array( + $limitations_modules['plugins'] = [ 'limit' => $plugins_limit, - ); + ]; } /** @@ -1239,61 +1239,61 @@ class Migrator extends Base_Installer { * @since 2.0.7 */ if (is_array($allowed_themes)) { - $themes_limit = array(); + $themes_limit = []; foreach (Limitation_Manager::get_instance()->get_all_themes() as $stylesheet => &$theme_data) { - $themes_limit[ $stylesheet ] = array( + $themes_limit[ $stylesheet ] = [ 'visibility' => in_array($stylesheet, $allowed_themes, true) ? 'visible' : 'hidden', 'behavior' => in_array($stylesheet, $allowed_themes, true) ? 'available' : 'not_available', - ); + ]; } - $limitations_modules['themes'] = array( + $limitations_modules['themes'] = [ 'limit' => $themes_limit, - ); + ]; } $unlimited_users = (bool) get_post_meta($plan->ID, 'wpu_unlimited_extra_users', true); - $post_types_limit = array(); + $post_types_limit = []; foreach ($quotas as $post_type => $quota) { if ($post_type === 'users' && ! $unlimited_users) { $user_roles = get_editable_roles(); - $roles_limit = array(); + $roles_limit = []; foreach ($user_roles as $role => $role_data) { - $roles_limit[ $role ] = array( + $roles_limit[ $role ] = [ 'enabled' => true, 'number' => $quota ? absint($quota) : '', - ); + ]; } - $limitations_modules['users'] = array( + $limitations_modules['users'] = [ 'limit' => $roles_limit, 'enabled' => true, - ); + ]; } elseif ($post_type === 'upload') { - $limitations_modules['disk_space'] = array( + $limitations_modules['disk_space'] = [ 'limit' => absint($quota), 'enabled' => true, - ); + ]; } elseif ($post_type === 'visits') { - $limitations_modules['visits'] = array( + $limitations_modules['visits'] = [ 'limit' => $quota ? absint($quota) : '', 'enabled' => true, - ); + ]; } elseif ($post_type === 'sites') { - $limitations_modules['sites'] = array( + $limitations_modules['sites'] = [ 'limit' => absint($quota), 'enabled' => true, - ); + ]; } else { - $post_types_limit[ $post_type ] = array( + $post_types_limit[ $post_type ] = [ 'enabled' => in_array($post_type, $disabled_post_types, true) === false, 'number' => $quota ? absint($quota) : '', - ); + ]; } } @@ -1301,10 +1301,10 @@ class Migrator extends Base_Installer { * If there's any limitations to post types, add it. */ if ($post_types_limit) { - $limitations_modules['post_types'] = array( + $limitations_modules['post_types'] = [ 'limit' => $post_types_limit, 'enabled' => true, - ); + ]; } $limitations = new \WP_Ultimo\Objects\Limitations($limitations_modules); @@ -1365,10 +1365,10 @@ class Migrator extends Base_Installer { */ if ($this->is_parallel() === false) { if ($total_records > $threshold) { - $args = array( + $args = [ 'installer' => $this->get_installer(), 'dry-run' => $this->dry_run, - ); + ]; $result = \WP_Ultimo\Async_Calls::run('parallel_installers', $args, $total_records, $threshold, 10); @@ -1461,13 +1461,13 @@ class Migrator extends Base_Installer { } $customer = wu_create_customer( - array( + [ 'user_id' => $user->user_id, 'email_verification' => 'verified', 'vip' => false, 'date_registered' => $user->created_at, 'last_login' => $user->created_at, - ) + ] ); if (is_wp_error($customer)) { @@ -1555,9 +1555,9 @@ class Migrator extends Base_Installer { $product = wu_get_product_by('migrated_from_id', absint($subscription->plan_id)); - $v1_subscription_meta = (object) ($subscription->meta ? maybe_unserialize($subscription->meta) : array()); + $v1_subscription_meta = (object) ($subscription->meta ? maybe_unserialize($subscription->meta) : []); - $membership_data = array(); + $membership_data = []; if ( ! $product) { $this->add_id_of_interest($subscription->plan_id, 'plan_not_migrated', 'memberships'); @@ -1738,8 +1738,8 @@ class Migrator extends Base_Installer { $membership_data['times_billed'] = absint($payments_count); $membership_data = array_merge( - $product ? $product->to_array() : array(), - $customer ? $customer->to_array() : array(), + $product ? $product->to_array() : [], + $customer ? $customer->to_array() : [], $membership_data ); @@ -1822,17 +1822,17 @@ class Migrator extends Base_Installer { * * @since 2.0.0 */ - $types_to_skip = array( + $types_to_skip = [ 'recurring_setup', 'cancel', - ); + ]; - $map_status = array( + $map_status = [ 'payment' => Payment_Status::COMPLETED, 'failed' => Payment_Status::FAILED, 'refund' => Payment_Status::REFUND, 'pending' => Payment_Status::PENDING, - ); + ]; foreach ($transactions as $transaction) { /* @@ -1857,10 +1857,10 @@ class Migrator extends Base_Installer { } $line_item = new \WP_Ultimo\Checkout\Line_Item( - array( + [ 'product' => $product, 'quantity' => 1, - ) + ] ); $line_item->set_title($transaction->description); @@ -1870,11 +1870,11 @@ class Migrator extends Base_Installer { $line_item->set_subtotal(wu_to_float($transaction->amount)); $line_item->set_total(wu_to_float($transaction->amount)); - $line_items = array( + $line_items = [ $line_item->get_id() => $line_item, - ); + ]; - $payment_data = array( + $payment_data = [ 'parent' => 0, 'line_items' => $line_items, 'status' => wu_get_isset($map_status, $transaction->type, Payment_Status::COMPLETED), @@ -1892,7 +1892,7 @@ class Migrator extends Base_Installer { 'migrated_from_id' => $transaction->id, 'date_created' => $transaction->time, 'date_modified' => $transaction->time, - ); + ]; if ( ! $customer) { $this->add_id_of_interest($transaction->user_id, 'customer_not_migrated', 'transactions'); @@ -1963,7 +1963,7 @@ class Migrator extends Base_Installer { $limit_products = false; - $allowed_products = array(); + $allowed_products = []; if ($allowed_plans) { $limit_products = true; @@ -1977,7 +1977,7 @@ class Migrator extends Base_Installer { } } - $discount_code_data = array( + $discount_code_data = [ 'uses' => get_post_meta($coupon->ID, 'wpu_uses', true), 'max_uses' => get_post_meta($coupon->ID, 'wpu_allowed_uses', true), 'name' => $coupon->name, @@ -1994,7 +1994,7 @@ class Migrator extends Base_Installer { 'date_created' => $coupon->date_create, 'date_modified' => $coupon->post_modified, 'skip_validation' => true, - ); + ]; /* * Fix the type name. @@ -2111,19 +2111,19 @@ class Migrator extends Base_Installer { require_once wu_path('inc/functions/membership.php'); require_once wu_path('inc/functions/site.php'); - $skip_ids = array(); + $skip_ids = []; /* * First thing, add the main site to the skip list. */ $skip_ids[] = wu_get_main_site_id(); - $search_arguments = array( + $search_arguments = [ 'network_id' => get_current_site()->id, 'fields' => 'ids', 'site__not_in' => $skip_ids, 'no_found_rows' => true, - ); + ]; if ($this->dry_run) { $per_page = 10; @@ -2185,9 +2185,9 @@ class Migrator extends Base_Installer { */ wu_enqueue_async_action( 'wu_async_take_screenshot', - array( + [ 'site_id' => $site_template->get_id(), - ), + ], 'site' ); } @@ -2267,14 +2267,14 @@ class Migrator extends Base_Installer { } $domain = wu_create_domain( - array( + [ 'stage' => 'done', 'domain' => $domain->name, 'blog_id' => $domain->blog_id, 'active' => $domain->active, 'primary_domain' => true, 'secure' => $https, - ) + ] ); if (is_wp_error($domain)) { @@ -2306,12 +2306,12 @@ class Migrator extends Base_Installer { return; } - $checkout_form = array( + $checkout_form = [ 'name' => __('Signup Form', 'wp-ultimo'), 'slug' => 'main-form', - 'allowed_countries' => $this->get_old_setting('allowed_countries', array()), - 'settings' => array(), - ); + 'allowed_countries' => $this->get_old_setting('allowed_countries', []), + 'settings' => [], + ]; $status = wu_create_checkout_form($checkout_form); @@ -2342,14 +2342,14 @@ class Migrator extends Base_Installer { /* * Create the page on the main site. */ - $post_details = array( + $post_details = [ 'post_name' => $page_slug, 'post_title' => __('Signup', 'wp-ultimo'), 'post_status' => 'publish', 'post_type' => 'page', 'post_content' => sprintf($post_content, $status->get_slug()), 'post_author' => get_current_user_id(), - ); + ]; $page_id = wp_insert_post($post_details); @@ -2382,14 +2382,14 @@ class Migrator extends Base_Installer { /* * Create the page on the main site. */ - $login_post_details = array( + $login_post_details = [ 'post_name' => $login_page_slug, 'post_title' => __('Login', 'wp-ultimo'), 'post_status' => 'publish', 'post_type' => 'page', 'post_content' => '', 'post_author' => get_current_user_id(), - ); + ]; $login_page_id = wp_insert_post($login_post_details); @@ -2484,23 +2484,23 @@ class Migrator extends Base_Installer { $product_targets ); - $targets = array( + $targets = [ 'customers' => array_filter($customer_targets), 'products' => array_filter($product_targets), - ); + ]; $broadcast = wu_create_broadcast( - array( + [ 'name' => $broadcast->post_title, 'content' => $broadcast->post_content, 'type' => $new_type, - 'style' => $style ? $style : 'success', + 'style' => $style ?: 'success', 'date_created' => $broadcast->post_date, 'date_modified' => $broadcast->post_modified, 'message_targets' => $targets, 'migrated_from_id' => $broadcast->ID, 'skip_validation' => true, - ) + ] ); if (is_wp_error($broadcast)) { @@ -2538,7 +2538,7 @@ class Migrator extends Base_Installer { foreach ($webhooks as $webhook) { $webhook = wu_create_webhook( - array( + [ 'name' => $webhook->post_title, 'migrated_from_id' => $webhook->ID, 'webhook_url' => get_post_meta($webhook->ID, 'wpu_url', true), @@ -2546,7 +2546,7 @@ class Migrator extends Base_Installer { 'active' => (bool) get_post_meta($webhook->ID, 'wpu_active', true), 'date_created' => $webhook->post_date, 'date_modified' => $webhook->post_modified, - ) + ] ); if (is_wp_error($webhook)) { diff --git a/inc/integrations/host-providers/class-base-host-provider.php b/inc/integrations/host-providers/class-base-host-provider.php index f512be8..237b650 100644 --- a/inc/integrations/host-providers/class-base-host-provider.php +++ b/inc/integrations/host-providers/class-base-host-provider.php @@ -49,7 +49,7 @@ abstract class Base_Host_Provider { * @var array * @since 2.0.0 */ - protected $supports = array(); + protected $supports = []; /** * Constants that need to be present on wp-config.php for this integration to work. @@ -58,7 +58,7 @@ abstract class Base_Host_Provider { * @since 2.0.0 * @var array */ - protected $constants = array(); + protected $constants = []; /** * Constants that are optional on wp-config.php. @@ -66,7 +66,7 @@ abstract class Base_Host_Provider { * @since 2.0.0 * @var array */ - protected $optional_constants = array(); + protected $optional_constants = []; /** * Runs on singleton instantiation. @@ -74,11 +74,11 @@ abstract class Base_Host_Provider { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - add_filter('wu_domain_manager_get_integrations', array($this, 'self_register')); + add_filter('wu_domain_manager_get_integrations', [$this, 'self_register']); - add_action('init', array($this, 'add_to_integration_list')); + add_action('init', [$this, 'add_to_integration_list']); } /** @@ -131,7 +131,7 @@ abstract class Base_Host_Provider { */ final public function self_register($integrations) { - $integrations[ $this->get_id() ] = get_called_class(); + $integrations[ $this->get_id() ] = static::class; return $integrations; } @@ -144,7 +144,7 @@ abstract class Base_Host_Provider { */ protected function get_enabled_list() { - return get_network_option(null, 'wu_host_integrations_enabled', array()); + return get_network_option(null, 'wu_host_integrations_enabled', []); } /** @@ -196,7 +196,7 @@ abstract class Base_Host_Provider { * @since 2.0.0 * @return void */ - public function add_to_integration_list() { + public function add_to_integration_list(): void { $slug = $this->get_id(); @@ -204,9 +204,9 @@ abstract class Base_Host_Provider { $url = wu_network_admin_url( 'wp-ultimo-hosting-integration-wizard', - array( + [ 'integration' => $slug, - ) + ] ); $html .= sprintf('%s', $url, __('Configuration', 'wp-ultimo')); @@ -222,11 +222,11 @@ abstract class Base_Host_Provider { wu_register_settings_field( 'integrations', "integration_{$slug}", - array( + [ 'type' => 'note', 'title' => $title, 'desc' => $html, - ) + ] ); } @@ -236,7 +236,7 @@ abstract class Base_Host_Provider { * @since 2.0.0 * @return void */ - public function alert_provider_detected() { + public function alert_provider_detected(): void { if (WP_Ultimo()->is_loaded() === false) { return; @@ -247,18 +247,18 @@ abstract class Base_Host_Provider { $slug = $this->get_id(); - $actions = array( - 'activate' => array( + $actions = [ + 'activate' => [ // translators: %s is the integration name. 'title' => sprintf(__('Activate %s', 'wp-ultimo'), $this->get_title()), 'url' => wu_network_admin_url( 'wp-ultimo-hosting-integration-wizard', - array( + [ 'integration' => $slug, - ) + ] ), - ), - ); + ], + ]; WP_Ultimo()->notices->add($message, 'info', 'network-admin', "should-enable-{$slug}-integration", $actions); } @@ -269,7 +269,7 @@ abstract class Base_Host_Provider { * @since 2.0.0 * @return void */ - public function alert_provider_not_setup() { + public function alert_provider_not_setup(): void { if (WP_Ultimo()->is_loaded() === false) { return; @@ -280,19 +280,19 @@ abstract class Base_Host_Provider { $slug = $this->get_id(); - $actions = array( - 'activate' => array( + $actions = [ + 'activate' => [ // translators: %s is the integration name 'title' => sprintf(__('Setup %s', 'wp-ultimo'), $this->get_title()), 'url' => wu_network_admin_url( 'wp-ultimo-hosting-integration-wizard', - array( + [ 'integration' => $slug, 'tab' => 'config', - ) + ] ), - ), - ); + ], + ]; WP_Ultimo()->notices->add($message, 'warning', 'network-admin', "should-setup-{$slug}-integration", $actions); } @@ -305,7 +305,7 @@ abstract class Base_Host_Provider { */ public function get_fields() { - return array(); + return []; } /** @@ -348,26 +348,26 @@ abstract class Base_Host_Provider { * @since 2.0.0 * @return void */ - public function register_hooks() { + public function register_hooks(): void { /* * Hooks the event that is triggered when a new domain is added. */ - add_action('wu_add_domain', array($this, 'on_add_domain'), 10, 2); + add_action('wu_add_domain', [$this, 'on_add_domain'], 10, 2); /* * Hooks the event that is triggered when a domain is deleted. */ - add_action('wu_remove_domain', array($this, 'on_remove_domain'), 10, 2); + add_action('wu_remove_domain', [$this, 'on_remove_domain'], 10, 2); /* * Hooks the event that is triggered when a sub-domain is added. */ - add_action('wu_add_subdomain', array($this, 'on_add_subdomain'), 10, 2); + add_action('wu_add_subdomain', [$this, 'on_add_subdomain'], 10, 2); /* * Hooks the event that is triggered when a sub-domain is added. */ - add_action('wu_remove_subdomain', array($this, 'on_remove_subdomain'), 10, 2); + add_action('wu_remove_subdomain', [$this, 'on_remove_subdomain'], 10, 2); /* * Add additional hooks. @@ -412,7 +412,7 @@ abstract class Base_Host_Provider { $all_set = true; foreach ($this->constants as $constant) { - $constants = is_array($constant) ? $constant : array($constant); + $constants = is_array($constant) ? $constant : [$constant]; $current = false; @@ -445,10 +445,10 @@ abstract class Base_Host_Provider { */ public function get_missing_constants() { - $missing_constants = array(); + $missing_constants = []; foreach ($this->constants as $constant) { - $constants = is_array($constant) ? $constant : array($constant); + $constants = is_array($constant) ? $constant : [$constant]; $current = false; @@ -474,10 +474,10 @@ abstract class Base_Host_Provider { */ public function get_all_constants() { - $constants = array(); + $constants = []; foreach ($this->constants as $constant) { - $current = is_array($constant) ? $constant : array($constant); + $current = is_array($constant) ? $constant : [$constant]; $constants = array_merge($constants, $current); } @@ -493,7 +493,7 @@ abstract class Base_Host_Provider { * @param array $constant_values Key => Value of the necessary constants. * @return void */ - public function setup_constants($constant_values) { + public function setup_constants($constant_values): void { /* * Important: This step is crucial, as it makes sure we clean up undesired constants. * Removing this can allow insertion of arbitrary constants onto the wp-config.pp file @@ -523,9 +523,9 @@ abstract class Base_Host_Provider { /* * Initializes the array with an opening comment. */ - $content = array( + $content = [ sprintf('// WP Multisite WaaS - Domain Mapping - %s', $this->get_title()), - ); + ]; /* * Important: This step is crucial, as it makes sure we clean up undesired constants. @@ -557,13 +557,13 @@ abstract class Base_Host_Provider { */ public function get_explainer_lines() { - $explainer_lines = array( - 'will' => array( + $explainer_lines = [ + 'will' => [ // translators: %s is the name of the integration e.g. RunCloud 'send_domains' => sprintf(__('Send API calls to %s servers with domain names added to this network', 'wp-ultimo'), $this->get_title()), - ), - 'will_not' => array(), - ); + ], + 'will_not' => [], + ]; if ($this->supports('autossl')) { @@ -630,9 +630,9 @@ abstract class Base_Host_Provider { * @since 2.0.0 * @return void */ - public function test_connection() { + public function test_connection(): void { - wp_send_json_success(array()); + wp_send_json_success([]); } /** diff --git a/inc/integrations/host-providers/class-closte-host-provider.php b/inc/integrations/host-providers/class-closte-host-provider.php index 13cbddf..9bdb871 100644 --- a/inc/integrations/host-providers/class-closte-host-provider.php +++ b/inc/integrations/host-providers/class-closte-host-provider.php @@ -51,11 +51,11 @@ class Closte_Host_Provider extends Base_Host_Provider { * @var array * @since 2.0.0 */ - protected $supports = array( + protected $supports = [ 'autossl', 'no-instructions', 'no-config', - ); + ]; /** * Constants that need to be present on wp-config.php for this integration to work. @@ -63,9 +63,9 @@ class Closte_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @var array */ - protected $constants = array( + protected $constants = [ 'CLOSTE_CLIENT_API_KEY', - ); + ]; /** * Picks up on tips that a given host provider is being used. @@ -88,14 +88,14 @@ class Closte_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_add_domain($domain, $site_id) { + public function on_add_domain($domain, $site_id): void { $this->send_closte_api_request( '/adddomainalias', - array( + [ 'domain' => $domain, - 'wildcard' => strncmp($domain, '*.', strlen('*.')) === 0, - ) + 'wildcard' => str_starts_with($domain, '*.'), + ] ); } @@ -107,14 +107,14 @@ class Closte_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_remove_domain($domain, $site_id) { + public function on_remove_domain($domain, $site_id): void { $this->send_closte_api_request( '/deletedomainalias', - array( + [ 'domain' => $domain, - 'wildcard' => strncmp($domain, '*.', strlen('*.')) === 0, - ) + 'wildcard' => str_starts_with($domain, '*.'), + ] ); } @@ -150,15 +150,15 @@ class Closte_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @return void */ - public function test_connection() { + public function test_connection(): void { - $response = $this->send_closte_api_request('/adddomainalias', array()); + $response = $this->send_closte_api_request('/adddomainalias', []); if (wu_get_isset($response, 'error') === 'Invalid or empty domain: ') { wp_send_json_success( - array( + [ 'message' => __('Access Authorized'), - ) + ] ); } @@ -178,23 +178,23 @@ class Closte_Host_Provider extends Base_Host_Provider { public function send_closte_api_request($endpoint, $data) { if (defined('CLOSTE_CLIENT_API_KEY') === false) { - return (object) array( + return (object) [ 'success' => false, 'error' => 'Closte API Key not found.', - ); + ]; } - $post_fields = array( + $post_fields = [ 'blocking' => true, 'timeout' => 45, 'method' => 'POST', 'body' => array_merge( - array( + [ 'apikey' => CLOSTE_CLIENT_API_KEY, - ), + ], $data ), - ); + ]; $response = wp_remote_post('https://app.closte.com/api/client' . $endpoint, $post_fields); @@ -207,10 +207,10 @@ class Closte_Host_Provider extends Base_Host_Provider { return $body; } - return (object) array( + return (object) [ 'success' => false, 'error' => 'unknown', - ); + ]; } return $response; diff --git a/inc/integrations/host-providers/class-cloudflare-host-provider.php b/inc/integrations/host-providers/class-cloudflare-host-provider.php index 33cb147..c48d67e 100644 --- a/inc/integrations/host-providers/class-cloudflare-host-provider.php +++ b/inc/integrations/host-providers/class-cloudflare-host-provider.php @@ -52,9 +52,9 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { * @var array * @since 2.0.0 */ - protected $supports = array( + protected $supports = [ 'autossl', - ); + ]; /** * Constants that need to be present on wp-config.php for this integration to work. @@ -62,10 +62,10 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @var array */ - protected $constants = array( + protected $constants = [ 'WU_CLOUDFLARE_API_KEY', 'WU_CLOUDFLARE_ZONE_ID', - ); + ]; /** * Add Cloudflare own DNS entries to the comparison table. @@ -78,7 +78,7 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { */ public function add_cloudflare_dns_entries($dns_records, $domain) { - $zone_ids = array(); + $zone_ids = []; $default_zone_id = defined('WU_CLOUDFLARE_ZONE_ID') && WU_CLOUDFLARE_ZONE_ID ? WU_CLOUDFLARE_ZONE_ID : false; @@ -89,10 +89,10 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { $cloudflare_zones = $this->cloudflare_api_call( 'client/v4/zones', 'GET', - array( + [ 'name' => $domain, 'status' => 'active', - ) + ] ); foreach ($cloudflare_zones->result as $zone) { @@ -108,11 +108,11 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { $dns_entries = $this->cloudflare_api_call( "client/v4/zones/$zone_id/dns_records/", 'GET', - array( + [ 'name' => $domain, 'match' => 'any', 'type' => 'A,AAAA,CNAME', - ) + ] ); if ( ! empty($dns_entries->result)) { @@ -121,13 +121,13 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { $not_proxied_tag = sprintf('%s', wu_tooltip_text(__('Not Proxied', 'wp-ultimo')), __('Cloudflare', 'wp-ultimo')); foreach ($dns_entries->result as $entry) { - $dns_records[] = array( + $dns_records[] = [ 'ttl' => $entry->ttl, 'data' => $entry->content, 'type' => $entry->type, 'host' => $entry->name, 'tag' => $entry->proxied ? $proxied_tag : $not_proxied_tag, - ); + ]; } } } @@ -160,16 +160,16 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { */ public function get_fields() { - return array( - 'WU_CLOUDFLARE_ZONE_ID' => array( + return [ + 'WU_CLOUDFLARE_ZONE_ID' => [ 'title' => __('Zone ID', 'wp-ultimo'), 'placeholder' => __('e.g. 644c7705723d62e31f700bb798219c75', 'wp-ultimo'), - ), - 'WU_CLOUDFLARE_API_KEY' => array( + ], + 'WU_CLOUDFLARE_API_KEY' => [ 'title' => __('API Key', 'wp-ultimo'), 'placeholder' => __('e.g. xKGbxxVDpdcUv9dUzRf4i4ngv0QNf1wCtbehiec_o', 'wp-ultimo'), - ), - ); + ], + ]; } /** @@ -178,7 +178,7 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @return void */ - public function test_connection() { + public function test_connection(): void { $results = $this->cloudflare_api_call('client/v4/user/tokens/verify'); @@ -195,9 +195,9 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { * @since 2.0.7 * @return void */ - public function additional_hooks() { + public function additional_hooks(): void { - add_filter('wu_domain_dns_get_record', array($this, 'add_cloudflare_dns_entries'), 10, 2); + add_filter('wu_domain_dns_get_record', [$this, 'add_cloudflare_dns_entries'], 10, 2); } /** @@ -230,7 +230,7 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_add_subdomain($subdomain, $site_id) { + public function on_add_subdomain($subdomain, $site_id): void { global $current_site; @@ -240,7 +240,7 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { return; } - if (strpos($subdomain, (string) $current_site->domain) === false) { + if (! str_contains($subdomain, (string) $current_site->domain)) { return; // Not a sub-domain of the main domain. } @@ -253,12 +253,12 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { $should_add_www = apply_filters('wu_cloudflare_should_add_www', true, $subdomain, $site_id); - $domains_to_send = array($subdomain); + $domains_to_send = [$subdomain]; /** * Adds the www version, if necessary. */ - if (strncmp($subdomain, 'www.', strlen('www.')) !== 0 && $should_add_www) { + if (! str_starts_with($subdomain, 'www.') && $should_add_www) { $domains_to_send[] = 'www.' . $subdomain; } @@ -267,13 +267,13 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { $data = apply_filters( 'wu_cloudflare_on_add_domain_data', - array( + [ 'type' => 'CNAME', 'name' => $subdomain, 'content' => '@', 'proxied' => $should_proxy, 'ttl' => 1, - ), + ], $subdomain, $site_id ); @@ -300,7 +300,7 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_remove_subdomain($subdomain, $site_id) { + public function on_remove_subdomain($subdomain, $site_id): void { global $current_site; @@ -310,7 +310,7 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { return; } - if (strpos($subdomain, (string) $current_site->domain) === false) { + if (! str_contains($subdomain, (string) $current_site->domain)) { return; // Not a sub-domain of the main domain. } @@ -326,19 +326,19 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { /** * Created the list that we should remove. */ - $domains_to_remove = array( + $domains_to_remove = [ $original_subdomain, 'www.' . $original_subdomain, - ); + ]; foreach ($domains_to_remove as $original_subdomain) { $dns_entries = $this->cloudflare_api_call( "client/v4/zones/$zone_id/dns_records/", 'GET', - array( + [ 'name' => $original_subdomain, 'type' => 'CNAME', - ) + ] ); if ( ! $dns_entries->result) { @@ -368,7 +368,7 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { * @param array $data The date to send. * @return object|\WP_Error */ - protected function cloudflare_api_call($endpoint = 'client/v4/user/tokens/verify', $method = 'GET', $data = array()): object { + protected function cloudflare_api_call($endpoint = 'client/v4/user/tokens/verify', $method = 'GET', $data = []): object { $api_url = 'https://api.cloudflare.com/'; @@ -376,15 +376,15 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { $response = wp_remote_request( $endpoint_url, - array( + [ 'method' => $method, 'body' => $method === 'GET' ? $data : wp_json_encode($data), 'data_format' => 'body', - 'headers' => array( + 'headers' => [ 'Authorization' => sprintf('Bearer %s', defined('WU_CLOUDFLARE_API_KEY') ? WU_CLOUDFLARE_API_KEY : ''), 'Content-Type' => 'application/json', - ), - ) + ], + ] ); if ( ! is_wp_error($response)) { @@ -408,7 +408,7 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @return void */ - public function get_instructions() { + public function get_instructions(): void { wu_get_template('wizards/host-integrations/cloudflare-instructions'); } @@ -443,10 +443,10 @@ class Cloudflare_Host_Provider extends Base_Host_Provider { */ public function get_explainer_lines() { - $explainer_lines = array( - 'will' => array(), - 'will_not' => array(), - ); + $explainer_lines = [ + 'will' => [], + 'will_not' => [], + ]; if (is_subdomain_install()) { $explainer_lines['will']['send_sub_domains'] = __('Add a new proxied subdomain to the configured CloudFlare zone whenever a new site gets created', 'wp-ultimo'); diff --git a/inc/integrations/host-providers/class-cloudways-host-provider.php b/inc/integrations/host-providers/class-cloudways-host-provider.php index 6ade886..36ee6b8 100644 --- a/inc/integrations/host-providers/class-cloudways-host-provider.php +++ b/inc/integrations/host-providers/class-cloudways-host-provider.php @@ -53,9 +53,9 @@ class Cloudways_Host_Provider extends Base_Host_Provider { * @var array * @since 2.0.0 */ - protected $supports = array( + protected $supports = [ 'autossl', - ); + ]; /** * Constants that need to be present on wp-config.php for this integration to work. @@ -63,12 +63,12 @@ class Cloudways_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @var array */ - protected $constants = array( + protected $constants = [ 'WU_CLOUDWAYS_EMAIL', 'WU_CLOUDWAYS_API_KEY', 'WU_CLOUDWAYS_SERVER_ID', 'WU_CLOUDWAYS_APP_ID', - ); + ]; /** * Constants that maybe present on wp-config.php for this integration to work. @@ -76,9 +76,9 @@ class Cloudways_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @var array */ - protected $optional_constants = array( + protected $optional_constants = [ 'WU_CLOUDWAYS_EXTRA_DOMAINS', - ); + ]; /** * Runs on singleton instantiation. @@ -86,12 +86,12 @@ class Cloudways_Host_Provider extends Base_Host_Provider { * @since 2.1.1 * @return void */ - public function init() { + public function init(): void { parent::init(); // Add the action to sync domains SSL. - add_action('wu_domain_manager_dns_propagation_finished', array($this, 'request_ssl'), 10, 0); + add_action('wu_domain_manager_dns_propagation_finished', [$this, 'request_ssl'], 10, 0); } /** @@ -100,7 +100,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider { * @since 2.1.1 * @return void */ - public function request_ssl() { + public function request_ssl(): void { /** * If the integration is not active, bail. */ @@ -112,9 +112,9 @@ class Cloudways_Host_Provider extends Base_Host_Provider { $ssl_response = $this->send_cloudways_request( '/security/lets_encrypt_install', - array( + [ 'ssl_domains' => $this->get_valid_ssl_domains($all_domains), - ) + ] ); if (is_wp_error($ssl_response)) { @@ -132,7 +132,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider { */ public function detect(): bool { - return strpos(ABSPATH, 'cloudways') !== false; + return str_contains(ABSPATH, 'cloudways'); } /** @@ -143,34 +143,34 @@ class Cloudways_Host_Provider extends Base_Host_Provider { */ public function get_fields() { - return array( - 'WU_CLOUDWAYS_EMAIL' => array( + return [ + 'WU_CLOUDWAYS_EMAIL' => [ 'title' => __('Cloudways Account Email', 'wp-ultimo'), 'desc' => __('Your Cloudways account email address.', 'wp-ultimo'), 'placeholder' => __('e.g. me@gmail.com', 'wp-ultimo'), - ), - 'WU_CLOUDWAYS_API_KEY' => array( + ], + 'WU_CLOUDWAYS_API_KEY' => [ 'title' => __('Cloudways API Key', 'wp-ultimo'), 'desc' => __('The API Key retrieved in the previous step.', 'wp-ultimo'), 'placeholder' => __('e.g. eYP0Jo3Fzzm5SOZCi5nLR0Mki2lbYZ', 'wp-ultimo'), - ), - 'WU_CLOUDWAYS_SERVER_ID' => array( + ], + 'WU_CLOUDWAYS_SERVER_ID' => [ 'title' => __('Cloudways Server ID', 'wp-ultimo'), 'desc' => __('The Server ID retrieved in the previous step.', 'wp-ultimo'), 'placeholder' => __('e.g. 11667', 'wp-ultimo'), - ), - 'WU_CLOUDWAYS_APP_ID' => array( + ], + 'WU_CLOUDWAYS_APP_ID' => [ 'title' => __('Cloudways App ID', 'wp-ultimo'), 'desc' => __('The App ID retrieved in the previous step.', 'wp-ultimo'), 'placeholder' => __('e.g. 940288', 'wp-ultimo'), - ), - 'WU_CLOUDWAYS_EXTRA_DOMAINS' => array( + ], + 'WU_CLOUDWAYS_EXTRA_DOMAINS' => [ 'title' => __('Cloudways Extra Domains', 'wp-ultimo'), 'tooltip' => __('The Cloudways API is a bit strange in that it doesn’t offer a way to add or remove just one domain, only a way to update the whole domain list. That means that WP Multisite WaaS will replace all domains you might have there with the list of mapped domains of the network every time a new domain is added.', 'wp-ultimo'), 'desc' => __('Comma-separated list of additional domains to add to Cloudways.', 'wp-ultimo'), 'placeholder' => __('e.g. *.test.com, test.com', 'wp-ultimo'), - ), - ); + ], + ]; } /** @@ -181,7 +181,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_add_domain($domain, $site_id) { + public function on_add_domain($domain, $site_id): void { $this->sync_domains(); } @@ -194,7 +194,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_remove_domain($domain, $site_id) { + public function on_remove_domain($domain, $site_id): void { $this->sync_domains(); } @@ -231,15 +231,15 @@ class Cloudways_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @return void */ - private function sync_domains() { + private function sync_domains(): void { $all_domains = $this->get_domains(); $alias_response = $this->send_cloudways_request( '/app/manage/aliases', - array( + [ 'aliases' => $all_domains, - ) + ] ); if (is_wp_error($alias_response)) { @@ -260,7 +260,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider { array_map( function ($domain) { - if (strncmp($domain, '*.', strlen('*.')) === 0) { + if (str_starts_with($domain, '*.')) { $domain = str_replace('*.', '', $domain); } @@ -290,7 +290,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider { $domain_list = $this->get_domain_list(); foreach ($domain_list as $naked_domain) { - if (strncmp((string) $naked_domain, 'www.', strlen('www.')) !== 0 && strncmp((string) $naked_domain, '*.', strlen('*.')) !== 0) { + if (! str_starts_with((string) $naked_domain, 'www.') && ! str_starts_with((string) $naked_domain, '*.')) { $domain_list[] = 'www.' . $naked_domain; } } @@ -311,7 +311,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider { */ private function check_domain_dns($domain_names, $network_ip) { - $valid_domains = array(); + $valid_domains = []; foreach ($domain_names as $domain_name) { $response = wp_remote_get('https://dns.google/resolve?name=' . $domain_name); @@ -343,9 +343,9 @@ class Cloudways_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @return void */ - public function test_connection() { + public function test_connection(): void { - $response = $this->send_cloudways_request('/app/manage/fpm_setting', array(), 'GET'); + $response = $this->send_cloudways_request('/app/manage/fpm_setting', [], 'GET'); if (is_wp_error($response) || wu_get_isset($response, 'error')) { wp_send_json_error($response); @@ -364,7 +364,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider { global $wpdb; - $final_domain_list = array(); + $final_domain_list = []; // Prepare the query $query = "SELECT domain FROM {$wpdb->base_prefix}wu_domain_mappings"; @@ -377,7 +377,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider { foreach ($mappings as $domain) { $final_domain_list[] = $domain; - if (strncmp((string) $domain, 'www.', strlen('www.')) !== 0) { + if (! str_starts_with((string) $domain, 'www.')) { $final_domain_list[] = "www.$domain"; } } @@ -421,25 +421,25 @@ class Cloudways_Host_Provider extends Base_Host_Provider { if ( ! $token) { $response = wp_remote_post( 'https://api.cloudways.com/api/v1/oauth/access_token', - array( + [ 'blocking' => true, 'method' => 'POST', - 'headers' => array( + 'headers' => [ 'cache-control' => 'no-cache', 'content-type' => 'application/x-www-form-urlencoded', - ), - 'body' => array( + ], + 'body' => [ 'email' => defined('WU_CLOUDWAYS_EMAIL') ? WU_CLOUDWAYS_EMAIL : '', 'api_key' => defined('WU_CLOUDWAYS_API_KEY') ? WU_CLOUDWAYS_API_KEY : '', - ), - ) + ], + ] ); if ( ! is_wp_error($response)) { $body = json_decode(wp_remote_retrieve_body($response), true); if (isset($body['access_token'])) { - $expires_in = isset($body['expires_in']) ? $body['expires_in'] : 50 * MINUTE_IN_SECONDS; + $expires_in = $body['expires_in'] ?? 50 * MINUTE_IN_SECONDS; set_site_transient('wu_cloudways_token', $body['access_token'], $expires_in); @@ -461,7 +461,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider { * @param string $method The HTTP verb. * @return object|\WP_Error */ - protected function send_cloudways_request($endpoint, $data = array(), $method = 'POST'): object { + protected function send_cloudways_request($endpoint, $data = [], $method = 'POST'): object { $token = $this->get_cloudways_access_token(); @@ -471,10 +471,10 @@ class Cloudways_Host_Provider extends Base_Host_Provider { if ($method === 'GET') { $endpoint_url = add_query_arg( - array( + [ 'server_id' => defined('WU_CLOUDWAYS_SERVER_ID') ? WU_CLOUDWAYS_SERVER_ID : '', 'app_id' => defined('WU_CLOUDWAYS_APP_ID') ? WU_CLOUDWAYS_APP_ID : '', - ), + ], $endpoint_url ); } else { @@ -486,17 +486,17 @@ class Cloudways_Host_Provider extends Base_Host_Provider { $response = wp_remote_post( $endpoint_url, - array( + [ 'blocking' => true, 'method' => $method, 'timeout' => 45, 'body' => $data, - 'headers' => array( + 'headers' => [ 'cache-control' => 'no-cache', 'content-type' => 'application/x-www-form-urlencoded', 'authorization' => "Bearer $token", - ), - ) + ], + ] ); if (is_wp_error($response)) { @@ -514,7 +514,7 @@ class Cloudways_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @return void */ - public function get_instructions() { + public function get_instructions(): void { wu_get_template('wizards/host-integrations/cloudways-instructions'); } @@ -538,6 +538,6 @@ class Cloudways_Host_Provider extends Base_Host_Provider { */ public function get_logo() { - return wu_get_asset('cloudways.png', 'img/hosts'); + return wu_get_asset('cloudways.webp', 'img/hosts'); } } diff --git a/inc/integrations/host-providers/class-cpanel-host-provider.php b/inc/integrations/host-providers/class-cpanel-host-provider.php index b8fd82c..0b0fe3d 100644 --- a/inc/integrations/host-providers/class-cpanel-host-provider.php +++ b/inc/integrations/host-providers/class-cpanel-host-provider.php @@ -53,10 +53,10 @@ class CPanel_Host_Provider extends Base_Host_Provider { * @var array * @since 2.0.0 */ - protected $supports = array( + protected $supports = [ 'autossl', 'no-instructions', - ); + ]; /** * Constants that need to be present on wp-config.php for this integration to work. @@ -64,11 +64,11 @@ class CPanel_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @var array */ - protected $constants = array( + protected $constants = [ 'WU_CPANEL_USERNAME', 'WU_CPANEL_PASSWORD', 'WU_CPANEL_HOST', - ); + ]; /** * Constants that are optional on wp-config.php. @@ -76,10 +76,10 @@ class CPanel_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @var array */ - protected $optional_constants = array( + protected $optional_constants = [ 'WU_CPANEL_PORT', 'WU_CPANEL_ROOT_DIR', - ); + ]; /** * Holds the API object. @@ -110,31 +110,31 @@ class CPanel_Host_Provider extends Base_Host_Provider { */ public function get_fields() { - return array( - 'WU_CPANEL_USERNAME' => array( + return [ + 'WU_CPANEL_USERNAME' => [ 'title' => __('cPanel Username', 'wp-ultimo'), 'placeholder' => __('e.g. username', 'wp-ultimo'), - ), - 'WU_CPANEL_PASSWORD' => array( + ], + 'WU_CPANEL_PASSWORD' => [ 'type' => 'password', 'title' => __('cPanel Password', 'wp-ultimo'), 'placeholder' => __('password', 'wp-ultimo'), - ), - 'WU_CPANEL_HOST' => array( + ], + 'WU_CPANEL_HOST' => [ 'title' => __('cPanel Host', 'wp-ultimo'), 'placeholder' => __('e.g. yourdomain.com', 'wp-ultimo'), - ), - 'WU_CPANEL_PORT' => array( + ], + 'WU_CPANEL_PORT' => [ 'title' => __('cPanel Port', 'wp-ultimo'), 'placeholder' => __('Defaults to 2083', 'wp-ultimo'), 'value' => 2083, - ), - 'WU_CPANEL_ROOT_DIR' => array( + ], + 'WU_CPANEL_ROOT_DIR' => [ 'title' => __('Root Directory', 'wp-ultimo'), 'placeholder' => __('Defaults to /public_html', 'wp-ultimo'), 'value' => '/public_html', - ), - ); + ], + ]; } /** @@ -145,7 +145,7 @@ class CPanel_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_add_domain($domain, $site_id) { + public function on_add_domain($domain, $site_id): void { // Root Directory $root_dir = defined('WU_CPANEL_ROOT_DIR') && WU_CPANEL_ROOT_DIR ? WU_CPANEL_ROOT_DIR : '/public_html'; @@ -154,11 +154,11 @@ class CPanel_Host_Provider extends Base_Host_Provider { $results = $this->load_api()->api2( 'AddonDomain', 'addaddondomain', - array( + [ 'dir' => $root_dir, 'newdomain' => $domain, 'subdomain' => $this->get_subdomain($domain), - ) + ] ); $this->log_calls($results); @@ -172,16 +172,16 @@ class CPanel_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_remove_domain($domain, $site_id) { + public function on_remove_domain($domain, $site_id): void { // Send Request $results = $this->load_api()->api2( 'AddonDomain', 'deladdondomain', - array( + [ 'domain' => $domain, 'subdomain' => $this->get_subdomain($domain) . '_' . $this->get_site_url(), - ) + ] ); $this->log_calls($results); @@ -197,7 +197,7 @@ class CPanel_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_add_subdomain($subdomain, $site_id) { + public function on_add_subdomain($subdomain, $site_id): void { // Root Directory $root_dir = defined('WU_CPANEL_ROOT_DIR') && WU_CPANEL_ROOT_DIR ? WU_CPANEL_ROOT_DIR : '/public_html'; @@ -210,11 +210,11 @@ class CPanel_Host_Provider extends Base_Host_Provider { $results = $this->load_api()->api2( 'SubDomain', 'addsubdomain', - array( + [ 'dir' => $root_dir, 'domain' => $subdomain, 'rootdomain' => $rootdomain, - ) + ] ); // Check the results @@ -282,7 +282,7 @@ class CPanel_Host_Provider extends Base_Host_Provider { return array_shift($domain_parts); } - $subdomain = str_replace(array('.', '/'), '', $domain); + $subdomain = str_replace(['.', '/'], '', $domain); return $subdomain; } @@ -333,9 +333,9 @@ class CPanel_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @return void */ - public function test_connection() { + public function test_connection(): void { - $results = $this->load_api()->api2('Cron', 'fetchcron', array()); + $results = $this->load_api()->api2('Cron', 'fetchcron', []); $this->log_calls($results); @@ -356,12 +356,12 @@ class CPanel_Host_Provider extends Base_Host_Provider { */ public function get_explainer_lines() { - $explainer_lines = array( - 'will' => array( + $explainer_lines = [ + 'will' => [ 'send_domains' => __('Add a new Addon Domain on cPanel whenever a new domain mapping gets created on your network', 'wp-ultimo'), - ), - 'will_not' => array(), - ); + ], + 'will_not' => [], + ]; if (is_subdomain_install()) { $explainer_lines['will']['send_sub_domains'] = __('Add a new SubDomain on cPanel whenever a new site gets created on your network', 'wp-ultimo'); diff --git a/inc/integrations/host-providers/class-gridpane-host-provider.php b/inc/integrations/host-providers/class-gridpane-host-provider.php index b3fb4f3..7af16bd 100644 --- a/inc/integrations/host-providers/class-gridpane-host-provider.php +++ b/inc/integrations/host-providers/class-gridpane-host-provider.php @@ -51,10 +51,10 @@ class Gridpane_Host_Provider extends Base_Host_Provider { * @var array * @since 2.0.0 */ - protected $supports = array( + protected $supports = [ 'autossl', 'no-config', - ); + ]; /** * Constants that need to be present on wp-config.php for this integration to work. @@ -62,9 +62,9 @@ class Gridpane_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @var array */ - protected $constants = array( + protected $constants = [ 'WU_GRIDPANE', - ); + ]; /** * Picks up on tips that a given host provider is being used. @@ -85,7 +85,7 @@ class Gridpane_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @return void */ - public function enable() { + public function enable(): void { /* * Prevent issues with Gridpane */ @@ -104,19 +104,19 @@ class Gridpane_Host_Provider extends Base_Host_Provider { * @param string $method The HTTP method. * @return mixed */ - public function send_gridpane_api_request($endpoint, $data = array(), $method = 'POST') { + public function send_gridpane_api_request($endpoint, $data = [], $method = 'POST') { - $post_fields = array( + $post_fields = [ 'timeout' => 45, 'blocking' => true, 'method' => $method, 'body' => array_merge( - array( + [ 'api_token' => WU_GRIDPANE_API_KEY, - ), + ], $data ), - ); + ]; $response = wp_remote_request("https://my.gridpane.com/api/{$endpoint}", $post_fields); @@ -143,11 +143,11 @@ class Gridpane_Host_Provider extends Base_Host_Provider { return $this->send_gridpane_api_request( 'application/add-domain', - array( + [ 'server_ip' => WU_GRIDPANE_SERVER_ID, 'site_url' => WU_GRIDPANE_APP_ID, 'domain_url' => $domain, - ) + ] ); } @@ -163,11 +163,11 @@ class Gridpane_Host_Provider extends Base_Host_Provider { return $this->send_gridpane_api_request( 'application/delete-domain', - array( + [ 'server_ip' => WU_GRIDPANE_SERVER_ID, 'site_url' => WU_GRIDPANE_APP_ID, 'domain_url' => $domain, - ) + ] ); } @@ -201,30 +201,30 @@ class Gridpane_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @return void */ - public function test_connection() { + public function test_connection(): void { $results = $this->on_remove_domain('test.com', false); if (wu_get_isset($results, 'message') === 'This action is unauthorized.') { wp_send_json_error( - array( + [ 'error' => __('We were not able to successfully establish a connection.', 'wp-ultimo'), - ) + ] ); } if (is_wp_error($results)) { wp_send_json_error( - array( + [ 'error' => __('We were not able to successfully establish a connection.', 'wp-ultimo'), - ) + ] ); } wp_send_json_success( - array( + [ 'success' => __('Connection successfully established.', 'wp-ultimo'), - ) + ] ); } @@ -234,7 +234,7 @@ class Gridpane_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @return void */ - public function get_instructions() { + public function get_instructions(): void { wu_get_template('wizards/host-integrations/gridpane-instructions'); } @@ -258,6 +258,6 @@ class Gridpane_Host_Provider extends Base_Host_Provider { */ public function get_logo() { - return wu_get_asset('gridpane.png', 'img/hosts'); + return wu_get_asset('gridpane.webp', 'img/hosts'); } } diff --git a/inc/integrations/host-providers/class-runcloud-host-provider.php b/inc/integrations/host-providers/class-runcloud-host-provider.php index 2034a48..12e6ece 100644 --- a/inc/integrations/host-providers/class-runcloud-host-provider.php +++ b/inc/integrations/host-providers/class-runcloud-host-provider.php @@ -52,9 +52,9 @@ class Runcloud_Host_Provider extends Base_Host_Provider { * @var array * @since 2.0.0 */ - protected $supports = array( + protected $supports = [ 'autossl', - ); + ]; /** * Constants that need to be present on wp-config.php for this integration to work. @@ -62,12 +62,12 @@ class Runcloud_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @var array */ - protected $constants = array( + protected $constants = [ 'WU_RUNCLOUD_API_KEY', 'WU_RUNCLOUD_API_SECRET', 'WU_RUNCLOUD_SERVER_ID', 'WU_RUNCLOUD_APP_ID', - ); + ]; /** * Picks up on tips that a given host provider is being used. @@ -78,7 +78,7 @@ class Runcloud_Host_Provider extends Base_Host_Provider { */ public function detect(): bool { - return strpos(ABSPATH, 'runcloud') !== false; + return str_contains(ABSPATH, 'runcloud'); } /** @@ -89,28 +89,28 @@ class Runcloud_Host_Provider extends Base_Host_Provider { */ public function get_fields() { - return array( - 'WU_RUNCLOUD_API_KEY' => array( + return [ + 'WU_RUNCLOUD_API_KEY' => [ 'title' => __('RunCloud API Key', 'wp-ultimo'), 'desc' => __('The API Key retrieved in the previous step.', 'wp-ultimo'), 'placeholder' => __('e.g. Sx9tHAn5XMrkeyZKS1a7uj8dGTLgKnlEOaJEFRt1m95L', 'wp-ultimo'), - ), - 'WU_RUNCLOUD_API_SECRET' => array( + ], + 'WU_RUNCLOUD_API_SECRET' => [ 'title' => __('RunCloud API Secret', 'wp-ultimo'), 'desc' => __('The API secret retrieved in the previous step.', 'wp-ultimo'), 'placeholder' => __('e.g. ZlAebXp2sa6J5xsrPoiPcMXZRIVsHJ2rEkNCNGknZnF0UK5cSNSePS8GBW9FXIQd', 'wp-ultimo'), - ), - 'WU_RUNCLOUD_SERVER_ID' => array( + ], + 'WU_RUNCLOUD_SERVER_ID' => [ 'title' => __('RunCloud Server ID', 'wp-ultimo'), 'desc' => __('The Server ID retrieved in the previous step.', 'wp-ultimo'), 'placeholder' => __('e.g. 11667', 'wp-ultimo'), - ), - 'WU_RUNCLOUD_APP_ID' => array( + ], + 'WU_RUNCLOUD_APP_ID' => [ 'title' => __('RunCloud App ID', 'wp-ultimo'), 'desc' => __('The App ID retrieved in the previous step.', 'wp-ultimo'), 'placeholder' => __('e.g. 940288', 'wp-ultimo'), - ), - ); + ], + ]; } /** @@ -121,17 +121,17 @@ class Runcloud_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_add_domain($domain, $site_id) { + public function on_add_domain($domain, $site_id): void { $success = false; $response = $this->send_runcloud_request( $this->get_runcloud_base_url('domains'), - array( + [ 'name' => $domain, 'www' => true, 'redirection' => 'non-www', - ), + ], 'POST' ); @@ -163,7 +163,7 @@ class Runcloud_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_remove_domain($domain, $site_id) { + public function on_remove_domain($domain, $site_id): void { $domain_id = $this->get_runcloud_domain_id($domain); @@ -171,7 +171,7 @@ class Runcloud_Host_Provider extends Base_Host_Provider { wu_log_add('integration-runcloud', __('Domain name not found on runcloud', 'wp-ultimo')); } - $response = $this->send_runcloud_request($this->get_runcloud_base_url("domains/$domain_id"), array(), 'DELETE'); + $response = $this->send_runcloud_request($this->get_runcloud_base_url("domains/$domain_id"), [], 'DELETE'); if (is_wp_error($response)) { wu_log_add('integration-runcloud', $response->get_error_message(), LogLevel::ERROR); @@ -210,9 +210,9 @@ class Runcloud_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @return void */ - public function test_connection() { + public function test_connection(): void { - $response = $this->send_runcloud_request($this->get_runcloud_base_url('domains'), array(), 'GET'); + $response = $this->send_runcloud_request($this->get_runcloud_base_url('domains'), [], 'GET'); if (is_wp_error($response) || wp_remote_retrieve_response_code($response) !== 200) { wp_send_json_error($response); @@ -246,7 +246,7 @@ class Runcloud_Host_Provider extends Base_Host_Provider { * @param string $method HTTP Method to send. Defaults to POST. * @return array */ - public function send_runcloud_request($url, $data = array(), $method = 'POST') { + public function send_runcloud_request($url, $data = [], $method = 'POST') { $username = defined('WU_RUNCLOUD_API_KEY') ? WU_RUNCLOUD_API_KEY : ''; @@ -254,15 +254,15 @@ class Runcloud_Host_Provider extends Base_Host_Provider { $response = wp_remote_request( $url, - array( + [ 'timeout' => 100, 'redirection' => 5, 'body' => $data, 'method' => $method, - 'headers' => array( + 'headers' => [ 'Authorization' => 'Basic ' . base64_encode($username . ':' . $password), - ), - ) + ], + ] ); return $response; @@ -293,7 +293,7 @@ class Runcloud_Host_Provider extends Base_Host_Provider { */ public function get_runcloud_domain_id($domain) { - $domains_list = $this->send_runcloud_request($this->get_runcloud_base_url('domains'), array(), 'GET'); + $domains_list = $this->send_runcloud_request($this->get_runcloud_base_url('domains'), [], 'GET'); $list = $this->maybe_return_runcloud_body($domains_list); @@ -317,7 +317,7 @@ class Runcloud_Host_Provider extends Base_Host_Provider { $ssl_id = false; - $response = $this->send_runcloud_request($this->get_runcloud_base_url('ssl'), array(), 'GET'); + $response = $this->send_runcloud_request($this->get_runcloud_base_url('ssl'), [], 'GET'); if (is_wp_error($response)) { wu_log_add('integration-runcloud', $response->get_error_message(), LogLevel::ERROR); @@ -341,9 +341,9 @@ class Runcloud_Host_Provider extends Base_Host_Provider { * @param int $ssl_id The SSL id on RunCloud. * @return void */ - public function redeploy_runcloud_ssl($ssl_id) { + public function redeploy_runcloud_ssl($ssl_id): void { - $response = $this->send_runcloud_request($this->get_runcloud_base_url("ssl/$ssl_id"), array(), 'PUT'); + $response = $this->send_runcloud_request($this->get_runcloud_base_url("ssl/$ssl_id"), [], 'PUT'); if (is_wp_error($response)) { wu_log_add('integration-runcloud', $response->get_error_message(), LogLevel::ERROR); @@ -358,7 +358,7 @@ class Runcloud_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @return void */ - public function get_instructions() { + public function get_instructions(): void { wu_get_template('wizards/host-integrations/runcloud-instructions'); } diff --git a/inc/integrations/host-providers/class-serverpilot-host-provider.php b/inc/integrations/host-providers/class-serverpilot-host-provider.php index 151420c..99b1efc 100644 --- a/inc/integrations/host-providers/class-serverpilot-host-provider.php +++ b/inc/integrations/host-providers/class-serverpilot-host-provider.php @@ -52,9 +52,9 @@ class ServerPilot_Host_Provider extends Base_Host_Provider { * @var array * @since 2.0.0 */ - protected $supports = array( + protected $supports = [ 'autossl', - ); + ]; /** * Constants that need to be present on wp-config.php for this integration to work. @@ -62,11 +62,11 @@ class ServerPilot_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @var array */ - protected $constants = array( + protected $constants = [ 'WU_SERVER_PILOT_CLIENT_ID', 'WU_SERVER_PILOT_API_KEY', 'WU_SERVER_PILOT_APP_ID', - ); + ]; /** * Picks up on tips that a given host provider is being used. @@ -89,23 +89,23 @@ class ServerPilot_Host_Provider extends Base_Host_Provider { */ public function get_fields() { - return array( - 'WU_SERVER_PILOT_CLIENT_ID' => array( + return [ + 'WU_SERVER_PILOT_CLIENT_ID' => [ 'title' => __('ServerPilot Client ID', 'wp-ultimo'), 'desc' => __('Your ServerPilot Client ID.', 'wp-ultimo'), 'placeholder' => __('e.g. cid_lSmjevkdoSOpasYVqm', 'wp-ultimo'), - ), - 'WU_SERVER_PILOT_API_KEY' => array( + ], + 'WU_SERVER_PILOT_API_KEY' => [ 'title' => __('ServerPilot API Key', 'wp-ultimo'), 'desc' => __('The API Key retrieved in the previous step.', 'wp-ultimo'), 'placeholder' => __('e.g. eYP0Jo3Fzzm5SOZCi5nLR0Mki2lbYZ', 'wp-ultimo'), - ), - 'WU_SERVER_PILOT_APP_ID' => array( + ], + 'WU_SERVER_PILOT_APP_ID' => [ 'title' => __('ServerPilot App ID', 'wp-ultimo'), 'desc' => __('The App ID retrieved in the previous step.', 'wp-ultimo'), 'placeholder' => __('e.g. 940288', 'wp-ultimo'), - ), - ); + ], + ]; } /** @@ -116,16 +116,16 @@ class ServerPilot_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_add_domain($domain, $site_id) { + public function on_add_domain($domain, $site_id): void { $current_domain_list = $this->get_server_pilot_domains(); if ($current_domain_list && is_array($current_domain_list)) { $this->send_server_pilot_api_request( '', - array( - 'domains' => array_merge($current_domain_list, array($domain, 'www.' . $domain)), - ) + [ + 'domains' => array_merge($current_domain_list, [$domain, 'www.' . $domain]), + ] ); /** @@ -143,7 +143,7 @@ class ServerPilot_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_remove_domain($domain, $site_id) { + public function on_remove_domain($domain, $site_id): void { $current_domain_list = $this->get_server_pilot_domains(); @@ -156,9 +156,9 @@ class ServerPilot_Host_Provider extends Base_Host_Provider { $this->send_server_pilot_api_request( '', - array( + [ 'domains' => $current_domain_list, - ) + ] ); } } @@ -173,16 +173,16 @@ class ServerPilot_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_add_subdomain($subdomain, $site_id) { + public function on_add_subdomain($subdomain, $site_id): void { $current_domain_list = $this->get_server_pilot_domains(); if ($current_domain_list && is_array($current_domain_list)) { $this->send_server_pilot_api_request( '', - array( - 'domains' => array_merge($current_domain_list, array($subdomain)), - ) + [ + 'domains' => array_merge($current_domain_list, [$subdomain]), + ] ); /** @@ -213,18 +213,18 @@ class ServerPilot_Host_Provider extends Base_Host_Provider { * @param string $method HTTP Method: POST, GET, PUT, etc. * @return object */ - public function send_server_pilot_api_request($endpoint, $data = array(), $method = 'POST') { + public function send_server_pilot_api_request($endpoint, $data = [], $method = 'POST') { - $post_fields = array( + $post_fields = [ 'timeout' => 45, 'blocking' => true, 'method' => $method, - 'body' => $data ? json_encode($data) : array(), - 'headers' => array( + 'body' => $data ? json_encode($data) : [], + 'headers' => [ 'Authorization' => 'Basic ' . base64_encode(WU_SERVER_PILOT_CLIENT_ID . ':' . WU_SERVER_PILOT_API_KEY), 'Content-Type' => 'application/json', - ), - ); + ], + ]; $response = wp_remote_request('https://api.serverpilot.io/v1/apps/' . WU_SERVER_PILOT_APP_ID . $endpoint, $post_fields); @@ -249,9 +249,9 @@ class ServerPilot_Host_Provider extends Base_Host_Provider { return $this->send_server_pilot_api_request( '/ssl', - array( + [ 'auto' => true, - ) + ] ); } @@ -263,7 +263,7 @@ class ServerPilot_Host_Provider extends Base_Host_Provider { */ public function get_server_pilot_domains() { - $app_info = $this->send_server_pilot_api_request('', array(), 'GET'); + $app_info = $this->send_server_pilot_api_request('', [], 'GET'); if (isset($app_info['data']['domains'])) { return $app_info['data']['domains']; @@ -285,9 +285,9 @@ class ServerPilot_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @return void */ - public function test_connection() { + public function test_connection(): void { - $response = $this->send_server_pilot_api_request('', array(), 'GET'); + $response = $this->send_server_pilot_api_request('', [], 'GET'); if (is_wp_error($response) || wu_get_isset($response, 'error')) { wp_send_json_error($response); @@ -302,7 +302,7 @@ class ServerPilot_Host_Provider extends Base_Host_Provider { * @since 2.1.2 * @return void */ - public function get_instructions() { + public function get_instructions(): void { wu_get_template('wizards/host-integrations/serverpilot-instructions'); } diff --git a/inc/integrations/host-providers/class-wpengine-host-provider.php b/inc/integrations/host-providers/class-wpengine-host-provider.php index f83ef23..0b1cae3 100644 --- a/inc/integrations/host-providers/class-wpengine-host-provider.php +++ b/inc/integrations/host-providers/class-wpengine-host-provider.php @@ -52,10 +52,10 @@ class WPEngine_Host_Provider extends Base_Host_Provider { * @var array * @since 2.0.0 */ - protected $supports = array( + protected $supports = [ 'no-instructions', 'no-config', - ); + ]; /** * Constants that need to be present on wp-config.php for this integration to work. @@ -63,9 +63,9 @@ class WPEngine_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @var array */ - protected $constants = array( - array('WPE_API', 'WPE_APIKEY'), - ); + protected $constants = [ + ['WPE_API', 'WPE_APIKEY'], + ]; /** * Picks up on tips that a given host provider is being used. @@ -86,7 +86,7 @@ class WPEngine_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @return void */ - public function load_dependencies() { + public function load_dependencies(): void { // if WP Engine is not defined, then return if ( ! defined('WPE_PLUGIN_DIR') || ! is_readable(WPE_PLUGIN_DIR . '/class-wpeapi.php')) { @@ -104,7 +104,7 @@ class WPEngine_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_add_domain($domain, $site_id) { + public function on_add_domain($domain, $site_id): void { $api = new \WPE_API(); @@ -123,7 +123,7 @@ class WPEngine_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_remove_domain($domain, $site_id) { + public function on_remove_domain($domain, $site_id): void { $api = new \WPE_API(); @@ -144,7 +144,7 @@ class WPEngine_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_add_subdomain($subdomain, $site_id) { + public function on_add_subdomain($subdomain, $site_id): void { $this->on_add_domain($subdomain, $site_id); } @@ -159,7 +159,7 @@ class WPEngine_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_remove_subdomain($subdomain, $site_id) { + public function on_remove_subdomain($subdomain, $site_id): void { $this->on_remove_domain($subdomain, $site_id); } @@ -196,7 +196,7 @@ class WPEngine_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @return void */ - public function test_connection() { + public function test_connection(): void { $api = new \WPE_API(); diff --git a/inc/integrations/host-providers/class-wpmudev-host-provider.php b/inc/integrations/host-providers/class-wpmudev-host-provider.php index e7d85db..75040c0 100644 --- a/inc/integrations/host-providers/class-wpmudev-host-provider.php +++ b/inc/integrations/host-providers/class-wpmudev-host-provider.php @@ -52,11 +52,11 @@ class WPMUDEV_Host_Provider extends Base_Host_Provider { * @var array * @since 2.0.0 */ - protected $supports = array( + protected $supports = [ 'autossl', 'no-instructions', 'no-config', - ); + ]; /** * Constants that need to be present on wp-config.php for this integration to work. @@ -64,9 +64,9 @@ class WPMUDEV_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @var array */ - protected $constants = array( + protected $constants = [ 'WPMUDEV_HOSTING_SITE_ID', - ); + ]; /** * Runs on singleton instantiation. @@ -74,7 +74,7 @@ class WPMUDEV_Host_Provider extends Base_Host_Provider { * @since 2.1.1 * @return void */ - public function init() { + public function init(): void { parent::init(); @@ -82,7 +82,7 @@ class WPMUDEV_Host_Provider extends Base_Host_Provider { * Add filter to increase the number of tries to get the SSL certificate. * This is needed because, from our tests, WPMU DEV hosting takes a while to get the SSL certificate. */ - add_filter('wu_async_process_domain_stage_max_tries', array($this, 'ssl_tries'), 10, 2); + add_filter('wu_async_process_domain_stage_max_tries', [$this, 'ssl_tries'], 10, 2); } /** @@ -127,31 +127,31 @@ class WPMUDEV_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_add_domain($domain, $site_id) { + public function on_add_domain($domain, $site_id): void { $site_id = WPMUDEV_HOSTING_SITE_ID; $api_key = get_site_option('wpmudev_apikey'); - $domains = array($domain); + $domains = [$domain]; - if (strncmp($domain, 'www.', strlen('www.')) !== 0) { + if (! str_starts_with($domain, 'www.')) { $domains[] = "www.$domain"; } foreach ($domains as $_domain) { $response = wp_remote_post( "https://premium.wpmudev.org/api/hosting/v1/$site_id/domains", - array( + [ 'timeout' => 50, - 'body' => array( + 'body' => [ 'domain' => $_domain, 'site_id' => $site_id, - ), - 'headers' => array( + ], + 'headers' => [ 'Authorization' => $api_key, - ), - ) + ], + ] ); if (is_wp_error($response)) { @@ -182,7 +182,7 @@ class WPMUDEV_Host_Provider extends Base_Host_Provider { * @param int $site_id ID of the site that is receiving that mapping. * @return void */ - public function on_remove_domain($domain, $site_id) { + public function on_remove_domain($domain, $site_id): void { /** * The WPMU DEV Hosting REST API does not offer an endpoint to remove domains yet. @@ -222,7 +222,7 @@ class WPMUDEV_Host_Provider extends Base_Host_Provider { * @since 2.0.0 * @return void */ - public function test_connection() { + public function test_connection(): void { $site_id = WPMUDEV_HOSTING_SITE_ID; @@ -230,12 +230,12 @@ class WPMUDEV_Host_Provider extends Base_Host_Provider { $response = wp_remote_get( "https://premium.wpmudev.org/api/hosting/v1/{$site_id}/domains", - array( + [ 'timeout' => 50, - 'headers' => array( + 'headers' => [ 'Authorization' => $api_key, - ), - ) + ], + ] ); if (is_wp_error($response) || wp_remote_retrieve_response_code($response) !== 200) { @@ -264,6 +264,6 @@ class WPMUDEV_Host_Provider extends Base_Host_Provider { */ public function get_logo() { - return wu_get_asset('wpmudev.jpg', 'img/hosts'); + return wu_get_asset('wpmudev.webp', 'img/hosts'); } } diff --git a/inc/integrations/host-providers/cpanel-api/class-cpanel-api.php b/inc/integrations/host-providers/cpanel-api/class-cpanel-api.php index 91f466d..6a723ef 100644 --- a/inc/integrations/host-providers/cpanel-api/class-cpanel-api.php +++ b/inc/integrations/host-providers/cpanel-api/class-cpanel-api.php @@ -113,7 +113,7 @@ class CPanel_API { * @since 1.6.2 * @return void */ - public function generate_cookie() { + public function generate_cookie(): void { wu_log_add('integration-cpanel-cookie', ''); } @@ -138,7 +138,7 @@ class CPanel_API { * @param array $params Request parameters to send. * @return mixed */ - private function request($url, $params = array()) { + private function request($url, $params = []) { if ($this->log) { $curl_log = fopen($this->curlfile, 'a+'); @@ -162,7 +162,7 @@ class CPanel_API { $ch = curl_init(); - $curl_opts = array( + $curl_opts = [ CURLOPT_URL => $url, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, @@ -170,7 +170,7 @@ class CPanel_API { CURLOPT_FOLLOWLOCATION => true, CURLOPT_COOKIEJAR => realpath($this->cookie_file), CURLOPT_COOKIEFILE => realpath($this->cookie_file), - CURLOPT_HTTPHEADER => array( + CURLOPT_HTTPHEADER => [ CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows NT 6.3; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0', 'Host: ' . $this->host, 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', @@ -178,8 +178,8 @@ class CPanel_API { 'Accept-Encoding: gzip, deflate', 'Connection: keep-alive', 'Content-Type: application/x-www-form-urlencoded', - ), - ); + ], + ]; if ( ! empty($params)) { $curl_opts[ CURLOPT_POST ] = true; @@ -258,7 +258,7 @@ class CPanel_API { * @param array $parameters Parameters to the API endpoint. * @return boolean */ - public function execute($api, $module, $function, array $parameters = array()) { + public function execute($api, $module, $function, array $parameters = []) { switch ($api) { case 'api2': @@ -279,7 +279,7 @@ class CPanel_API { * @param array $parameters Parameters to the API endpoint. * @return mixed */ - public function uapi($module, $function, array $parameters = array()) { + public function uapi($module, $function, array $parameters = []) { if (count($parameters) < 1) { $parameters = ''; @@ -299,7 +299,7 @@ class CPanel_API { * @param array $parameters Parameters to the API endpoint. * @return mixed */ - public function api2($module, $function, array $parameters = array()) { + public function api2($module, $function, array $parameters = []) { if (count($parameters) < 1) { $parameters = ''; diff --git a/inc/internal/class-memory-trap.php b/inc/internal/class-memory-trap.php index 02cf2db..a5f1a24 100644 --- a/inc/internal/class-memory-trap.php +++ b/inc/internal/class-memory-trap.php @@ -54,7 +54,7 @@ class Memory_Trap { * @param string $return_type 'json' or 'plain'. * @return void */ - public function set_return_type($return_type) { + public function set_return_type($return_type): void { $this->return_type = $return_type; } @@ -65,7 +65,7 @@ class Memory_Trap { * @since 2.0.11 * @return void */ - public function setup() { + public function setup(): void { $this->memory_reserve = str_repeat('*', 1024 * 1024); @@ -78,7 +78,7 @@ class Memory_Trap { $err = error_get_last(); - if ((!is_null($err)) && (!in_array($err['type'], array(E_NOTICE, E_WARNING, E_DEPRECATED, E_USER_DEPRECATED)))) { // phpcs:ignore + if ((!is_null($err)) && (!in_array($err['type'], [E_NOTICE, E_WARNING, E_DEPRECATED, E_USER_DEPRECATED]))) { // phpcs:ignore $this->memory_limit_error_handler($err); } @@ -95,15 +95,15 @@ class Memory_Trap { * @param array $error The error array. * @return void */ - public function memory_limit_error_handler($error) { // phpcs:ignore + public function memory_limit_error_handler($error): void { // phpcs:ignore $message = sprintf(__('Your server\'s PHP and WordPress memory limits are too low to perform this check. You might need to contact your host provider and ask the PHP memory limit in particular to be raised.', 'wp-ultimo')); if ($this->return_type === 'json') { wp_send_json_error( - array( + [ 'message' => $message, - ) + ] ); die; diff --git a/inc/invoices/class-invoice.php b/inc/invoices/class-invoice.php index d9097a8..775122e 100644 --- a/inc/invoices/class-invoice.php +++ b/inc/invoices/class-invoice.php @@ -59,7 +59,7 @@ class Invoice { * @param \WP_Ultimo\Checkout\Cart $payment The payment. * @param array $atts Attributes to make available on template. */ - public function __construct($payment, $atts = array()) { + public function __construct($payment, $atts = []) { $this->set_payment($payment); @@ -80,7 +80,7 @@ class Invoice { */ public function __get($key) { - return isset($this->attributes[ $key ]) ? $this->attributes[ $key ] : ''; + return $this->attributes[ $key ] ?? ''; } /** @@ -89,20 +89,20 @@ class Invoice { * @since 2.0.0 * @return void */ - private function pdf_setup() { + private function pdf_setup(): void { $this->printer = new Mpdf( - array( + [ 'mode' => '+aCJK', 'autoScriptToLang' => true, 'autoLangToFont' => true, 'tempDir' => get_temp_dir(), - ) + ] ); $this->printer->setDefaultFont($this->font); - $this->printer->SetProtection(array('print')); + $this->printer->SetProtection(['print']); $this->printer->SetTitle(__('Invoice', 'wp-ultimo')); @@ -133,7 +133,7 @@ class Invoice { * @param boolean $file_name The name of the file. Should include the .pdf extension. * @return void */ - public function save_file($file_name) { + public function save_file($file_name): void { $file_name = self::get_folder() . $file_name; @@ -146,7 +146,7 @@ class Invoice { * @since 2.0.0 * @return void */ - public function print_file() { + public function print_file(): void { $this->pdf(); } @@ -167,7 +167,7 @@ class Invoice { $atts['membership'] = $this->payment->get_membership(); - $atts['billing_address'] = $atts['membership'] ? $atts['membership']->get_billing_address()->to_array() : array(); + $atts['billing_address'] = $atts['membership'] ? $atts['membership']->get_billing_address()->to_array() : []; return wu_get_template_contents('invoice/template', $atts); } @@ -215,7 +215,7 @@ class Invoice { * @param mixed $payment The Order object to add to the invoice. * @return void */ - public function set_payment($payment) { + public function set_payment($payment): void { $this->payment = $payment; } @@ -238,11 +238,11 @@ class Invoice { * @param mixed $attributes The list of attributes to add to the invoice. * @return void */ - public function set_attributes($attributes) { + public function set_attributes($attributes): void { $attributes = wp_parse_args( $attributes, - array( + [ 'company_name' => wu_get_setting('company_name'), 'company_address' => wu_get_setting('company_address'), 'primary_color' => '#675645', @@ -252,7 +252,7 @@ class Invoice { 'custom_logo' => false, 'footer_message' => '', 'paid_tag_text' => __('Paid', 'wp-ultimo'), - ) + ] ); $this->attributes = $attributes; @@ -277,7 +277,7 @@ class Invoice { */ public static function get_settings() { - return wu_get_option(self::KEY, array()); + return wu_get_option(self::KEY, []); } /** diff --git a/inc/limitations/class-limit-customer-user-role.php b/inc/limitations/class-limit-customer-user-role.php index d0193ae..0fff20d 100644 --- a/inc/limitations/class-limit-customer-user-role.php +++ b/inc/limitations/class-limit-customer-user-role.php @@ -35,10 +35,10 @@ class Limit_Customer_User_Role extends Limit { */ public static function default_state() { - return array( + return [ 'enabled' => true, 'limit' => 'default', - ); + ]; } /** diff --git a/inc/limitations/class-limit-domain-mapping.php b/inc/limitations/class-limit-domain-mapping.php index 667f6db..5d972c5 100644 --- a/inc/limitations/class-limit-domain-mapping.php +++ b/inc/limitations/class-limit-domain-mapping.php @@ -51,7 +51,7 @@ class Limit_Domain_Mapping extends Limit { * @param array $data The module data. * @return void */ - public function setup($data) { + public function setup($data): void { parent::setup($data); @@ -99,9 +99,9 @@ class Limit_Domain_Mapping extends Limit { */ public function get_default_permissions($type) { - return array( + return [ 'behavior' => 'available', - ); + ]; } /** @@ -112,10 +112,10 @@ class Limit_Domain_Mapping extends Limit { */ public static function default_state() { - return array( + return [ 'enabled' => true, 'limit' => null, 'mode' => 'default', - ); + ]; } } diff --git a/inc/limitations/class-limit-plugins.php b/inc/limitations/class-limit-plugins.php index 53c1f4b..140951e 100644 --- a/inc/limitations/class-limit-plugins.php +++ b/inc/limitations/class-limit-plugins.php @@ -44,7 +44,7 @@ class Limit_Plugins extends Limit { $plugin = (object) $this->{$value_to_check}; - $types = array( + $types = [ 'visible' => $plugin->visibility === 'visible', 'hidden' => $plugin->visibility === 'hidden', 'default' => $plugin->behavior === 'default', @@ -52,7 +52,7 @@ class Limit_Plugins extends Limit { 'force_inactive' => $plugin->behavior === 'force_inactive', 'force_active_locked' => $plugin->behavior === 'force_active_locked', 'force_inactive_locked' => $plugin->behavior === 'force_inactive_locked', - ); + ]; return wu_get_isset($types, $type, false); } @@ -83,21 +83,21 @@ class Limit_Plugins extends Limit { */ public function get_by_type($behavior = null, $visibility = null) { - $search_params = array(); + $search_params = []; if ($behavior) { - $search_params[] = array('behavior', $behavior); + $search_params[] = ['behavior', $behavior]; } if ($visibility) { - $search_params[] = array('visibility', $visibility); + $search_params[] = ['visibility', $visibility]; } $results = \Arrch\Arrch::find( (array) $this->get_limit(), - array( + [ 'where' => $search_params, - ) + ] ); return $results; @@ -113,10 +113,10 @@ class Limit_Plugins extends Limit { */ public function get_default_permissions($type) { - return array( + return [ 'visibility' => 'visible', 'behavior' => 'default', - ); + ]; } /** @@ -129,7 +129,7 @@ class Limit_Plugins extends Limit { */ public function exists($plugin_name) { - $results = wu_get_isset($this->get_limit(), $plugin_name, array()); + $results = wu_get_isset($this->get_limit(), $plugin_name, []); return wu_get_isset($results, 'visibility', 'not-set') !== 'not-set' || wu_get_isset($results, 'behavior', 'not-set') !== 'not-set'; } diff --git a/inc/limitations/class-limit-post-types.php b/inc/limitations/class-limit-post-types.php index 1539ca5..dc234ac 100644 --- a/inc/limitations/class-limit-post-types.php +++ b/inc/limitations/class-limit-post-types.php @@ -39,7 +39,7 @@ class Limit_Post_Types extends Limit_Subtype { /* * Calculate post count based on all different status */ - $post_count = $this->get_post_count($post_type); + $post_count = static::get_post_count($post_type); // Get the allowed quota $quota = $this->{$post_type}->number; @@ -70,7 +70,7 @@ class Limit_Post_Types extends Limit_Subtype { $post_count = wp_count_posts($post_type); - $statuses = $post_type === 'attachment' ? array('inherit') : array('publish', 'private'); + $statuses = $post_type === 'attachment' ? ['inherit'] : ['publish', 'private']; /** * Allow plugin developers to change which post status should be counted diff --git a/inc/limitations/class-limit-site-templates.php b/inc/limitations/class-limit-site-templates.php index a23f333..c7d22b4 100644 --- a/inc/limitations/class-limit-site-templates.php +++ b/inc/limitations/class-limit-site-templates.php @@ -51,7 +51,7 @@ class Limit_Site_Templates extends Limit { * @param array $data The module data. * @return void */ - public function setup($data) { + public function setup($data): void { parent::setup($data); @@ -86,11 +86,11 @@ class Limit_Site_Templates extends Limit { $template = (object) $this->{$value_to_check}; - $types = array( + $types = [ 'available' => $template->behavior === 'available', 'not_available' => $template->behavior === 'not_available', 'pre_selected' => $template->behavior === 'pre_selected', - ); + ]; return wu_get_isset($types, $type, true); } @@ -122,9 +122,9 @@ class Limit_Site_Templates extends Limit { */ public function get_default_permissions($type) { - return array( + return [ 'behavior' => 'available', - ); + ]; } /** @@ -139,7 +139,7 @@ class Limit_Site_Templates extends Limit { $template_id = str_replace('site_', '', $template_id); - $results = wu_get_isset($this->get_limit(), $template_id, array()); + $results = wu_get_isset($this->get_limit(), $template_id, []); return wu_get_isset($results, 'behavior', 'not-set') !== 'not-set'; } @@ -173,7 +173,7 @@ class Limit_Site_Templates extends Limit { $limits = (array) $limits; - $available = array(); + $available = []; foreach ($limits as $site_id => $site_settings) { $site_settings = (object) $site_settings; @@ -221,7 +221,7 @@ class Limit_Site_Templates extends Limit { */ public function handle_limit() { - $module = wu_get_isset($_POST['modules'], $this->id, array()); + $module = wu_get_isset($_POST['modules'], $this->id, []); return wu_get_isset($module, 'limit', $this->get_limit()); } @@ -236,7 +236,7 @@ class Limit_Site_Templates extends Limit { */ public function handle_others($module) { - $_module = wu_get_isset($_POST['modules'], $this->id, array()); + $_module = wu_get_isset($_POST['modules'], $this->id, []); $module['mode'] = wu_get_isset($_module, 'mode', 'default'); @@ -251,10 +251,10 @@ class Limit_Site_Templates extends Limit { */ public static function default_state() { - return array( + return [ 'enabled' => true, 'limit' => null, 'mode' => 'default', - ); + ]; } } diff --git a/inc/limitations/class-limit-subtype.php b/inc/limitations/class-limit-subtype.php index 199db44..12977af 100644 --- a/inc/limitations/class-limit-subtype.php +++ b/inc/limitations/class-limit-subtype.php @@ -88,10 +88,10 @@ class Limit_Subtype extends Limit { */ public function get_default_permissions($type) { - return array( + return [ 'enabled' => true, 'number' => '', // unlimited - ); + ]; } /** @@ -104,7 +104,7 @@ class Limit_Subtype extends Limit { */ public function exists($type) { - $results = wu_get_isset($this->get_limit(), $type, array()); + $results = wu_get_isset($this->get_limit(), $type, []); return wu_get_isset($results, 'number', 'not-set') !== 'not-set'; } @@ -117,7 +117,7 @@ class Limit_Subtype extends Limit { */ public function handle_limit() { - $received = wu_get_isset($_POST['modules'][ $this->id ], 'limit', array()); + $received = wu_get_isset($_POST['modules'][ $this->id ], 'limit', []); foreach ($received as $post_type => &$limitations) { $limitations['enabled'] = (bool) wu_get_isset($_POST['modules'][ $this->id ]['limit'][ $post_type ], 'enabled', false); diff --git a/inc/limitations/class-limit-themes.php b/inc/limitations/class-limit-themes.php index ac36db4..48fa1ab 100644 --- a/inc/limitations/class-limit-themes.php +++ b/inc/limitations/class-limit-themes.php @@ -52,12 +52,12 @@ class Limit_Themes extends Limit { $theme = (object) $this->{$value_to_check}; - $types = array( + $types = [ 'visible' => $theme->visibility === 'visible', 'hidden' => $theme->visibility === 'hidden', 'available' => $theme->behavior === 'available', 'not_available' => $theme->behavior === 'not_available', - ); + ]; return wu_get_isset($types, $type, false); } @@ -87,10 +87,10 @@ class Limit_Themes extends Limit { */ public function get_default_permissions($type) { - return array( + return [ 'visibility' => 'visible', 'behavior' => 'available', - ); + ]; } /** @@ -103,7 +103,7 @@ class Limit_Themes extends Limit { */ public function exists($theme_name) { - $results = wu_get_isset($this->get_limit(), $theme_name, array()); + $results = wu_get_isset($this->get_limit(), $theme_name, []); return wu_get_isset($results, 'visibility', 'not-set') !== 'not-set' || wu_get_isset($results, 'behavior', 'not-set') !== 'not-set'; } @@ -131,7 +131,7 @@ class Limit_Themes extends Limit { $limits = $this->get_limit(); - $available = array(); + $available = []; foreach ($limits as $theme_slug => $theme_settings) { $theme_settings = (object) $theme_settings; diff --git a/inc/limitations/class-limit.php b/inc/limitations/class-limit.php index 42e5c06..f44ec69 100644 --- a/inc/limitations/class-limit.php +++ b/inc/limitations/class-limit.php @@ -123,7 +123,7 @@ abstract class Limit implements \JsonSerializable { * @param array $data The module data. * @return void */ - public function setup($data) { + public function setup($data): void { if ( ! is_array($data)) { $data = (array) $data; @@ -147,10 +147,10 @@ abstract class Limit implements \JsonSerializable { $data = wp_parse_args( $data, - array( + [ 'limit' => null, 'enabled' => $this->enabled_default_value, - ) + ] ); $this->limit = is_array($data['limit']) ? (object) $data['limit'] : $data['limit']; @@ -299,7 +299,7 @@ abstract class Limit implements \JsonSerializable { */ public function handle_enabled() { - $module = wu_get_isset($_POST['modules'], $this->id, array()); + $module = wu_get_isset($_POST['modules'], $this->id, []); return (bool) wu_get_isset($module, 'enabled', false); } @@ -325,7 +325,7 @@ abstract class Limit implements \JsonSerializable { */ public function handle_limit() { - $module = wu_get_isset($_POST['modules'], $this->id, array()); + $module = wu_get_isset($_POST['modules'], $this->id, []); return wu_get_isset($module, 'limit', null); } @@ -338,9 +338,9 @@ abstract class Limit implements \JsonSerializable { */ public static function default_state() { - return array( + return [ 'enabled' => false, 'limit' => null, - ); + ]; } } diff --git a/inc/limits/class-customer-user-role-limits.php b/inc/limits/class-customer-user-role-limits.php index 17f4c63..8271531 100644 --- a/inc/limits/class-customer-user-role-limits.php +++ b/inc/limits/class-customer-user-role-limits.php @@ -28,13 +28,13 @@ class Customer_User_Role_Limits { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - add_action('in_admin_header', array($this, 'block_new_user_page')); + add_action('in_admin_header', [$this, 'block_new_user_page']); - add_action('wu_async_after_membership_update_products', array($this, 'update_site_user_roles')); + add_action('wu_async_after_membership_update_products', [$this, 'update_site_user_roles']); - add_filter('editable_roles', array($this, 'filter_editable_roles')); + add_filter('editable_roles', [$this, 'filter_editable_roles']); if ( ! wu_get_current_site()->has_module_limitation('customer_user_role')) { return; @@ -46,7 +46,7 @@ class Customer_User_Role_Limits { * * @since 2.0.20 */ - public function block_new_user_page() { + public function block_new_user_page(): void { if (is_super_admin()) { return; @@ -71,7 +71,7 @@ class Customer_User_Role_Limits { */ $message = apply_filters('wu_users_membership_limit_message', $message); - wp_die($message, __('Limit Reached', 'wp-ultimo'), array('back_link' => true)); + wp_die($message, __('Limit Reached', 'wp-ultimo'), ['back_link' => true]); } /** @@ -94,7 +94,7 @@ class Customer_User_Role_Limits { $limit = $users_limitation->{$role}; if (property_exists($limit, 'enabled') && $limit->enabled) { - $user_list = get_users(array('role' => $role)); + $user_list = get_users(['role' => $role]); $count = (int) count($user_list); @@ -119,7 +119,7 @@ class Customer_User_Role_Limits { * @param int $membership_id The membership upgraded or downgraded. * @return void */ - public function update_site_user_roles($membership_id) { + public function update_site_user_roles($membership_id): void { $membership = wu_get_membership($membership_id); diff --git a/inc/limits/class-disk-space-limits.php b/inc/limits/class-disk-space-limits.php index b7e78e2..9752cdd 100644 --- a/inc/limits/class-disk-space-limits.php +++ b/inc/limits/class-disk-space-limits.php @@ -45,11 +45,11 @@ class Disk_Space_Limits { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - add_filter('site_option_upload_space_check_disabled', array($this, 'upload_space_check_disabled')); + add_filter('site_option_upload_space_check_disabled', [$this, 'upload_space_check_disabled']); - add_filter('get_space_allowed', array($this, 'apply_disk_space_limitations')); + add_filter('get_space_allowed', [$this, 'apply_disk_space_limitations']); } /** diff --git a/inc/limits/class-plugin-limits.php b/inc/limits/class-plugin-limits.php index 9c6b59b..d479773 100644 --- a/inc/limits/class-plugin-limits.php +++ b/inc/limits/class-plugin-limits.php @@ -43,9 +43,9 @@ class Plugin_Limits { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - add_action('wu_sunrise_loaded', array($this, 'load_limitations')); + add_action('wu_sunrise_loaded', [$this, 'load_limitations']); } /** @@ -54,27 +54,27 @@ class Plugin_Limits { * @since 2.0.0 * @return void */ - public function load_limitations() { + public function load_limitations(): void { if (wu_get_current_site()->has_limitations()) { - add_filter('site_option_active_sitewide_plugins', array($this, 'deactivate_network_plugins')); + add_filter('site_option_active_sitewide_plugins', [$this, 'deactivate_network_plugins']); - add_filter('option_active_plugins', array($this, 'deactivate_plugins')); + add_filter('option_active_plugins', [$this, 'deactivate_plugins']); - add_filter('all_plugins', array($this, 'clear_plugin_list')); + add_filter('all_plugins', [$this, 'clear_plugin_list']); - add_filter('the_content', array($this, 'clean_unused_shortcodes'), 9999); + add_filter('the_content', [$this, 'clean_unused_shortcodes'], 9999); - add_filter('plugin_action_links', array($this, 'clear_actions'), -2000, 2); + add_filter('plugin_action_links', [$this, 'clear_actions'], -2000, 2); add_filter('show_network_active_plugins', '__return_true'); - add_action('load-plugins.php', array($this, 'admin_page_hooks')); + add_action('load-plugins.php', [$this, 'admin_page_hooks']); } - add_action('wu_site_post_save', array($this, 'activate_and_inactive_plugins'), 10, 3); + add_action('wu_site_post_save', [$this, 'activate_and_inactive_plugins'], 10, 3); - add_action('wu_checkout_done', array($this, 'maybe_activate_and_inactive_plugins'), 10, 5); + add_action('wu_checkout_done', [$this, 'maybe_activate_and_inactive_plugins'], 10, 5); } /** @@ -83,7 +83,7 @@ class Plugin_Limits { * @since 2.0.5 * @return void */ - public function admin_page_hooks() { + public function admin_page_hooks(): void { add_action('admin_enqueue_scripts', 'add_wubox'); } @@ -97,7 +97,7 @@ class Plugin_Limits { * @param bool $new_site If this site is a new one. * @return void */ - public function activate_and_inactive_plugins($data, $site_object, $new_site) { + public function activate_and_inactive_plugins($data, $site_object, $new_site): void { if ($site_object && $new_site) { $site_object->sync_plugins(); } @@ -115,7 +115,7 @@ class Plugin_Limits { * @param string $type The cart type. * @return void */ - public function maybe_activate_and_inactive_plugins($payment, $membership, $customer, $cart, $type) { + public function maybe_activate_and_inactive_plugins($payment, $membership, $customer, $cart, $type): void { if ('new' !== $type && $membership) { $membership->sync_plugins(); } @@ -155,10 +155,10 @@ class Plugin_Limits { $upgrade = sprintf( '%s', wu_generate_upgrade_to_unlock_url( - array( + [ 'module' => 'plugins', 'type' => $plugin_file, - ) + ] ), __('Upgrade to unlock', 'wp-ultimo'), __('Upgrade to unlock', 'wp-ultimo') @@ -196,7 +196,7 @@ class Plugin_Limits { unset($plugins[ $plugin_slug ]); } - if (strncmp($plugin_slug, 'wp-ultimo', strlen('wp-ultimo')) === 0) { + if (str_starts_with($plugin_slug, 'wp-ultimo')) { unset($plugins[ $plugin_slug ]); } @@ -236,7 +236,7 @@ class Plugin_Limits { $plugin_limits = wu_get_current_site()->get_limitations()->plugins; foreach ($plugins as $plugin_slug => $timestamp) { - if (strpos($plugin_slug, 'wp-ultimo') !== false) { + if (str_contains($plugin_slug, 'wp-ultimo')) { continue; } @@ -289,7 +289,7 @@ class Plugin_Limits { $plugin_limits = wu_get_current_site()->get_limitations()->plugins; foreach ($plugins as $plugin_slug) { - if (strpos((string) $plugin_slug, 'wp-ultimo') !== false) { + if (str_contains((string) $plugin_slug, 'wp-ultimo')) { continue; } diff --git a/inc/limits/class-post-type-limits.php b/inc/limits/class-post-type-limits.php index e5cb904..3e02668 100644 --- a/inc/limits/class-post-type-limits.php +++ b/inc/limits/class-post-type-limits.php @@ -28,7 +28,7 @@ class Post_Type_Limits { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { /** * Emulated post types. @@ -36,7 +36,7 @@ class Post_Type_Limits { * @since 2.0.6 */ if (is_main_site() && is_network_admin()) { - add_action('init', array($this, 'register_emulated_post_types'), 999); + add_action('init', [$this, 'register_emulated_post_types'], 999); } /** @@ -57,15 +57,15 @@ class Post_Type_Limits { return; } - add_action('load-post-new.php', array($this, 'limit_posts')); + add_action('load-post-new.php', [$this, 'limit_posts']); - add_filter('wp_handle_upload', array($this, 'limit_media')); + add_filter('wp_handle_upload', [$this, 'limit_media']); - add_filter('media_upload_tabs', array($this, 'limit_tabs')); + add_filter('media_upload_tabs', [$this, 'limit_tabs']); - add_action('current_screen', array($this, 'limit_restoring'), 10); + add_action('current_screen', [$this, 'limit_restoring'], 10); - add_filter('wp_insert_post_data', array($this, 'limit_draft_publishing'), 10, 2); + add_filter('wp_insert_post_data', [$this, 'limit_draft_publishing'], 10, 2); } /** @@ -74,9 +74,9 @@ class Post_Type_Limits { * @since 2.0.6 * @return void */ - public function register_emulated_post_types() { + public function register_emulated_post_types(): void { - $emulated_post_types = wu_get_setting('emulated_post_types', array()); + $emulated_post_types = wu_get_setting('emulated_post_types', []); if (is_array($emulated_post_types) && ! empty($emulated_post_types)) { foreach ($emulated_post_types as $pt) { @@ -90,7 +90,7 @@ class Post_Type_Limits { register_post_type( $pt->post_type, - array( + [ 'label' => $pt->label, 'exclude_from_search' => true, 'public' => true, @@ -98,7 +98,7 @@ class Post_Type_Limits { 'has_archive' => false, 'can_export' => false, 'delete_with_user' => false, - ) + ] ); } } @@ -110,7 +110,7 @@ class Post_Type_Limits { * @since 2.0.0 * @return void */ - public function limit_restoring() { + public function limit_restoring(): void { if (isset($_REQUEST['action']) && $_REQUEST['action'] === 'untrash') { $this->limit_posts(); @@ -123,7 +123,7 @@ class Post_Type_Limits { * @since 1.0.0 * @since 1.5.4 Checks for blocked post types */ - public function limit_posts() { + public function limit_posts(): void { if (is_main_site()) { return; @@ -135,7 +135,7 @@ class Post_Type_Limits { $upgrade_message = __('Your plan does not support this post type.', 'wp-ultimo'); // translators: %s is the URL. - wp_die($upgrade_message, __('Limit Reached', 'wp-ultimo'), array('back_link' => true)); + wp_die($upgrade_message, __('Limit Reached', 'wp-ultimo'), ['back_link' => true]); } // Check if that is more than our limit @@ -143,7 +143,7 @@ class Post_Type_Limits { $upgrade_message = __('You reached your plan\'s post limit.', 'wp-ultimo'); // translators: %s is the URL - wp_die($upgrade_message, __('Limit Reached', 'wp-ultimo'), array('back_link' => true)); + wp_die($upgrade_message, __('Limit Reached', 'wp-ultimo'), ['back_link' => true]); } } @@ -174,7 +174,7 @@ class Post_Type_Limits { return $data; } - $post_type = isset($data['post_type']) ? $data['post_type'] : 'post'; + $post_type = $data['post_type'] ?? 'post'; $post_type_limits = wu_get_current_site()->get_limitations()->post_types; diff --git a/inc/limits/class-site-template-limits.php b/inc/limits/class-site-template-limits.php index 01208d6..fe03319 100644 --- a/inc/limits/class-site-template-limits.php +++ b/inc/limits/class-site-template-limits.php @@ -30,9 +30,9 @@ class Site_Template_Limits { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - add_action('plugins_loaded', array($this, 'setup')); + add_action('plugins_loaded', [$this, 'setup']); } /** @@ -41,13 +41,13 @@ class Site_Template_Limits { * @since 2.0.0 * @return void */ - public function setup() { + public function setup(): void { - add_filter('wu_template_selection_render_attributes', array($this, 'maybe_filter_template_selection_options')); + add_filter('wu_template_selection_render_attributes', [$this, 'maybe_filter_template_selection_options']); - add_filter('wu_checkout_template_id', array($this, 'maybe_force_template_selection'), 10, 2); + add_filter('wu_checkout_template_id', [$this, 'maybe_force_template_selection'], 10, 2); - add_filter('wu_cart_get_extra_params', array($this, 'maybe_force_template_selection_on_cart'), 10, 2); + add_filter('wu_cart_get_extra_params', [$this, 'maybe_force_template_selection_on_cart'], 10, 2); } /** @@ -62,16 +62,16 @@ class Site_Template_Limits { $attributes['should_display'] = true; - $products = array_map('wu_get_product', wu_get_isset($attributes, 'products', array())); + $products = array_map('wu_get_product', wu_get_isset($attributes, 'products', [])); $products = array_filter($products); if ( ! empty($products)) { $limits = new \WP_Ultimo\Objects\Limitations(); - list($plan, $additional_products) = wu_segregate_products($products); + [$plan, $additional_products] = wu_segregate_products($products); - $products = array_merge(array($plan), $additional_products); + $products = array_merge([$plan], $additional_products); foreach ($products as $product) { $limits = $limits->merge($product->get_limitations()); @@ -127,9 +127,9 @@ class Site_Template_Limits { $products = $cart->get_all_products(); - list($plan, $additional_products) = wu_segregate_products($products); + [$plan, $additional_products] = wu_segregate_products($products); - $products = array_merge(array($plan), $additional_products); + $products = array_merge([$plan], $additional_products); $products = array_filter($products); @@ -162,9 +162,9 @@ class Site_Template_Limits { if ( ! empty($products)) { $limits = new \WP_Ultimo\Objects\Limitations(); - list($plan, $additional_products) = wu_segregate_products($products); + [$plan, $additional_products] = wu_segregate_products($products); - $products = array_merge(array($plan), $additional_products); + $products = array_merge([$plan], $additional_products); foreach ($products as $product) { $limits = $limits->merge($product->get_limitations()); diff --git a/inc/limits/class-theme-limits.php b/inc/limits/class-theme-limits.php index 3c6f51e..44ed2aa 100644 --- a/inc/limits/class-theme-limits.php +++ b/inc/limits/class-theme-limits.php @@ -27,7 +27,7 @@ class Theme_Limits { * @since 2.0.0 * @var array */ - protected $themes_not_available = array(); + protected $themes_not_available = []; /** * Keep a cache of the results as the check is costly. @@ -51,7 +51,7 @@ class Theme_Limits { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { /** * We need to bail if we're inside the WP CLI context and the @@ -68,7 +68,7 @@ class Theme_Limits { return; } - add_action('wu_sunrise_loaded', array($this, 'load_limitations')); + add_action('wu_sunrise_loaded', [$this, 'load_limitations']); } /** @@ -77,24 +77,24 @@ class Theme_Limits { * @since 2.0.0 * @return void */ - public function load_limitations() { + public function load_limitations(): void { if (wu_get_current_site()->has_limitations()) { - add_filter('stylesheet', array($this, 'force_active_theme_stylesheet')); + add_filter('stylesheet', [$this, 'force_active_theme_stylesheet']); - add_filter('template', array($this, 'force_active_theme_template')); + add_filter('template', [$this, 'force_active_theme_template']); - add_filter('allowed_themes', array($this, 'add_extra_available_themes')); + add_filter('allowed_themes', [$this, 'add_extra_available_themes']); - add_filter('site_allowed_themes', array($this, 'add_extra_available_themes')); + add_filter('site_allowed_themes', [$this, 'add_extra_available_themes']); - add_filter('wp_prepare_themes_for_js', array($this, 'maybe_remove_activate_button')); + add_filter('wp_prepare_themes_for_js', [$this, 'maybe_remove_activate_button']); - add_action('admin_enqueue_scripts', array($this, 'hacky_remove_activate_button')); + add_action('admin_enqueue_scripts', [$this, 'hacky_remove_activate_button']); - add_action('admin_footer-themes.php', array($this, 'modify_backbone_template')); + add_action('admin_footer-themes.php', [$this, 'modify_backbone_template']); - add_action('customize_changeset_save_data', array($this, 'prevent_theme_activation_on_customizer'), 99, 2); + add_action('customize_changeset_save_data', [$this, 'prevent_theme_activation_on_customizer'], 99, 2); } } @@ -124,10 +124,10 @@ class Theme_Limits { $theme_limitations = wu_get_current_site()->get_limitations()->themes; if ($theme_limitations->allowed($new_theme, 'not_available')) { - $response = array( + $response = [ 'code' => 'not-available', 'message' => __('This theme is not available on your current plan.', 'wp-ultimo'), - ); + ]; wp_send_json($response, 'not-available'); @@ -149,7 +149,7 @@ class Theme_Limits { * @since 2.0.0 * @return void */ - public function hacky_remove_activate_button() { + public function hacky_remove_activate_button(): void { global $pagenow; @@ -169,20 +169,20 @@ class Theme_Limits { $upgrade_button = wu_generate_upgrade_to_unlock_button( __('Upgrade to unlock', 'wp-ultimo'), - array( + [ 'module' => 'themes', 'type' => 'EXTENSION', 'classes' => 'button', - ) + ] ); wp_localize_script( 'theme', 'wu_theme_settings', - array( + [ 'themes_not_available' => $this->themes_not_available, 'replacement_message' => $upgrade_button, - ) + ] ); } @@ -192,7 +192,7 @@ class Theme_Limits { * @since 2.0.0 * @return void */ - public function modify_backbone_template() { // phpcs:disable ?> + public function modify_backbone_template(): void { // phpcs:disable ?> ', $line); @@ -301,14 +299,14 @@ class Webhook_Manager extends Base_Manager { $message .= sprintf('Got error: %s', $response); } - $event_data = array( + $event_data = [ 'object_id' => $id, 'object_type' => $this->slug, 'slug' => $event_name, - 'payload' => array( + 'payload' => [ 'message' => $message, - ), - ); + ], + ]; wu_create_event($event_data); } diff --git a/inc/models/class-base-model.php b/inc/models/class-base-model.php index b01b96f..95794e6 100644 --- a/inc/models/class-base-model.php +++ b/inc/models/class-base-model.php @@ -62,7 +62,7 @@ abstract class Base_Model implements \JsonSerializable { * @since 2.0.0 * @var array */ - protected $meta_fields = array(); + protected $meta_fields = []; /** * Model creation date. @@ -86,7 +86,7 @@ abstract class Base_Model implements \JsonSerializable { * @since 2.0.0 * @var array */ - public $meta = array(); + public $meta = []; /** * The ID of the original 1.X model that was used to generate this item on migration. @@ -118,7 +118,7 @@ abstract class Base_Model implements \JsonSerializable { * @since 2.0.0 * @var array */ - protected $_mappings = array(); + protected $_mappings = []; /** * Mocked status. Used to suppress errors. @@ -165,7 +165,7 @@ abstract class Base_Model implements \JsonSerializable { * * @param mixed $slug The slug. */ - public function set_slug($slug) { + public function set_slug($slug): void { $this->slug = $slug; } @@ -179,7 +179,7 @@ abstract class Base_Model implements \JsonSerializable { */ public function get_hash($field = 'id') { - $value = call_user_func(array($this, "get_{$field}")); + $value = call_user_func([$this, "get_{$field}"]); if ( ! is_numeric($value)) { _doing_it_wrong(__METHOD__, __('You can only use numeric fields to generate hashes.', 'wp-ultimo'), '2.0.0'); @@ -232,13 +232,13 @@ abstract class Base_Model implements \JsonSerializable { } if (method_exists($this, "set_$key")) { - call_user_func(array($this, "set_$key"), $value); + call_user_func([$this, "set_$key"], $value); } $mapping = wu_get_isset($this->_mappings, $key); if ($mapping && method_exists($this, "set_$mapping")) { - call_user_func(array($this, "set_$mapping"), $value); + call_user_func([$this, "set_$mapping"], $value); } } @@ -376,7 +376,7 @@ abstract class Base_Model implements \JsonSerializable { * @param array $query Arguments for the query. * @return array|int List of items, or number of items when 'count' is passed as a query var. */ - public static function get_items_as_array($query = array()) { + public static function get_items_as_array($query = []) { $instance = new static(); @@ -406,12 +406,12 @@ abstract class Base_Model implements \JsonSerializable { public function has_running_jobs() { $jobs = wu_get_scheduled_actions( - array( + [ 'status' => \ActionScheduler_Store::STATUS_RUNNING, - 'args' => array( + 'args' => [ "{$this->model}_id" => $this->get_id(), - ), - ) + ], + ] ); return $jobs; @@ -424,7 +424,7 @@ abstract class Base_Model implements \JsonSerializable { * @param integer $id ID of the object. * @return void */ - private function set_id($id) { + private function set_id($id): void { $this->id = $id; } @@ -441,7 +441,7 @@ abstract class Base_Model implements \JsonSerializable { */ public function validation_rules() { - return array(); + return []; } /** @@ -492,7 +492,7 @@ abstract class Base_Model implements \JsonSerializable { $data_unserialized = $data; - $meta = wu_get_isset($data, 'meta', array()); + $meta = wu_get_isset($data, 'meta', []); $new = ! $this->exists(); @@ -507,10 +507,10 @@ abstract class Base_Model implements \JsonSerializable { */ $meta = apply_filters("wu_{$this->model}_meta_pre_save", $meta, $data_unserialized, $this); - $blocked_attributes = array( + $blocked_attributes = [ 'query_class', 'meta', - ); + ]; foreach ($blocked_attributes as $attribute) { unset($data[ $attribute ]); @@ -805,7 +805,7 @@ abstract class Base_Model implements \JsonSerializable { * @param array $args Query arguments. * @return array|int List of items, or number of items when 'count' is passed as a query var. */ - public static function query($args = array()) { + public static function query($args = []) { $instance = new static(); @@ -835,7 +835,7 @@ abstract class Base_Model implements \JsonSerializable { unset($array['_mocked']); foreach ($array as $key => $value) { - if (strncmp('_', $key, strlen($key)) === 0) { + if (str_starts_with('_', $key)) { unset($array[ $key ]); } } @@ -864,7 +864,7 @@ abstract class Base_Model implements \JsonSerializable { */ protected static function to_instances($data) { - return array_map(array(get_called_class(), 'to_instance'), $data); + return array_map([static::class, 'to_instance'], $data); } /** @@ -931,7 +931,7 @@ abstract class Base_Model implements \JsonSerializable { * @param string $date_created Model creation date. * @return void */ - public function set_date_created($date_created) { + public function set_date_created($date_created): void { $this->date_created = $date_created; } @@ -943,7 +943,7 @@ abstract class Base_Model implements \JsonSerializable { * @param string $date_modified Model last modification date. * @return void */ - public function set_date_modified($date_modified) { + public function set_date_modified($date_modified): void { $this->date_modified = $date_modified; } @@ -966,7 +966,7 @@ abstract class Base_Model implements \JsonSerializable { * @param int $migrated_from_id The ID of the original 1.X model that was used to generate this item on migration. * @return void */ - public function set_migrated_from_id($migrated_from_id) { + public function set_migrated_from_id($migrated_from_id): void { $this->migrated_from_id = absint($migrated_from_id); } @@ -1034,7 +1034,7 @@ abstract class Base_Model implements \JsonSerializable { * @param array $query_args If you need to select a type to get all. * @return array With all items requested. */ - public static function get_all($query_args = array()) { + public static function get_all($query_args = []) { $instance = new static(); @@ -1072,7 +1072,7 @@ abstract class Base_Model implements \JsonSerializable { * @since 2.0.0 * @return void */ - public function hydrate() { + public function hydrate(): void { $attributes = get_object_vars($this); $attributes = array_filter($attributes, fn ($value) => $value === null); @@ -1080,10 +1080,10 @@ abstract class Base_Model implements \JsonSerializable { unset($attributes['meta']); foreach ($attributes as $attribute => $maybe_null) { - $possible_setters = array( + $possible_setters = [ "get_{$attribute}", "is_{$attribute}", - ); + ]; foreach ($possible_setters as $setter) { $setter = method_exists($this, $setter) ? $setter : ''; @@ -1106,7 +1106,7 @@ abstract class Base_Model implements \JsonSerializable { * @param boolean $skip_validation Set true to have field information validation bypassed when saving this event. * @return void */ - public function set_skip_validation($skip_validation = false) { + public function set_skip_validation($skip_validation = false): void { $this->skip_validation = $skip_validation; } diff --git a/inc/models/class-broadcast.php b/inc/models/class-broadcast.php index b84e22c..d3844ce 100644 --- a/inc/models/class-broadcast.php +++ b/inc/models/class-broadcast.php @@ -35,7 +35,7 @@ class Broadcast extends Post_Base_Model { * @access public * @var mixed */ - protected $query_class = '\\WP_Ultimo\\Database\\Broadcasts\\Broadcast_Query'; + protected $query_class = \WP_Ultimo\Database\Broadcasts\Broadcast_Query::class; /** * Post type. @@ -51,7 +51,7 @@ class Broadcast extends Post_Base_Model { * @since 2.0.0 * @var array */ - protected $allowed_types = array('broadcast_email', 'broadcast_notice'); + protected $allowed_types = ['broadcast_email', 'broadcast_notice']; /** * Set the allowed status to prevent saving wrong status. @@ -59,7 +59,7 @@ class Broadcast extends Post_Base_Model { * @since 2.0.0 * @var array */ - protected $allowed_status = array('publish', 'draft'); + protected $allowed_status = ['publish', 'draft']; /** * Broadcast status. @@ -107,14 +107,14 @@ class Broadcast extends Post_Base_Model { */ public function validation_rules() { - return array( + return [ 'notice_type' => 'in:info,success,warning,error', 'status' => 'default:publish', 'name' => 'default:title', 'title' => 'required|min:2', 'content' => 'required|min:3', 'type' => 'required|in:broadcast_email,broadcast_notice|default:broadcast_notice', - ); + ]; } /** @@ -139,7 +139,7 @@ class Broadcast extends Post_Base_Model { * @param int $migrated_from_id The ID of the original 1.X model that was used to generate this item on migration. * @return void */ - public function set_migrated_from_id($migrated_from_id) { + public function set_migrated_from_id($migrated_from_id): void { $this->meta['migrated_from_id'] = $migrated_from_id; @@ -202,7 +202,7 @@ class Broadcast extends Post_Base_Model { * @param string $message_targets The targets for this broadcast. * @return void */ - public function set_message_targets($message_targets) { + public function set_message_targets($message_targets): void { $this->meta['message_targets'] = $message_targets; } @@ -216,7 +216,7 @@ class Broadcast extends Post_Base_Model { * @options info,success,warning,error * @return void */ - public function set_notice_type($notice_type) { + public function set_notice_type($notice_type): void { $this->meta['notice_type'] = $notice_type; @@ -231,7 +231,7 @@ class Broadcast extends Post_Base_Model { * @param string $name This broadcast name, which is used as broadcast title as well. * @return void */ - public function set_name($name) { + public function set_name($name): void { $this->set_title($name); } diff --git a/inc/models/class-checkout-form.php b/inc/models/class-checkout-form.php index b4a6498..040e4bf 100644 --- a/inc/models/class-checkout-form.php +++ b/inc/models/class-checkout-form.php @@ -104,7 +104,7 @@ class Checkout_Form extends Base_Model { * @since 2.0.0 * @var string */ - protected $query_class = '\\WP_Ultimo\\Database\\Checkout_Forms\\Checkout_Form_Query'; + protected $query_class = \WP_Ultimo\Database\Checkout_Forms\Checkout_Form_Query::class; /** * The steps to show to user in checkout form. @@ -128,7 +128,7 @@ class Checkout_Form extends Base_Model { $id = $this->get_id(); - return array( + return [ 'name' => 'required', 'slug' => "required|unique:\WP_Ultimo\Models\Checkout_Form,slug,{$id}|min:3", 'active' => 'required|default:1', @@ -138,7 +138,7 @@ class Checkout_Form extends Base_Model { 'thank_you_page_id' => 'integer', 'conversion_snippets' => 'nullable|default:', 'template' => 'in:blank,single-step,multi-step', - ); + ]; } /** @@ -160,7 +160,7 @@ class Checkout_Form extends Base_Model { * @param string $slug The checkout form slug. It needs to be unique and preferably make it clear what it is about. E.g. my_checkout_form. * @return void */ - public function set_slug($slug) { + public function set_slug($slug): void { $this->slug = $slug; } @@ -183,7 +183,7 @@ class Checkout_Form extends Base_Model { * @param string $name Your checkout form name, which is used as checkout form title as well. * @return void */ - public function set_name($name) { + public function set_name($name): void { $this->name = $name; } @@ -206,7 +206,7 @@ class Checkout_Form extends Base_Model { * @param boolean $active Set this checkout form as active (true), which means available to be used, or inactive (false). * @return void */ - public function set_active($active) { + public function set_active($active): void { $this->active = (bool) $active; } @@ -229,7 +229,7 @@ class Checkout_Form extends Base_Model { * @param string $custom_css Custom CSS code for the checkout form. * @return void */ - public function set_custom_css($custom_css) { + public function set_custom_css($custom_css): void { $this->custom_css = $custom_css; } @@ -243,7 +243,7 @@ class Checkout_Form extends Base_Model { public function get_settings() { if (empty($this->settings)) { - return array(); + return []; } if (is_string($this->settings)) { @@ -260,7 +260,7 @@ class Checkout_Form extends Base_Model { * @param object $settings The checkout form settings and configurations. * @return void */ - public function set_settings($settings) { + public function set_settings($settings): void { if (is_string($settings)) { // @phpstan-ignore-line @@ -294,10 +294,10 @@ class Checkout_Form extends Base_Model { if ($step) { $step = wp_parse_args( $step, - array( + [ 'logged' => 'always', - 'fields' => array(), - ) + 'fields' => [], + ] ); } @@ -319,19 +319,19 @@ class Checkout_Form extends Base_Model { $user_exists = is_user_logged_in(); - $final_steps = array(); + $final_steps = []; - $non_data_fields = array( + $non_data_fields = [ 'submit_button', 'period_selection', 'steps', - ); + ]; - $hidden_fields = array( + $hidden_fields = [ 'hidden', - ); + ]; - $final_data_fields = array(); + $final_data_fields = []; foreach ($steps as $key => $step) { $logged = wu_get_isset($step, 'logged', 'always'); @@ -402,13 +402,13 @@ class Checkout_Form extends Base_Model { $settings = $this->get_settings(); if ( ! is_array($settings)) { - return array(); + return []; } $fields = array_column($settings, 'fields'); if (empty($fields)) { - return array(); + return []; } return call_user_func_array('array_merge', $fields); @@ -430,11 +430,11 @@ class Checkout_Form extends Base_Model { return Array_Search::find( $all_fields, - array( - 'where' => array( - array('type', $types), - ), - ) + [ + 'where' => [ + ['type', $types], + ], + ] ); } @@ -450,16 +450,16 @@ class Checkout_Form extends Base_Model { $all_fields = $this->get_all_fields(); - $types = apply_filters('wu_checkout_form_meta_fields_list', array('text', 'select', 'color', 'color_picker', 'textarea', 'checkbox'), $this); + $types = apply_filters('wu_checkout_form_meta_fields_list', ['text', 'select', 'color', 'color_picker', 'textarea', 'checkbox'], $this); return Array_Search::find( $all_fields, - array( - 'where' => array( - array('type', $types), - array('save_as', $meta_type), - ), - ) + [ + 'where' => [ + ['type', $types], + ['save_as', $meta_type], + ], + ] ); } @@ -506,9 +506,9 @@ class Checkout_Form extends Base_Model { * @param string $template The type of the template. * @return void */ - public function use_template($template = 'single-step') { + public function use_template($template = 'single-step'): void { - $fields = array(); + $fields = []; if ($template === 'multi-step') { $fields = $this->get_multi_step_template(); @@ -529,22 +529,22 @@ class Checkout_Form extends Base_Model { */ private function get_single_step_template() { - $steps = array( - array( + $steps = [ + [ 'id' => 'checkout', 'name' => __('Checkout', 'wp-ultimo'), 'desc' => '', - 'fields' => array( - array( + 'fields' => [ + [ 'step' => 'checkout', 'name' => __('Plans', 'wp-ultimo'), 'type' => 'pricing_table', 'id' => 'pricing_table', 'required' => true, - 'pricing_table_products' => implode(',', wu_get_plans(array('fields' => 'ids'))), + 'pricing_table_products' => implode(',', wu_get_plans(['fields' => 'ids'])), 'pricing_table_template' => 'list', - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Email', 'wp-ultimo'), 'type' => 'email', @@ -552,8 +552,8 @@ class Checkout_Form extends Base_Model { 'required' => true, 'placeholder' => '', 'tooltip' => '', - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Username', 'wp-ultimo'), 'type' => 'username', @@ -562,8 +562,8 @@ class Checkout_Form extends Base_Model { 'placeholder' => '', 'tooltip' => '', 'auto_generate' => false, - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Password', 'wp-ultimo'), 'type' => 'password', @@ -573,8 +573,8 @@ class Checkout_Form extends Base_Model { 'tooltip' => '', 'password_strength_meter' => '1', 'password_confirm_field' => '1', - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Site Title', 'wp-ultimo'), 'type' => 'site_title', @@ -583,8 +583,8 @@ class Checkout_Form extends Base_Model { 'placeholder' => '', 'tooltip' => '', 'auto_generate' => false, - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Site URL', 'wp-ultimo'), 'type' => 'site_url', @@ -594,38 +594,38 @@ class Checkout_Form extends Base_Model { 'required' => true, 'auto_generate' => false, 'display_url_preview' => true, - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Your Order', 'wp-ultimo'), 'type' => 'order_summary', 'id' => 'order_summary', 'order_summary_template' => 'clean', 'table_columns' => 'simple', - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Payment Method', 'wp-ultimo'), 'type' => 'payment', 'id' => 'payment', - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Billing Address', 'wp-ultimo'), 'type' => 'billing_address', 'id' => 'billing_address', 'required' => true, 'zip_and_country' => '1', - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Checkout', 'wp-ultimo'), 'type' => 'submit_button', 'id' => 'checkout', - ), - ), - ), - ); + ], + ], + ], + ]; return apply_filters('wu_checkout_form_single_step_template', $steps); } @@ -638,35 +638,35 @@ class Checkout_Form extends Base_Model { */ private function get_multi_step_template() { - $steps = array( - array( + $steps = [ + [ 'id' => 'checkout', 'name' => __('Checkout', 'wp-ultimo'), 'desc' => '', - 'fields' => array( - array( + 'fields' => [ + [ 'step' => 'checkout', 'name' => 'Plans', 'type' => 'pricing_table', 'id' => 'pricing_table', 'required' => true, - 'pricing_table_products' => implode(',', wu_get_plans(array('fields' => 'ids'))), + 'pricing_table_products' => implode(',', wu_get_plans(['fields' => 'ids'])), 'pricing_table_template' => 'list', - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Next Step', 'wp-ultimo'), 'type' => 'submit_button', 'id' => 'next_step', - ), - ), - ), - array( + ], + ], + ], + [ 'id' => 'site', 'name' => __('Site Info', 'wp-ultimo'), 'desc' => '', - 'fields' => array( - array( + 'fields' => [ + [ 'step' => 'checkout', 'name' => __('Site Title', 'wp-ultimo'), 'type' => 'site_title', @@ -675,8 +675,8 @@ class Checkout_Form extends Base_Model { 'placeholder' => '', 'tooltip' => '', 'auto_generate' => false, - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Site URL', 'wp-ultimo'), 'type' => 'site_url', @@ -686,22 +686,22 @@ class Checkout_Form extends Base_Model { 'tooltip' => '', 'auto_generate' => false, 'display_url_preview' => true, - ), - array( + ], + [ 'step' => 'site', 'name' => __('Next Step', 'wp-ultimo'), 'type' => 'submit_button', 'id' => 'next_step_site', - ), - ), - ), - array( + ], + ], + ], + [ 'id' => 'user', 'name' => __('User Info', 'wp-ultimo'), 'logged' => 'guests_only', 'desc' => '', - 'fields' => array( - array( + 'fields' => [ + [ 'step' => 'checkout', 'name' => __('Email', 'wp-ultimo'), 'type' => 'email', @@ -709,8 +709,8 @@ class Checkout_Form extends Base_Model { 'required' => true, 'placeholder' => '', 'tooltip' => '', - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Username', 'wp-ultimo'), 'type' => 'username', @@ -719,8 +719,8 @@ class Checkout_Form extends Base_Model { 'placeholder' => '', 'tooltip' => '', 'auto_generate' => false, - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Password', 'wp-ultimo'), 'type' => 'password', @@ -730,51 +730,51 @@ class Checkout_Form extends Base_Model { 'tooltip' => '', 'password_strength_meter' => '1', 'password_confirm_field' => '1', - ), - array( + ], + [ 'step' => 'user', 'name' => __('Next Step', 'wp-ultimo'), 'type' => 'submit_button', 'id' => 'next_step_user', - ), - ), - ), - array( + ], + ], + ], + [ 'id' => 'payment', 'name' => __('Payment', 'wp-ultimo'), 'desc' => '', - 'fields' => array( - array( + 'fields' => [ + [ 'step' => 'checkout', 'name' => __('Your Order', 'wp-ultimo'), 'type' => 'order_summary', 'id' => 'order_summary', 'order_summary_template' => 'clean', 'table_columns' => 'simple', - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Payment Method', 'wp-ultimo'), 'type' => 'payment', 'id' => 'payment', - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Billing Address', 'wp-ultimo'), 'type' => 'billing_address', 'id' => 'billing_address', 'required' => true, 'zip_and_country' => '1', - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Checkout', 'wp-ultimo'), 'type' => 'submit_button', 'id' => 'checkout', - ), - ), - ), - ); + ], + ], + ], + ]; return apply_filters('wu_checkout_form_multi_step_template', $steps); } @@ -788,20 +788,20 @@ class Checkout_Form extends Base_Model { * @param array $old_settings The old settings. * @return array */ - public static function convert_steps_to_v2($steps, $old_settings = array()) { + public static function convert_steps_to_v2($steps, $old_settings = []) { - $exclude_steps = array( + $exclude_steps = [ 'begin-signup', 'create-account', - ); + ]; - $old_template_list = wu_get_isset($old_settings, 'templates', array()); + $old_template_list = wu_get_isset($old_settings, 'templates', []); if (empty($old_template_list)) { $exclude_steps[] = 'template'; } - $new_format = array(); + $new_format = []; foreach ($steps as $step_id => $step) { if (in_array($step_id, $exclude_steps, true)) { @@ -813,33 +813,33 @@ class Checkout_Form extends Base_Model { */ if ($step_id === 'plan') { $products_list = wu_get_plans( - array( + [ 'fields' => 'ids', - ) + ] ); /* * Calculate the period selector */ - $available_periods = array(); + $available_periods = []; - $period_options = array( - 'enable_price_1' => array( + $period_options = [ + 'enable_price_1' => [ 'duration' => '1', 'duration_unit' => 'month', 'label' => __('Monthly', 'wp-ultimo'), - ), - 'enable_price_3' => array( + ], + 'enable_price_3' => [ 'duration' => '3', 'duration_unit' => 'month', 'label' => __('Quarterly', 'wp-ultimo'), - ), - 'enable_price_12' => array( + ], + 'enable_price_12' => [ 'duration' => '1', 'duration_unit' => 'year', 'label' => __('Yearly', 'wp-ultimo'), - ), - ); + ], + ]; foreach ($period_options as $period_option_key => $period_option) { $has_period_option = wu_get_isset($old_settings, $period_option_key, true); @@ -849,52 +849,52 @@ class Checkout_Form extends Base_Model { } } - $step['fields'] = array(); + $step['fields'] = []; if ($available_periods && count($available_periods) > 1) { - $step['fields']['period_selection'] = array( + $step['fields']['period_selection'] = [ 'type' => 'period_selection', 'id' => 'period_selection', 'period_selection_template' => 'legacy', 'period_options_header' => '', 'period_options' => $available_periods, - ); + ]; } - $step['fields']['pricing_table'] = array( + $step['fields']['pricing_table'] = [ 'name' => __('Pricing Tables', 'wp-ultimo'), 'id' => 'pricing_table', 'type' => 'pricing_table', 'pricing_table_template' => 'legacy', 'pricing_table_products' => implode(',', $products_list), - ); + ]; } /** * Deal with special cases. */ if ($step_id === 'template' && wu_get_isset($old_settings, 'allow_template', true)) { - $templates = array(); + $templates = []; foreach (wu_get_site_templates() as $site) { $templates[] = $site->get_id(); } - $old_template_list = is_array($old_template_list) ? $old_template_list : array(); + $old_template_list = is_array($old_template_list) ? $old_template_list : []; $template_list = array_flip($old_template_list); $template_list = ! empty($template_list) ? $template_list : $templates; - $step['fields'] = array( - 'template_selection' => array( + $step['fields'] = [ + 'template_selection' => [ 'name' => __('Template Selection', 'wp-ultimo'), 'id' => 'template_selection', 'type' => 'template_selection', 'template_selection_template' => 'legacy', 'template_selection_sites' => implode(',', $template_list), - ), - ); + ], + ]; } /** @@ -904,15 +904,15 @@ class Checkout_Form extends Base_Model { unset($step['view']); unset($step['hidden']); - $new_fields = array(); + $new_fields = []; $step['id'] = $step_id; - $fields_to_skip = array( + $fields_to_skip = [ 'user_pass_conf', 'url_preview', 'site_url', // Despite the name, this is the Honeypot field. - ); + ]; foreach ($step['fields'] as $field_id => $field) { if (in_array($field_id, $fields_to_skip, true)) { @@ -958,7 +958,7 @@ class Checkout_Form extends Base_Model { $field['required'] = true; $field['display_field_attachments'] = false; $field['enable_domain_selection'] = wu_get_isset($old_settings, 'enable_multiple_domains', false); - $field['available_domains'] = wu_get_isset($old_settings, 'domain_options', array()); + $field['available_domains'] = wu_get_isset($old_settings, 'domain_options', []); break; case 'submit': @@ -985,42 +985,42 @@ class Checkout_Form extends Base_Model { /** * Add Checkout step */ - $new_format[] = array( + $new_format[] = [ 'id' => 'payment', 'name' => __('Checkout', 'wp-ultimo'), - 'fields' => array( - array( + 'fields' => [ + [ 'name' => __('Order Summary', 'wp-ultimo'), 'type' => 'order_summary', 'id' => 'order_summary', 'order_summary_template' => 'clean', 'table_columns' => 'simple', - ), - array( + ], + [ 'name' => __('Billing Address', 'wp-ultimo'), 'type' => 'billing_address', 'id' => 'billing_address', 'zip_and_country' => true, - ), - array( + ], + [ 'type' => 'discount_code', 'id' => 'discount_code', 'name' => __('Coupon Code', 'wp-ultimo'), 'tooltip' => __('Coupon Code', 'wp-ultimo'), 'display_checkbox' => true, - ), - array( + ], + [ 'name' => __('Payment Methods', 'wp-ultimo'), 'type' => 'payment', 'id' => 'payment', - ), - array( + ], + [ 'type' => 'submit_button', 'id' => 'submit_button', 'name' => __('Pay & Create Account', 'wp-ultimo'), - ), - ), - ); + ], + ], + ]; return $new_format; } @@ -1058,7 +1058,7 @@ class Checkout_Form extends Base_Model { * @param string $allowed_countries The allowed countries that can access this checkout. * @return void */ - public function set_allowed_countries($allowed_countries) { + public function set_allowed_countries($allowed_countries): void { $this->allowed_countries = $allowed_countries; } @@ -1098,7 +1098,7 @@ class Checkout_Form extends Base_Model { * @param int $thank_you_page_id The thank you page ID. This page is shown after a successful purchase. * @return void */ - public function set_thank_you_page_id($thank_you_page_id) { + public function set_thank_you_page_id($thank_you_page_id): void { $this->meta['wu_thank_you_page_id'] = $thank_you_page_id; @@ -1127,7 +1127,7 @@ class Checkout_Form extends Base_Model { * @param string $conversion_snippets Snippets to run on thank you page. * @return void */ - public function set_conversion_snippets($conversion_snippets) { + public function set_conversion_snippets($conversion_snippets): void { $this->meta['wu_conversion_snippets'] = $conversion_snippets; @@ -1146,10 +1146,10 @@ class Checkout_Form extends Base_Model { */ public function save() { - $step_types = array( + $step_types = [ 'multi-step', 'single-step', - ); + ]; if ($this->template && in_array($this->template, $step_types, true)) { $this->use_template($this->template); @@ -1177,7 +1177,7 @@ class Checkout_Form extends Base_Model { * @options blank,single-step,multi-step * @return void */ - public function set_template($template) { + public function set_template($template): void { $this->template = $template; } @@ -1201,41 +1201,41 @@ class Checkout_Form extends Base_Model { } if ( ! $payment) { - return array(); + return []; } - $fields = array( - array( + $fields = [ + [ 'step' => 'checkout', 'name' => __('Your Order', 'wp-ultimo'), 'type' => 'order_summary', 'id' => 'order_summary', 'order_summary_template' => 'clean', 'table_columns' => 'simple', - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Payment Method', 'wp-ultimo'), 'type' => 'payment', 'id' => 'payment', - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Finish Payment', 'wp-ultimo'), 'type' => 'submit_button', 'id' => 'checkout', 'order' => 0, - ), - ); + ], + ]; - $steps = array( - array( + $steps = [ + [ 'id' => 'checkout', 'name' => __('Checkout', 'wp-ultimo'), 'desc' => '', 'fields' => $fields, - ), - ); + ], + ]; return apply_filters('wu_checkout_form_finish_checkout_form_fields', $steps); } @@ -1259,10 +1259,10 @@ class Checkout_Form extends Base_Model { } if ( ! $membership) { - return array(); + return []; } - $fields = array(); + $fields = []; /* * Adds the addons @@ -1276,9 +1276,9 @@ class Checkout_Form extends Base_Model { */ $group = $plan->get_group(); - $search_arguments = array( + $search_arguments = [ 'fields' => 'ids', - ); + ]; if ($group) { $search_arguments['product_group'] = $group; @@ -1294,7 +1294,7 @@ class Checkout_Form extends Base_Model { $products = array_map('wu_get_product', $plans); - $period_selection = array(); + $period_selection = []; $should_use_period_selector = false; @@ -1312,11 +1312,11 @@ class Checkout_Form extends Base_Model { wu_get_translatable_string($product->get_duration() <= 1 ? $product->get_duration_unit() : $product->get_duration_unit() . 's') ); - $period_selection[ $days_in_cycle ] = array( + $period_selection[ $days_in_cycle ] = [ 'duration' => $product->get_duration(), 'duration_unit' => $product->get_duration_unit(), 'label' => $label, - ); + ]; $variations = $product->get_price_variations(); @@ -1343,28 +1343,28 @@ class Checkout_Form extends Base_Model { wu_get_translatable_string($variation['duration'] <= 1 ? $variation['duration_unit'] : $variation['duration_unit'] . 's') ); - $period_selection[ $days_in_cycle ] = array( + $period_selection[ $days_in_cycle ] = [ 'duration' => $variation['duration'], 'duration_unit' => $variation['duration_unit'], 'label' => $label, - ); + ]; } } ksort($period_selection); if ($should_use_period_selector) { - $fields[] = array( + $fields[] = [ 'step' => 'checkout', 'name' => '', 'type' => 'period_selection', 'id' => 'period_selection', 'period_selection_template' => 'clean', 'period_options' => array_values($period_selection), - ); + ]; } - $fields[] = array( + $fields[] = [ 'step' => 'checkout', 'name' => __('Plans', 'wp-ultimo'), 'type' => 'pricing_table', @@ -1373,7 +1373,7 @@ class Checkout_Form extends Base_Model { 'pricing_table_products' => implode(',', $plans), 'pricing_table_template' => 'list', 'force_different_durations' => (int) ! $should_use_period_selector, - ); + ]; $available_addons = (array) $plan->get_available_addons(); @@ -1388,50 +1388,50 @@ class Checkout_Form extends Base_Model { continue; } - $fields[] = array( + $fields[] = [ 'id' => "order_bump_{$addon_id}", 'type' => 'order_bump', 'name' => $addon->get_name(), 'product' => $addon_id, 'display_product_image' => true, - ); + ]; } } - $end_fields = array( - array( + $end_fields = [ + [ 'step' => 'checkout', 'name' => __('Your Order', 'wp-ultimo'), 'type' => 'order_summary', 'id' => 'order_summary', 'order_summary_template' => 'clean', 'table_columns' => 'simple', - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Payment Method', 'wp-ultimo'), 'type' => 'payment', 'id' => 'payment', - ), - array( + ], + [ 'step' => 'checkout', 'name' => __('Complete Checkout', 'wp-ultimo'), 'type' => 'submit_button', 'id' => 'checkout', 'order' => 0, - ), - ); + ], + ]; $fields = array_merge($fields, $end_fields); - $steps = array( - array( + $steps = [ + [ 'id' => 'checkout', 'name' => __('Checkout', 'wp-ultimo'), 'desc' => '', 'fields' => $fields, - ), - ); + ], + ]; return apply_filters('wu_checkout_form_membership_change_form_fields', $steps); } @@ -1447,7 +1447,7 @@ class Checkout_Form extends Base_Model { $membership = WP_Ultimo()->currents->get_membership(); if ( ! $membership) { - return array(); + return []; } /* @@ -1456,12 +1456,12 @@ class Checkout_Form extends Base_Model { */ $plan = $membership->get_plan(); - $steps = array(); + $steps = []; // As this limit is not membership based, we need to exclude from verification here if ($membership->get_limitations(true, true)->site_templates->is_enabled()) { - $template_selection_fields = array( - array( + $template_selection_fields = [ + [ 'step' => 'template', 'name' => __('Template Selection', 'wp-ultimo'), 'type' => 'template_selection', @@ -1469,62 +1469,62 @@ class Checkout_Form extends Base_Model { 'cols' => 4, 'template_selection_template' => 'clean', 'order' => 0, - ), - array( + ], + [ 'step' => 'template', 'type' => 'hidden', 'id' => 'create-new-site', 'fixed_value' => wp_create_nonce('create-new-site'), - ), - ); + ], + ]; - $steps[] = array( + $steps[] = [ 'id' => 'template', 'name' => __('Template Selection', 'wp-ultimo'), 'desc' => '', 'fields' => $template_selection_fields, - ); + ]; } - $final_fields = array( - array( + $final_fields = [ + [ 'step' => 'create', 'type' => 'products', 'id' => 'products', 'products' => $plan->get_id(), - ), - array( + ], + [ 'step' => 'create', 'type' => 'hidden', 'id' => 'membership_id', 'fixed_value' => $membership->get_id(), - ), - array( + ], + [ 'step' => 'create', 'type' => 'hidden', 'id' => 'create-new-site', 'fixed_value' => wp_create_nonce('create-new-site'), - ), - array( + ], + [ 'step' => 'create', 'type' => 'hidden', 'id' => 'redirect_url', 'fixed_value' => wu_request('redirect_url'), - ), - ); + ], + ]; - $final_fields[] = array( + $final_fields[] = [ 'step' => 'create', 'id' => 'site_title', 'name' => __('Site Title', 'wp-ultimo'), 'tooltip' => '', 'placeholder' => '', 'type' => 'site_title', - ); + ]; $domain_options = wu_get_available_domain_options(); - $final_fields[] = array( + $final_fields[] = [ 'step' => 'create', 'id' => 'site_url', 'name' => __('Site URL', 'wp-ultimo'), @@ -1534,23 +1534,23 @@ class Checkout_Form extends Base_Model { 'type' => 'site_url', 'enable_domain_selection' => ! empty($domain_options), 'available_domains' => implode(PHP_EOL, $domain_options), - ); + ]; - $final_fields[] = array( + $final_fields[] = [ 'step' => 'create', 'name' => __('Create Site', 'wp-ultimo'), 'type' => 'submit_button', 'id' => 'checkout', 'order' => 0, - ); + ]; - $steps[] = array( + $steps[] = [ 'id' => 'create', 'name' => __('Create Site', 'wp-ultimo'), 'desc' => '', 'classes' => 'wu-max-w-sm', 'fields' => $final_fields, - ); + ]; return apply_filters('wu_checkout_form_add_new_site_form_fields', $steps); } diff --git a/inc/models/class-customer.php b/inc/models/class-customer.php index 24452e3..63d6b8b 100644 --- a/inc/models/class-customer.php +++ b/inc/models/class-customer.php @@ -119,7 +119,7 @@ class Customer extends Base_Model { * @since 2.0.0 * @var string */ - protected $query_class = '\\WP_Ultimo\\Database\\Customers\\Customer_Query'; + protected $query_class = \WP_Ultimo\Database\Customers\Customer_Query::class; /** * Allows injection, which is useful for mocking. @@ -153,7 +153,7 @@ class Customer extends Base_Model { $id = $this->get_id(); - return array( + return [ 'user_id' => "required|integer|unique:\WP_Ultimo\Models\Customer,user_id,{$id}", 'email_verification' => 'required|in:none,pending,verified', 'type' => 'required|in:customer', @@ -163,7 +163,7 @@ class Customer extends Base_Model { 'ips' => 'array', 'extra_information' => 'default:', 'signup_form' => 'default:', - ); + ]; } /** @@ -184,7 +184,7 @@ class Customer extends Base_Model { * @param int $user_id The WordPress user ID attached to this customer. * @return void */ - public function set_user_id($user_id) { + public function set_user_id($user_id): void { $this->user_id = $user_id; } @@ -229,11 +229,11 @@ class Customer extends Base_Model { public function get_default_billing_address() { return new \WP_Ultimo\Objects\Billing_Address( - array( + [ 'company_name' => $this->get_display_name(), 'billing_email' => $this->get_email_address(), 'billing_country' => $this->get_meta('ip_country'), - ) + ] ); } @@ -309,7 +309,7 @@ class Customer extends Base_Model { * @param string $date_registered Date when the customer was created. * @return void */ - public function set_date_registered($date_registered) { + public function set_date_registered($date_registered): void { $this->date_registered = $date_registered; } @@ -332,7 +332,7 @@ class Customer extends Base_Model { * @param string $email_verification Email verification status - either `none`, `pending`, or `verified`. * @return void */ - public function set_email_verification($email_verification) { + public function set_email_verification($email_verification): void { $this->email_verification = $email_verification; } @@ -356,7 +356,7 @@ class Customer extends Base_Model { * @param string $last_login Date this customer last logged in. * @return void */ - public function set_last_login($last_login) { + public function set_last_login($last_login): void { $this->last_login = $last_login; } @@ -377,12 +377,12 @@ class Customer extends Base_Model { if ( ! $this->has_trialed) { $trial = wu_get_memberships( - array( + [ 'customer_id' => $this->get_id(), - 'date_trial_end__not_in' => array(null, '0000-00-00 00:00:00'), + 'date_trial_end__not_in' => [null, '0000-00-00 00:00:00'], 'fields' => 'ids', 'number' => 1, - ) + ] ); if ( ! empty($trial)) { @@ -402,7 +402,7 @@ class Customer extends Base_Model { * @param bool $has_trialed Whether or not the customer has trialed before. * @return void */ - public function set_has_trialed($has_trialed) { + public function set_has_trialed($has_trialed): void { $this->meta['wu_has_trialed'] = $has_trialed; @@ -427,7 +427,7 @@ class Customer extends Base_Model { * @param bool $vip If this customer is a VIP customer or not. * @return void */ - public function set_vip($vip) { + public function set_vip($vip): void { $this->vip = $vip; } @@ -441,7 +441,7 @@ class Customer extends Base_Model { public function get_ips() { if (empty($this->ips)) { - return array(); + return []; } if (is_string($this->ips)) { @@ -471,7 +471,7 @@ class Customer extends Base_Model { * @param array $ips List of IP addresses used by this customer. * @return void */ - public function set_ips($ips) { + public function set_ips($ips): void { if (is_string($ips)) { $ips = maybe_unserialize(wp_unslash($ips)); @@ -488,12 +488,12 @@ class Customer extends Base_Model { * @param string $ip New IP address to add. * @return void */ - public function add_ip($ip) { + public function add_ip($ip): void { $ips = $this->get_ips(); if ( ! is_array($ips)) { - $ips = array(); + $ips = []; } /* @@ -520,9 +520,9 @@ class Customer extends Base_Model { public function update_last_login($update_ip = true, $update_country_and_state = false) { $this->attributes( - array( + [ 'last_login' => wu_get_current_time('mysql', true), - ) + ] ); $geolocation = $update_ip || $update_country_and_state ? \WP_Ultimo\Geolocation::geolocate_ip('', true) : false; @@ -563,7 +563,7 @@ class Customer extends Base_Model { * @param array $extra_information Any extra information related to this customer. * @return void */ - public function set_extra_information($extra_information) { + public function set_extra_information($extra_information): void { $extra_information = array_filter((array) $extra_information); @@ -580,9 +580,9 @@ class Customer extends Base_Model { public function get_memberships() { return Membership::query( - array( + [ 'customer_id' => $this->get_id(), - ) + ] ); } @@ -593,18 +593,18 @@ class Customer extends Base_Model { * @param array $query_args Query arguments. * @return array */ - public function get_sites($query_args = array()) { + public function get_sites($query_args = []) { $query_args = array_merge( $query_args, - array( - 'meta_query' => array( - 'customer_id' => array( + [ + 'meta_query' => [ + 'customer_id' => [ 'key' => 'wu_customer_id', 'value' => $this->get_id(), - ), - ), - ) + ], + ], + ] ); return Site::query($query_args); @@ -618,7 +618,7 @@ class Customer extends Base_Model { */ public function get_pending_sites() { - $pending_sites = array(); + $pending_sites = []; $memberships = $this->get_memberships(); @@ -666,9 +666,9 @@ class Customer extends Base_Model { public function get_payments() { return Payment::query( - array( + [ 'customer_id' => $this->get_id(), - ) + ] ); } @@ -696,10 +696,10 @@ class Customer extends Base_Model { 40, 'identicon', '', - array( + [ 'force_display' => true, 'class' => 'wu-rounded-full wu-mr-3', - ) + ] ); $search_result = array_merge((array) $user->data, $search_result); @@ -730,7 +730,7 @@ class Customer extends Base_Model { * @options customer * @return void */ - public function set_type($type) { + public function set_type($type): void { $this->type = $type; } @@ -832,10 +832,10 @@ class Customer extends Base_Model { } return add_query_arg( - array( + [ 'email-verification-key' => $key, 'customer' => $this->get_hash(), - ), + ], get_site_url(wu_get_main_site_id()) ); } @@ -846,12 +846,12 @@ class Customer extends Base_Model { * @since 2.0.4 * @return void */ - public function send_verification_email() { + public function send_verification_email(): void { $this->generate_verification_key(); $payload = array_merge( - array('verification_link' => $this->get_verification_url()), + ['verification_link' => $this->get_verification_url()], wu_generate_event_payload('customer', $this) ); @@ -876,7 +876,7 @@ class Customer extends Base_Model { * @param string $signup_form The form used to signup. * @return void */ - public function set_signup_form($signup_form) { + public function set_signup_form($signup_form): void { $this->signup_form = $signup_form; } diff --git a/inc/models/class-discount-code.php b/inc/models/class-discount-code.php index 7103459..f984fb1 100644 --- a/inc/models/class-discount-code.php +++ b/inc/models/class-discount-code.php @@ -157,7 +157,7 @@ class Discount_Code extends Base_Model { * @since 2.0.0 * @var string */ - protected $query_class = '\\WP_Ultimo\\Database\\Discount_Codes\\Discount_Code_Query'; + protected $query_class = \WP_Ultimo\Database\Discount_Codes\Discount_Code_Query::class; /** * Set the validation rules for this particular model. @@ -171,7 +171,7 @@ class Discount_Code extends Base_Model { */ public function validation_rules() { - return array( + return [ 'name' => 'required|min:2', 'code' => 'required|min:2|max:20|alpha_dash', 'uses' => 'integer|default:0', @@ -184,7 +184,7 @@ class Discount_Code extends Base_Model { 'setup_fee_value' => 'numeric', 'allowed_products' => 'array', 'limit_products' => 'default:0', - ); + ]; } /** @@ -205,7 +205,7 @@ class Discount_Code extends Base_Model { * @param string $name Your discount code name, which is used as discount code title as well. * @return void */ - public function set_name($name) { + public function set_name($name): void { $this->name = $name; } @@ -228,7 +228,7 @@ class Discount_Code extends Base_Model { * @param string $code A unique identification to redeem the discount code. E.g. PROMO10. * @return void */ - public function set_code($code) { + public function set_code($code): void { $this->code = $code; } @@ -251,7 +251,7 @@ class Discount_Code extends Base_Model { * @param string $description A description for the discount code, usually a short text. * @return void */ - public function set_description($description) { + public function set_description($description): void { $this->description = $description; } @@ -274,7 +274,7 @@ class Discount_Code extends Base_Model { * @param int $uses Number of times this discount was applied. * @return void */ - public function set_uses($uses) { + public function set_uses($uses): void { $this->uses = (int) $uses; } @@ -286,7 +286,7 @@ class Discount_Code extends Base_Model { * @param integer $uses Number of uses to add. * @return void */ - public function add_use($uses = 1) { + public function add_use($uses = 1): void { $use_count = (int) $this->get_uses(); @@ -311,7 +311,7 @@ class Discount_Code extends Base_Model { * @param int $max_uses The number of times this discount can be used before becoming inactive. * @return void */ - public function set_max_uses($max_uses) { + public function set_max_uses($max_uses): void { $this->max_uses = (int) $max_uses; } @@ -345,7 +345,7 @@ class Discount_Code extends Base_Model { * @param bool $apply_to_renewals Wether or not we should apply the discount to membership renewals. * @return void */ - public function set_apply_to_renewals($apply_to_renewals) { + public function set_apply_to_renewals($apply_to_renewals): void { $this->apply_to_renewals = (bool) $apply_to_renewals; } @@ -369,7 +369,7 @@ class Discount_Code extends Base_Model { * @options percentage,absolute * @return void */ - public function set_type($type) { + public function set_type($type): void { $this->type = $type; } @@ -392,7 +392,7 @@ class Discount_Code extends Base_Model { * @param int $value Amount discounted in cents. * @return void */ - public function set_value($value) { + public function set_value($value): void { $this->value = $value; } @@ -416,7 +416,7 @@ class Discount_Code extends Base_Model { * @options percentage,absolute * @return void */ - public function set_setup_fee_type($setup_fee_type) { + public function set_setup_fee_type($setup_fee_type): void { $this->setup_fee_type = $setup_fee_type; } @@ -439,7 +439,7 @@ class Discount_Code extends Base_Model { * @param int $setup_fee_value Amount discounted for setup fees in cents. * @return void */ - public function set_setup_fee_value($setup_fee_value) { + public function set_setup_fee_value($setup_fee_value): void { $this->setup_fee_value = $setup_fee_value; } @@ -540,7 +540,7 @@ class Discount_Code extends Base_Model { * @param bool $active Set this discount code as active (true), which means available to be used, or inactive (false). * @return void */ - public function set_active($active) { + public function set_active($active): void { $this->active = (bool) $active; } @@ -567,7 +567,7 @@ class Discount_Code extends Base_Model { * @param string $date_start Start date for the coupon code to be considered valid. * @return void */ - public function set_date_start($date_start) { + public function set_date_start($date_start): void { $this->date_start = $date_start; } @@ -594,7 +594,7 @@ class Discount_Code extends Base_Model { * @param string $date_expiration Expiration date for the coupon code. * @return void */ - public function set_date_expiration($date_expiration) { + public function set_date_expiration($date_expiration): void { $this->date_expiration = $date_expiration; } @@ -617,7 +617,7 @@ class Discount_Code extends Base_Model { * @param string $date_created Date when this discount code was created. * @return void */ - public function set_date_created($date_created) { + public function set_date_created($date_created): void { $this->date_created = $date_created; } @@ -628,7 +628,7 @@ class Discount_Code extends Base_Model { */ public function get_discount_description(): string { - $description = array(); + $description = []; if ($this->get_value() > 0) { $value = wu_format_currency($this->get_value()); @@ -694,7 +694,7 @@ class Discount_Code extends Base_Model { $compat_coupon = $this; - do_action_deprecated('wp_ultimo_coupon_after_save', array($compat_coupon), '2.0.0', 'wu_discount_code_post_save'); + do_action_deprecated('wp_ultimo_coupon_after_save', [$compat_coupon], '2.0.0', 'wu_discount_code_post_save'); } return $results; @@ -709,7 +709,7 @@ class Discount_Code extends Base_Model { public function get_allowed_products() { if ($this->allowed_products === null) { - $this->allowed_products = $this->get_meta('wu_allowed_products', array()); + $this->allowed_products = $this->get_meta('wu_allowed_products', []); } return (array) $this->allowed_products; @@ -722,7 +722,7 @@ class Discount_Code extends Base_Model { * @param array $allowed_products The list of products that allows this discount code to be used. If empty, all products will accept this code. * @return void */ - public function set_allowed_products($allowed_products) { + public function set_allowed_products($allowed_products): void { $this->meta['wu_allowed_products'] = (array) $allowed_products; @@ -751,7 +751,7 @@ class Discount_Code extends Base_Model { * @param bool $limit_products This discount code will be limited to be used in certain products? If set to true, you must define a list of allowed products. * @return void */ - public function set_limit_products($limit_products) { + public function set_limit_products($limit_products): void { $this->meta['wu_limit_products'] = (bool) $limit_products; diff --git a/inc/models/class-domain.php b/inc/models/class-domain.php index 8f40cff..7b20a54 100644 --- a/inc/models/class-domain.php +++ b/inc/models/class-domain.php @@ -90,11 +90,11 @@ class Domain extends Base_Model { * @since 2.0.0 * @var array */ - const INACTIVE_STAGES = array( + const INACTIVE_STAGES = [ 'checking-dns', 'checking-ssl-cert', 'failed', - ); + ]; /** * Query Class to the static query methods. @@ -102,7 +102,7 @@ class Domain extends Base_Model { * @since 2.0.0 * @var string */ - protected $query_class = '\\WP_Ultimo\\Database\\Domains\\Domain_Query'; + protected $query_class = \WP_Ultimo\Database\Domains\Domain_Query::class; /** * Set the validation rules for this particular model. @@ -118,14 +118,14 @@ class Domain extends Base_Model { $id = $this->get_id(); - return array( + return [ 'blog_id' => 'required|integer', 'domain' => "required|domain|unique:\WP_Ultimo\Models\Domain,domain,{$id}", 'stage' => 'required|in:checking-dns,checking-ssl-cert,done-without-ssl,done,failed|default:checking-dns', 'active' => 'default:1', 'secure' => 'default:0', 'primary_domain' => 'default:0', - ); + ]; } /** @@ -147,7 +147,7 @@ class Domain extends Base_Model { * @param string $domain Your Domain name. You don't need to put http or https in front of your domain in this field. e.g: example.com. * @return void */ - public function set_domain($domain) { + public function set_domain($domain): void { $this->domain = strtolower($domain); } @@ -185,7 +185,7 @@ class Domain extends Base_Model { * @param int $blog_id The blog ID attached to this domain. * @return void */ - public function set_blog_id($blog_id) { + public function set_blog_id($blog_id): void { $this->blog_id = $blog_id; } @@ -245,7 +245,7 @@ class Domain extends Base_Model { * @param boolean $active Set this domain as active (true), which means available to be used, or inactive (false). * @return void */ - public function set_active($active) { + public function set_active($active): void { $this->active = $active; } @@ -269,7 +269,7 @@ class Domain extends Base_Model { * @param boolean $primary_domain Define true to set this as primary domain of a site, meaning it's the main url, or set false. * @return void */ - public function set_primary_domain($primary_domain) { + public function set_primary_domain($primary_domain): void { $this->primary_domain = $primary_domain; } @@ -293,7 +293,7 @@ class Domain extends Base_Model { * @param boolean $secure If this domain has some SSL security or not. * @return void */ - public function set_secure($secure) { + public function set_secure($secure): void { $this->secure = $secure; } @@ -319,7 +319,7 @@ class Domain extends Base_Model { * @param string $stage The state of the domain model object. Can be one of this options: checking-dns, checking-ssl-cert, done-without-ssl, done and failed. * @return void */ - public function set_stage($stage) { + public function set_stage($stage): void { $this->stage = $stage; } @@ -377,7 +377,7 @@ class Domain extends Base_Model { * @param string $date_created Date when the domain was created. If no date is set, the current date and time will be used. * @return void */ - public function set_date_created($date_created) { + public function set_date_created($date_created): void { $this->date_created = $date_created; } @@ -456,9 +456,9 @@ class Domain extends Base_Model { if (is_wp_error($results) === false) { if ($new_domain) { if (has_action('mercator.mapping.created')) { - $deprecated_args = array( + $deprecated_args = [ $this, - ); + ]; /** * Deprecated: Mercator created domain. @@ -471,10 +471,10 @@ class Domain extends Base_Model { do_action_deprecated('mercator.mapping.created', $deprecated_args, '2.0.0', 'wu_domain_post_save'); } } elseif (has_action('mercator.mapping.updated')) { - $deprecated_args = array( + $deprecated_args = [ $this, $before_changes, - ); + ]; /** * Deprecated: Mercator updated domain. @@ -509,9 +509,9 @@ class Domain extends Base_Model { $results = parent::delete(); if (is_wp_error($results) === false && has_action('mercator.mapping.deleted')) { - $deprecated_args = array( + $deprecated_args = [ $this, - ); + ]; /** * Deprecated: Mercator Deleted domain. diff --git a/inc/models/class-email.php b/inc/models/class-email.php index 4d01f14..959b0a1 100644 --- a/inc/models/class-email.php +++ b/inc/models/class-email.php @@ -36,7 +36,7 @@ class Email extends Post_Base_Model { * @access public * @var mixed */ - protected $query_class = '\\WP_Ultimo\\Database\\Emails\\Email_Query'; + protected $query_class = \WP_Ultimo\Database\Emails\Email_Query::class; /** * Post type. @@ -52,7 +52,7 @@ class Email extends Post_Base_Model { * @since 2.0.0 * @var array */ - protected $allowed_types = array('system_email'); + protected $allowed_types = ['system_email']; /** * Email slug. @@ -68,7 +68,7 @@ class Email extends Post_Base_Model { * @since 2.0.0 * @var string */ - protected $allowed_status = array('publish', 'draft'); + protected $allowed_status = ['publish', 'draft']; /** * If this email is going to be send later. @@ -142,7 +142,7 @@ class Email extends Post_Base_Model { */ public function validation_rules() { - return array( + return [ 'schedule' => 'boolean|default:0', 'type' => 'in:system_email|default:system_email', 'event' => 'required|default:', @@ -159,7 +159,7 @@ class Email extends Post_Base_Model { 'send_copy_to_admin' => 'boolean|default:0', 'active' => 'default:1', 'legacy' => 'boolean|default:0', - ); + ]; } /** @@ -233,7 +233,7 @@ class Email extends Post_Base_Model { * @options html,plain-text * @return void */ - public function set_style($style) { + public function set_style($style): void { $this->style = $style; @@ -262,7 +262,7 @@ class Email extends Post_Base_Model { * @param bool $schedule Whether or not this is a scheduled email. * @return void */ - public function set_schedule($schedule) { + public function set_schedule($schedule): void { $this->schedule = $schedule; @@ -398,7 +398,7 @@ class Email extends Post_Base_Model { * @param string $event The event that needs to be fired for this email to be sent. * @return void */ - public function set_event($event) { + public function set_event($event): void { $this->event = $event; @@ -413,7 +413,7 @@ class Email extends Post_Base_Model { * @param string $email_schedule if the send will be schedule. * @return void */ - public function set_email_schedule($email_schedule) { + public function set_email_schedule($email_schedule): void { $this->meta['system_email_schedule'] = $email_schedule; } @@ -426,7 +426,7 @@ class Email extends Post_Base_Model { * @param string $send_hours The amount of hours that the email will wait before is sent. * @return void */ - public function set_send_hours($send_hours) { + public function set_send_hours($send_hours): void { $this->meta['system_email_send_hours'] = $send_hours; } @@ -439,7 +439,7 @@ class Email extends Post_Base_Model { * @param string $send_days The amount of days that the email will wait before is sent. * @return void */ - public function set_send_days($send_days) { + public function set_send_days($send_days): void { $this->meta['system_email_send_days'] = $send_days; } @@ -453,7 +453,7 @@ class Email extends Post_Base_Model { * @options days,hours * @return void */ - public function set_schedule_type($schedule_type) { + public function set_schedule_type($schedule_type): void { $this->meta['system_email_schedule_type'] = $schedule_type; } @@ -466,7 +466,7 @@ class Email extends Post_Base_Model { * @param string $name The name being set as title. * @return void */ - public function set_name($name) { + public function set_name($name): void { $this->set_title($name); } @@ -479,7 +479,7 @@ class Email extends Post_Base_Model { * @param string $slug The slug being set. * @return void */ - public function set_slug($slug) { + public function set_slug($slug): void { $this->slug = $slug; } @@ -492,7 +492,7 @@ class Email extends Post_Base_Model { * @param boolean $custom_sender If has a custom sender. * @return void */ - public function set_custom_sender($custom_sender) { + public function set_custom_sender($custom_sender): void { $this->meta['system_email_custom_sender'] = $custom_sender; } @@ -505,7 +505,7 @@ class Email extends Post_Base_Model { * @param string $custom_sender_name The name of the custom sender. E.g. From: John Doe. * @return void */ - public function set_custom_sender_name($custom_sender_name) { + public function set_custom_sender_name($custom_sender_name): void { $this->meta['system_email_custom_sender_name'] = $custom_sender_name; } @@ -518,7 +518,7 @@ class Email extends Post_Base_Model { * @param string $custom_sender_email The email of the custom sender. E.g. From: johndoe@gmail.com. * @return void */ - public function set_custom_sender_email($custom_sender_email) { + public function set_custom_sender_email($custom_sender_email): void { $this->meta['system_email_custom_sender_email'] = $custom_sender_email; } @@ -546,7 +546,7 @@ class Email extends Post_Base_Model { * @options customer,admin * @return void */ - public function set_target($target) { + public function set_target($target): void { $this->target = $target; @@ -561,9 +561,9 @@ class Email extends Post_Base_Model { * @param array $payload The payload of the email being sent. Used to get the customer id. * @return array */ - public function get_target_list($payload = array()) { + public function get_target_list($payload = []) { - $target_list = array(); + $target_list = []; $target_type = $this->get_target(); @@ -571,19 +571,19 @@ class Email extends Post_Base_Model { $target_list = self::get_super_admin_targets(); } elseif ($target_type === 'customer') { if ( ! wu_get_isset($payload, 'customer_id')) { - return array(); + return []; } $customer = wu_get_customer($payload['customer_id']); if ( ! $customer) { - return array(); + return []; } - $target_list[] = array( + $target_list[] = [ 'name' => $customer->get_display_name(), 'email' => $customer->get_email_address(), - ); + ]; /* * Maybe ad super admins as well. @@ -606,7 +606,7 @@ class Email extends Post_Base_Model { */ public static function get_super_admin_targets() { - $target_list = array(); + $target_list = []; $super_admins = get_super_admins(); @@ -614,10 +614,10 @@ class Email extends Post_Base_Model { $user = get_user_by('login', $super_admin); if ($user) { - $target_list[] = array( + $target_list[] = [ 'name' => $user->display_name, 'email' => $user->user_email, - ); + ]; } } @@ -646,7 +646,7 @@ class Email extends Post_Base_Model { * @param boolean $send_copy_to_admin Checks if we should send a copy of the email to the admin. * @return void */ - public function set_send_copy_to_admin($send_copy_to_admin) { + public function set_send_copy_to_admin($send_copy_to_admin): void { $this->send_copy_to_admin = $send_copy_to_admin; @@ -675,7 +675,7 @@ class Email extends Post_Base_Model { * @param bool $active Set this email as active (true), which means available will fire when the event occur, or inactive (false). * @return void */ - public function set_active($active) { + public function set_active($active): void { $this->active = $active; @@ -704,7 +704,7 @@ class Email extends Post_Base_Model { * @param bool $legacy Whether or not this is a legacy email. * @return void */ - public function set_legacy($legacy) { + public function set_legacy($legacy): void { $this->legacy = $legacy; diff --git a/inc/models/class-event.php b/inc/models/class-event.php index e8a8f7f..97f7ed0 100644 --- a/inc/models/class-event.php +++ b/inc/models/class-event.php @@ -107,7 +107,7 @@ class Event extends Base_Model { * @since 2.0.0 * @var string */ - protected $query_class = '\\WP_Ultimo\\Database\\Events\\Event_Query'; + protected $query_class = \WP_Ultimo\Database\Events\Event_Query::class; /** * Set the validation rules for this particular model. @@ -121,7 +121,7 @@ class Event extends Base_Model { */ public function validation_rules() { - return array( + return [ 'severity' => 'required|numeric|between:1,5', 'payload' => 'required', 'object_type' => 'required|alpha_dash|lowercase', @@ -129,7 +129,7 @@ class Event extends Base_Model { 'author_id' => 'integer|default:0', 'slug' => 'required|alpha_dash', 'initiator' => 'required|in:system,manual', - ); + ]; } /** @@ -151,15 +151,15 @@ class Event extends Base_Model { */ public function get_severity_label() { - $labels = array( + $labels = [ self::SEVERITY_SUCCESS => __('Success', 'wp-ultimo'), self::SEVERITY_NEUTRAL => __('Neutral', 'wp-ultimo'), self::SEVERITY_INFO => __('Info', 'wp-ultimo'), self::SEVERITY_WARNING => __('Warning', 'wp-ultimo'), self::SEVERITY_FATAL => __('Fatal', 'wp-ultimo'), - ); + ]; - return isset($labels[ $this->get_severity() ]) ? $labels[ $this->get_severity() ] : __('Note', 'wp-ultimo'); + return $labels[ $this->get_severity() ] ?? __('Note', 'wp-ultimo'); } /** @@ -170,15 +170,15 @@ class Event extends Base_Model { */ public function get_severity_class() { - $classes = array( + $classes = [ self::SEVERITY_SUCCESS => 'wu-bg-green-200 wu-text-green-700', self::SEVERITY_NEUTRAL => 'wu-bg-gray-200 wu-text-gray-700', self::SEVERITY_INFO => 'wu-bg-blue-200 wu-text-blue-700', self::SEVERITY_WARNING => 'wu-bg-yellow-200 wu-text-yellow-700', self::SEVERITY_FATAL => 'wu-bg-red-200 wu-text-red-700', - ); + ]; - return isset($classes[ $this->get_severity() ]) ? $classes[ $this->get_severity() ] : ''; + return $classes[ $this->get_severity() ] ?? ''; } /** @@ -188,7 +188,7 @@ class Event extends Base_Model { * @param int $severity Severity of the problem. * @return void */ - public function set_severity($severity) { + public function set_severity($severity): void { $this->severity = $severity; } @@ -211,7 +211,7 @@ class Event extends Base_Model { * @param string $date_created Date when the event was created. * @return void */ - public function set_date_created($date_created) { + public function set_date_created($date_created): void { $this->date_created = $date_created; } @@ -236,7 +236,7 @@ class Event extends Base_Model { * @param object $payload Payload of the event. * @return void */ - public function set_payload($payload) { + public function set_payload($payload): void { $this->payload = $payload; } @@ -265,7 +265,7 @@ class Event extends Base_Model { $payload = json_decode(json_encode($payload), true); - $interpolation_keys = array(); + $interpolation_keys = []; foreach ($payload as $key => &$value) { $interpolation_keys[] = "{{{$key}}}"; @@ -296,7 +296,7 @@ class Event extends Base_Model { */ public static function get_default_system_messages($slug) { - $default_messages = array(); + $default_messages = []; $default_messages['changed'] = __('The {{model}} #{{object_id}} was changed: {{payload}}', 'wp-ultimo'); $default_messages['created'] = __('The {{model}} #{{object_id}} was created.', 'wp-ultimo'); @@ -326,7 +326,7 @@ class Event extends Base_Model { * @param string $initiator The type of user responsible for initiating the event. There are two options: Manual and System. By default, the event is saved as manual. * @return void */ - public function set_initiator($initiator) { + public function set_initiator($initiator): void { $this->initiator = $initiator; } @@ -396,7 +396,7 @@ class Event extends Base_Model { * @param int $author_id The user responsible for creating the event. By default, the event is saved with the current user_id. * @return void */ - public function set_author_id($author_id) { + public function set_author_id($author_id): void { $this->author_id = $author_id; } @@ -518,7 +518,7 @@ class Event extends Base_Model { * @param string $object_type The type of object related to this event. It's usually the model name. * @return void */ - public function set_object_type($object_type) { + public function set_object_type($object_type): void { $this->object_type = $object_type; } @@ -541,7 +541,7 @@ class Event extends Base_Model { * @param string $slug The event slug. It needs to be unique and preferably make it clear what it is about. Example: account_created is about creating an account. * @return void */ - public function set_slug($slug) { + public function set_slug($slug): void { $this->slug = $slug; } @@ -564,7 +564,7 @@ class Event extends Base_Model { * @param int $object_id The ID of the related objects. * @return void */ - public function set_object_id($object_id) { + public function set_object_id($object_id): void { $this->object_id = $object_id; } @@ -587,7 +587,7 @@ class Event extends Base_Model { $array['severity_classes'] = $this->get_severity_class(); - $array['author'] = array(); + $array['author'] = []; if ($this->get_initiator() === 'manual') { $user = get_user_by('ID', $this->get_author_id()); @@ -600,9 +600,9 @@ class Event extends Base_Model { $array['author']['avatar'] = get_avatar_url( $this->get_author_id(), - array( + [ 'default' => 'identicon', - ) + ] ); } } diff --git a/inc/models/class-membership.php b/inc/models/class-membership.php index 95193d6..65e7e49 100644 --- a/inc/models/class-membership.php +++ b/inc/models/class-membership.php @@ -60,7 +60,7 @@ class Membership extends Base_Model { * @since 2.0.0 * @var array */ - protected $addon_products = array(); + protected $addon_products = []; /** * Currency for this membership. 3-letter currency code. @@ -290,7 +290,7 @@ class Membership extends Base_Model { * @since 2.0.10 * @var array */ - protected $_compiled_product_list = array(); + protected $_compiled_product_list = []; /** * Keep original gateway info. @@ -302,7 +302,7 @@ class Membership extends Base_Model { * @since 2.0.15 * @var array */ - protected $_gateway_info = array(); + protected $_gateway_info = []; /** * Query Class to the static query methods. @@ -310,7 +310,7 @@ class Membership extends Base_Model { * @since 2.0.0 * @var string */ - protected $query_class = '\\WP_Ultimo\\Database\\Memberships\\Membership_Query'; + protected $query_class = \WP_Ultimo\Database\Memberships\Membership_Query::class; /** * Constructs the object via the constructor arguments @@ -323,11 +323,11 @@ class Membership extends Base_Model { parent::__construct($object); - $this->_gateway_info = array( + $this->_gateway_info = [ 'gateway' => $this->get_gateway(), 'gateway_customer_id' => $this->get_gateway_customer_id(), 'gateway_subscription_id' => $this->get_gateway_subscription_id(), - ); + ]; if (did_action('plugins_loaded')) { $this->_compiled_product_list = $this->get_all_products(); @@ -352,7 +352,7 @@ class Membership extends Base_Model { $membership_status = $membership_status->get_allowed_list(true); - return array( + return [ 'customer_id' => 'required|integer|exists:\WP_Ultimo\Models\Customer,id', 'user_id' => 'integer', 'plan_id' => 'required|integer|exists:\WP_Ultimo\Models\Product,id', @@ -371,7 +371,7 @@ class Membership extends Base_Model { 'signup_method' => 'default:', 'disabled' => 'default:0', 'recurring' => 'default:0', - ); + ]; } /** @@ -404,7 +404,7 @@ class Membership extends Base_Model { * @param int $customer_id The ID of the customer attached to this membership. * @return void */ - public function set_customer_id($customer_id) { + public function set_customer_id($customer_id): void { $this->customer_id = absint($customer_id); } @@ -452,7 +452,7 @@ class Membership extends Base_Model { * @param int $user_id The user ID attached to this membership. * @return void */ - public function set_user_id($user_id) { + public function set_user_id($user_id): void { $this->user_id = absint($user_id); } @@ -482,7 +482,7 @@ class Membership extends Base_Model { if ($plan && ($plan->get_duration() !== $this->get_duration() || $plan->get_duration_unit() !== $this->get_duration_unit())) { $variation = $plan->get_as_variation($this->get_duration(), $this->get_duration_unit()); - $plan = ($variation ? $variation : null) ?? $plan; + $plan = ($variation ?: null) ?? $plan; } return $plan; @@ -495,7 +495,7 @@ class Membership extends Base_Model { * @param int $plan_id The plan ID associated with the membership. * @return void */ - public function set_plan_id($plan_id) { + public function set_plan_id($plan_id): void { $this->plan_id = absint($plan_id); } @@ -553,7 +553,7 @@ class Membership extends Base_Model { * @param integer $quantity The quantity. * @return void */ - public function add_product($product_id, $quantity = 1) { + public function add_product($product_id, $quantity = 1): void { $has_product = wu_get_isset($this->addon_products, $product_id); @@ -577,7 +577,7 @@ class Membership extends Base_Model { * @param integer $quantity The quantity to remove. * @return void */ - public function remove_product($product_id, $quantity = 1) { + public function remove_product($product_id, $quantity = 1): void { $has_product = wu_get_isset($this->addon_products, $product_id); @@ -598,9 +598,9 @@ class Membership extends Base_Model { */ public function get_addon_products() { - $products = array(); + $products = []; - $this->addon_products = is_array($this->addon_products) ? $this->addon_products : array(); + $this->addon_products = is_array($this->addon_products) ? $this->addon_products : []; foreach ($this->addon_products as $product_id => $quantity) { $product = wu_get_product($product_id); @@ -609,10 +609,10 @@ class Membership extends Base_Model { continue; } - $products[] = array( + $products[] = [ 'quantity' => $quantity, 'product' => $product, - ); + ]; } return $products; @@ -626,12 +626,12 @@ class Membership extends Base_Model { */ public function get_all_products() { - $products = array( - array( + $products = [ + [ 'quantity' => 1, 'product' => $this->get_plan(), - ), - ); + ], + ]; return array_merge($products, $this->get_addon_products()); } @@ -643,7 +643,7 @@ class Membership extends Base_Model { * @param mixed $addon_products Additional products related to this membership. Services, Packages or other types of products. * @return void */ - public function set_addon_products($addon_products) { + public function set_addon_products($addon_products): void { $this->addon_products = maybe_unserialize($addon_products); } @@ -673,7 +673,7 @@ class Membership extends Base_Model { } // clear the current addons. - $this->addon_products = array(); + $this->addon_products = []; /* * We'll do that based on the line items, @@ -761,9 +761,9 @@ class Membership extends Base_Model { */ wu_unschedule_action( 'wu_async_membership_swap', - array( + [ 'membership_id' => $this->get_id(), - ), + ], 'membership' ); @@ -773,9 +773,9 @@ class Membership extends Base_Model { return wu_schedule_single_action( $date_instance->format('U'), 'wu_async_membership_swap', - array( + [ 'membership_id' => $this->get_id(), - ), + ], 'membership' ); } @@ -798,10 +798,10 @@ class Membership extends Base_Model { return false; } - return (object) array( + return (object) [ 'order' => $order, 'scheduled_date' => $scheduled_date, - ); + ]; } /** @@ -810,7 +810,7 @@ class Membership extends Base_Model { * @since 2.0.0 * @return void */ - public function delete_scheduled_swap() { + public function delete_scheduled_swap(): void { $this->delete_meta('wu_swap_order'); @@ -861,7 +861,7 @@ class Membership extends Base_Model { */ public function get_price_description(): string { - $pricing = array(); + $pricing = []; if ($this->is_recurring()) { $duration = $this->get_duration(); @@ -919,7 +919,7 @@ class Membership extends Base_Model { * @param string $currency The currency that this membership. It's a 3-letter code. E.g. 'USD'. * @return void */ - public function set_currency($currency) { + public function set_currency($currency): void { $this->currency = $currency; } @@ -939,7 +939,7 @@ class Membership extends Base_Model { * * @param int $duration The interval period between a charge. Only the interval amount, the unit will be defined in another property. */ - public function set_duration($duration) { + public function set_duration($duration): void { $this->duration = absint($duration); } @@ -959,7 +959,7 @@ class Membership extends Base_Model { * * @param string $duration_unit The duration amount type. Can be 'day', 'week', 'month' or 'year'. */ - public function set_duration_unit($duration_unit) { + public function set_duration_unit($duration_unit): void { $this->duration_unit = $duration_unit; } @@ -1000,7 +1000,7 @@ class Membership extends Base_Model { * * @param float $amount The product amount. */ - public function set_amount($amount) { + public function set_amount($amount): void { $this->amount = wu_to_float($amount); } @@ -1020,7 +1020,7 @@ class Membership extends Base_Model { * * @param float $initial_amount The initial amount charged for this membership, including the setup fee. */ - public function set_initial_amount($initial_amount) { + public function set_initial_amount($initial_amount): void { $this->initial_amount = wu_to_float($initial_amount); } @@ -1043,7 +1043,7 @@ class Membership extends Base_Model { * @param string $date_created Date of creation of this membership. * @return void */ - public function set_date_created($date_created) { + public function set_date_created($date_created): void { $this->date_created = $date_created; } @@ -1066,7 +1066,7 @@ class Membership extends Base_Model { * @param string $date_activated Date when this membership was activated. * @return void */ - public function set_date_activated($date_activated) { + public function set_date_activated($date_activated): void { $this->date_activated = $date_activated; } @@ -1089,7 +1089,7 @@ class Membership extends Base_Model { * @param string $date_trial_end Date when the trial period ends, if this membership has or had a trial period. * @return void */ - public function set_date_trial_end($date_trial_end) { + public function set_date_trial_end($date_trial_end): void { $this->date_trial_end = $date_trial_end; } @@ -1112,7 +1112,7 @@ class Membership extends Base_Model { * @param string $date_renewed Date when the membership was cancelled. * @return void */ - public function set_date_renewed($date_renewed) { + public function set_date_renewed($date_renewed): void { $this->date_renewed = $date_renewed; } @@ -1135,7 +1135,7 @@ class Membership extends Base_Model { * @param string $date_cancellation Date when the membership was cancelled. * @return void */ - public function set_date_cancellation($date_cancellation) { + public function set_date_cancellation($date_cancellation): void { $this->date_cancellation = $date_cancellation; } @@ -1166,7 +1166,7 @@ class Membership extends Base_Model { * @param string $reason The reason to cancel the membership. * @return void */ - public function set_cancellation_reason($reason) { + public function set_cancellation_reason($reason): void { $this->meta['cancellation_reason'] = $reason; $this->cancellation_reason = $reason; @@ -1190,7 +1190,7 @@ class Membership extends Base_Model { * @param string $date_expiration Date when the membership will expiry. * @return void */ - public function set_date_expiration($date_expiration) { + public function set_date_expiration($date_expiration): void { $this->date_expiration = $date_expiration; } @@ -1233,7 +1233,7 @@ class Membership extends Base_Model { $expire_timestamp = strtotime('+' . $this->get_duration() . ' ' . $this->get_duration_unit() . ' 23:59:59', $base_timestamp); } - $extension_days = array('29', '30', '31'); + $extension_days = ['29', '30', '31']; if (in_array(gmdate('j', $expire_timestamp), $extension_days, true) && 'month' === $this->get_duration_unit()) { $month = gmdate('n', $expire_timestamp); @@ -1289,7 +1289,7 @@ class Membership extends Base_Model { * @param string $date_payment_plan_completed Change of the payment completion for the plan value. * @return void */ - public function set_date_payment_plan_completed($date_payment_plan_completed) { + public function set_date_payment_plan_completed($date_payment_plan_completed): void { $this->date_payment_plan_completed = $date_payment_plan_completed; } @@ -1325,7 +1325,7 @@ class Membership extends Base_Model { * @param bool $auto_renew If this membership should auto-renewal. * @return void */ - public function set_auto_renew($auto_renew) { + public function set_auto_renew($auto_renew): void { $this->auto_renew = (bool) $auto_renew; } @@ -1344,12 +1344,12 @@ class Membership extends Base_Model { // Get discount code from original payment for compatibility if (empty($this->discount_code) && ! $this->get_meta('verified_payment_discount')) { $original_payment = wu_get_payments( - array( + [ 'number' => 1, 'membership_id' => $this->get_id(), 'orderby' => 'id', 'order' => 'ASC', - ) + ] ); if (isset($original_payment[0])) { @@ -1375,7 +1375,7 @@ class Membership extends Base_Model { * @param string|WP_Ultimo\Models\Discount_Code $discount_code Discount code object. * @return void */ - public function set_discount_code($discount_code) { + public function set_discount_code($discount_code): void { if (is_a($discount_code, '\WP_Ultimo\Models\Discount_Code')) { $this->meta['discount_code'] = $discount_code; @@ -1412,7 +1412,7 @@ class Membership extends Base_Model { * @param int $times_billed Amount of times this membership got billed. * @return void */ - public function set_times_billed($times_billed) { + public function set_times_billed($times_billed): void { $this->times_billed = $times_billed; } @@ -1481,7 +1481,7 @@ class Membership extends Base_Model { * @param int $billing_cycles Maximum times we should charge this membership. * @return void */ - public function set_billing_cycles($billing_cycles) { + public function set_billing_cycles($billing_cycles): void { $this->billing_cycles = $billing_cycles; } @@ -1516,10 +1516,10 @@ class Membership extends Base_Model { */ public function is_active() { - $active_statuses = array( + $active_statuses = [ Membership_Status::ACTIVE, Membership_Status::ON_HOLD, - ); + ]; $active = in_array($this->status, $active_statuses, true); @@ -1545,7 +1545,7 @@ class Membership extends Base_Model { * @options \WP_Ultimo\Database\Payments\Payment_Status * @return void */ - public function set_status($status) { + public function set_status($status): void { $this->status = $status; } @@ -1594,7 +1594,7 @@ class Membership extends Base_Model { * @param string $gateway_customer_id The ID of the customer on the payment gateway database. * @return void */ - public function set_gateway_customer_id($gateway_customer_id) { + public function set_gateway_customer_id($gateway_customer_id): void { $this->gateway_customer_id = $gateway_customer_id; } @@ -1617,7 +1617,7 @@ class Membership extends Base_Model { * @param string $gateway_subscription_id The ID of the subscription on the payment gateway database. * @return void */ - public function set_gateway_subscription_id($gateway_subscription_id) { + public function set_gateway_subscription_id($gateway_subscription_id): void { $this->gateway_subscription_id = $gateway_subscription_id; } @@ -1640,7 +1640,7 @@ class Membership extends Base_Model { * @param string $gateway ID of the gateway being used on this subscription. * @return void */ - public function set_gateway($gateway) { + public function set_gateway($gateway): void { $this->gateway = $gateway; } @@ -1663,7 +1663,7 @@ class Membership extends Base_Model { * @param string $signup_method Signup method used to create this membership. * @return void */ - public function set_signup_method($signup_method) { + public function set_signup_method($signup_method): void { $this->signup_method = $signup_method; } @@ -1686,7 +1686,7 @@ class Membership extends Base_Model { * @param int $upgraded_from Plan that this membership upgraded from. * @return void */ - public function set_upgraded_from($upgraded_from) { + public function set_upgraded_from($upgraded_from): void { $this->upgraded_from = $upgraded_from; } @@ -1709,7 +1709,7 @@ class Membership extends Base_Model { * @param string $date_modified Date this membership was last modified. * @return void */ - public function set_date_modified($date_modified) { + public function set_date_modified($date_modified): void { $this->date_modified = $date_modified; } @@ -1732,7 +1732,7 @@ class Membership extends Base_Model { * @param bool $disabled If this membership is a disabled one. * @return void */ - public function set_disabled($disabled) { + public function set_disabled($disabled): void { $this->disabled = (bool) $disabled; } @@ -1744,13 +1744,13 @@ class Membership extends Base_Model { * @param array $query Query arguments. * @return array */ - public function get_payments($query = array()) { + public function get_payments($query = []) { $query = array_merge( $query, - array( + [ 'membership_id' => $this->get_id(), - ) + ] ); return wu_get_payments($query); @@ -1764,14 +1764,14 @@ class Membership extends Base_Model { public function get_last_pending_payment() { $payments = wu_get_payments( - array( + [ 'membership_id' => $this->get_id(), 'status' => 'pending', 'number' => 1, 'orderby' => 'id', 'order' => 'DESC', 'gateway_payment_id' => '', - ) + ] ); return ! empty($payments) ? array_pop($payments) : false; @@ -1786,14 +1786,14 @@ class Membership extends Base_Model { public function get_published_sites() { $sites = Site::query( - array( - 'meta_query' => array( - 'customer_id' => array( + [ + 'meta_query' => [ + 'customer_id' => [ 'key' => 'wu_membership_id', 'value' => $this->get_id(), - ), - ), - ) + ], + ], + ] ); return $sites; @@ -1809,14 +1809,14 @@ class Membership extends Base_Model { public function get_sites($include_pending = true) { $sites = Site::query( - array( - 'meta_query' => array( - 'customer_id' => array( + [ + 'meta_query' => [ + 'customer_id' => [ 'key' => 'wu_membership_id', 'value' => $this->get_id(), - ), - ), - ) + ], + ], + ] ); $pending_site = $include_pending ? $this->get_pending_site() : false; @@ -1844,13 +1844,13 @@ class Membership extends Base_Model { $site_info = wp_parse_args( $site_info, - array( + [ 'title' => '', 'domain' => $current_site->domain, 'path' => '', - 'transient' => array(), + 'transient' => [], 'is_publishing' => false, - ) + ] ); $site = new \WP_Ultimo\Models\Site($site_info); @@ -1887,7 +1887,7 @@ class Membership extends Base_Model { * @since 2.0.0 * @return void */ - public function publish_pending_site_async() { + public function publish_pending_site_async(): void { /* * If the force sync setting is on, fallback to the sync version. */ @@ -1899,11 +1899,11 @@ class Membership extends Base_Model { // We first try to generate the site through request to start earlier as possible. $rest_path = add_query_arg( - array( + [ 'action' => 'wu_publish_pending_site', '_ajax_nonce' => wp_create_nonce('wu_publish_pending_site'), 'membership_id' => $this->get_id(), - ), + ], admin_url('admin-ajax.php') ); @@ -1912,23 +1912,23 @@ class Membership extends Base_Model { wp_remote_request( $rest_path, - array( + [ 'sslverify' => false, - ) + ] ); } elseif (ignore_user_abort(true) !== ignore_user_abort(false)) { // We do not have fastcgi but can make the request continue without listening wp_remote_request( $rest_path, - array( + [ 'sslverify' => false, 'blocking' => false, - ) + ] ); } - wu_enqueue_async_action('wu_async_publish_pending_site', array('membership_id' => $this->get_id()), 'membership'); + wu_enqueue_async_action('wu_async_publish_pending_site', ['membership_id' => $this->get_id()], 'membership'); } /** @@ -2039,7 +2039,7 @@ class Membership extends Base_Model { * @param boolean $recurring If this membership is recurring (true), which means the customer paid a defined amount each period of time, or not recurring (false). * @return void */ - public function set_recurring($recurring) { + public function set_recurring($recurring): void { $this->recurring = (bool) $recurring; } @@ -2199,7 +2199,7 @@ class Membership extends Base_Model { * @param string $reason Reason for cancellation. * @return void */ - public function cancel($reason = '') { + public function cancel($reason = ''): void { if ($this->get_status() === Membership_Status::CANCELLED) { return; // Already cancelled @@ -2298,9 +2298,9 @@ class Membership extends Base_Model { */ public function limitations_to_merge() { - $limitations_to_merge = array(); + $limitations_to_merge = []; - $product_ids = array($this->get_plan_id()); + $product_ids = [$this->get_plan_id()]; $product_ids = array_merge($this->get_addon_ids(), $product_ids); @@ -2357,11 +2357,11 @@ class Membership extends Base_Model { $has_change = false; - $current_gateway = array( + $current_gateway = [ 'gateway' => $this->get_gateway(), 'gateway_customer_id' => $this->get_gateway_customer_id(), 'gateway_subscription_id' => $this->get_gateway_subscription_id(), - ); + ]; foreach ($this->_gateway_info as $key => $value) { if ($value !== $current_gateway[ $key ]) { @@ -2433,9 +2433,9 @@ class Membership extends Base_Model { if ($this->has_product_changes()) { wu_enqueue_async_action( 'wu_async_after_membership_update_products', - array( + [ 'membership_id' => $this->get_id(), - ), + ], 'membership' ); } diff --git a/inc/models/class-payment.php b/inc/models/class-payment.php index af12888..2a10db1 100644 --- a/inc/models/class-payment.php +++ b/inc/models/class-payment.php @@ -172,7 +172,7 @@ class Payment extends Base_Model { * @since 2.0.0 * @var string */ - protected $query_class = '\\WP_Ultimo\\Database\\Payments\\Payment_Query'; + protected $query_class = \WP_Ultimo\Database\Payments\Payment_Query::class; /** * Adds magic methods to return formatted values automatically. @@ -188,7 +188,7 @@ class Payment extends Base_Model { $method_key = str_replace('_formatted', '', $name); - if (strpos($name, '_formatted') !== false && method_exists($this, $method_key)) { + if (str_contains($name, '_formatted') && method_exists($this, $method_key)) { return wu_format_currency($this->{"$method_key"}(), $this->get_currency()); } @@ -213,7 +213,7 @@ class Payment extends Base_Model { $payment_types = $payment_types->get_allowed_list(true); - return array( + return [ 'customer_id' => 'required|integer|exists:\WP_Ultimo\Models\Customer,id', 'membership_id' => 'required|integer|exists:\WP_Ultimo\Models\Membership,id', 'parent_id' => 'integer|default:', @@ -229,7 +229,7 @@ class Payment extends Base_Model { 'discount_total' => 'integer', 'invoice_number' => 'default:', 'cancel_membership_on_refund' => 'boolean|default:0', - ); + ]; } /** @@ -262,7 +262,7 @@ class Payment extends Base_Model { * @param int $customer_id The ID of the customer attached to this payment. * @return void */ - public function set_customer_id($customer_id) { + public function set_customer_id($customer_id): void { $this->customer_id = absint($customer_id); } @@ -296,7 +296,7 @@ class Payment extends Base_Model { * @param int $membership_id The ID of the membership attached to this payment. * @return void */ - public function set_membership_id($membership_id) { + public function set_membership_id($membership_id): void { $this->membership_id = $membership_id; } @@ -319,7 +319,7 @@ class Payment extends Base_Model { * @param int $parent_id The ID from another payment that this payment is related to. * @return void */ - public function set_parent_id($parent_id) { + public function set_parent_id($parent_id): void { $this->parent_id = $parent_id; } @@ -343,7 +343,7 @@ class Payment extends Base_Model { * @param string $currency The currency of this payment. It's a 3-letter code. E.g. 'USD'. * @return void */ - public function set_currency($currency) { + public function set_currency($currency): void { $this->currency = $currency; } @@ -366,7 +366,7 @@ class Payment extends Base_Model { * @param float $subtotal Value before taxes, discounts, fees and other changes. * @return void */ - public function set_subtotal($subtotal) { + public function set_subtotal($subtotal): void { $this->subtotal = $subtotal; } @@ -435,7 +435,7 @@ class Payment extends Base_Model { * @param string $discount_code Discount code used. * @return void */ - public function set_discount_code($discount_code) { + public function set_discount_code($discount_code): void { $this->discount_code = $discount_code; } @@ -458,7 +458,7 @@ class Payment extends Base_Model { * @param float $total This takes into account fees, discounts and credits. * @return void */ - public function set_total($total) { + public function set_total($total): void { $this->total = $total; } @@ -508,7 +508,7 @@ class Payment extends Base_Model { * @options \WP_Ultimo\Database\Payments\Payment_Status * @return void */ - public function set_status($status) { + public function set_status($status): void { $this->status = $status; } @@ -531,7 +531,7 @@ class Payment extends Base_Model { * @param string $gateway ID of the gateway being used on this payment. * @return void */ - public function set_gateway($gateway) { + public function set_gateway($gateway): void { $this->gateway = $gateway; } @@ -613,7 +613,7 @@ class Payment extends Base_Model { * @param Line_Item[] $line_items THe line items. * @return void */ - public function set_line_items(array $line_items) { + public function set_line_items(array $line_items): void { $line_items = array_filter($line_items); @@ -630,7 +630,7 @@ class Payment extends Base_Model { * @param Line_Item $line_item The line item. * @return void */ - public function add_line_item($line_item) { + public function add_line_item($line_item): void { $line_items = $this->get_line_items(); @@ -655,7 +655,7 @@ class Payment extends Base_Model { $line_items = $this->get_line_items(); - $tax_brackets = array(); + $tax_brackets = []; foreach ($line_items as $line_item) { $tax_bracket = $line_item->get_tax_rate(); @@ -711,12 +711,12 @@ class Payment extends Base_Model { } $this->attributes( - array( + [ 'tax_total' => $tax_total, 'subtotal' => $sub_total, 'refund_total' => $refund_total, 'total' => $total, - ) + ] ); return $this; @@ -732,10 +732,10 @@ class Payment extends Base_Model { $payable_statuses = apply_filters( 'wu_payment_payable_statuses', - array( + [ Payment_Status::PENDING, Payment_Status::FAILED, - ) + ] ); return $this->get_total() > 0 && in_array($this->get_status(), $payable_statuses, true); @@ -756,9 +756,9 @@ class Payment extends Base_Model { $slug = $this->get_hash(); return add_query_arg( - array( + [ 'payment' => $slug, - ), + ], wu_get_registration_url() ); } @@ -781,7 +781,7 @@ class Payment extends Base_Model { * @param int $product_id The ID of the product of this payment. * @return void */ - public function set_product_id($product_id) { + public function set_product_id($product_id): void { $this->product_id = $product_id; } @@ -794,11 +794,11 @@ class Payment extends Base_Model { */ public function get_invoice_url() { - $url_atts = array( + $url_atts = [ 'action' => 'invoice', 'reference' => $this->get_hash(), 'key' => wp_create_nonce('see_invoice'), - ); + ]; return add_query_arg($url_atts, get_site_url(wu_get_main_site_id())); } @@ -821,7 +821,7 @@ class Payment extends Base_Model { * @param string $gateway_payment_id The ID of the payment on the gateway, if it exists. * @return void */ - public function set_gateway_payment_id($gateway_payment_id) { + public function set_gateway_payment_id($gateway_payment_id): void { $this->gateway_payment_id = $gateway_payment_id; } @@ -863,7 +863,7 @@ class Payment extends Base_Model { * @param integer $discount_total The total value of the discounts applied to this payment. * @return void */ - public function set_discount_total($discount_total) { + public function set_discount_total($discount_total): void { $this->discount_total = (float) $discount_total; } @@ -909,23 +909,23 @@ class Payment extends Base_Model { $prefix = wu_get_setting('invoice_prefix', ''); - $search = array( + $search = [ '%YEAR%', '%MONTH%', '%DAY%', '%%YEAR%%', '%%MONTH%%', '%%DAY%%', - ); + ]; - $replace = array( + $replace = [ gmdate('Y'), gmdate('m'), gmdate('d'), gmdate('Y'), gmdate('m'), gmdate('d'), - ); + ]; $prefix = str_replace($search, $replace, (string) $prefix); @@ -939,7 +939,7 @@ class Payment extends Base_Model { * @param int $invoice_number Sequential invoice number assigned to this payment. * @return void */ - public function set_invoice_number($invoice_number) { + public function set_invoice_number($invoice_number): void { $this->meta['wu_invoice_number'] = $invoice_number; @@ -994,7 +994,7 @@ class Payment extends Base_Model { * @param bool $cancel_membership_on_refund Holds if we need to cancel the membership on refund. * @return void */ - public function set_cancel_membership_on_refund($cancel_membership_on_refund) { + public function set_cancel_membership_on_refund($cancel_membership_on_refund): void { $this->meta['wu_cancel_membership_on_refund'] = $cancel_membership_on_refund; @@ -1065,7 +1065,7 @@ class Payment extends Base_Model { // translators: %s is the date of processing. $description = sprintf(__('Processed on %s', 'wp-ultimo'), $formatted_value); - $line_item_data = array( + $line_item_data = [ 'type' => 'refund', 'hash' => uniqid(), 'title' => $title, @@ -1074,7 +1074,7 @@ class Payment extends Base_Model { 'taxable' => false, 'unit_price' => -$amount, 'quantity' => 1, - ); + ]; $refund_line_item = new Line_Item($line_item_data); diff --git a/inc/models/class-post-base-model.php b/inc/models/class-post-base-model.php index 1b00797..d3b7798 100644 --- a/inc/models/class-post-base-model.php +++ b/inc/models/class-post-base-model.php @@ -94,7 +94,7 @@ class Post_Base_Model extends Base_Model { * @since 2.0.0 * @var string */ - protected $query_class = '\\WP_Ultimo\\Database\\Posts\\Post_Query'; + protected $query_class = \WP_Ultimo\Database\Posts\Post_Query::class; /** * Get author ID. @@ -111,7 +111,7 @@ class Post_Base_Model extends Base_Model { * * @param int $author_id The author ID. */ - public function set_author_id($author_id) { + public function set_author_id($author_id): void { $this->author_id = $author_id; } @@ -131,7 +131,7 @@ class Post_Base_Model extends Base_Model { * * @param string $type Post type. */ - public function set_type($type) { + public function set_type($type): void { $this->type = $type; } @@ -151,7 +151,7 @@ class Post_Base_Model extends Base_Model { * * @param string $title Post title. */ - public function set_title($title) { + public function set_title($title): void { $this->title = $title; } @@ -174,7 +174,7 @@ class Post_Base_Model extends Base_Model { * * @param string $content Post content. */ - public function set_content($content) { + public function set_content($content): void { $this->content = $content; } @@ -194,7 +194,7 @@ class Post_Base_Model extends Base_Model { * * @param string $excerpt Post excerpt. */ - public function set_excerpt($excerpt) { + public function set_excerpt($excerpt): void { $this->excerpt = $excerpt; } @@ -214,7 +214,7 @@ class Post_Base_Model extends Base_Model { * * @param string $date_created Post creation date. */ - public function set_date_created($date_created) { + public function set_date_created($date_created): void { $this->date_created = $date_created; } @@ -234,7 +234,7 @@ class Post_Base_Model extends Base_Model { * * @param string $date_modified Post last modification date. */ - public function set_date_modified($date_modified) { + public function set_date_modified($date_modified): void { $this->date_modified = $date_modified; } @@ -254,7 +254,7 @@ class Post_Base_Model extends Base_Model { * * @param int $list_order The post list order. */ - public function set_list_order($list_order) { + public function set_list_order($list_order): void { $this->list_order = $list_order; } @@ -274,7 +274,7 @@ class Post_Base_Model extends Base_Model { * * @param string $status The post status. */ - public function set_status($status) { + public function set_status($status): void { $this->status = $status; } diff --git a/inc/models/class-product.php b/inc/models/class-product.php index e4744ed..ebe2972 100644 --- a/inc/models/class-product.php +++ b/inc/models/class-product.php @@ -267,7 +267,7 @@ class Product extends Base_Model { * @since 2.0.0 * @var string */ - protected $query_class = '\\WP_Ultimo\\Database\\Products\\Product_Query'; + protected $query_class = \WP_Ultimo\Database\Products\Product_Query::class; /** * Map setters to other parameters. @@ -275,9 +275,9 @@ class Product extends Base_Model { * @since 2.0.0 * @var array */ - protected $_mappings = array( + protected $_mappings = [ 'product_group' => 'group', - ); + ]; /** * Set the validation rules for this particular model. @@ -301,7 +301,7 @@ class Product extends Base_Model { $currency = wu_get_setting('currency_symbol', 'USD'); - return array( + return [ 'featured_image_id' => 'integer', 'currency' => "required|default:{$currency}", 'pricing_type' => 'required|in:free,paid,contact_us', @@ -323,7 +323,7 @@ class Product extends Base_Model { 'contact_us_label' => 'default:', 'contact_us_link' => 'url:http,https', 'customer_role' => 'alpha_dash', - ); + ]; } /** @@ -366,7 +366,7 @@ class Product extends Base_Model { * @param int $image_id The ID of the feature image of the product. * @return void */ - public function set_featured_image_id($image_id) { + public function set_featured_image_id($image_id): void { $this->meta['wu_featured_image_id'] = $image_id; @@ -388,7 +388,7 @@ class Product extends Base_Model { * * @param string $slug The product slug. It needs to be unique and preferably make it clear what it is about. Example: my_new_product. */ - public function set_slug($slug) { + public function set_slug($slug): void { $this->slug = $slug; } @@ -408,7 +408,7 @@ class Product extends Base_Model { * * @param string $name Your product name, which is used as product title as well. */ - public function set_name($name) { + public function set_name($name): void { $this->name = $name; } @@ -428,7 +428,7 @@ class Product extends Base_Model { * * @param string $description A description for the product, usually a short text. */ - public function set_description($description) { + public function set_description($description): void { $this->description = $description; } @@ -459,7 +459,7 @@ class Product extends Base_Model { * @param string $currency The currency that this product accepts. It's a 3-letter code. E.g. 'USD'. * @return void */ - public function set_currency($currency) { + public function set_currency($currency): void { $this->currency = $currency; } @@ -483,7 +483,7 @@ class Product extends Base_Model { * @options free,paid,contact_us * @return void */ - public function set_pricing_type($pricing_type) { + public function set_pricing_type($pricing_type): void { $this->pricing_type = $pricing_type; @@ -523,7 +523,7 @@ class Product extends Base_Model { * @param int $trial_duration The duration of the trial period of this product, if the product has one. * @return void */ - public function set_trial_duration($trial_duration) { + public function set_trial_duration($trial_duration): void { $this->trial_duration = $trial_duration; } @@ -547,7 +547,7 @@ class Product extends Base_Model { * @options day,week,month,year * @return void */ - public function set_trial_duration_unit($trial_duration_unit) { + public function set_trial_duration_unit($trial_duration_unit): void { $this->trial_duration_unit = $trial_duration_unit; } @@ -567,7 +567,7 @@ class Product extends Base_Model { * * @param int $duration Time interval between charges. */ - public function set_duration($duration) { + public function set_duration($duration): void { $this->duration = $duration; } @@ -587,7 +587,7 @@ class Product extends Base_Model { * * @param string $duration_unit Time interval unit between charges. */ - public function set_duration_unit($duration_unit) { + public function set_duration_unit($duration_unit): void { $this->duration_unit = $duration_unit; } @@ -624,7 +624,7 @@ class Product extends Base_Model { } if ($this->get_pricing_type() === 'contact_us') { - return $this->get_contact_us_label() ? $this->get_contact_us_label() : __('Contact Us', 'wp-ultimo'); + return $this->get_contact_us_label() ?: __('Contact Us', 'wp-ultimo'); } return wu_format_currency($this->get_amount(), $this->get_currency()); @@ -635,7 +635,7 @@ class Product extends Base_Model { * * @param int $amount The value of this product. E.g. 19.99. */ - public function set_amount($amount) { + public function set_amount($amount): void { $this->amount = wu_to_float($amount); } @@ -658,7 +658,7 @@ class Product extends Base_Model { * @param int $setup_fee The setup fee value, if the product has one. E.g. 159.99. * @return void */ - public function set_setup_fee($setup_fee) { + public function set_setup_fee($setup_fee): void { $this->setup_fee = wu_to_float($setup_fee); } @@ -694,7 +694,7 @@ class Product extends Base_Model { */ public function get_price_description($include_fees = true) { - $pricing = array(); + $pricing = []; if ($this->get_pricing_type() === 'contact_us') { return __('Contact us', 'wp-ultimo'); @@ -786,7 +786,7 @@ class Product extends Base_Model { * * @param int $list_order The product list order. Useful when ordering products in a list. */ - public function set_list_order($list_order) { + public function set_list_order($list_order): void { $this->list_order = $list_order; } @@ -809,7 +809,7 @@ class Product extends Base_Model { * @param boolean $active Set this product as active (true), which means available to be used, or inactive (false). * @return void */ - public function set_active($active) { + public function set_active($active): void { $this->active = (bool) $active; } @@ -830,7 +830,7 @@ class Product extends Base_Model { * @param string $type The default product types are 'product', 'service' and 'package'. More types can be add using the product type filter. * @options plan,service,package */ - public function set_type($type) { + public function set_type($type): void { $this->type = $type; } @@ -879,7 +879,7 @@ class Product extends Base_Model { * @param int $parent_id The ID from another Product that this product is related to. * @return void */ - public function set_parent_id($parent_id) { + public function set_parent_id($parent_id): void { $this->parent_id = $parent_id; } @@ -913,7 +913,7 @@ class Product extends Base_Model { * @param boolean $recurring Set this product as a recurring one (true), which means the customer paid a defined amount each period of time, or not recurring (false). * @return void */ - public function set_recurring($recurring) { + public function set_recurring($recurring): void { $this->recurring = (bool) $recurring; } @@ -947,7 +947,7 @@ class Product extends Base_Model { * @param int $billing_cycles The number of times we should charge this product. * @return void */ - public function set_billing_cycles($billing_cycles) { + public function set_billing_cycles($billing_cycles): void { $this->billing_cycles = (int) $billing_cycles; } @@ -970,7 +970,7 @@ class Product extends Base_Model { * @param string $date_created Date when this was created. * @return void */ - public function set_date_created($date_created) { + public function set_date_created($date_created): void { $this->date_created = $date_created; } @@ -993,7 +993,7 @@ class Product extends Base_Model { * @param string $date_modified Date when this was last modified. * @return void */ - public function set_date_modified($date_modified) { + public function set_date_modified($date_modified): void { $this->date_modified = $date_modified; } @@ -1040,7 +1040,7 @@ class Product extends Base_Model { * @param bool $is_taxable Set this product as a taxable one (true), which means tax rules are applied to, or not taxable (false). * @return void */ - public function set_taxable($is_taxable) { + public function set_taxable($is_taxable): void { $this->meta['taxable'] = (bool) $is_taxable; @@ -1070,7 +1070,7 @@ class Product extends Base_Model { * @param string $tax_category Category of taxes applied to this product. You need to set this if taxable is set to true. * @return void */ - public function set_tax_category($tax_category) { + public function set_tax_category($tax_category): void { $this->meta['tax_category'] = $tax_category; @@ -1099,7 +1099,7 @@ class Product extends Base_Model { * @param string $contact_us_label If the product is the 'contact_us' type, it will need a label for the contact us button. * @return void */ - public function set_contact_us_label($contact_us_label) { + public function set_contact_us_label($contact_us_label): void { $this->meta['wu_contact_us_label'] = $contact_us_label; @@ -1128,7 +1128,7 @@ class Product extends Base_Model { * @param string $contact_us_link The url where the contact us button will lead to. * @return void */ - public function set_contact_us_link($contact_us_link) { + public function set_contact_us_link($contact_us_link): void { $this->meta['wu_contact_us_link'] = $contact_us_link; @@ -1157,7 +1157,7 @@ class Product extends Base_Model { * @param array $feature_list A list (array) of features of the product. * @return void */ - public function set_feature_list($feature_list) { + public function set_feature_list($feature_list): void { $this->meta['feature_list'] = $feature_list; @@ -1203,8 +1203,8 @@ class Product extends Base_Model { */ public function get_as_variation($duration, $duration_unit) { - $duration = $duration ? $duration : 1; - $duration_unit = $duration_unit ? $duration_unit : 'month'; + $duration = $duration ?: 1; + $duration_unit = $duration_unit ?: 'month'; if ($this->is_free()) { return $this; @@ -1215,9 +1215,9 @@ class Product extends Base_Model { } if (absint($duration) === $this->get_duration() && $duration_unit === $this->get_duration_unit()) { - $price_variation = array( + $price_variation = [ 'amount' => $this->get_amount(), - ); + ]; } $price_variation = apply_filters('wu_get_as_variation_price_variation', $price_variation, $duration, $duration_unit, $this); @@ -1249,7 +1249,7 @@ class Product extends Base_Model { return $price_variation; }, - $this->get_meta('price_variations', array()) + $this->get_meta('price_variations', []) ); } @@ -1263,7 +1263,7 @@ class Product extends Base_Model { * @param ?array $price_variations Price variations array. * @return void */ - public function set_price_variations(?array $price_variations) { + public function set_price_variations(?array $price_variations): void { // Ensure the amount is a float. $price_variations = array_map( @@ -1273,7 +1273,7 @@ class Product extends Base_Model { return $price_variation; }, - $price_variations ?? array() + $price_variations ?? [] ); $this->meta['price_variations'] = $price_variations; @@ -1337,13 +1337,13 @@ class Product extends Base_Model { $results = parent::save(); if ( ! is_wp_error($results) && has_action('save_post_wpultimo_plan')) { - do_action_deprecated('save_post_wpultimo_plan', array($this->get_id()), '2.0.0'); + do_action_deprecated('save_post_wpultimo_plan', [$this->get_id()], '2.0.0'); } if ( ! is_wp_error($results) && has_action('wu_save_plan')) { $compat_plan = new \WU_Plan($this); - do_action_deprecated('wu_save_plan', array($compat_plan), '2.0.0', 'wu_product_post_save'); + do_action_deprecated('wu_save_plan', [$compat_plan], '2.0.0', 'wu_product_post_save'); } return $results; @@ -1373,7 +1373,7 @@ class Product extends Base_Model { public function get_available_addons() { if ($this->available_addons === null) { - $this->available_addons = $this->get_meta('wu_available_addons', array()); + $this->available_addons = $this->get_meta('wu_available_addons', []); if (is_string($this->available_addons)) { $this->available_addons = explode(',', $this->available_addons); @@ -1390,7 +1390,7 @@ class Product extends Base_Model { * @param array $available_addons The available addons of this product. * @return void */ - public function set_available_addons($available_addons) { + public function set_available_addons($available_addons): void { $this->meta['wu_available_addons'] = $available_addons; @@ -1427,7 +1427,7 @@ class Product extends Base_Model { * @param array $group The group of this product, if has any. * @return void */ - public function set_group($group) { + public function set_group($group): void { $this->product_group = $group; } @@ -1454,7 +1454,7 @@ class Product extends Base_Model { * @param bool $legacy_options If the legacy options are enabled. * @return void */ - public function set_legacy_options($legacy_options) { + public function set_legacy_options($legacy_options): void { $this->meta['legacy_options'] = $legacy_options; @@ -1477,6 +1477,6 @@ class Product extends Base_Model { */ public function limitations_to_merge() { - return array(); + return []; } } diff --git a/inc/models/class-site.php b/inc/models/class-site.php index 928e883..3af99bc 100644 --- a/inc/models/class-site.php +++ b/inc/models/class-site.php @@ -205,7 +205,7 @@ class Site extends Base_Model { * @since 2.0.0 * @var array */ - private $duplication_arguments = array(); + private $duplication_arguments = []; /** * The site type of this particular site. @@ -237,7 +237,7 @@ class Site extends Base_Model { * @since 2.0.0 * @var string */ - protected $query_class = '\\WP_Ultimo\\Database\\Sites\\Site_Query'; + protected $query_class = \WP_Ultimo\Database\Sites\Site_Query::class; /** * Keeps form date from the signup form. @@ -281,7 +281,7 @@ class Site extends Base_Model { $site_types = implode(',', array_values($site_types->get_options())); - return array( + return [ 'categories' => 'default:', 'featured_image_id' => 'integer|default:', 'site_id' => 'required|integer', @@ -304,7 +304,7 @@ class Site extends Base_Model { 'template_id' => 'integer|default:', 'type' => "required|in:{$site_types}", 'signup_options' => 'default:', - ); + ]; } /** @@ -328,7 +328,7 @@ class Site extends Base_Model { * @param array $categories The categories this site belongs to. * @return void */ - public function set_categories($categories) { + public function set_categories($categories): void { $this->meta['wu_categories'] = $categories; @@ -344,11 +344,11 @@ class Site extends Base_Model { public function get_categories() { if ($this->categories === null) { - $this->categories = $this->get_meta('wu_categories', array()); + $this->categories = $this->get_meta('wu_categories', []); } if ( ! is_array($this->categories)) { - return array(); + return []; } return array_filter($this->categories); @@ -378,7 +378,7 @@ class Site extends Base_Model { public function get_featured_image($size = 'wu-thumb-medium') { if ($this->get_type() === 'external') { - return wu_get_asset('wp-ultimo-screenshot.png'); + return wu_get_asset('wp-ultimo-screenshot.webp'); } is_multisite() && switch_to_blog(wu_get_main_site_id()); @@ -393,7 +393,7 @@ class Site extends Base_Model { return $image_attributes[0]; } - return wu_get_asset('site-placeholder-image.png', 'img'); + return wu_get_asset('site-placeholder-image.webp', 'img'); } /** @@ -403,7 +403,7 @@ class Site extends Base_Model { * @param int $image_id The ID of the feature image of the site. * @return void */ - public function set_featured_image_id($image_id) { + public function set_featured_image_id($image_id): void { $this->meta['wu_featured_image_id'] = $image_id; @@ -469,7 +469,7 @@ class Site extends Base_Model { * @param int $blog_id The blog ID. Should be accessed via id. * @return void */ - public function set_blog_id($blog_id) { + public function set_blog_id($blog_id): void { $this->blog_id = $blog_id; } @@ -492,7 +492,7 @@ class Site extends Base_Model { * @param int $site_id The network ID for this site. * @return void */ - public function set_site_id($site_id) { + public function set_site_id($site_id): void { $this->site_id = $site_id; } @@ -514,7 +514,7 @@ class Site extends Base_Model { * @param string $title The site title. * @return void */ - public function set_title($title) { + public function set_title($title): void { $this->title = sanitize_text_field($title); } @@ -537,7 +537,7 @@ class Site extends Base_Model { * @param string $title The site name. * @return void */ - public function set_name($title) { + public function set_name($title): void { $this->set_title($title); } @@ -566,7 +566,7 @@ class Site extends Base_Model { * @param string $description A description for the site, usually a short text. * @return void */ - public function set_description($description) { + public function set_description($description): void { $this->description = $description; } @@ -589,7 +589,7 @@ class Site extends Base_Model { * @param string $domain The site domain. You don't need to put http or https in front of your domain in this field. e.g: example.com. * @return void */ - public function set_domain($domain) { + public function set_domain($domain): void { $this->domain = $domain; } @@ -610,7 +610,7 @@ class Site extends Base_Model { * @param string $path Path of the site. Used when in sub-directory mode. * @return void */ - public function set_path($path) { + public function set_path($path): void { $this->path = $path; } @@ -644,7 +644,7 @@ class Site extends Base_Model { * @param string $registered Date when the site was registered. * @return void */ - public function set_registered($registered) { + public function set_registered($registered): void { $this->registered = $registered; } @@ -678,7 +678,7 @@ class Site extends Base_Model { * @param string $last_updated Date of the last update on this site. * @return void */ - public function set_last_updated($last_updated) { + public function set_last_updated($last_updated): void { $this->last_updated = $last_updated; } @@ -701,7 +701,7 @@ class Site extends Base_Model { * @param int $publishing Holds the ID of the customer that owns this site. * @return void */ - public function set_publishing($publishing) { + public function set_publishing($publishing): void { $this->is_publishing = $publishing; } @@ -728,7 +728,7 @@ class Site extends Base_Model { * @param int $active Holds the ID of the customer that owns this site. * @return void */ - public function set_active($active) { + public function set_active($active): void { $this->meta['wu_active'] = $active; @@ -753,7 +753,7 @@ class Site extends Base_Model { * @param bool $public Set true if this site is a public one, false if not. * @return void */ - public function set_public($public) { + public function set_public($public): void { $this->public = $public; } @@ -776,7 +776,7 @@ class Site extends Base_Model { * @param bool $archived Is this an archived site. * @return void */ - public function set_archived($archived) { + public function set_archived($archived): void { $this->archived = $archived; } @@ -799,7 +799,7 @@ class Site extends Base_Model { * @param bool $mature Is this a site with mature content. * @return void */ - public function set_mature($mature) { + public function set_mature($mature): void { $this->mature = $mature; } @@ -822,7 +822,7 @@ class Site extends Base_Model { * @param bool $spam Is this an spam site. * @return void */ - public function set_spam($spam) { + public function set_spam($spam): void { $this->spam = $spam; } @@ -845,7 +845,7 @@ class Site extends Base_Model { * @param bool $deleted Is this site deleted. * @return void */ - public function set_deleted($deleted) { + public function set_deleted($deleted): void { $this->deleted = $deleted; } @@ -868,7 +868,7 @@ class Site extends Base_Model { * @param int $lang_id The ID of the language being used on this site. * @return void */ - public function set_lang_id($lang_id) { + public function set_lang_id($lang_id): void { $this->lang_id = $lang_id; } @@ -895,7 +895,7 @@ class Site extends Base_Model { * @param int $customer_id The ID of the customer that owns this site. * @return void */ - public function set_customer_id($customer_id) { + public function set_customer_id($customer_id): void { $this->meta['wu_customer_id'] = $customer_id; @@ -960,7 +960,7 @@ class Site extends Base_Model { * @param int $membership_id The ID of the membership associated with this site, if any. * @return void */ - public function set_membership_id($membership_id) { + public function set_membership_id($membership_id): void { $this->meta['wu_membership_id'] = $membership_id; @@ -1066,7 +1066,7 @@ class Site extends Base_Model { * @param int $template_id The ID of the templated used to create this site. * @return void */ - public function set_template_id($template_id) { + public function set_template_id($template_id): void { $this->meta['wu_template_id'] = absint($template_id); @@ -1092,11 +1092,11 @@ class Site extends Base_Model { */ protected function get_default_duplication_arguments() { - return array( + return [ 'keep_users' => true, 'copy_files' => true, 'public' => true, - ); + ]; } /** @@ -1130,7 +1130,7 @@ class Site extends Base_Model { * @param array $duplication_arguments Duplication arguments. * @return void */ - public function set_duplication_arguments($duplication_arguments) { + public function set_duplication_arguments($duplication_arguments): void { $this->duplication_arguments = $duplication_arguments; } @@ -1150,7 +1150,7 @@ class Site extends Base_Model { if ($this->type === null) { $type = $this->get_meta('wu_type'); - $this->type = $type ? $type : 'default'; + $this->type = $type ?: 'default'; } return $this->type; @@ -1164,7 +1164,7 @@ class Site extends Base_Model { * @options \WP_Ultimo\Database\Sites\Site_Type * @return void */ - public function set_type($type) { + public function set_type($type): void { $this->meta = (array) $this->meta; @@ -1185,12 +1185,12 @@ class Site extends Base_Model { } $domains = wu_get_domains( - array( + [ 'primary_domain' => true, 'blog_id' => $this->get_id(), 'stage__not_in' => \WP_Ultimo\Models\Domain::INACTIVE_STAGES, 'number' => 1, - ) + ] ); return empty($domains) ? false : $domains[0]; @@ -1297,7 +1297,7 @@ class Site extends Base_Model { * @param array $transient Form data. * @return void */ - public function set_transient($transient) { + public function set_transient($transient): void { $this->meta['wu_transient'] = $transient; @@ -1312,7 +1312,7 @@ class Site extends Base_Model { */ public function get_signup_options() { - return is_array($this->signup_options) ? $this->signup_options : array(); + return is_array($this->signup_options) ? $this->signup_options : []; } /** @@ -1322,7 +1322,7 @@ class Site extends Base_Model { * @param array $signup_options Keeps signup options for the site. * @return void */ - public function set_signup_options($signup_options) { + public function set_signup_options($signup_options): void { $this->signup_options = $signup_options; } @@ -1335,7 +1335,7 @@ class Site extends Base_Model { */ public function get_signup_meta() { - return is_array($this->signup_meta) ? $this->signup_meta : array(); + return is_array($this->signup_meta) ? $this->signup_meta : []; } /** @@ -1345,7 +1345,7 @@ class Site extends Base_Model { * @param array $signup_meta Keeps signup meta for the site. * @return void */ - public function set_signup_meta($signup_meta) { + public function set_signup_meta($signup_meta): void { $this->signup_meta = $signup_meta; } @@ -1388,13 +1388,13 @@ class Site extends Base_Model { */ public function __call($name, $args) { - if (strpos($name, 'get_option_') !== false) { + if (str_contains($name, 'get_option_')) { $option = str_replace('get_option_', '', $name); return get_blog_option($this->get_id(), $option, false); } - throw new \BadMethodCallException(__CLASS__ . "::$name()"); + throw new \BadMethodCallException(self::class . "::$name()"); } /** @@ -1538,9 +1538,9 @@ class Site extends Base_Model { if ($new) { $network = get_network(); - $domain = $this->get_domain() ? $this->get_domain() : $network->domain; + $domain = $this->get_domain() ?: $network->domain; - $network_id = $this->get_site_id() ? $this->get_site_id() : get_current_network_id(); + $network_id = $this->get_site_id() ?: get_current_network_id(); $user_id = get_current_user_id(); @@ -1564,13 +1564,13 @@ class Site extends Base_Model { $saved = \WP_Ultimo\Helpers\Site_Duplicator::duplicate_site( $this->get_template_id(), $this->get_title(), - array( + [ 'email' => $email, 'path' => $this->get_path(), 'domain' => $domain, 'meta' => $this->get_signup_options(), - 'user_id' => $user_id ? $user_id : 0, - ) + 'user_id' => $user_id ?: 0, + ] ); if (is_wp_error($saved)) { @@ -1592,9 +1592,9 @@ class Site extends Base_Model { wp_update_site( $site_id, - array( + [ 'public' => $this->get_public(), - ) + ] ); } @@ -1613,9 +1613,9 @@ class Site extends Base_Model { if ( ! is_wp_error($saved) && wu_get_setting('enable_screenshot_generator', true)) { wu_enqueue_async_action( 'wu_async_take_screenshot', - array( + [ 'site_id' => $saved, - ), + ], 'site' ); } @@ -1740,7 +1740,7 @@ class Site extends Base_Model { * @param array $query_args Additional query args. * @return array */ - public static function get_all_by_type($type = 'customer_owned', $query_args = array()) { + public static function get_all_by_type($type = 'customer_owned', $query_args = []) { global $wpdb; @@ -1753,10 +1753,10 @@ class Site extends Base_Model { if ($customer_id) { $memberships = wu_get_memberships( - array( - 'fields' => array('id'), + [ + 'fields' => ['id'], 'customer_id' => $customer_id, - ) + ] ); $memberships_str = ''; @@ -1789,12 +1789,12 @@ class Site extends Base_Model { $query = $query_args; - $query['meta_query'] = array( - array( + $query['meta_query'] = [ + [ 'key' => 'wu_type', 'value' => $type, - ), - ); + ], + ]; return static::query($query); } @@ -1808,19 +1808,19 @@ class Site extends Base_Model { * @param array $query_args Additional query args. * @return array */ - public static function get_all_by_categories($categories = array(), $query_args = array()) { + public static function get_all_by_categories($categories = [], $query_args = []) { global $wpdb; $query = $query_args; - $query['meta_query'] = array( - array( + $query['meta_query'] = [ + [ 'key' => 'wu_categories', 'value' => maybe_serialize($categories), 'compare' => 'LIKE', - ), - ); + ], + ]; return static::query($query); } @@ -1832,7 +1832,7 @@ class Site extends Base_Model { * @param array $sites An array of selected site ids or site objects. * @return array */ - public static function get_all_categories($sites = array()) { + public static function get_all_categories($sites = []) { global $wpdb; @@ -1842,7 +1842,7 @@ class Site extends Base_Model { return $cache; } - $final_array = array(); + $final_array = []; $query = "SELECT DISTINCT meta_value FROM {$wpdb->base_prefix}blogmeta WHERE meta_key = %s"; @@ -1867,7 +1867,7 @@ class Site extends Base_Model { $all_arrays = array_map('maybe_unserialize', $all_arrays); if ($all_arrays) { - $filtered_array = array(); + $filtered_array = []; foreach ($all_arrays as $array) { if (is_array($array)) { @@ -1904,7 +1904,7 @@ class Site extends Base_Model { */ public function limitations_to_merge() { - $limitations_to_merge = array(); + $limitations_to_merge = []; $membership = $this->get_membership(); diff --git a/inc/models/class-webhook.php b/inc/models/class-webhook.php index 493b27d..95d7d36 100644 --- a/inc/models/class-webhook.php +++ b/inc/models/class-webhook.php @@ -99,7 +99,7 @@ class Webhook extends Base_Model { * @since 2.0.0 * @var string */ - protected $query_class = '\\WP_Ultimo\\Database\\Webhooks\\Webhook_Query'; + protected $query_class = \WP_Ultimo\Database\Webhooks\Webhook_Query::class; /** * Set the validation rules for this particular model. @@ -113,7 +113,7 @@ class Webhook extends Base_Model { */ public function validation_rules() { - return array( + return [ 'name' => 'required|min:2', 'webhook_url' => 'required|url:http,https', 'event' => 'required', @@ -122,7 +122,7 @@ class Webhook extends Base_Model { 'hidden' => 'default:0', 'integration' => 'required|min:2', 'date_last_failed' => 'default:', - ); + ]; } /** @@ -140,7 +140,7 @@ class Webhook extends Base_Model { * * @param string $name Webhook name, which is used as product title as well. */ - public function set_name($name) { + public function set_name($name): void { $this->name = $name; } @@ -160,7 +160,7 @@ class Webhook extends Base_Model { * * @param string $webhook_url The URL used for the webhook call. */ - public function set_webhook_url($webhook_url) { + public function set_webhook_url($webhook_url): void { $this->webhook_url = $webhook_url; } @@ -180,7 +180,7 @@ class Webhook extends Base_Model { * * @param string $event The event that needs to be fired for this webhook to be sent. */ - public function set_event($event) { + public function set_event($event): void { $this->event = $event; } @@ -200,7 +200,7 @@ class Webhook extends Base_Model { * * @param int $event_count How many times this webhook was sent. */ - public function set_event_count($event_count) { + public function set_event_count($event_count): void { $this->event_count = $event_count; } @@ -224,7 +224,7 @@ class Webhook extends Base_Model { * @param boolean $active Set this webhook as active (true), which means available will fire when the event occur, or inactive (false). * @return void */ - public function set_active($active) { + public function set_active($active): void { $this->active = (bool) wu_string_to_bool($active); } @@ -244,7 +244,7 @@ class Webhook extends Base_Model { * * @param boolean $hidden Is this webhook hidden. */ - public function set_hidden($hidden) { + public function set_hidden($hidden): void { $this->hidden = $hidden; } @@ -288,7 +288,7 @@ class Webhook extends Base_Model { * @param string $date_created Date when this was created. * @return void */ - public function set_date_created($date_created) { + public function set_date_created($date_created): void { $this->date_created = $date_created; } @@ -298,7 +298,7 @@ class Webhook extends Base_Model { * * @param string $integration The integration that created this webhook. */ - public function set_integration($integration) { + public function set_integration($integration): void { $this->integration = $integration; } diff --git a/inc/models/traits/trait-billable.php b/inc/models/traits/trait-billable.php index e0c6dab..ef260a8 100644 --- a/inc/models/traits/trait-billable.php +++ b/inc/models/traits/trait-billable.php @@ -60,7 +60,7 @@ trait Billable { * @param array|\WP_Ultimo\Objects\Billing_Address $billing_address The billing address. * @return void */ - public function set_billing_address($billing_address) { + public function set_billing_address($billing_address): void { if (is_array($billing_address)) { $billing_address = new Billing_Address($billing_address); diff --git a/inc/models/traits/trait-limitable.php b/inc/models/traits/trait-limitable.php index 1078a0d..6c99ce6 100644 --- a/inc/models/traits/trait-limitable.php +++ b/inc/models/traits/trait-limitable.php @@ -23,7 +23,7 @@ trait Limitable { * @since 2.0.0 * @var array */ - protected $_limitations = array(); + protected $_limitations = []; /** * List of limitations that need to be merged. @@ -54,7 +54,7 @@ trait Limitable { * This is because we don't want to limit sites other than the customer owned ones. */ if ($this->model === 'site' && $this->get_type() !== Site_Type::CUSTOMER_OWNED) { - return new Limitations(array()); + return new Limitations([]); } $cache_key = $waterfall ? '_composite_limitations_' : '_limitations_'; @@ -70,16 +70,16 @@ trait Limitable { } if ( ! is_array($this->meta)) { - $this->meta = array(); + $this->meta = []; } if (did_action('muplugins_loaded') === false) { - $modules_data = $this->get_meta('wu_limitations', array()); + $modules_data = $this->get_meta('wu_limitations', []); } else { $modules_data = Limitations::early_get_limitations($this->model, $this->get_id()); } - $limitations = new Limitations(array()); + $limitations = new Limitations([]); if ($waterfall) { $limitations = $limitations->merge(...$this->limitations_to_merge()); @@ -155,9 +155,9 @@ trait Limitable { * @since 2.0.5 * @return void */ - public function sync_plugins() { + public function sync_plugins(): void { - $sites = array(); + $sites = []; if ($this->model === 'site') { $sites[] = $this; @@ -201,7 +201,7 @@ trait Limitable { * @since 2.0.0 * @return void */ - public function handle_limitations() { + public function handle_limitations(): void { /* * Only handle limitations if there are to handle in the first place. */ @@ -213,14 +213,14 @@ trait Limitable { $saved_limitations = $object_limitations->to_array(); - $modules_to_save = array(); + $modules_to_save = []; $limitations = Limitations::repository(); $current_limitations = $this->get_limitations(true, true); foreach ($limitations as $limitation_id => $class_name) { - $module = wu_get_isset($saved_limitations, $limitation_id, array()); + $module = wu_get_isset($saved_limitations, $limitation_id, []); try { if (is_string($module)) { @@ -265,10 +265,10 @@ trait Limitable { public function get_applicable_product_slugs() { if ($this->model === 'product') { - return array($this->get_slug()); + return [$this->get_slug()]; } - $slugs = array(); + $slugs = []; if ($this->model === 'membership') { $membership = $this; diff --git a/inc/objects/class-billing-address.php b/inc/objects/class-billing-address.php index afa9354..fab3cd7 100644 --- a/inc/objects/class-billing-address.php +++ b/inc/objects/class-billing-address.php @@ -25,7 +25,7 @@ class Billing_Address { * @since 2.0.0 * @var array */ - protected $attributes = array(); + protected $attributes = []; /** * Initializes the object. @@ -34,7 +34,7 @@ class Billing_Address { * * @param array $data Array of key => values billing address fields. */ - public function __construct($data = array()) { + public function __construct($data = []) { $this->attributes($data); } @@ -47,7 +47,7 @@ class Billing_Address { * @param array $data Array of key => values billing address fields. * @return void */ - public function attributes($data) { + public function attributes($data): void { $allowed_attributes = array_keys(self::fields()); @@ -154,7 +154,7 @@ class Billing_Address { */ public function to_array($labels = false) { - $address_array = array(); + $address_array = []; $fields = self::fields(); @@ -217,7 +217,7 @@ class Billing_Address { */ public static function fields($zip_only = false, $checkout_form = false) { - $fields = array(); + $fields = []; $countries = wu_get_countries_as_options(); @@ -235,37 +235,37 @@ class Billing_Address { } } - $fields['company_name'] = array( + $fields['company_name'] = [ 'type' => 'text', 'title' => __('Company Name', 'wp-ultimo'), 'default_placeholder' => __('E.g. Google (optional)', 'wp-ultimo'), 'wrapper_classes' => 'sm:wu-col-span-1', - ); + ]; - $fields['billing_email'] = array( + $fields['billing_email'] = [ 'type' => 'text', 'title' => __('Billing Email', 'wp-ultimo'), 'default_placeholder' => __('E.g. john@company.com', 'wp-ultimo'), 'wrapper_classes' => 'sm:wu-col-span-1', 'required' => true, - ); + ]; - $fields['billing_address_line_1'] = array( + $fields['billing_address_line_1'] = [ 'type' => 'text', 'title' => __('Address Line 1', 'wp-ultimo'), 'default_placeholder' => __('E.g. 555 1st Avenue', 'wp-ultimo'), 'wrapper_classes' => 'wu-col-span-2', 'required' => true, - ); + ]; - $fields['billing_address_line_2'] = array( + $fields['billing_address_line_2'] = [ 'type' => 'text', 'title' => __('Address Line 2', 'wp-ultimo'), 'default_placeholder' => __('E.g. Apartment 10a', 'wp-ultimo'), 'wrapper_classes' => 'wu-col-span-2', - ); + ]; - $fields['billing_country'] = array( + $fields['billing_country'] = [ 'type' => 'select', 'title' => __('Country', 'wp-ultimo'), 'default_placeholder' => __('E.g. US', 'wp-ultimo'), @@ -273,37 +273,37 @@ class Billing_Address { 'value' => ' ', 'options' => $countries, 'required' => true, - ); + ]; - $fields['billing_state'] = array( + $fields['billing_state'] = [ 'type' => 'text', 'title' => __('State / Province', 'wp-ultimo'), 'default_placeholder' => __('E.g. NY', 'wp-ultimo'), 'wrapper_classes' => 'sm:wu-col-span-1', - ); + ]; - $fields['billing_city'] = array( + $fields['billing_city'] = [ 'type' => 'text', 'title' => __('City / Town', 'wp-ultimo'), 'default_placeholder' => __('E.g. New York City', 'wp-ultimo'), 'wrapper_classes' => 'sm:wu-col-span-1', - ); + ]; - $fields['billing_zip_code'] = array( + $fields['billing_zip_code'] = [ 'type' => 'text', 'title' => __('ZIP / Postal Code', 'wp-ultimo'), 'default_placeholder' => __('E.g. 10009', 'wp-ultimo'), 'wrapper_classes' => 'sm:wu-col-span-1', 'required' => true, - ); + ]; $fields = wu_set_order_from_index($fields); // Adds missing order attributes if ($zip_only) { - $fields = array( + $fields = [ 'billing_zip_code' => $fields['billing_zip_code'], 'billing_country' => $fields['billing_country'], - ); + ]; } /** @@ -331,18 +331,18 @@ class Billing_Address { */ public static function fields_for_rest($zip_only = false) { - $fields_for_rest = array(); + $fields_for_rest = []; foreach (self::fields($zip_only) as $field_key => $field) { $options = wu_get_isset($field, 'options', false); $enum = is_callable($options) ? call_user_func($options) : false; - $fields_for_rest[ $field_key ] = array( + $fields_for_rest[ $field_key ] = [ 'description' => wu_get_isset($field, 'title', false) . '. ' . wu_get_isset($field, 'default_placeholder', false), 'type' => 'string', 'required' => wu_get_isset($field, 'required', false), - ); + ]; if ($enum) { $fields_for_rest[ $field_key ]['enum'] = array_keys($enum); diff --git a/inc/objects/class-limitations.php b/inc/objects/class-limitations.php index 8e6f6d2..a9c201d 100644 --- a/inc/objects/class-limitations.php +++ b/inc/objects/class-limitations.php @@ -32,7 +32,7 @@ class Limitations { * @since 2.0.0 * @var array */ - static $limitations_cache = array(); + static $limitations_cache = []; /** * Version of the limitation schema. @@ -48,7 +48,7 @@ class Limitations { * @since 2.0.0 * @var array */ - protected $modules = array(); + protected $modules = []; /** * The current limitation being merged in merge_recursive. @@ -65,7 +65,7 @@ class Limitations { * * @param array $modules_data Array of modules data. */ - public function __construct($modules_data = array()) { + public function __construct($modules_data = []) { $this->build_modules($modules_data); } @@ -88,7 +88,7 @@ class Limitations { $class_name = wu_get_isset($repo, $name, false); if (class_exists($class_name)) { - $module = new $class_name(array()); + $module = new $class_name([]); $this->modules[ $name ] = $module; @@ -270,10 +270,10 @@ class Limitations { $current_id = $this->current_merge_id; - $force_enabled_list = array( + $force_enabled_list = [ 'plugins', 'themes', - ); + ]; $force_enabled = in_array($current_id, $force_enabled_list, true); @@ -283,9 +283,9 @@ class Limitations { } if ( ! wu_get_isset($array1, 'enabled', true)) { - $array1 = array( + $array1 = [ 'enabled' => false, - ); + ]; } if ( ! wu_get_isset($array2, 'enabled', true) && $should_sum) { @@ -325,32 +325,32 @@ class Limitations { } elseif (isset($array1[ $key ]) && is_numeric($array1[ $key ]) && is_numeric($value) && $should_sum && ! $is_unlimited) { $array1[ $key ] = ((int) $array1[ $key ]) + $value; } elseif ($key === 'visibility' && isset($array1[ $key ]) && $should_sum) { - $key_priority = array( + $key_priority = [ 'hidden' => 0, 'visible' => 1, - ); + ]; $array1[ $key ] = $key_priority[ $value ] > $key_priority[ $array1[ $key ] ] ? $value : $array1[ $key ]; } elseif ($key === 'behavior' && isset($array1[ $key ]) && $should_sum) { - $key_priority_list = array( - 'plugins' => array( + $key_priority_list = [ + 'plugins' => [ 'default' => 10, 'force_inactive_locked' => 20, 'force_inactive' => 30, 'force_active_locked' => 40, 'force_active' => 50, - ), - 'site' => array( + ], + 'site' => [ 'not_available' => 10, 'available' => 20, 'pre_selected' => 30, - ), - 'themes' => array( + ], + 'themes' => [ 'not_available' => 10, 'available' => 20, 'force_active' => 30, - ), - ); + ], + ]; $key_priority = apply_filters("wu_limitation_{$current_id}_priority", $key_priority_list[ $current_id ]); @@ -408,7 +408,7 @@ class Limitations { global $wpdb; - $limitations = array(); + $limitations = []; $table_name = "{$wpdb->base_prefix}{$wu_prefix}{$slug}meta"; @@ -437,7 +437,7 @@ class Limitations { * @param int $id The id of the meta id. * @return void */ - public static function remove_limitations($slug, $id) { + public static function remove_limitations($slug, $id): void { global $wpdb; @@ -487,7 +487,7 @@ class Limitations { */ public static function repository() { - $classes = array( + $classes = [ 'post_types' => \WP_Ultimo\Limitations\Limit_Post_Types::class, 'plugins' => \WP_Ultimo\Limitations\Limit_Plugins::class, 'sites' => \WP_Ultimo\Limitations\Limit_Sites::class, @@ -498,7 +498,7 @@ class Limitations { 'site_templates' => \WP_Ultimo\Limitations\Limit_Site_Templates::class, 'domain_mapping' => \WP_Ultimo\Limitations\Limit_Domain_Mapping::class, 'customer_user_role' => \WP_Ultimo\Limitations\Limit_Customer_User_Role::class, - ); + ]; return apply_filters('wu_limit_classes', $classes); } diff --git a/inc/objects/class-note.php b/inc/objects/class-note.php index 12ecafc..6bbe01b 100644 --- a/inc/objects/class-note.php +++ b/inc/objects/class-note.php @@ -25,7 +25,7 @@ class Note { * @since 2.0.0 * @var array */ - protected $attributes = array(); + protected $attributes = []; /** * Initializes the object. @@ -34,7 +34,7 @@ class Note { * * @param array $data Array of key => values note fields. */ - public function __construct($data = array()) { + public function __construct($data = []) { $this->attributes($data); } @@ -47,7 +47,7 @@ class Note { * @param array $data Array of key => values note fields. * @return void */ - public function attributes($data) { + public function attributes($data): void { $allowed_attributes = array_keys(self::fields()); @@ -122,7 +122,7 @@ class Note { */ protected function validation_rules() { - return array(); + return []; } /** @@ -154,7 +154,7 @@ class Note { */ public function to_array($labels = false) { - $address_array = array(); + $address_array = []; $fields = self::fields(); @@ -190,22 +190,22 @@ class Note { */ public static function fields() { - $fields = array(); + $fields = []; - $fields['text'] = array( + $fields['text'] = [ 'type' => 'text', 'title' => __('Text', 'wp-ultimo'), - ); + ]; - $fields['author_id'] = array( + $fields['author_id'] = [ 'type' => 'number', 'title' => __('Author ID', 'wp-ultimo'), - ); + ]; - $fields['note_id'] = array( + $fields['note_id'] = [ 'type' => 'text', 'title' => __('Note ID', 'wp-ultimo'), - ); + ]; uasort($fields, 'wu_sort_by_order'); diff --git a/inc/site-templates/class-template-placeholders.php b/inc/site-templates/class-template-placeholders.php index 0ac5a7a..c6434b9 100644 --- a/inc/site-templates/class-template-placeholders.php +++ b/inc/site-templates/class-template-placeholders.php @@ -29,7 +29,7 @@ class Template_Placeholders { * @since 2.0.0 * @var array */ - protected $placeholders_as_saved = array(); + protected $placeholders_as_saved = []; /** * Keeps an array of placeholder => value. @@ -37,7 +37,7 @@ class Template_Placeholders { * @since 2.0.0 * @var array */ - protected $placeholders = array(); + protected $placeholders = []; /** * Holds the placeholder tags. @@ -45,7 +45,7 @@ class Template_Placeholders { * @since 2.0.0 * @var array */ - protected $placeholder_keys = array(); + protected $placeholder_keys = []; /** * Holds the placeholder values. @@ -53,7 +53,7 @@ class Template_Placeholders { * @since 2.0.0 * @var array */ - protected $placeholder_values = array(); + protected $placeholder_values = []; /** * Loads the placeholders and adds the hooks. @@ -61,19 +61,19 @@ class Template_Placeholders { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { $this->load_placeholders(); - add_action('wp_ultimo_admin_pages', array($this, 'add_template_placeholders_admin_page')); + add_action('wp_ultimo_admin_pages', [$this, 'add_template_placeholders_admin_page']); - add_action('wp_ajax_wu_get_placeholders', array($this, 'serve_placeholders_via_ajax')); + add_action('wp_ajax_wu_get_placeholders', [$this, 'serve_placeholders_via_ajax']); - add_action('wp_ajax_wu_save_placeholders', array($this, 'save_placeholders')); + add_action('wp_ajax_wu_save_placeholders', [$this, 'save_placeholders']); - add_filter('the_content', array($this, 'placeholder_replacer')); + add_filter('the_content', [$this, 'placeholder_replacer']); - add_filter('the_title', array($this, 'placeholder_replacer')); + add_filter('the_title', [$this, 'placeholder_replacer']); } /** @@ -86,9 +86,9 @@ class Template_Placeholders { $placeholders = wu_get_option( 'template_placeholders', - array( - 'placeholders' => array(), - ) + [ + 'placeholders' => [], + ] ); $this->placeholders_as_saved = $placeholders; @@ -98,7 +98,7 @@ class Template_Placeholders { $tags = array_column($placeholders, 'placeholder'); $values = array_column($placeholders, 'content'); - $tags = array_map(array($this, 'add_curly_braces'), $tags); + $tags = array_map([$this, 'add_curly_braces'], $tags); $values = array_map('nl2br', $values); $this->placeholder_keys = $tags; @@ -143,7 +143,7 @@ class Template_Placeholders { * @since 2.0.0 * @return void */ - public function serve_placeholders_via_ajax() { + public function serve_placeholders_via_ajax(): void { wp_send_json_success($this->placeholders_as_saved); } @@ -154,33 +154,33 @@ class Template_Placeholders { * @since 2.0.0 * @return void */ - public function save_placeholders() { + public function save_placeholders(): void { if ( ! check_ajax_referer('wu_edit_placeholders_editing')) { wp_send_json( - array( + [ 'code' => 'not-enough-permissions', 'message' => __('You don\'t have permission to alter placeholders.', 'wp-ultimo'), - ) + ] ); } $data = json_decode(file_get_contents('php://input'), true); - $placeholders = isset($data['placeholders']) ? $data['placeholders'] : array(); + $placeholders = $data['placeholders'] ?? []; wu_save_option( 'template_placeholders', - array( + [ 'placeholders' => $placeholders, - ) + ] ); wp_send_json( - array( + [ 'code' => 'success', 'message' => __('Placeholders successfully updated!', 'wp-ultimo'), - ) + ] ); } @@ -190,7 +190,7 @@ class Template_Placeholders { * @since 2.0.0 * @return void */ - public function add_template_placeholders_admin_page() { + public function add_template_placeholders_admin_page(): void { new \WP_Ultimo\Admin_Pages\Placeholders_Admin_Page(); } diff --git a/inc/sso/auth-functions.php b/inc/sso/auth-functions.php index 8a4c501..067a87e 100644 --- a/inc/sso/auth-functions.php +++ b/inc/sso/auth-functions.php @@ -191,8 +191,8 @@ if ( !function_exists( 'auth_redirect' ) ) : $secure = apply_filters( 'secure_auth_redirect', $secure ); // If https is required and request is http, redirect. - if ( $secure && ! is_ssl() && strpos((string) $_SERVER['REQUEST_URI'], 'wp-admin') !== false ) { - if ( strncmp((string) $_SERVER['REQUEST_URI'], 'http', strlen('http')) === 0 ) { + if ( $secure && ! is_ssl() && str_contains((string) $_SERVER['REQUEST_URI'], 'wp-admin') ) { + if ( str_starts_with((string) $_SERVER['REQUEST_URI'], 'http') ) { wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) ); exit; } else { @@ -222,8 +222,8 @@ if ( !function_exists( 'auth_redirect' ) ) : do_action( 'auth_redirect', $user_id ); // If the user wants ssl but the session is not ssl, redirect. - if ( ! $secure && get_user_option( 'use_ssl', $user_id ) && strpos((string) $_SERVER['REQUEST_URI'], 'wp-admin') !== false ) { - if ( strncmp((string) $_SERVER['REQUEST_URI'], 'http', strlen('http')) === 0 ) { + if ( ! $secure && get_user_option( 'use_ssl', $user_id ) && str_contains((string) $_SERVER['REQUEST_URI'], 'wp-admin') ) { + if ( str_starts_with((string) $_SERVER['REQUEST_URI'], 'http') ) { wp_redirect( set_url_scheme( $_SERVER['REQUEST_URI'], 'https' ) ); exit; } else { diff --git a/inc/sso/class-sso-broker.php b/inc/sso/class-sso-broker.php index 5d19a03..9df4937 100644 --- a/inc/sso/class-sso-broker.php +++ b/inc/sso/class-sso-broker.php @@ -35,17 +35,17 @@ class SSO_Broker extends Broker { * * @param array $params The params to be passed. */ - public function getAttachUrl(array $params = array()): string { + public function getAttachUrl(array $params = []): string { if ($this->getToken() === null) { $this->generateToken(); } - $data = array( + $data = [ 'broker' => $this->broker, 'token' => $this->getToken(), 'checksum' => $this->generateChecksum('attach'), - ); + ]; return add_query_arg($data + $params, $this->url); } diff --git a/inc/sso/class-sso.php b/inc/sso/class-sso.php index 480899c..8ef5b78 100644 --- a/inc/sso/class-sso.php +++ b/inc/sso/class-sso.php @@ -71,7 +71,7 @@ class SSO { * @since 2.0.11 * @return void */ - public function init() { + public function init(): void { $this->is_enabled() && $this->startup(); } @@ -182,7 +182,7 @@ class SSO { * @since 2.0.11 * @return void */ - public function startup() { + public function startup(): void { /** * Loads the modified auth functions we need @@ -206,9 +206,9 @@ class SSO { * @see https://developer.wordpress.org/reference/functions/auth_redirect/ * @see https://developer.wordpress.org/reference/functions/wp_set_auth_cookie/ */ - add_filter('secure_logged_in_cookie', array($this, 'force_secure_login_cookie')); + add_filter('secure_logged_in_cookie', [$this, 'force_secure_login_cookie']); - add_filter('wu_auth_redirect', array($this, 'handle_auth_redirect')); + add_filter('wu_auth_redirect', [$this, 'handle_auth_redirect']); /** * Install the SSO listeners for the Server and the Broker. @@ -230,13 +230,13 @@ class SSO { add_action('wu_sso_handle', 'send_origin_headers'); - add_action('plugins_loaded', array($this, 'handle_requests'), 0); + add_action('plugins_loaded', [$this, 'handle_requests'], 0); - add_action('wu_sso_handle_sso_grant', array($this, 'handle_server')); + add_action('wu_sso_handle_sso_grant', [$this, 'handle_server']); - add_action('wu_sso_handle_sso', array($this, 'handle_broker'), 20); + add_action('wu_sso_handle_sso', [$this, 'handle_broker'], 20); - add_filter('allowed_http_origins', array($this, 'add_additional_origins')); + add_filter('allowed_http_origins', [$this, 'add_additional_origins']); /** * Authorize a user via a bearer, and converts it into a regular cookie @@ -250,11 +250,11 @@ class SSO { * * @see https://developer.wordpress.org/reference/hooks/determine_current_user/ */ - add_filter('determine_current_user', array($this, 'determine_current_user'), 90); + add_filter('determine_current_user', [$this, 'determine_current_user'], 90); - add_action('init', array($this, 'convert_bearer_into_auth_cookies')); + add_action('init', [$this, 'convert_bearer_into_auth_cookies']); - add_filter('removable_query_args', array($this, 'add_sso_removable_query_args')); + add_filter('removable_query_args', [$this, 'add_sso_removable_query_args']); /** * Adds the SSO scripts to the head of the front-end @@ -262,9 +262,9 @@ class SSO { * * @see assets/js/sso.js */ - add_action('wp_head', array($this, 'enqueue_script')); + add_action('wp_head', [$this, 'enqueue_script']); - add_action('login_head', array($this, 'enqueue_script')); + add_action('login_head', [$this, 'enqueue_script']); /** * Allow plugin developers to add additional hooks, if needed. @@ -280,7 +280,7 @@ class SSO { * Schedule another loaded hook to be triggered * on init, so later functionality can also hook into it. */ - add_action('init', array($this, 'loaded_on_init')); + add_action('init', [$this, 'loaded_on_init']); } /** @@ -289,7 +289,7 @@ class SSO { * @since 2.0.0 * @return void */ - public function loaded_on_init() { + public function loaded_on_init(): void { do_action('wu_sso_loaded_on_init', $this); } @@ -362,9 +362,9 @@ class SSO { $redirect_after = 'index.php' === $pagenow ? '' : $this->get_current_url(); $redirect_url = add_query_arg( - array( + [ $sso_path => 'login', - ), + ], wp_login_url($redirect_after) ); @@ -392,7 +392,7 @@ class SSO { * @since 2.0.11 * @return void */ - public function handle_requests() { + public function handle_requests(): void { $action = $this->get_sso_action(); @@ -402,7 +402,7 @@ class SSO { header('Access-Control-Allow-Headers: Content-Type'); - remove_filter('determine_current_user', array($this, 'determine_current_user'), 90); + remove_filter('determine_current_user', [$this, 'determine_current_user'], 90); status_header(200); @@ -425,7 +425,7 @@ class SSO { * @param string $response_type Redirect or jsonp. * @return void */ - public function handle_server($response_type = 'redirect') { + public function handle_server($response_type = 'redirect'): void { nocache_headers(); @@ -438,29 +438,29 @@ class SSO { if (is_ssl()) { $verification_code = null; - $error = array( + $error = [ 'code' => $e->getCode(), 'message' => $e->getMessage(), - ); + ]; } else { $verification_code = 'must-redirect'; } } catch (\Throwable $th) { $verification_code = null; - $error = array( + $error = [ 'code' => $th->getCode(), 'message' => $th->getMessage(), - ); + ]; } if ('jsonp' === $response_type) { $data = wp_json_encode( - $error ?? array( // phpcs:ignore + $error ?? [ // phpcs:ignore 'code' => 200, 'verify' => $verification_code, 'return_url' => $this->input('return_url', ''), - ) + ] ); $response_code = 200; // phpcs:ignore @@ -471,9 +471,9 @@ class SSO { exit; } elseif ($response_type === 'redirect') { - $args = array( - 'sso_verify' => $verification_code ? $verification_code : 'invalid', - ); + $args = [ + 'sso_verify' => $verification_code ?: 'invalid', + ]; if (isset($error) && $error) { $args['sso_error'] = $error['message']; @@ -497,7 +497,7 @@ class SSO { * @param string $response_type Redirect or jsonp. * @return void */ - public function handle_broker($response_type = 'redirect') { + public function handle_broker($response_type = 'redirect'): void { if (is_main_site()) { return; @@ -531,15 +531,15 @@ class SSO { if ( 'jsonp' === $response_type) { $attach_url = $broker->getAttachUrl( - array( + [ '_jsonp' => '1', - ) + ] ); } else { $attach_url = $broker->getAttachUrl( - array( + [ 'return_url' => $return_url, - ) + ] ); } @@ -569,18 +569,18 @@ class SSO { global $current_site; - $additional_domains = array( + $additional_domains = [ "http://{$current_site->domain}", "https://{$current_site->domain}", - ); + ]; $origin_url = wp_parse_url(get_http_origin()); $sites = get_sites( - array( + [ 'network_id' => get_current_network_id(), 'domain' => $this->get_isset($origin_url, 'host', 'invalid'), - ) + ] ); if ($sites) { @@ -592,12 +592,12 @@ class SSO { if ($site) { $domains = wu_get_domains( - array( + [ 'active' => true, 'blog_id' => $site->blog_id, 'stage__not_in' => \WP_Ultimo\Models\Domain::INACTIVE_STAGES, 'fields' => 'domain', - ) + ] ); foreach ($domains as $domain) { @@ -632,7 +632,7 @@ class SSO { try { $bearer = $broker->getBearerToken(); - $server_request = $this->build_server_request('GET', $this->get_current_url())->withHeader('Authorization', "Bearer $bearer"); + $server_request = $this->build_server_request('GET')->withHeader('Authorization', "Bearer $bearer"); $this->get_server()->startBrokerSession($server_request); @@ -667,7 +667,7 @@ class SSO { * @since 2.0.11 * @return void */ - public function convert_bearer_into_auth_cookies() { + public function convert_bearer_into_auth_cookies(): void { $broker = $this->get_broker(); @@ -702,7 +702,7 @@ class SSO { * @since 2.0.11 * @return void */ - public function enqueue_script() { + public function enqueue_script(): void { if (is_main_site()) { return; @@ -723,19 +723,19 @@ class SSO { wp_register_script('wu-detect-incognito', wu_get_asset('detectincognito.js', 'js/lib'), false, wu_get_version()); - wp_register_script('wu-sso', wu_get_asset('sso.js', 'js'), array('wu-cookie-helpers', 'wu-detect-incognito'), wu_get_version()); + wp_register_script('wu-sso', wu_get_asset('sso.js', 'js'), ['wu-cookie-helpers', 'wu-detect-incognito'], wu_get_version()); $sso_path = $this->get_url_path(); $home_site = get_home_url(get_current_blog_id(), $this->get_url_path()); - $removable_query_args = array( + $removable_query_args = [ $sso_path, "{$sso_path}-grant", 'return_url', - ); + ]; - $options = array( + $options = [ 'server_url' => $home_site, 'return_url' => $this->get_current_url(), 'is_user_logged_in' => is_user_logged_in() || $this->get_isset($_COOKIE, 'wu_sso_denied'), @@ -743,7 +743,7 @@ class SSO { 'filtered_url' => remove_query_arg($removable_query_args, $this->get_current_url()), 'img_folder' => dirname((string) wu_get_asset('img', 'img')), 'use_overlay' => $this->get_setting('enable_sso_loading_overlay', true), - ); + ]; wp_localize_script('wu-sso', 'wu_sso_config', $options); @@ -786,7 +786,7 @@ class SSO { $parsed_url = wp_parse_url($return_url); - $query_values = array(); + $query_values = []; if (isset($parsed_url['query'])) { parse_str($parsed_url['query'], $query_values); @@ -798,14 +798,14 @@ class SSO { $parsed_url['path'] = trim($parsed_url['path'], '/'); - $fragments = array( + $fragments = [ $parsed_url['scheme'] . '://' . $parsed_url['host'], $parsed_url['path'], - ); + ]; - $args = array( + $args = [ $sso_path => 'done', - ); + ]; if (isset($query_values['redirect_to'])) { $args['redirect_to'] = rawurlencode($query_values['redirect_to']); @@ -825,11 +825,11 @@ class SSO { */ public function get_return_type() { - $allowed_return_types = array( + $allowed_return_types = [ 'jsonp', 'json', 'redirect', - ); + ]; $received_type = $this->input('return_type', 'redirect'); @@ -848,7 +848,7 @@ class SSO { $pattern = "/\/?{$sso_path}(-grant)?\/?$/"; - $m = array(); + $m = []; $path = wp_parse_url($this->get_current_url(), PHP_URL_PATH); @@ -960,7 +960,7 @@ class SSO { $session_handler = new SSO_Session_Handler($this); - $server = (new Server(array($this, 'get_broker_by_id'), $this->cache()))->withSession($session_handler); + $server = (new Server([$this, 'get_broker_by_id'], $this->cache()))->withSession($session_handler); return apply_filters('wu_sso_get_server', $server, $this); } @@ -979,7 +979,7 @@ class SSO { $site_id = $this->decode($id, $this->salt()); - $site = get_site($site_id ? $site_id : 'non-existent'); + $site = get_site($site_id ?: 'non-existent'); if ( ! $site) { return null; @@ -987,10 +987,10 @@ class SSO { $main_domain = wp_parse_url(get_home_url($site_id), PHP_URL_HOST); - $domain_list = array( + $domain_list = [ $current_site->domain, $main_domain, - ); + ]; if (is_subdomain_install()) { $domain_list[] = $site->domain; @@ -998,10 +998,10 @@ class SSO { $domain_list = apply_filters('wu_sso_site_allowed_domains', $domain_list, $site_id, $site, $this); - return array( + return [ 'secret' => $this->calculate_secret_from_date($site->registered), 'domains' => $domain_list, - ); + ]; } /** @@ -1033,7 +1033,7 @@ class SSO { * @param int $target_user_id The target user id to set. * @return void */ - public function set_target_user_id($target_user_id) { + public function set_target_user_id($target_user_id): void { $this->target_user_id = $target_user_id; } @@ -1059,9 +1059,9 @@ class SSO { */ public function get_url_path($action = ''): string { - $fragments = array( + $fragments = [ apply_filters('wu_sso_get_url_path', 'sso', $action, $this), - ); + ]; if ($action) { $fragments[] = $action; @@ -1088,9 +1088,9 @@ class SSO { $sso_path = $sso->get_url_path(); - $sso_params = array( + $sso_params = [ $sso_path => 'login', - ); + ]; return add_query_arg($sso_params, $url); } diff --git a/inc/tax/class-dashboard-taxes-tab.php b/inc/tax/class-dashboard-taxes-tab.php index 7fe4527..fe378f9 100644 --- a/inc/tax/class-dashboard-taxes-tab.php +++ b/inc/tax/class-dashboard-taxes-tab.php @@ -33,9 +33,9 @@ class Dashboard_Taxes_Tab { */ public function __construct() { - add_filter('wu_dashboard_filter_bar', array($this, 'add_tab')); + add_filter('wu_dashboard_filter_bar', [$this, 'add_tab']); - add_action('wu_dashboard_taxes_widgets', array($this, 'register_widgets'), 10, 3); + add_action('wu_dashboard_taxes_widgets', [$this, 'register_widgets'], 10, 3); } /** @@ -58,12 +58,12 @@ class Dashboard_Taxes_Tab { */ public function add_tab($dashboard_filters) { - $dashboard_filters['taxes'] = array( + $dashboard_filters['taxes'] = [ 'field' => 'type', 'label' => __('Taxes', 'wp-ultimo'), 'url' => add_query_arg('tab', 'taxes'), 'count' => 0, - ); + ]; return $dashboard_filters; } @@ -74,20 +74,20 @@ class Dashboard_Taxes_Tab { * @since 2.0.0 * @return void */ - public function disabled_message() { + public function disabled_message(): void { echo wu_render_empty_state( - array( + [ 'message' => __('You do not have tax support enabled yet...'), 'sub_message' => __('If you need to collect taxes, you\'ll be glad to hear that WP Multisite WaaS offers tax support!'), 'link_label' => __('Enable Tax Support', 'wp-ultimo'), 'link_url' => wu_network_admin_url( 'wp-ultimo-settings', - array( + [ 'tab' => 'taxes', - ) + ] ), - ) + ] ); } @@ -101,13 +101,13 @@ class Dashboard_Taxes_Tab { */ public function add_back_link($links) { - $back_link = array( - array( + $back_link = [ + [ 'url' => wu_network_admin_url('wp-ultimo'), 'label' => __('Go Back', 'wp-ultimo'), 'icon' => 'wu-reply', - ), - ); + ], + ]; return array_merge($back_link, $links); } @@ -122,7 +122,7 @@ class Dashboard_Taxes_Tab { * @param \WP_Ultimo\Admin_Pages\Dashboard_Admin_Page $dashboard_page Name of selected tab. * @return void */ - public function register_widgets($tab, $screen, $dashboard_page) { + public function register_widgets($tab, $screen, $dashboard_page): void { /** * Set the dashboard page as a property @@ -139,20 +139,20 @@ class Dashboard_Taxes_Tab { add_filter('wu_dashboard_display_widgets', '__return_false'); - add_action('wu_dash_before_metaboxes', array($this, 'disabled_message')); + add_action('wu_dash_before_metaboxes', [$this, 'disabled_message']); - add_filter('wu_page_get_title_links', array($this, 'add_back_link')); + add_filter('wu_page_get_title_links', [$this, 'add_back_link']); return; } $this->dashboard_page = $dashboard_page; - add_meta_box('wp-ultimo-taxes', __('Taxes', 'wp-ultimo'), array($this, 'output_widget_taxes'), $screen->id, 'full', 'high'); + add_meta_box('wp-ultimo-taxes', __('Taxes', 'wp-ultimo'), [$this, 'output_widget_taxes'], $screen->id, 'full', 'high'); - add_meta_box('wp-ultimo-taxes-by-rate', __('Taxes by Code', 'wp-ultimo'), array($this, 'output_widget_taxes_by_rate'), $screen->id, 'normal', 'high'); + add_meta_box('wp-ultimo-taxes-by-rate', __('Taxes by Code', 'wp-ultimo'), [$this, 'output_widget_taxes_by_rate'], $screen->id, 'normal', 'high'); - add_meta_box('wp-ultimo-taxes-by-day', __('Taxes by Day', 'wp-ultimo'), array($this, 'output_widget_taxes_by_day'), $screen->id, 'side', 'high'); + add_meta_box('wp-ultimo-taxes-by-day', __('Taxes by Day', 'wp-ultimo'), [$this, 'output_widget_taxes_by_day'], $screen->id, 'side', 'high'); $this->register_scripts(); } @@ -164,22 +164,22 @@ class Dashboard_Taxes_Tab { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { - $payments_per_month = array( - 'january' => array(), - 'february' => array(), - 'march' => array(), - 'april' => array(), - 'may' => array(), - 'june' => array(), - 'july' => array(), - 'august' => array(), - 'september' => array(), - 'october' => array(), - 'november' => array(), - 'december' => array(), - ); + $payments_per_month = [ + 'january' => [], + 'february' => [], + 'march' => [], + 'april' => [], + 'may' => [], + 'june' => [], + 'july' => [], + 'august' => [], + 'september' => [], + 'october' => [], + 'november' => [], + 'december' => [], + ]; $data = wu_calculate_taxes_by_month(); @@ -191,7 +191,7 @@ class Dashboard_Taxes_Tab { ++$index; } - $month_list = array(); + $month_list = []; $current_year = date_i18n('Y'); @@ -199,22 +199,22 @@ class Dashboard_Taxes_Tab { $month_list[] = date_i18n('M y', mktime(0, 0, 0, $i, 1, $current_year)); } - wp_register_script('wu-tax-stats', wu_get_asset('tax-statistics.js', 'js'), array('jquery', 'wu-functions', 'wu-ajax-list-table', 'moment', 'wu-block-ui', 'dashboard', 'wu-apex-charts', 'wu-vue-apex-charts'), wu_get_version(), true); + wp_register_script('wu-tax-stats', wu_get_asset('tax-statistics.js', 'js'), ['jquery', 'wu-functions', 'wu-ajax-list-table', 'moment', 'wu-block-ui', 'dashboard', 'wu-apex-charts', 'wu-vue-apex-charts'], wu_get_version(), true); wp_localize_script( 'wu-tax-stats', 'wu_tax_statistics_vars', - array( + [ 'data' => $payments_per_month, 'start_date' => date_i18n('Y-m-d', strtotime((string) wu_request('start_date', '-1 month'))), 'end_date' => date_i18n('Y-m-d', strtotime((string) wu_request('end_date', 'tomorrow'))), 'today' => date_i18n('Y-m-d', strtotime('tomorrow')), 'month_list' => $month_list, - 'i18n' => array( + 'i18n' => [ 'net_profit_label' => __('Net Profit', 'wp-ultimo'), 'taxes_label' => __('Taxes Collected', 'wp-ultimo'), - ), - ) + ], + ] ); wp_enqueue_script('wu-tax-stats'); @@ -226,7 +226,7 @@ class Dashboard_Taxes_Tab { * @since 2.0.0 * @return void */ - public function output_widget_taxes() { + public function output_widget_taxes(): void { wu_get_template('dashboard-statistics/widget-tax-graph'); } @@ -237,16 +237,16 @@ class Dashboard_Taxes_Tab { * @since 2.0.0 * @return void */ - public function output_widget_taxes_by_rate() { + public function output_widget_taxes_by_rate(): void { $taxes_by_rate = wu_calculate_taxes_by_rate($this->dashboard_page->start_date, $this->dashboard_page->end_date); wu_get_template( 'dashboard-statistics/widget-tax-by-code', - array( + [ 'taxes_by_rate' => $taxes_by_rate, 'page' => $this->dashboard_page, - ) + ] ); } @@ -256,16 +256,16 @@ class Dashboard_Taxes_Tab { * @since 2.0.0 * @return void */ - public function output_widget_taxes_by_day() { + public function output_widget_taxes_by_day(): void { $taxes_by_day = wu_calculate_taxes_by_day($this->dashboard_page->start_date, $this->dashboard_page->end_date); wu_get_template( 'dashboard-statistics/widget-tax-by-day', - array( + [ 'taxes_by_day' => $taxes_by_day, 'page' => $this->dashboard_page, - ) + ] ); } } diff --git a/inc/tax/class-tax.php b/inc/tax/class-tax.php index e0aa157..9ceb862 100644 --- a/inc/tax/class-tax.php +++ b/inc/tax/class-tax.php @@ -26,18 +26,18 @@ class Tax { * * @since 1.9.0 */ - public function init() { + public function init(): void { - add_action('init', array($this, 'add_settings')); + add_action('init', [$this, 'add_settings']); - add_action('wu_page_wp-ultimo-settings_load', array($this, 'add_sidebar_widget')); + add_action('wu_page_wp-ultimo-settings_load', [$this, 'add_sidebar_widget']); if ($this->is_enabled()) { - add_action('wp_ultimo_admin_pages', array($this, 'add_admin_page')); + add_action('wp_ultimo_admin_pages', [$this, 'add_admin_page']); - add_action('wp_ajax_wu_get_tax_rates', array($this, 'serve_taxes_rates_via_ajax')); + add_action('wp_ajax_wu_get_tax_rates', [$this, 'serve_taxes_rates_via_ajax']); - add_action('wp_ajax_wu_save_tax_rates', array($this, 'save_taxes_rates')); + add_action('wp_ajax_wu_save_tax_rates', [$this, 'save_taxes_rates']); add_action( 'wu_before_search_models', @@ -61,24 +61,24 @@ class Tax { $query = wu_request( 'query', - array( + [ 'search' => 'searching....', - ) + ] ); $s = trim((string) wu_get_isset($query, 'search', 'searching...'), '*'); - $filtered = array(); + $filtered = []; if ( ! empty($s)) { $filtered = \Arrch\Arrch::find( $results, - array( + [ 'sort_key' => 'name', - 'where' => array( - array(array('slug', 'name'), '~', $s), - ), - ) + 'where' => [ + [['slug', 'name'], '~', $s], + ], + ] ); } @@ -96,41 +96,41 @@ class Tax { * @since 2.0.0 * @return void */ - public function add_settings() { + public function add_settings(): void { wu_register_settings_section( 'taxes', - array( + [ 'title' => __('Taxes', 'wp-ultimo'), 'desc' => __('Taxes', 'wp-ultimo'), 'icon' => 'dashicons-wu-percent', 'order' => 55, - ) + ] ); wu_register_settings_field( 'taxes', 'enable_taxes', - array( + [ 'title' => __('Enable Taxes', 'wp-ultimo'), 'desc' => __('Enable this option to be able to collect sales taxes on your network payments.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, - ) + ] ); wu_register_settings_field( 'taxes', 'inclusive_tax', - array( + [ 'title' => __('Inclusive Tax', 'wp-ultimo'), 'desc' => __('Enable this option if your prices include taxes. In that case, WP Multisite WaaS will calculate the included tax instead of adding taxes to the price.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 0, - 'require' => array( + 'require' => [ 'enable_taxes' => 1, - ), - ) + ], + ] ); } @@ -140,14 +140,14 @@ class Tax { * @since 2.0.0 * @return void */ - public function add_sidebar_widget() { + public function add_sidebar_widget(): void { wu_register_settings_side_panel( 'taxes', - array( + [ 'title' => __('Tax Rates', 'wp-ultimo'), - 'render' => array($this, 'render_taxes_side_panel'), - ) + 'render' => [$this, 'render_taxes_side_panel'], + ] ); } @@ -170,7 +170,7 @@ class Tax { * @since 2.0.0 * @return void */ - public function add_admin_page() { + public function add_admin_page(): void { new \WP_Ultimo\Admin_Pages\Tax_Rates_Admin_Page(); } @@ -185,9 +185,9 @@ class Tax { return apply_filters( 'wu_get_tax_rate_types', - array( + [ 'regular' => __('Regular', 'wp-ultimo'), - ) + ] ); } @@ -199,7 +199,7 @@ class Tax { */ public function get_tax_rate_defaults() { - $defaults = array( + $defaults = [ 'id' => uniqid(), 'title' => __('Tax Rate', 'wp-ultimo'), 'country' => '', @@ -210,7 +210,7 @@ class Tax { 'priority' => 10, 'compound' => false, 'type' => 'regular', - ); + ]; return apply_filters('wu_get_tax_rate_defaults', $defaults); } @@ -227,12 +227,12 @@ class Tax { $tax_rates_categories = wu_get_option( 'tax_rates', - array( - 'default' => array( + [ + 'default' => [ 'name' => __('Default', 'wp-ultimo'), - 'rates' => array(), - ), - ) + 'rates' => [], + ], + ] ); if ( ! isset($tax_rates_categories['default'])) { @@ -241,7 +241,7 @@ class Tax { */ $default = array_shift($tax_rates_categories); - $tax_rates_categories = array_merge(array('default' => $default), $tax_rates_categories); + $tax_rates_categories = array_merge(['default' => $default], $tax_rates_categories); } foreach ($tax_rates_categories as &$tax_rate_category) { @@ -269,9 +269,9 @@ class Tax { * @since 2.0.0 * @return void */ - public function serve_taxes_rates_via_ajax() { + public function serve_taxes_rates_via_ajax(): void { - $tax_rates = array(); + $tax_rates = []; if (current_user_can('read_tax_rates')) { $tax_rates = $this->get_tax_rates(true); @@ -286,31 +286,31 @@ class Tax { * @since 2.0.0 * @return void */ - public function save_taxes_rates() { + public function save_taxes_rates(): void { if ( ! check_ajax_referer('wu_tax_editing')) { wp_send_json( - array( + [ 'code' => 'not-enough-permissions', 'message' => __('You don\'t have permission to alter tax rates', 'wp-ultimo'), - ) + ] ); } $data = json_decode(file_get_contents('php://input'), true); - $tax_rates = isset($data['tax_rates']) ? $data['tax_rates'] : false; + $tax_rates = $data['tax_rates'] ?? false; if ( ! $tax_rates) { wp_send_json( - array( + [ 'code' => 'tax-rates-not-found', 'message' => __('No tax rates present in the request', 'wp-ultimo'), - ) + ] ); } - $treated_tax_rates = array(); + $treated_tax_rates = []; foreach ($tax_rates as $tax_rate_slug => $tax_rate) { if ( ! isset($tax_rate['rates'])) { @@ -335,11 +335,11 @@ class Tax { wu_save_option('tax_rates', $treated_tax_rates); wp_send_json( - array( + [ 'code' => 'success', 'message' => __('Tax Rates successfully updated!', 'wp-ultimo'), 'tax_category' => strtolower(sanitize_title(wu_get_isset($data, 'tax_category', 'default'))), - ) + ] ); } @@ -349,7 +349,7 @@ class Tax { * @since 2.0.0 * @return void */ - public function render_taxes_side_panel() { + public function render_taxes_side_panel(): void { ?>
@@ -361,7 +361,7 @@ class Tax {
- <?php esc_attr_e('Manage Tax Rates', 'wp-ultimo'); ?> + <?php esc_attr_e('Manage Tax Rates', 'wp-ultimo'); ?>

diff --git a/inc/traits/trait-singleton.php b/inc/traits/trait-singleton.php index 03da815..e3b9e3b 100644 --- a/inc/traits/trait-singleton.php +++ b/inc/traits/trait-singleton.php @@ -43,7 +43,7 @@ trait Singleton { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { $this->has_parents() && method_exists(get_parent_class($this), 'init') && parent::init(); } diff --git a/inc/traits/trait-wp-ultimo-deprecated.php b/inc/traits/trait-wp-ultimo-deprecated.php index 2afa1d7..8839384 100644 --- a/inc/traits/trait-wp-ultimo-deprecated.php +++ b/inc/traits/trait-wp-ultimo-deprecated.php @@ -21,7 +21,7 @@ trait WP_Ultimo_Deprecated { * @param string $term Returns a string based on the term and this plugin slug. * @return void */ - public function slugfy($term) { + public function slugfy($term): void { _deprecated_function(__METHOD__, '2.0.0', 'wu_slugify($term)'); @@ -34,7 +34,7 @@ trait WP_Ultimo_Deprecated { * @since 2.0.0 * @return void */ - public function add_page_to_branding() { + public function add_page_to_branding(): void { _deprecated_function(__METHOD__, '2.0.0'); } @@ -49,7 +49,7 @@ trait WP_Ultimo_Deprecated { * @param boolean $vars Key => Value pairs to be made available as local variables inside the view scope. * @return void */ - public function render($view, $vars = false) { + public function render($view, $vars = false): void { _deprecated_function(__METHOD__, '2.0.0', 'wu_get_template()'); @@ -82,7 +82,7 @@ trait WP_Ultimo_Deprecated { * @param boolean $network Where to display, network admin or normal admin. * @return void */ - public function add_message($message, $type = 'success', $network = false) { + public function add_message($message, $type = 'success', $network = false): void { _deprecated_function(__METHOD__, '2.0.0', 'WP_Ultimo()->notices->add()'); @@ -117,12 +117,12 @@ trait WP_Ultimo_Deprecated { * @since 2.0.0 * @return void */ - public function enqueue_select2() { + public function enqueue_select2(): void { _deprecated_function(__METHOD__, '2.0.0'); wp_enqueue_style('wu-select2css', 'https://cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.css', false, '1.0', 'all'); - wp_enqueue_script('wu-select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.js', array('jquery'), '1.0', true); + wp_enqueue_script('wu-select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/3.4.8/select2.js', ['jquery'], '1.0', true); } } diff --git a/inc/traits/trait-wp-ultimo-plan-deprecated.php b/inc/traits/trait-wp-ultimo-plan-deprecated.php index 3ead03d..dd50ff7 100644 --- a/inc/traits/trait-wp-ultimo-plan-deprecated.php +++ b/inc/traits/trait-wp-ultimo-plan-deprecated.php @@ -58,17 +58,17 @@ trait WP_Ultimo_Plan_Deprecated { $value = $this->get_feature_list(); break; case 'quotas': - $value = array( + $value = [ // 'sites' => 300, 'upload' => 1024 * 1024 * 1024, 'visits' => 300, - ); + ]; break; case 'post': - $value = (object) array( + $value = (object) [ 'ID' => $this->get_id(), 'post_title' => $this->get_name(), - ); + ]; break; default: $value = $this->get_meta('wpu_' . $key, false, true); @@ -107,7 +107,7 @@ trait WP_Ultimo_Plan_Deprecated { * @param array $featured_plan Feature list for pricing tables. * @return void */ - public function set_featured_plan($featured_plan) { + public function set_featured_plan($featured_plan): void { $this->meta['featured_plan'] = $featured_plan; } @@ -134,7 +134,7 @@ trait WP_Ultimo_Plan_Deprecated { */ public function get_pricing_table_lines() { - $pricing_table_lines = array(); + $pricing_table_lines = []; /* * Setup Fee @@ -155,7 +155,7 @@ trait WP_Ultimo_Plan_Deprecated { * Post Type Lines * Gets the post type lines to be displayed on the pricing table options */ - $post_types = get_post_types(array('public' => true), 'objects'); + $post_types = get_post_types(['public' => true], 'objects'); $post_types = apply_filters('wu_get_post_types', $post_types); foreach ($post_types as $pt_slug => $post_type) { @@ -233,7 +233,7 @@ trait WP_Ultimo_Plan_Deprecated { $trial_days_plan = $this->get_trial_duration(); if ($trial_days > 0 || $trial_days_plan) { - $trial_days = $trial_days_plan ? $trial_days_plan : $trial_days; + $trial_days = $trial_days_plan ?: $trial_days; $pricing_table_lines['wu_product_trial'] = ! $this->is_free() ? sprintf(__('%s day Free Trial', 'wp-ultimo'), $trial_days) : '-'; } @@ -297,7 +297,7 @@ trait WP_Ultimo_Plan_Deprecated { /* * @since 1.3.3 Only Show elements allowed on the plan settings */ - $elements = array(); + $elements = []; if ( ! $elements) { return true; @@ -347,13 +347,13 @@ trait WP_Ultimo_Plan_Deprecated { $quotas, fn($quota_name) => ! in_array( $quota_name, - array( + [ 'sites', 'attachment', 'upload', 'users', 'visits', - ), + ], true ), ARRAY_FILTER_USE_KEY diff --git a/inc/traits/trait-wp-ultimo-settings-deprecated.php b/inc/traits/trait-wp-ultimo-settings-deprecated.php index 18e0d36..39f72c0 100644 --- a/inc/traits/trait-wp-ultimo-settings-deprecated.php +++ b/inc/traits/trait-wp-ultimo-settings-deprecated.php @@ -20,7 +20,7 @@ trait WP_Ultimo_Settings_Deprecated { * @since 2.0.0 * @return void */ - public function handle_legacy_scripts() { + public function handle_legacy_scripts(): void { /* * Mailchimp: Backwards compatibility. */ @@ -35,14 +35,14 @@ trait WP_Ultimo_Settings_Deprecated { * @since 2.0.0 * @return void */ - public function handle_legacy_filters() { + public function handle_legacy_filters(): void { - $legacy_settings = array(); + $legacy_settings = []; /* * Fetch Extra Sections */ - $sections = apply_filters_deprecated('wu_settings_sections', array(array()), '2.0.0', 'wu_register_settings_section()'); + $sections = apply_filters_deprecated('wu_settings_sections', [[]], '2.0.0', 'wu_register_settings_section()'); foreach ($sections as $section_key => $section) { if ($section_key === 'activation') { @@ -53,7 +53,7 @@ trait WP_Ultimo_Settings_Deprecated { $legacy_settings = array_merge($legacy_settings, $section['fields']); } - $filters = array( + $filters = [ 'wu_settings_section_general', 'wu_settings_section_network', 'wu_settings_section_domain_mapping', @@ -62,25 +62,25 @@ trait WP_Ultimo_Settings_Deprecated { 'wu_settings_section_styling', 'wu_settings_section_tools', 'wu_settings_section_advanced', - ); + ]; foreach ($filters as $filter) { $message = __('Adding setting sections directly via filters is no longer supported.'); - $legacy_settings = apply_filters_deprecated($filter, array($legacy_settings), '2.0.0', 'wu_register_settings_field()', $message); + $legacy_settings = apply_filters_deprecated($filter, [$legacy_settings], '2.0.0', 'wu_register_settings_field()', $message); } if ($legacy_settings) { $this->add_section( 'other', - array( + [ 'title' => __('Other', 'wp-ultimo'), 'desc' => __('Other', 'wp-ultimo'), - ) + ] ); foreach ($legacy_settings as $setting_key => $setting) { - if (strpos((string) $setting_key, 'license_key_') !== false) { + if (str_contains((string) $setting_key, 'license_key_')) { continue; // Remove old license key fields } diff --git a/inc/traits/trait-wp-ultimo-site-deprecated.php b/inc/traits/trait-wp-ultimo-site-deprecated.php index 9c9a9b6..6db5237 100644 --- a/inc/traits/trait-wp-ultimo-site-deprecated.php +++ b/inc/traits/trait-wp-ultimo-site-deprecated.php @@ -53,7 +53,7 @@ trait WP_Ultimo_Site_Deprecated { */ public function get_subscription() { - _deprecated_function(__CLASS__, '2.0.0', '\WP_Ultimo\Models\Site::get_membership()'); + _deprecated_function(self::class, '2.0.0', '\WP_Ultimo\Models\Site::get_membership()'); return $this->get_membership(); } diff --git a/inc/ui/class-account-summary-element.php b/inc/ui/class-account-summary-element.php index e84e31e..972a84b 100644 --- a/inc/ui/class-account-summary-element.php +++ b/inc/ui/class-account-summary-element.php @@ -145,21 +145,21 @@ class Account_Summary_Element extends Base_Element { */ public function fields() { - $fields = array(); + $fields = []; - $fields['header'] = array( + $fields['header'] = [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['title'] = array( + $fields['title'] = [ 'type' => 'text', 'title' => __('Title', 'wp-ultimo'), 'value' => __('About this Site', 'wp-ultimo'), 'desc' => __('Leave blank to hide the title completely.', 'wp-ultimo'), 'tooltip' => '', - ); + ]; return $fields; } @@ -183,12 +183,12 @@ class Account_Summary_Element extends Base_Element { */ public function keywords() { - return array( + return [ 'WP Ultimo', 'Account', 'Summary', 'WP Multisite WaaS', - ); + ]; } /** @@ -207,9 +207,9 @@ class Account_Summary_Element extends Base_Element { */ public function defaults() { - return array( + return [ 'title' => __('About this Site', 'wp-ultimo'), - ); + ]; } /** @@ -218,7 +218,7 @@ class Account_Summary_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup() { + public function setup(): void { $this->site = WP_Ultimo()->currents->get_site(); @@ -242,14 +242,14 @@ class Account_Summary_Element extends Base_Element { is_multisite() && restore_current_blog(); - $this->atts = array( + $this->atts = [ 'site_trial' => 0, // @todo: fix this 'space_used' => $space_used, 'space_allowed' => $space_allowed, 'percentage' => $percentage, 'unlimited_space' => $unlimited_space, 'message' => $message, - ); + ]; } /** @@ -258,7 +258,7 @@ class Account_Summary_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup_preview() { + public function setup_preview(): void { $this->site = wu_mock_site(); @@ -269,14 +269,14 @@ class Account_Summary_Element extends Base_Element { $unlimited_space = get_site_option('upload_space_check_disabled'); $message = $unlimited_space ? '%s' : '%s / %s'; - $this->atts = array( + $this->atts = [ 'site_trial' => 30, // @todo: fix this 'space_used' => 120 * MB_IN_BYTES, 'space_allowed' => 1 * GB_IN_BYTES, 'percentage' => 120 * MB_IN_BYTES / 1 * GB_IN_BYTES, 'unlimited_space' => $unlimited_space, 'message' => $message, - ); + ]; } /** diff --git a/inc/ui/class-base-element.php b/inc/ui/class-base-element.php index 05215c9..91151a4 100644 --- a/inc/ui/class-base-element.php +++ b/inc/ui/class-base-element.php @@ -66,7 +66,7 @@ abstract class Base_Element { * @since 2.0.24 * @var boolean */ - protected static $public_elements = array(); + protected static $public_elements = []; /** * If the element exists, we pre-load the parameters. @@ -217,25 +217,25 @@ abstract class Base_Element { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - add_action('plugins_loaded', array($this, 'register_form')); + add_action('plugins_loaded', [$this, 'register_form']); - add_action('init', array($this, 'register_shortcode')); + add_action('init', [$this, 'register_shortcode']); - add_action('wp_enqueue_scripts', array($this, 'enqueue_element_scripts')); + add_action('wp_enqueue_scripts', [$this, 'enqueue_element_scripts']); - add_action("wu_{$this->id}_scripts", array($this, 'register_default_scripts')); + add_action("wu_{$this->id}_scripts", [$this, 'register_default_scripts']); - add_action("wu_{$this->id}_scripts", array($this, 'register_scripts')); + add_action("wu_{$this->id}_scripts", [$this, 'register_scripts']); - add_action('wp', array($this, 'maybe_setup')); + add_action('wp', [$this, 'maybe_setup']); - add_action('admin_head', array($this, 'setup_for_admin'), 100); + add_action('admin_head', [$this, 'setup_for_admin'], 100); - add_filter('pre_render_block', array($this, 'setup_for_block_editor'), 100, 2); + add_filter('pre_render_block', [$this, 'setup_for_block_editor'], 100, 2); - add_action('wu_element_preview', array($this, 'setup_preview')); + add_action('wu_element_preview', [$this, 'setup_preview']); // Init should be the correct time to call this to avoid the deprecated notice from I18N. // But it doesn't work for some reason, fix later. @@ -255,7 +255,7 @@ abstract class Base_Element { * @param mixed $element The element instance to be registered. * @return void */ - public static function register_public_element($element) { + public static function register_public_element($element): void { static::$public_elements[] = $element; } @@ -296,10 +296,10 @@ abstract class Base_Element { */ $blocks_to_check = apply_filters( 'wu_element_block_types_to_check', - array( + [ 'core/shortcode', 'core/paragraph', - ) + ] ); if (in_array($block['blockName'], $blocks_to_check, true)) { @@ -352,7 +352,7 @@ abstract class Base_Element { $contains_metaboxes = wu_get_isset($wp_meta_boxes, $screen->id) || wu_get_isset($wp_meta_boxes, $pagenow); - $elements_to_cache = array(); + $elements_to_cache = []; $found = false; @@ -384,7 +384,7 @@ abstract class Base_Element { * @since 2.0.0 * @return void */ - public function setup_for_admin() { + public function setup_for_admin(): void { if ($this->loaded === true) { return; @@ -406,7 +406,7 @@ abstract class Base_Element { * @since 2.0.0 * @return void */ - public function maybe_setup() { + public function maybe_setup(): void { global $post; @@ -534,7 +534,7 @@ abstract class Base_Element { * Tries to parse the shortcode out of the content * passed using the WordPress shortcode regex. */ - $shortcode_regex = get_shortcode_regex(array($this->get_shortcode_id())); + $shortcode_regex = get_shortcode_regex([$this->get_shortcode_id()]); preg_match_all('/' . $shortcode_regex . '/', $content, $matches, PREG_SET_ORDER); @@ -573,7 +573,7 @@ abstract class Base_Element { * @since 2.0.0 * @return void */ - public function enqueue_element_scripts() { + public function enqueue_element_scripts(): void { global $post; @@ -626,13 +626,13 @@ abstract class Base_Element { * @since 2.0.0 * @return void */ - public function register_shortcode() { + public function register_shortcode(): void { if (wu_get_current_site()->get_type() === Site_Type::CUSTOMER_OWNED && is_admin() === false) { return; } - add_shortcode($this->get_shortcode_id(), array($this, 'display')); + add_shortcode($this->get_shortcode_id(), [$this, 'display']); } /** @@ -641,17 +641,17 @@ abstract class Base_Element { * @since 2.0.0 * @return void */ - public function register_form() { + public function register_form(): void { /* * Add Generator Forms */ wu_register_form( "shortcode_{$this->id}", - array( - 'render' => array($this, 'render_generator_modal'), + [ + 'render' => [$this, 'render_generator_modal'], 'handler' => '__return_empty_string', 'capability' => 'manage_network', - ) + ] ); /* @@ -659,11 +659,11 @@ abstract class Base_Element { */ wu_register_form( "customize_{$this->id}", - array( - 'render' => array($this, 'render_customize_modal'), - 'handler' => array($this, 'handle_customize_modal'), + [ + 'render' => [$this, 'render_customize_modal'], + 'handler' => [$this, 'handle_customize_modal'], 'capability' => 'manage_network', - ) + ] ); } @@ -673,13 +673,13 @@ abstract class Base_Element { * @since 2.0.0 * @return void */ - public function render_generator_modal() { + public function render_generator_modal(): void { $fields = $this->fields(); $defaults = $this->defaults(); - $state = array(); + $state = []; foreach ($fields as $field_slug => &$field) { if ($field['type'] === 'header' || $field['type'] === 'note') { @@ -695,13 +695,13 @@ abstract class Base_Element { * specially when we're dealing with * complex fields, such as group. */ - $additional_state = array(); + $additional_state = []; if ($field['type'] === 'group') { foreach ($field['fields'] as $sub_field_slug => &$sub_field) { - $sub_field['html_attr'] = array( + $sub_field['html_attr'] = [ 'v-model.lazy' => "attributes.{$sub_field_slug}", - ); + ]; $additional_state[ $sub_field_slug ] = wu_request($sub_field_slug, wu_get_isset($defaults, $sub_field_slug)); } @@ -712,14 +712,14 @@ abstract class Base_Element { /* * Set v-model */ - $field['html_attr'] = array( + $field['html_attr'] = [ 'v-model.lazy' => "attributes.{$field_slug}", - ); + ]; $required = wu_get_isset($field, 'required'); if (wu_get_isset($field, 'required')) { - $shows = array(); + $shows = []; foreach ($required as $key => $value) { $value = is_string($value) ? "\"$value\"" : $value; @@ -727,9 +727,9 @@ abstract class Base_Element { $shows[] = "attributes.{$key} == $value"; } - $field['wrapper_html_attr'] = array( + $field['wrapper_html_attr'] = [ 'v-show' => implode(' && ', $shows), - ); + ]; $state[ $field_slug . '_shortcode_requires' ] = $required; } @@ -737,42 +737,42 @@ abstract class Base_Element { $state[ $field_slug ] = wu_request($field_slug, wu_get_isset($defaults, $field_slug)); } - $fields['shortcode_result'] = array( + $fields['shortcode_result'] = [ 'type' => 'note', 'wrapper_classes' => 'sm:wu-block', 'desc' => '

' . __('Result', 'wp-ultimo') . '
', - ); + ]; - $fields['submit_copy'] = array( + $fields['submit_copy'] = [ 'type' => 'submit', 'title' => __('Copy Shortcode', 'wp-ultimo'), 'value' => 'edit', 'classes' => 'button button-primary wu-w-full wu-copy', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'data-clipboard-action' => 'copy', 'data-clipboard-target' => '#wu-shortcode', - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( $this->id, $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0 wu-w-full', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => "{$this->id}_generator", 'data-state' => wu_convert_to_state( - array( + [ 'id' => $this->get_shortcode_id(), 'defaults' => $defaults, 'attributes' => $state, - ) + ] ), - ), - ) + ], + ] ); echo '
'; @@ -788,18 +788,18 @@ abstract class Base_Element { * @since 2.0.0 * @return void */ - public function render_customize_modal() { + public function render_customize_modal(): void { - $fields = array(); + $fields = []; - $fields['hide'] = array( + $fields['hide'] = [ 'type' => 'toggle', 'title' => __('Hide Element', 'wp-ultimo'), 'desc' => __('Be careful. Hiding an element from the account page might remove important functionality from your customers\' reach.', 'wp-ultimo'), 'value' => $this->hidden_by_default, 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - ); + ]; $fields = array_merge($fields, $this->fields()); @@ -823,40 +823,40 @@ abstract class Base_Element { } } - $fields['save_line'] = array( + $fields['save_line'] = [ 'type' => 'group', 'classes' => 'wu-justify-between', 'wrapper_classes' => 'wu-bg-gray-100', - 'fields' => array( - 'restore' => array( + 'fields' => [ + 'restore' => [ 'type' => 'submit', 'title' => __('Reset Settings', 'wp-ultimo'), 'value' => 'edit', 'classes' => 'button', 'wrapper_classes' => 'wu-mb-0', - ), - 'submit' => array( + ], + 'submit' => [ 'type' => 'submit', 'title' => __('Save Changes', 'wp-ultimo'), 'value' => 'edit', 'classes' => 'button button-primary', 'wrapper_classes' => 'wu-mb-0', - ), - ), - ); + ], + ], + ]; $form = new \WP_Ultimo\UI\Form( $this->id, $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => "{$this->id}_customize", 'data-state' => wu_convert_to_state($state), - ), - ) + ], + ] ); echo '
'; @@ -872,16 +872,16 @@ abstract class Base_Element { * @since 2.0.0 * @return void */ - public function handle_customize_modal() { + public function handle_customize_modal(): void { - $settings = array(); + $settings = []; if (wu_request('submit') !== 'restore') { $fields = $this->fields(); - $fields['hide'] = array( + $fields['hide'] = [ 'type' => 'toggle', - ); + ]; foreach ($fields as $field_slug => $field) { $setting = wu_request($field_slug, false); @@ -895,14 +895,14 @@ abstract class Base_Element { $this->save_widget_settings($settings); wp_send_json_success( - array( - 'send' => array( + [ + 'send' => [ 'scope' => 'window', 'function_name' => 'wu_block_ui', 'data' => '#wpcontent', - ), + ], 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']), - ) + ] ); } @@ -912,7 +912,7 @@ abstract class Base_Element { * @since 2.0.0 * @return void */ - public function register_default_scripts() { + public function register_default_scripts(): void { wp_enqueue_style('wu-admin'); } @@ -984,7 +984,7 @@ abstract class Base_Element { */ $atts['element'] = $this; - return call_user_func(array($this, 'output'), $atts); + return call_user_func([$this, 'output'], $atts); } /** @@ -1002,20 +1002,20 @@ abstract class Base_Element { $content = $this->display($atts); $content = str_replace( - array( + [ 'v-', 'data-wu', 'data-state', - ), + ], 'inactive-', $content ); $content = str_replace( - array( + [ '{{', '}}', - ), + ], '', $content ); @@ -1045,7 +1045,7 @@ abstract class Base_Element { * @param array $atts Array containing the shortcode attributes. * @return void */ - public function as_inline_content($screen_id, $hook = 'admin_notices', $atts = array()) { + public function as_inline_content($screen_id, $hook = 'admin_notices', $atts = []): void { if ( ! function_exists('get_current_screen')) { _doing_it_wrong(__METHOD__, __('An element can not be loaded as inline content unless the get_current_screen() function is already available.', 'wp-ultimo'), '2.0.0'); @@ -1112,7 +1112,7 @@ abstract class Base_Element { * @param array $settings The settings to save. Key => value array. * @return void */ - public function save_widget_settings($settings) { + public function save_widget_settings($settings): void { $key = wu_replace_dashes($this->id); @@ -1129,7 +1129,7 @@ abstract class Base_Element { $key = wu_replace_dashes($this->id); - return wu_get_setting("widget_{$key}_settings", array()); + return wu_get_setting("widget_{$key}_settings", []); } /** @@ -1142,7 +1142,7 @@ abstract class Base_Element { * @param array $atts Array containing the shortcode attributes. * @return void */ - public function as_metabox($screen_id, $position = 'normal', $atts = array()) { + public function as_metabox($screen_id, $position = 'normal', $atts = []): void { $this->setup(); @@ -1195,7 +1195,7 @@ abstract class Base_Element { * @since 2.0.0 * @return void */ - public function super_admin_notice() { + public function super_admin_notice(): void { $should_display = $this->should_display_customize_controls(); @@ -1264,7 +1264,7 @@ abstract class Base_Element { * @param boolean $display Controls whether or not the widget and element should display. * @return void */ - public function set_display($display) { + public function set_display($display): void { $this->display = $display; } diff --git a/inc/ui/class-billing-info-element.php b/inc/ui/class-billing-info-element.php index 0d7c25c..ccbc0ef 100644 --- a/inc/ui/class-billing-info-element.php +++ b/inc/ui/class-billing-info-element.php @@ -84,17 +84,17 @@ class Billing_Info_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { parent::init(); wu_register_form( 'update_billing_address', - array( - 'render' => array($this, 'render_update_billing_address'), - 'handler' => array($this, 'handle_update_billing_address'), + [ + 'render' => [$this, 'render_update_billing_address'], + 'handler' => [$this, 'handle_update_billing_address'], 'capability' => 'exist', - ) + ] ); } @@ -104,7 +104,7 @@ class Billing_Info_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { add_wubox(); } @@ -159,21 +159,21 @@ class Billing_Info_Element extends Base_Element { */ public function fields() { - $fields = array(); + $fields = []; - $fields['header'] = array( + $fields['header'] = [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['title'] = array( + $fields['title'] = [ 'type' => 'text', 'title' => __('Title', 'wp-ultimo'), 'value' => __('Billing Address', 'wp-ultimo'), 'desc' => __('Leave blank to hide the title completely.', 'wp-ultimo'), 'tooltip' => '', - ); + ]; return $fields; } @@ -197,13 +197,13 @@ class Billing_Info_Element extends Base_Element { */ public function keywords() { - return array( + return [ 'WP Ultimo', 'WP Multisite WaaS', 'Billing Information', 'Form', 'Cart', - ); + ]; } /** @@ -222,9 +222,9 @@ class Billing_Info_Element extends Base_Element { */ public function defaults() { - return array( + return [ 'title' => __('Billing Address', 'wp-ultimo'), - ); + ]; } /** @@ -233,7 +233,7 @@ class Billing_Info_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup() { + public function setup(): void { $this->membership = WP_Ultimo()->currents->get_membership(); @@ -250,7 +250,7 @@ class Billing_Info_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup_preview() { + public function setup_preview(): void { $this->site = wu_mock_site(); @@ -278,10 +278,10 @@ class Billing_Info_Element extends Base_Element { $atts['update_billing_address_link'] = wu_get_form_url( 'update_billing_address', - array( + [ 'membership' => $this->membership->get_hash(), 'width' => 500, - ) + ] ); return wu_get_template_contents('dashboard-widgets/billing-info', $atts); @@ -320,45 +320,45 @@ class Billing_Info_Element extends Base_Element { $billing_address = $membership->get_billing_address(); - $fields = array(); + $fields = []; - $fields['billing-title'] = array( + $fields['billing-title'] = [ 'type' => 'header', 'order' => 1, 'title' => __('Your Address', 'wp-ultimo'), 'desc' => __('Enter your billing address here. This info will be used on your invoices.', 'wp-ultimo'), 'wrapper_classes' => 'wu-col-span-2', - ); + ]; $billing_fields = $this->apply_placeholders($billing_address->get_fields()); $fields = array_merge($fields, $billing_fields); - $fields['submit'] = array( + $fields['submit'] = [ 'type' => 'submit', 'title' => __('Save Changes', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-col-span-2', - ); + ]; - $fields['membership'] = array( + $fields['membership'] = [ 'type' => 'hidden', 'value' => wu_request('membership'), - ); + ]; $form = new \WP_Ultimo\UI\Form( 'edit_site', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0 wu-grid-cols-2 wu-grid', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid wu-grid-col-span-2', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'edit_site', 'data-state' => wu_convert_to_state(), - ), - ) + ], + ] ); $form->render(); @@ -370,7 +370,7 @@ class Billing_Info_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function handle_update_billing_address() { + public function handle_update_billing_address(): void { $membership = wu_get_membership_by_hash(wu_request('membership')); @@ -399,9 +399,9 @@ class Billing_Info_Element extends Base_Element { } wp_send_json_success( - array( + [ 'redirect_url' => add_query_arg('updated', (int) $saved, $_SERVER['HTTP_REFERER']), - ) + ] ); } } diff --git a/inc/ui/class-checkout-element.php b/inc/ui/class-checkout-element.php index 83180f9..9bab239 100644 --- a/inc/ui/class-checkout-element.php +++ b/inc/ui/class-checkout-element.php @@ -146,19 +146,19 @@ class Checkout_Element extends Base_Element { */ public function fields() { - $fields = array(); + $fields = []; - $fields['header'] = array( + $fields['header'] = [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['slug'] = array( + $fields['slug'] = [ 'title' => __('Slug', 'wp-ultimo'), 'desc' => __('The checkout form slug.', 'wp-ultimo'), 'type' => 'text', - ); + ]; return $fields; } @@ -182,13 +182,13 @@ class Checkout_Element extends Base_Element { */ public function keywords() { - return array( + return [ 'WP Ultimo', 'WP Multisite WaaS', 'Checkout', 'Form', 'Cart', - ); + ]; } /** @@ -207,12 +207,12 @@ class Checkout_Element extends Base_Element { */ public function defaults() { - return array( + return [ 'slug' => 'main-form', 'step' => false, 'display_title' => false, - 'membership_limitations' => array(), - ); + 'membership_limitations' => [], + ]; } /** @@ -232,7 +232,7 @@ class Checkout_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup() { + public function setup(): void { if ($this->is_thank_you_page()) { \WP_Ultimo\UI\Thank_You_Element::get_instance()->setup(); @@ -251,7 +251,7 @@ class Checkout_Element extends Base_Element { * @param \WP_Ultimo\Models\Checkout_Form $checkout_form The current checkout form. * @return void */ - public function print_custom_css($checkout_form) { + public function print_custom_css($checkout_form): void { $scss = new Compiler(); @@ -339,9 +339,9 @@ class Checkout_Element extends Base_Element { $message = sprintf(__('Hi %s. You have a pending payment for your membership!', 'wp-ultimo'), $customer->get_display_name()); $payment_url = add_query_arg( - array( + [ 'payment' => $pending_payment->get_hash(), - ), + ], wu_get_registration_url() ); @@ -360,9 +360,9 @@ class Checkout_Element extends Base_Element { return apply_filters('wu_checkout_pending_payment_error_message', $message, $membership, $customer); } - $membership_blocked_forms = array( + $membership_blocked_forms = [ 'wu-add-new-site', - ); + ]; if ( ! $membership->is_active() && $membership->get_status() !== Membership_Status::TRIALING && in_array($atts['slug'], $membership_blocked_forms, true)) { @@ -373,20 +373,20 @@ class Checkout_Element extends Base_Element { /** * Enqueue thank you page scripts to handle resend email verification link */ - wp_register_script('wu-thank-you', wu_get_asset('thank-you.js', 'js'), array(), wu_get_version()); + wp_register_script('wu-thank-you', wu_get_asset('thank-you.js', 'js'), [], wu_get_version()); wp_localize_script( 'wu-thank-you', 'wu_thank_you', - array( + [ 'ajaxurl' => admin_url('admin-ajax.php'), 'resend_verification_email_nonce' => wp_create_nonce('wu_resend_verification_email_nonce'), 'membership_hash' => $membership->get_hash(), - 'i18n' => array( + 'i18n' => [ 'resending_verification_email' => __('Resending verification email...', 'wp-ultimo'), 'email_sent' => __('Verification email sent!', 'wp-ultimo'), - ), - ) + ], + ] ); wp_enqueue_script('wu-thank-you'); @@ -416,10 +416,10 @@ class Checkout_Element extends Base_Element { */ $allowed_forms = apply_filters( 'wu_get_membership_allowed_forms', - array( + [ 'wu-checkout', 'wu-add-new-site', - ) + ] ); if ( ! in_array($slug, $allowed_forms, true) && ! wu_request('payment')) { @@ -502,9 +502,9 @@ class Checkout_Element extends Base_Element { if ($update_url) { $update_link = add_query_arg( - array( + [ 'membership' => $membership->get_hash(), - ), + ], $update_url ); } elseif (is_admin()) { @@ -590,14 +590,14 @@ class Checkout_Element extends Base_Element { $step = $checkout_form->get_step($atts['step'], true); - $this->step = $step ? $step : current($this->steps); + $this->step = $step ?: current($this->steps); $this->step = wp_parse_args( $this->step, - array( + [ 'classes' => '', - 'fields' => array(), - ) + 'fields' => [], + ] ); $this->step_name = $this->step['id'] ?? ''; @@ -634,14 +634,14 @@ class Checkout_Element extends Base_Element { /* * Adds the product fields to keep them. */ - $final_fields['products[]'] = array( + $final_fields['products[]'] = [ 'type' => 'hidden', - 'html_attr' => array( + 'html_attr' => [ 'v-for' => '(product, index) in unique_products', 'v-model' => 'products[index]', 'v-bind:id' => '"products-" + index', - ), - ); + ], + ]; $this->inject_inline_auto_submittable_field($auto_submittable_field); @@ -649,14 +649,14 @@ class Checkout_Element extends Base_Element { return wu_get_template_contents( 'checkout/form', - array( + [ 'step' => $this->step, 'step_name' => $this->step_name, 'checkout_form_name' => $atts['slug'], 'errors' => $checkout->errors, 'display_title' => $atts['display_title'], 'final_fields' => $final_fields, - ) + ] ); } @@ -668,7 +668,7 @@ class Checkout_Element extends Base_Element { * @param string $auto_submittable_field The auto-submittable field. * @return void */ - public function inject_inline_auto_submittable_field($auto_submittable_field) { + public function inject_inline_auto_submittable_field($auto_submittable_field): void { $callback = function () use ($auto_submittable_field) { @@ -712,20 +712,20 @@ class Checkout_Element extends Base_Element { public function output($atts, $content = null) { if (wu_is_update_page()) { - $atts = array( + $atts = [ 'slug' => apply_filters('wu_membership_update_form', 'wu-checkout'), 'step' => false, 'display_title' => false, - ); + ]; } if (wu_is_new_site_page()) { - $atts = array( + $atts = [ 'slug' => apply_filters('wu_membership_new_site_form', 'wu-add-new-site'), 'step' => false, 'display_title' => false, - 'membership_limitations' => array('sites'), - ); + 'membership_limitations' => ['sites'], + ]; } if ($this->is_thank_you_page()) { @@ -739,25 +739,25 @@ class Checkout_Element extends Base_Element { */ $update_forms = apply_filters( 'wu_membership_update_forms', - array( + [ 'wu-checkout', - ) + ] ); if ( ! in_array($atts['slug'], $update_forms, true) && (wu_request('payment') || wu_request('payment_id'))) { - $atts = array( + $atts = [ 'slug' => 'wu-finish-checkout', 'step' => false, 'display_title' => false, - ); + ]; } if (wu_request('wu_form') && in_array(wu_request('wu_form'), $update_forms, true)) { - $atts = array( + $atts = [ 'slug' => wu_request('wu_form'), 'step' => false, 'display_title' => false, - ); + ]; } return $this->output_form($atts, $content); diff --git a/inc/ui/class-current-membership-element.php b/inc/ui/class-current-membership-element.php index c851ad1..b97a1a8 100644 --- a/inc/ui/class-current-membership-element.php +++ b/inc/ui/class-current-membership-element.php @@ -69,25 +69,25 @@ class Current_Membership_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { parent::init(); wu_register_form( 'see_product_details', - array( - 'render' => array($this, 'render_product_details'), + [ + 'render' => [$this, 'render_product_details'], 'capability' => 'exist', - ) + ] ); wu_register_form( 'edit_membership_product_modal', - array( - 'render' => array($this, 'render_edit_membership_product_modal'), - 'handler' => array($this, 'handle_edit_membership_product_modal'), + [ + 'render' => [$this, 'render_edit_membership_product_modal'], + 'handler' => [$this, 'handle_edit_membership_product_modal'], 'capability' => 'exist', - ) + ] ); } @@ -97,7 +97,7 @@ class Current_Membership_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { add_wubox(); } @@ -167,31 +167,31 @@ class Current_Membership_Element extends Base_Element { */ public function fields() { - $fields = array(); + $fields = []; - $fields['header'] = array( + $fields['header'] = [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['title'] = array( + $fields['title'] = [ 'type' => 'text', 'title' => __('Title', 'wp-ultimo'), 'value' => __('Your Membership', 'wp-ultimo'), 'desc' => __('Leave blank to hide the title completely.', 'wp-ultimo'), 'tooltip' => '', - ); + ]; - $fields['display_images'] = array( + $fields['display_images'] = [ 'type' => 'toggle', 'title' => __('Display Product Images?', 'wp-ultimo'), 'desc' => __('Toggle to show/hide the product images on the element.', 'wp-ultimo'), 'tooltip' => '', 'value' => 1, - ); + ]; - $fields['columns'] = array( + $fields['columns'] = [ 'type' => 'number', 'title' => __('Columns', 'wp-ultimo'), 'desc' => __('How many columns to use.', 'wp-ultimo'), @@ -199,7 +199,7 @@ class Current_Membership_Element extends Base_Element { 'value' => 2, 'min' => 1, 'max' => 5, - ); + ]; return $fields; } @@ -223,13 +223,13 @@ class Current_Membership_Element extends Base_Element { */ public function keywords() { - return array( + return [ 'WP Ultimo', 'WP Multisite WaaS', 'Membership', 'Form', 'Cart', - ); + ]; } /** @@ -248,11 +248,11 @@ class Current_Membership_Element extends Base_Element { */ public function defaults() { - return array( + return [ 'title' => __('Your Membership', 'wp-ultimo'), 'display_images' => 1, 'columns' => 2, - ); + ]; } /** @@ -261,7 +261,7 @@ class Current_Membership_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup() { + public function setup(): void { $this->membership = WP_Ultimo()->currents->get_membership(); @@ -280,7 +280,7 @@ class Current_Membership_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup_preview() { + public function setup_preview(): void { $this->membership = wu_mock_membership(); @@ -320,10 +320,10 @@ class Current_Membership_Element extends Base_Element { $swap_membership = (clone $this->membership)->swap($pending_swap_order->order); $pending_products = array_map( - fn($product) => array( + fn($product) => [ 'id' => $product['product']->get_id(), 'quantity' => $product['quantity'], - ), + ], $swap_membership->get_all_products() ); @@ -343,7 +343,7 @@ class Current_Membership_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function render_product_details() { + public function render_product_details(): void { $product = wu_get_product_by_slug(wu_request('product')); @@ -362,7 +362,7 @@ class Current_Membership_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function render_edit_membership_product_modal() { + public function render_edit_membership_product_modal(): void { $membership = wu_get_membership_by_hash(wu_request('membership')); @@ -385,21 +385,21 @@ class Current_Membership_Element extends Base_Element { } if ( ! empty($error)) { - $error_field = array( - 'error_message' => array( + $error_field = [ + 'error_message' => [ 'type' => 'note', 'desc' => $error, - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'cancel_payment_method', $error_field, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - ) + ] ); $form->render(); @@ -427,56 +427,56 @@ class Current_Membership_Element extends Base_Element { $existing_quantity = array_filter($membership->get_addon_products(), fn($item) => $item['product']->get_id() === $product->get_id())[0]['quantity']; - $fields = array( - 'membership' => array( + $fields = [ + 'membership' => [ 'type' => 'hidden', 'value' => wu_request('membership'), - ), - 'product' => array( + ], + 'product' => [ 'type' => 'hidden', 'value' => wu_request('product'), - ), - 'quantity' => array( + ], + 'quantity' => [ 'type' => 'number', 'title' => __('Quantity to Cancel', 'wp-ultimo'), 'value' => 1, 'placeholder' => 1, 'wrapper_classes' => 'wu-w-1/2', - 'html_attr' => array( + 'html_attr' => [ 'min' => 1, 'max' => $existing_quantity, 'required' => 'required', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => $existing_quantity > 1 ? 'true' : 'false', 'v-cloak' => '1', - ), - ), - 'confirm' => array( + ], + ], + 'confirm' => [ 'type' => 'toggle', 'title' => __('Confirm Product Cancellation', 'wp-ultimo'), 'desc' => __('This action can not be undone.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'confirmed', - ), - ), - 'update_note' => array( + ], + ], + 'update_note' => [ 'type' => 'note', 'desc' => $gateway_message, 'classes' => 'sm:wu-p-2 wu-bg-red-100 wu-text-red-600 wu-rounded wu-w-full', - ), - 'submit_button' => array( + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Cancel Product Subscription', 'wp-ultimo'), 'placeholder' => __('Cancel Product Subscription', 'wp-ultimo'), 'value' => 'save', 'classes' => 'wu-w-full button button-primary', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:disabled' => '!confirmed', - ), - ), - ); + ], + ], + ]; if ( ! $gateway_message) { unset($fields['update_note']); @@ -485,19 +485,19 @@ class Current_Membership_Element extends Base_Element { $form = new \WP_Ultimo\UI\Form( 'edit_membership_product', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'edit_membership_product', 'data-state' => wu_convert_to_state( - array( + [ 'confirmed' => false, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -509,7 +509,7 @@ class Current_Membership_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function handle_edit_membership_product_modal() { + public function handle_edit_membership_product_modal(): void { if ( ! wu_request('confirm')) { $error = new \WP_Error('not-confirmed', __('Please confirm the cancellation.', 'wp-ultimo')); @@ -605,9 +605,9 @@ class Current_Membership_Element extends Base_Element { } wp_send_json_success( - array( + [ 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']), - ) + ] ); } } diff --git a/inc/ui/class-current-site-element.php b/inc/ui/class-current-site-element.php index f89aa94..0991739 100644 --- a/inc/ui/class-current-site-element.php +++ b/inc/ui/class-current-site-element.php @@ -84,17 +84,17 @@ class Current_Site_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { parent::init(); wu_register_form( 'edit_site', - array( - 'render' => array($this, 'render_edit_site'), - 'handler' => array($this, 'handle_edit_site'), + [ + 'render' => [$this, 'render_edit_site'], + 'handler' => [$this, 'handle_edit_site'], 'capability' => 'exist', - ) + ] ); } @@ -148,61 +148,61 @@ class Current_Site_Element extends Base_Element { */ public function fields() { - $fields = array(); + $fields = []; - $fields['header'] = array( + $fields['header'] = [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['display_breadcrumbs'] = array( + $fields['display_breadcrumbs'] = [ 'type' => 'toggle', 'title' => __('Display Breadcrumbs?', 'wp-ultimo'), 'desc' => __('Toggle to show/hide the breadcrumbs block.', 'wp-ultimo'), 'tooltip' => '', 'value' => 1, - ); + ]; $pages = get_pages( - array( - 'exclude' => array(get_the_ID()), - ) + [ + 'exclude' => [get_the_ID()], + ] ); - $pages = $pages ? $pages : array(); + $pages = $pages ?: []; - $pages_list = array(0 => __('Current Page', 'wp-ultimo')); + $pages_list = [0 => __('Current Page', 'wp-ultimo')]; foreach ($pages as $page) { $pages_list[ $page->ID ] = $page->post_title; } - $fields['breadcrumbs_my_sites_page'] = array( + $fields['breadcrumbs_my_sites_page'] = [ 'type' => 'select', 'title' => __('My Sites Page', 'wp-ultimo'), 'value' => 0, 'desc' => __('The page with the customer sites list.', 'wp-ultimo'), 'options' => $pages_list, - ); + ]; - $fields['display_description'] = array( + $fields['display_description'] = [ 'type' => 'toggle', 'title' => __('Display Site Description?', 'wp-ultimo'), 'desc' => __('Toggle to show/hide the site description on the element.', 'wp-ultimo'), 'tooltip' => '', 'value' => 0, - ); + ]; - $fields['display_image'] = array( + $fields['display_image'] = [ 'type' => 'toggle', 'title' => __('Display Site Screenshot?', 'wp-ultimo'), 'desc' => __('Toggle to show/hide the site screenshots on the element.', 'wp-ultimo'), 'tooltip' => '', 'value' => 1, - ); + ]; - $fields['screenshot_size'] = array( + $fields['screenshot_size'] = [ 'type' => 'number', 'title' => __('Screenshot Size', 'wp-ultimo'), 'desc' => '', @@ -210,33 +210,33 @@ class Current_Site_Element extends Base_Element { 'value' => 200, 'min' => 100, 'max' => 400, - 'required' => array( + 'required' => [ 'display_image' => 1, - ), - ); + ], + ]; - $fields['screenshot_position'] = array( + $fields['screenshot_position'] = [ 'type' => 'select', 'title' => __('Screenshot Position', 'wp-ultimo'), - 'options' => array( + 'options' => [ 'right' => __('Right', 'wp-ultimo'), 'left' => __('Left', 'wp-ultimo'), - ), + ], 'desc' => '', 'tooltip' => '', 'value' => 'right', - 'required' => array( + 'required' => [ 'display_image' => 1, - ), - ); + ], + ]; - $fields['show_admin_link'] = array( + $fields['show_admin_link'] = [ 'type' => 'toggle', 'title' => __('Show Admin Link?', 'wp-ultimo'), 'desc' => __('Toggle to show/hide the WP admin link on the element.', 'wp-ultimo'), 'tooltip' => '', 'value' => 1, - ); + ]; return $fields; } @@ -260,13 +260,13 @@ class Current_Site_Element extends Base_Element { */ public function keywords() { - return array( + return [ 'WP Ultimo', 'WP Multisite WaaS', 'Site', 'Form', 'Cart', - ); + ]; } /** @@ -285,7 +285,7 @@ class Current_Site_Element extends Base_Element { */ public function defaults() { - return array( + return [ 'display_image' => 1, 'display_breadcrumbs' => 1, 'display_description' => 0, @@ -293,7 +293,7 @@ class Current_Site_Element extends Base_Element { 'screenshot_position' => 'right', 'breadcrumbs_my_sites_page' => 0, 'show_admin_link' => 1, - ); + ]; } /** @@ -302,7 +302,7 @@ class Current_Site_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup() { + public function setup(): void { $this->site = WP_Ultimo()->currents->get_site(); @@ -321,7 +321,7 @@ class Current_Site_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup_preview() { + public function setup_preview(): void { $this->site = wu_mock_site(); @@ -334,7 +334,7 @@ class Current_Site_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { add_wubox(); } @@ -354,33 +354,33 @@ class Current_Site_Element extends Base_Element { */ public function output($atts, $content = null) { - $actions = array( - 'visit_site' => array( + $actions = [ + 'visit_site' => [ 'label' => __('Visit Site', 'wp-ultimo'), 'icon_classes' => 'dashicons-wu-browser wu-align-text-bottom', 'classes' => '', 'href' => $this->site->get_active_site_url(), - ), - 'edit_site' => array( + ], + 'edit_site' => [ 'label' => __('Edit Site', 'wp-ultimo'), 'icon_classes' => 'dashicons-wu-edit wu-align-text-bottom', 'classes' => 'wubox', 'href' => wu_get_form_url( 'edit_site', - array( + [ 'site' => $this->site->get_hash(), - ) + ] ), - ), - ); + ], + ]; if ($atts['show_admin_link']) { - $actions['site_admin'] = array( + $actions['site_admin'] = [ 'label' => __('Admin Panel', 'wp-ultimo'), 'icon_classes' => 'dashicons-wu-grid wu-align-text-bottom', 'classes' => '', 'href' => get_admin_url($this->site->get_id()), - ); + ]; } $atts['actions'] = apply_filters('wu_current_site_actions', $actions, $this->site); @@ -410,59 +410,59 @@ class Current_Site_Element extends Base_Element { return ''; } - $fields = array( - 'site_title' => array( + $fields = [ + 'site_title' => [ 'type' => 'text', 'title' => __('Site Title', 'wp-ultimo'), 'placeholder' => __('e.g. My Awesome Site', 'wp-ultimo'), 'value' => $site->get_title(), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'site_title', - ), - ), - 'site_description' => array( + ], + ], + 'site_description' => [ 'type' => 'textarea', 'title' => __('Site Description', 'wp-ultimo'), 'placeholder' => __('e.g. My Awesome Site description.', 'wp-ultimo'), 'value' => $site->get_description(), - 'html_attr' => array( + 'html_attr' => [ 'rows' => 5, - ), - ), - 'site' => array( + ], + ], + 'site' => [ 'type' => 'hidden', 'value' => wu_request('site'), - ), - 'submit_button' => array( + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Save Changes', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:disabled' => '!site_title.length', - ), - ), - ); + ], + ], + ]; $fields = apply_filters('wu_form_edit_site', $fields, $this); $form = new \WP_Ultimo\UI\Form( 'edit_site', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'edit_site', 'data-state' => wu_convert_to_state( - array( + [ 'site_title' => $site->get_title(), - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -474,7 +474,7 @@ class Current_Site_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function handle_edit_site() { + public function handle_edit_site(): void { $site = wu_get_site_by_hash(wu_request('site')); @@ -497,9 +497,9 @@ class Current_Site_Element extends Base_Element { $status_desc = update_blog_option($site->get_id(), 'blogdescription', wu_request('site_description')); wp_send_json_success( - array( + [ 'redirect_url' => add_query_arg('updated', (int) $status, $_SERVER['HTTP_REFERER']), - ) + ] ); } } diff --git a/inc/ui/class-domain-mapping-element.php b/inc/ui/class-domain-mapping-element.php index 294807b..d44ec93 100644 --- a/inc/ui/class-domain-mapping-element.php +++ b/inc/ui/class-domain-mapping-element.php @@ -132,21 +132,21 @@ class Domain_Mapping_Element extends Base_Element { */ public function fields() { - $fields = array(); + $fields = []; - $fields['header'] = array( + $fields['header'] = [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['title'] = array( + $fields['title'] = [ 'type' => 'text', 'title' => __('Title', 'wp-ultimo'), 'value' => __('Domains', 'wp-ultimo'), 'desc' => __('Leave blank to hide the title completely.', 'wp-ultimo'), 'tooltip' => '', - ); + ]; return $fields; } @@ -170,11 +170,11 @@ class Domain_Mapping_Element extends Base_Element { */ public function keywords() { - return array( + return [ 'WP Ultimo', 'WP Multisite WaaS', 'Domain', - ); + ]; } /** @@ -193,9 +193,9 @@ class Domain_Mapping_Element extends Base_Element { */ public function defaults() { - return array( + return [ 'title' => __('Domains', 'wp-ultimo'), - ); + ]; } /** @@ -204,7 +204,7 @@ class Domain_Mapping_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { parent::init(); @@ -226,7 +226,7 @@ class Domain_Mapping_Element extends Base_Element { $this->set_display(false); } - add_action('plugins_loaded', array($this, 'register_forms')); + add_action('plugins_loaded', [$this, 'register_forms']); } /** @@ -235,7 +235,7 @@ class Domain_Mapping_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { add_wubox(); } @@ -246,35 +246,35 @@ class Domain_Mapping_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function register_forms() { + public function register_forms(): void { /* * Add new Domain */ wu_register_form( 'user_add_new_domain', - array( - 'render' => array($this, 'render_user_add_new_domain_modal'), - 'handler' => array($this, 'handle_user_add_new_domain_modal'), + [ + 'render' => [$this, 'render_user_add_new_domain_modal'], + 'handler' => [$this, 'handle_user_add_new_domain_modal'], 'capability' => 'exist', - ) + ] ); wu_register_form( 'user_make_domain_primary', - array( - 'render' => array($this, 'render_user_make_domain_primary_modal'), - 'handler' => array($this, 'handle_user_make_domain_primary_modal'), + [ + 'render' => [$this, 'render_user_make_domain_primary_modal'], + 'handler' => [$this, 'handle_user_make_domain_primary_modal'], 'capability' => 'exist', - ) + ] ); wu_register_form( 'user_delete_domain_modal', - array( - 'render' => array($this, 'render_user_delete_domain_modal'), - 'handler' => array($this, 'handle_user_delete_domain_modal'), + [ + 'render' => [$this, 'render_user_delete_domain_modal'], + 'handler' => [$this, 'handle_user_delete_domain_modal'], 'capability' => 'exist', - ) + ] ); } @@ -284,107 +284,107 @@ class Domain_Mapping_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function render_user_add_new_domain_modal() { + public function render_user_add_new_domain_modal(): void { $instructions = \WP_Ultimo\Managers\Domain_Manager::get_instance()->get_domain_mapping_instructions(); - $fields = array( - 'instructions_note' => array( + $fields = [ + 'instructions_note' => [ 'type' => 'note', 'desc' => sprintf('%s', __('← Back to the Instructions', 'wp-ultimo')), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => 'ready', 'v-cloak' => '1', - ), - ), - 'instructions' => array( + ], + ], + 'instructions' => [ 'type' => 'text-display', 'copy' => false, 'title' => __('Instructions', 'wp-ultimo'), 'tooltip' => '', 'display_value' => sprintf('
%s
', wpautop($instructions)), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => '!ready', 'v-cloak' => 1, - ), - ), - 'ready' => array( + ], + ], + 'ready' => [ 'type' => 'submit', 'title' => __('Next Step →', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'v-on:click.prevent' => 'ready = true', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => '!ready', 'v-cloak' => 1, - ), - ), - 'current_site' => array( + ], + ], + 'current_site' => [ 'type' => 'hidden', 'value' => wu_request('current_site'), - ), - 'domain' => array( + ], + 'domain' => [ 'type' => 'text', 'title' => __('Domain', 'wp-ultimo'), 'placeholder' => __('mydomain.com', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'ready', 'v-cloak' => 1, - ), - ), - 'primary_domain' => array( + ], + ], + 'primary_domain' => [ 'type' => 'toggle', 'title' => __('Primary Domain', 'wp-ultimo'), 'desc' => __('Check to set this domain as the primary', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'primary_domain', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'ready', 'v-cloak' => 1, - ), - ), - 'primary_note' => array( + ], + ], + 'primary_note' => [ 'type' => 'note', 'desc' => __('By making this the primary domain, we will convert the previous primary domain for this site, if one exists, into an alias domain.', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-if' => "require('primary_domain', true) && ready", 'v-cloak' => 1, - ), - ), - 'submit_button_new' => array( + ], + ], + 'submit_button_new' => [ 'type' => 'submit', 'title' => __('Add Domain', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'ready', 'v-cloak' => 1, - ), - ), - ); + ], + ], + ]; $form = new \WP_Ultimo\UI\Form( 'add_new_domain', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'add_new_domain', 'data-state' => json_encode( - array( + [ 'ready' => 0, 'primary_domain' => false, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -396,7 +396,7 @@ class Domain_Mapping_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function handle_user_add_new_domain_modal() { + public function handle_user_add_new_domain_modal(): void { $current_user_id = get_current_user_id(); @@ -416,11 +416,11 @@ class Domain_Mapping_Element extends Base_Element { * Tries to create the domain */ $domain = wu_create_domain( - array( + [ 'domain' => wu_request('domain'), 'blog_id' => absint($current_site_id), 'primary_domain' => (bool) wu_request('primary_domain'), - ) + ] ); if (is_wp_error($domain)) { @@ -429,21 +429,21 @@ class Domain_Mapping_Element extends Base_Element { if (wu_request('primary_domain')) { $old_primary_domains = wu_get_domains( - array( + [ 'primary_domain' => true, 'blog_id' => $current_site_id, - 'id__not_in' => array($domain->get_id()), + 'id__not_in' => [$domain->get_id()], 'fields' => 'ids', - ) + ] ); /* * Trigger async action to update the old primary domains. */ - do_action_ref_array('wu_async_remove_old_primary_domains', array($old_primary_domains)); + do_action_ref_array('wu_async_remove_old_primary_domains', [$old_primary_domains]); } - wu_enqueue_async_action('wu_async_process_domain_stage', array('domain_id' => $domain->get_id()), 'domain'); + wu_enqueue_async_action('wu_async_process_domain_stage', ['domain_id' => $domain->get_id()], 'domain'); /** * Triggers when a new domain mapping is added. @@ -451,9 +451,9 @@ class Domain_Mapping_Element extends Base_Element { do_action('wu_domain_created', $domain, $domain->get_site(), $domain->get_site()->get_membership()); wp_send_json_success( - array( + [ 'redirect_url' => wu_get_current_url(), - ) + ] ); exit; @@ -465,50 +465,50 @@ class Domain_Mapping_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function render_user_delete_domain_modal() { + public function render_user_delete_domain_modal(): void { - $fields = array( - 'confirm' => array( + $fields = [ + 'confirm' => [ 'type' => 'toggle', 'title' => __('Confirm Deletion', 'wp-ultimo'), 'desc' => __('This action can not be undone.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'confirmed', - ), - ), - 'domain_id' => array( + ], + ], + 'domain_id' => [ 'type' => 'hidden', 'value' => wu_request('domain_id'), - ), - 'submit_button' => array( + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Delete', 'wp-ultimo'), 'placeholder' => __('Delete', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:disabled' => '!confirmed', - ), - ), - ); + ], + ], + ]; $form = new \WP_Ultimo\UI\Form( 'user_delete_domain_modal', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'user_delete_domain_modal', 'data-state' => json_encode( - array( + [ 'confirmed' => false, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -520,7 +520,7 @@ class Domain_Mapping_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function handle_user_delete_domain_modal() { + public function handle_user_delete_domain_modal(): void { if (wu_request('user_id')) { $customer = wu_get_customer_by_user_id(wu_request('user_id')); @@ -537,9 +537,9 @@ class Domain_Mapping_Element extends Base_Element { } wp_send_json_success( - array( + [ 'redirect_url' => wu_get_current_url(), - ) + ] ); } @@ -549,50 +549,50 @@ class Domain_Mapping_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function render_user_make_domain_primary_modal() { + public function render_user_make_domain_primary_modal(): void { - $fields = array( - 'confirm' => array( + $fields = [ + 'confirm' => [ 'type' => 'toggle', 'title' => __('Confirm Action', 'wp-ultimo'), 'desc' => __('This action will also convert the previous primary domain (if any) to an alias to prevent unexpected behavior.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'confirmed', - ), - ), - 'domain_id' => array( + ], + ], + 'domain_id' => [ 'type' => 'hidden', 'value' => wu_request('domain_id'), - ), - 'submit_button' => array( + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Make it Primary', 'wp-ultimo'), 'placeholder' => __('Make it Primary', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:disabled' => '!confirmed', - ), - ), - ); + ], + ], + ]; $form = new \WP_Ultimo\UI\Form( 'user_delete_domain_modal', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'user_delete_domain_modal', 'data-state' => json_encode( - array( + [ 'confirmed' => false, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -604,7 +604,7 @@ class Domain_Mapping_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function handle_user_make_domain_primary_modal() { + public function handle_user_make_domain_primary_modal(): void { $current_site = wu_request('current_site'); @@ -622,23 +622,23 @@ class Domain_Mapping_Element extends Base_Element { } $old_primary_domains = wu_get_domains( - array( + [ 'primary_domain' => true, 'blog_id' => $domain->get_blog_id(), - 'id__not_in' => array($domain->get_id()), + 'id__not_in' => [$domain->get_id()], 'fields' => 'ids', - ) + ] ); /* * Trigger async action to update the old primary domains. */ - do_action_ref_array('wu_async_remove_old_primary_domains', array($old_primary_domains)); + do_action_ref_array('wu_async_remove_old_primary_domains', [$old_primary_domains]); wp_send_json_success( - array( + [ 'redirect_url' => is_main_site() ? wu_get_current_url() : get_admin_url($current_site), - ) + ] ); } @@ -651,7 +651,7 @@ class Domain_Mapping_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup() { + public function setup(): void { $this->site = WP_Ultimo()->currents->get_site(); @@ -673,7 +673,7 @@ class Domain_Mapping_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup_preview() { + public function setup_preview(): void { $this->site = wu_mock_site(); @@ -698,14 +698,14 @@ class Domain_Mapping_Element extends Base_Element { $current_site = $this->site; $all_domains = wu_get_domains( - array( + [ 'blog_id' => $current_site->get_id(), 'orderby' => 'primary_domain', 'order' => 'DESC', - ) + ] ); - $domains = array(); + $domains = []; foreach ($all_domains as $key => $domain) { $stage = new Domain_Stage($domain->get_stage()); @@ -720,15 +720,15 @@ class Domain_Mapping_Element extends Base_Element { $secure_message = __('Domain secured with HTTPS', 'wp-ultimo'); } - $url_atts = array( + $url_atts = [ 'current_site' => $current_site->get_id(), 'domain_id' => $domain->get_id(), - ); + ]; $delete_url = wu_get_form_url('user_delete_domain_modal', $url_atts); $primary_url = wu_get_form_url('user_make_domain_primary', $url_atts); - $domains[ $key ] = array( + $domains[ $key ] = [ 'id' => $domain->get_id(), 'domain_object' => $domain, 'domain' => $domain->get_domain(), @@ -739,22 +739,22 @@ class Domain_Mapping_Element extends Base_Element { 'secure_message' => $secure_message, 'delete_link' => $delete_url, 'primary_link' => $primary_url, - ); + ]; } - $url_atts = array( + $url_atts = [ 'current_site' => $current_site->get_ID(), - ); + ]; - $other_atts = array( + $other_atts = [ 'domains' => $domains, - 'modal' => array( + 'modal' => [ 'label' => __('Add Domain', 'wp-ultimo'), 'icon' => 'wu-circle-with-plus', 'classes' => 'wubox', 'url' => wu_get_form_url('user_add_new_domain', $url_atts), - ), - ); + ], + ]; $atts = array_merge($other_atts, $atts); diff --git a/inc/ui/class-field.php b/inc/ui/class-field.php index 74067b3..a85406b 100644 --- a/inc/ui/class-field.php +++ b/inc/ui/class-field.php @@ -25,7 +25,7 @@ class Field implements \JsonSerializable { * @since 2.0.0 * @var array */ - protected $atts = array(); + protected $atts = []; /** * Holds the value of the settings represented by this field. @@ -57,11 +57,11 @@ class Field implements \JsonSerializable { * @param array $atts Field attributes. * @return void */ - public function set_attributes($id, $atts) { + public function set_attributes($id, $atts): void { $this->atts = wp_parse_args( $atts, - array( + [ 'id' => $id, 'type' => 'text', 'icon' => 'dashicons-wu-cog', @@ -102,14 +102,14 @@ class Field implements \JsonSerializable { 'columns' => 1, 'classes' => '', 'wrapper_classes' => '', - 'html_attr' => array(), - 'wrapper_html_attr' => array(), - 'sub_fields' => array(), + 'html_attr' => [], + 'wrapper_html_attr' => [], + 'sub_fields' => [], 'prefix' => '', 'suffix' => '', - 'prefix_html_attr' => array(), - 'suffix_html_attr' => array(), - ) + 'prefix_html_attr' => [], + 'suffix_html_attr' => [], + ] ); } @@ -122,7 +122,7 @@ class Field implements \JsonSerializable { * @param mixed $value The new attribute value. * @return void */ - public function set_attribute($att, $value) { + public function set_attribute($att, $value): void { $this->atts[ $att ] = $value; } @@ -153,18 +153,18 @@ class Field implements \JsonSerializable { */ public function get_compat_template_name() { - $aliases = array( + $aliases = [ 'heading' => 'header', 'heading_collapsible' => 'header', 'select2' => 'select', 'checkbox' => 'toggle', - ); + ]; - $deprecated = array( + $deprecated = [ 'heading', 'heading_collapsible', 'select2', - ); + ]; if (array_key_exists($this->type, $aliases)) { $new_type_name = $aliases[ $this->type ]; @@ -204,7 +204,7 @@ class Field implements \JsonSerializable { $compat_name = $this->get_compat_template_name(); - $view_name = $compat_name ? $compat_name : $this->type; + $view_name = $compat_name ?: $this->type; return str_replace('_', '-', (string) $view_name); } @@ -219,7 +219,7 @@ class Field implements \JsonSerializable { */ public function __get($att) { - $allowed_callable = array( + $allowed_callable = [ 'title', 'desc', 'content', @@ -232,11 +232,11 @@ class Field implements \JsonSerializable { 'value', 'html_attr', 'img', - ); + ]; - $attr = isset($this->atts[ $att ]) ? $this->atts[ $att ] : false; + $attr = $this->atts[ $att ] ?? false; - $allow_callable_prefix = is_string($attr) && strncmp($attr, 'wu_get_', strlen('wu_get_')) === 0 && is_callable($attr); + $allow_callable_prefix = is_string($attr) && str_starts_with($attr, 'wu_get_') && is_callable($attr); $allow_callable_method = is_array($attr) && is_callable($attr); if (in_array($att, $allowed_callable, true) && ($allow_callable_prefix || $allow_callable_method || is_a($attr, \Closure::class))) { @@ -278,17 +278,17 @@ class Field implements \JsonSerializable { */ protected function sanitization_rules() { - $rules = array( + $rules = [ 'text' => 'sanitize_text_field', 'header' => '__return_null', - 'number' => array($this, 'validate_number_field'), - 'wp_editor' => array($this, 'validate_textarea_field'), - 'textarea' => array($this, 'validate_textarea_field'), + 'number' => [$this, 'validate_number_field'], + 'wp_editor' => [$this, 'validate_textarea_field'], + 'textarea' => [$this, 'validate_textarea_field'], 'checkbox' => 'wu_string_to_bool', 'multi_checkbox' => false, 'select2' => false, 'multiselect' => false, - ); + ]; return apply_filters('wu_settings_fields_sanitization_rules', $rules); } @@ -332,11 +332,11 @@ class Field implements \JsonSerializable { * @since 2.0.0 * @return void */ - public function sanitize() { + public function sanitize(): void { $rules = $this->sanitization_rules(); - $sanitize_method = isset($rules[ $this->type ]) ? $rules[ $this->type ] : $rules['text']; + $sanitize_method = $rules[ $this->type ] ?? $rules['text']; if ($sanitize_method) { $this->value = call_user_func($sanitize_method, $this->value); diff --git a/inc/ui/class-form.php b/inc/ui/class-form.php index 8020af1..d889d63 100644 --- a/inc/ui/class-form.php +++ b/inc/ui/class-form.php @@ -27,7 +27,7 @@ class Form implements \JsonSerializable { * @since 2.0.0 * @var array */ - protected $atts = array(); + protected $atts = []; /** * Holds the fields we want to display using this form. @@ -35,7 +35,7 @@ class Form implements \JsonSerializable { * @since 2.0.0 * @var array */ - protected $fields = array(); + protected $fields = []; /** * Set and the attributes passed via the constructor. @@ -46,13 +46,13 @@ class Form implements \JsonSerializable { * @param array $fields List of arrays representing the form fields. * @param array $atts Form attributes. */ - public function __construct($id, $fields, $atts = array()) { + public function __construct($id, $fields, $atts = []) { $this->atts = apply_filters( "wu_{$id}_form_atts", wp_parse_args( $atts, - array( + [ 'id' => $id, 'method' => 'post', 'before' => '', @@ -65,15 +65,15 @@ class Form implements \JsonSerializable { 'field_wrapper_classes' => false, 'field_classes' => false, 'views' => 'settings/fields', - 'variables' => array(), - 'step' => (object) array( + 'variables' => [], + 'step' => (object) [ 'classes' => '', 'element_id' => '', - ), - 'html_attr' => array( + ], + 'html_attr' => [ 'class' => '', - ), - ) + ], + ] ) ); @@ -90,12 +90,12 @@ class Form implements \JsonSerializable { */ public function __get($att) { - $allowed_callable = array( + $allowed_callable = [ 'before', 'after', - ); + ]; - $attr = isset($this->atts[ $att ]) ? $this->atts[ $att ] : false; + $attr = $this->atts[ $att ] ?? false; if (in_array($att, $allowed_callable, true) && is_callable($attr)) { $attr = call_user_func($attr, $this); @@ -134,7 +134,7 @@ class Form implements \JsonSerializable { * @param array $fields List of fields of the form. * @return void */ - public function set_fields($fields) { + public function set_fields($fields): void { $id = $this->id; @@ -160,15 +160,15 @@ class Form implements \JsonSerializable { * @since 2.0.0 * @return void */ - public function render() { + public function render(): void { $variables = array_merge( $this->variables, - array( + [ 'form_slug' => $this->id, 'form' => $this, 'step' => $this->step, - ) + ] ); ob_start(); @@ -186,10 +186,10 @@ class Form implements \JsonSerializable { wu_get_template( "{$this->views}/field-{$template_name}", - array( + [ 'field_slug' => $field_slug, 'field' => $field, - ), + ], "{$this->views}/field-text" ); } diff --git a/inc/ui/class-invoices-element.php b/inc/ui/class-invoices-element.php index 2610aef..04898d0 100644 --- a/inc/ui/class-invoices-element.php +++ b/inc/ui/class-invoices-element.php @@ -121,29 +121,29 @@ class Invoices_Element extends Base_Element { */ public function fields() { - $fields = array(); + $fields = []; - $fields['header'] = array( + $fields['header'] = [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['title'] = array( + $fields['title'] = [ 'type' => 'text', 'title' => __('Title', 'wp-ultimo'), 'value' => __('Invoices', 'wp-ultimo'), 'desc' => __('Leave blank to hide the title completely.', 'wp-ultimo'), 'tooltip' => '', - ); + ]; - $fields['limit'] = array( + $fields['limit'] = [ 'type' => 'int', 'title' => __('Limit', 'wp-ultimo'), 'value' => 10, 'desc' => __('Limit the number of invoices to show.', 'wp-ultimo'), 'tooltip' => '', - ); + ]; return $fields; } @@ -167,13 +167,13 @@ class Invoices_Element extends Base_Element { */ public function keywords() { - return array( + return [ 'WP Ultimo', 'WP Multisite WaaS', 'Invoices', 'Form', 'Cart', - ); + ]; } /** @@ -192,10 +192,10 @@ class Invoices_Element extends Base_Element { */ public function defaults() { - return array( + return [ 'title' => __('Invoices', 'wp-ultimo'), 'limit' => 0, - ); + ]; } /** @@ -204,7 +204,7 @@ class Invoices_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { wp_enqueue_script('wu-ajax-list-table'); } @@ -215,7 +215,7 @@ class Invoices_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function dependencies() { + public function dependencies(): void { if ( ! function_exists('convert_to_screen')) { require_once ABSPATH . 'wp-admin/includes/template.php'; @@ -237,7 +237,7 @@ class Invoices_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup() { + public function setup(): void { $this->membership = WP_Ultimo()->currents->get_membership(); @@ -254,7 +254,7 @@ class Invoices_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup_preview() { + public function setup_preview(): void { $this->membership = wu_mock_membership(); } diff --git a/inc/ui/class-jumper.php b/inc/ui/class-jumper.php index ca2eb05..7c41f0b 100644 --- a/inc/ui/class-jumper.php +++ b/inc/ui/class-jumper.php @@ -46,9 +46,9 @@ class Jumper { */ public function __construct() { - add_action('wp_ultimo_load', array($this, 'add_settings'), 20); + add_action('wp_ultimo_load', [$this, 'add_settings'], 20); - add_action('init', array($this, 'load_jumper')); + add_action('init', [$this, 'load_jumper']); } /** @@ -70,14 +70,14 @@ class Jumper { * @param \WP_Ultimo\Admin_Pages\Base_Admin_Page $page The current page. * @return void */ - public function add_jumper_trigger($page) { + public function add_jumper_trigger($page): void { wu_get_template( 'ui/jumper-trigger', - array( + [ 'page' => $page, 'jumper' => $this, - ) + ] ); } @@ -87,26 +87,26 @@ class Jumper { * @since 2.0.0 * @return void */ - public function load_jumper() { + public function load_jumper(): void { if ($this->is_jumper_enabled() && is_admin()) { - add_action('wu_header_right', array($this, 'add_jumper_trigger')); + add_action('wu_header_right', [$this, 'add_jumper_trigger']); - add_action('admin_init', array($this, 'rebuild_menu')); + add_action('admin_init', [$this, 'rebuild_menu']); - add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts')); + add_action('admin_enqueue_scripts', [$this, 'enqueue_scripts']); - add_action('admin_enqueue_scripts', array($this, 'enqueue_styles')); + add_action('admin_enqueue_scripts', [$this, 'enqueue_styles']); - add_action('admin_footer', array($this, 'output')); + add_action('admin_footer', [$this, 'output']); - add_filter('update_footer', array($this, 'add_jumper_footer_message'), 200); + add_filter('update_footer', [$this, 'add_jumper_footer_message'], 200); - add_action('wu_after_save_settings', array($this, 'clear_jump_cache_on_save')); + add_action('wu_after_save_settings', [$this, 'clear_jump_cache_on_save']); - add_filter('wu_link_list', array($this, 'add_wp_ultimo_extra_links')); + add_filter('wu_link_list', [$this, 'add_wp_ultimo_extra_links']); - add_filter('wu_link_list', array($this, 'add_user_custom_links')); + add_filter('wu_link_list', [$this, 'add_user_custom_links']); } } @@ -121,7 +121,7 @@ class Jumper { * @param array $settings Settings being saved. * @return void */ - public function clear_jump_cache_on_save($settings) { + public function clear_jump_cache_on_save($settings): void { if (isset($settings['jumper_custom_links'])) { delete_site_transient($this->transient_key); @@ -134,7 +134,7 @@ class Jumper { * @since 2.0.0 * @return void */ - public function rebuild_menu() { + public function rebuild_menu(): void { if (isset($_GET[ $this->reset_slug ]) && current_user_can('manage_network')) { delete_site_transient($this->transient_key); @@ -153,7 +153,7 @@ class Jumper { */ public function get_user_custom_links() { - $treated_lines = array(); + $treated_lines = []; $saved_links = wu_get_setting('jumper_custom_links'); @@ -202,7 +202,7 @@ class Jumper { public function add_wp_ultimo_extra_links($links) { if (isset($links['WP Ultimo'])) { - $settings_tabs = array( + $settings_tabs = [ 'general' => __('General', 'wp-ultimo'), 'network' => __('Network Settings', 'wp-ultimo'), 'gateways' => __('Payment Gateways', 'wp-ultimo'), @@ -212,7 +212,7 @@ class Jumper { 'tools' => __('Tools', 'wp-ultimo'), 'advanced' => __('Advanced', 'wp-ultimo'), 'activation' => __('Activation & Support', 'wp-ultimo'), - ); + ]; foreach ($settings_tabs as $tab => $tab_label) { $url = network_admin_url('admin.php?page=wp-ultimo-settings&wu-tab=' . $tab); @@ -262,12 +262,12 @@ class Jumper { $trigger_key = $this->get_defined_trigger_key(); - $keys = array( - 'win' => array('ctrl', 'alt', $trigger_key), - 'osx' => array('command', 'option', $trigger_key), - ); + $keys = [ + 'win' => ['ctrl', 'alt', $trigger_key], + 'osx' => ['command', 'option', $trigger_key], + ]; - return isset($keys[ $os ]) ? $keys[ $os ] : $keys['win']; + return $keys[ $os ] ?? $keys['win']; } /** @@ -306,22 +306,22 @@ class Jumper { * @since 2.0.0 * @return void */ - public function enqueue_scripts() { + public function enqueue_scripts(): void { - wp_register_script('wu-mousetrap', wu_get_asset('mousetrap.js', 'js/lib'), array('jquery'), wu_get_version(), true); + wp_register_script('wu-mousetrap', wu_get_asset('mousetrap.js', 'js/lib'), ['jquery'], wu_get_version(), true); - wp_register_script('wu-jumper', wu_get_asset('jumper.js', 'js'), array('jquery', 'wu-selectize', 'wu-mousetrap', 'underscore'), wu_get_version(), true); + wp_register_script('wu-jumper', wu_get_asset('jumper.js', 'js'), ['jquery', 'wu-selectize', 'wu-mousetrap', 'underscore'], wu_get_version(), true); wp_localize_script( 'wu-jumper', 'wu_jumper_vars', - array( + [ 'not_found_message' => __('Nothing found for', 'wp-ultimo'), 'trigger_key' => $this->get_defined_trigger_key(), 'network_base_url' => network_admin_url(), 'ajaxurl' => wu_ajax_url(), 'base_url' => get_admin_url(get_current_site()->blog_id), - ) + ] ); wp_enqueue_script('wu-jumper'); @@ -335,9 +335,9 @@ class Jumper { * @since 2.0.0 * @return void */ - public function enqueue_styles() { + public function enqueue_styles(): void { - wp_enqueue_style('wu-jumper', wu_get_asset('jumper.css', 'css'), array(), wu_get_version()); + wp_enqueue_style('wu-jumper', wu_get_asset('jumper.css', 'css'), [], wu_get_version()); } /** @@ -346,13 +346,13 @@ class Jumper { * @since 2.0.0 * @return void */ - public function output() { + public function output(): void { wu_get_template( 'ui/jumper', - array( + [ 'menu_groups' => $this->get_link_list(), - ) + ] ); } /** @@ -382,11 +382,11 @@ class Jumper { */ public function get_target_url($url) { - if (strpos($url, 'http') !== false) { + if (str_contains($url, 'http')) { return $url; } - if (strpos($url, '.php') !== false) { + if (str_contains($url, '.php')) { return network_admin_url($url); } @@ -410,11 +410,11 @@ class Jumper { global $menu, $submenu; // This variable is going to carry our options - $choices = array(); + $choices = []; // Prevent first run bug if ( ! is_array($menu) || ! is_array($submenu)) { - return array(); + return []; } // Loop all submenus so que can get our final @@ -457,7 +457,7 @@ class Jumper { $saved_menu = get_site_transient($this->transient_key); - return $saved_menu ? $saved_menu : array(); + return $saved_menu ?: []; } /** @@ -480,67 +480,67 @@ class Jumper { * * @return void */ - public function add_settings() { + public function add_settings(): void { wu_register_settings_section( 'tools', - array( + [ 'title' => __('Tools', 'wp-ultimo'), 'desc' => __('Tools', 'wp-ultimo'), 'icon' => 'dashicons-wu-tools', - ) + ] ); wu_register_settings_field( 'tools', 'tools_header', - array( + [ 'title' => __('Jumper', 'wp-ultimo'), 'desc' => __('Spotlight-like search bar that allows you to easily access everything on your network.', 'wp-ultimo'), 'type' => 'header', - ) + ] ); wu_register_settings_field( 'tools', 'enable_jumper', - array( + [ 'title' => __('Enable Jumper', 'wp-ultimo'), 'desc' => __('Turn this option on to make the Jumper available on your network.', 'wp-ultimo'), 'type' => 'toggle', 'default' => 1, - ) + ] ); wu_register_settings_field( 'tools', 'jumper_key', - array( + [ 'title' => __('Trigger Key', 'wp-ultimo'), 'desc' => __('Change the keyboard key used in conjunction with ctrl + alt (or cmd + option), to trigger the Jumper box.', 'wp-ultimo'), 'type' => 'text', 'default' => 'g', - 'require' => array( + 'require' => [ 'enable_jumper' => 1, - ), - ) + ], + ] ); wu_register_settings_field( 'tools', 'jumper_custom_links', - array( + [ 'title' => __('Custom Links', 'wp-ultimo'), 'desc' => __('Use this textarea to add custom links to the Jumper. Add one per line, with the format "Title : url".', 'wp-ultimo'), 'placeholder' => __('Tile of Custom Link : http://link.com', 'wp-ultimo'), 'type' => 'textarea', - 'html_attr' => array( + 'html_attr' => [ 'rows' => 4, - ), - 'require' => array( + ], + 'require' => [ 'enable_jumper' => 1, - ), - ) + ], + ] ); } diff --git a/inc/ui/class-limits-element.php b/inc/ui/class-limits-element.php index 7a9190a..8be1d9a 100644 --- a/inc/ui/class-limits-element.php +++ b/inc/ui/class-limits-element.php @@ -120,23 +120,23 @@ class Limits_Element extends Base_Element { */ public function fields() { - $fields = array(); + $fields = []; - $fields['header'] = array( + $fields['header'] = [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['title'] = array( + $fields['title'] = [ 'type' => 'text', 'title' => __('Title', 'wp-ultimo'), 'value' => __('Site Limits', 'wp-ultimo'), 'desc' => __('Leave blank to hide the title completely.', 'wp-ultimo'), 'tooltip' => '', - ); + ]; - $fields['columns'] = array( + $fields['columns'] = [ 'type' => 'number', 'title' => __('Columns', 'wp-ultimo'), 'desc' => __('How many columns to use.', 'wp-ultimo'), @@ -144,7 +144,7 @@ class Limits_Element extends Base_Element { 'value' => 1, 'min' => 1, 'max' => 10, - ); + ]; return $fields; } @@ -168,13 +168,13 @@ class Limits_Element extends Base_Element { */ public function keywords() { - return array( + return [ 'WP Ultimo', 'WP Multisite WaaS', 'Account', 'Limits', 'Quotas', - ); + ]; } /** @@ -193,10 +193,10 @@ class Limits_Element extends Base_Element { */ public function defaults() { - return array( + return [ 'columns' => 1, 'title' => __('Site Limits', 'wp-ultimo'), - ); + ]; } /** @@ -205,7 +205,7 @@ class Limits_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup() { + public function setup(): void { $this->site = WP_Ultimo()->currents->get_site(); @@ -220,7 +220,7 @@ class Limits_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup_preview() { + public function setup_preview(): void { $this->site = wu_mock_site(); } @@ -241,9 +241,9 @@ class Limits_Element extends Base_Element { public function output($atts, $content = null) { $post_types = get_post_types( - array( + [ 'public' => true, - ), + ], 'objects' ); diff --git a/inc/ui/class-login-form-element.php b/inc/ui/class-login-form-element.php index 2f98079..19dc6b2 100644 --- a/inc/ui/class-login-form-element.php +++ b/inc/ui/class-login-form-element.php @@ -61,10 +61,10 @@ class Login_Form_Element extends Base_Element { * @since 2.0.11 * @return void */ - public function init() { + public function init(): void { // Handle login redirection - add_filter('login_redirect', array($this, 'handle_redirect'), -1, 3); + add_filter('login_redirect', [$this, 'handle_redirect'], -1, 3); parent::init(); } @@ -135,160 +135,160 @@ class Login_Form_Element extends Base_Element { */ public function fields() { - $fields = array(); + $fields = []; - $fields['header'] = array( + $fields['header'] = [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['display_title'] = array( + $fields['display_title'] = [ 'type' => 'toggle', 'title' => __('Display Title?', 'wp-ultimo'), 'desc' => __('Toggle to show/hide the title element.', 'wp-ultimo'), 'tooltip' => '', 'value' => 1, - ); + ]; - $fields['title'] = array( + $fields['title'] = [ 'type' => 'text', 'title' => __('Title', 'wp-ultimo'), 'value' => __('Login', 'wp-ultimo'), 'desc' => '', 'tooltip' => '', - 'required' => array( + 'required' => [ 'display_title' => 1, - ), - ); + ], + ]; - $fields['redirect_type'] = array( + $fields['redirect_type'] = [ 'type' => 'select', 'title' => __('Redirect Type', 'wp-ultimo'), 'desc' => __('The behavior after login', 'wp-ultimo'), 'tooltip' => '', 'default' => 'default', - 'options' => array( + 'options' => [ 'default' => __('Wordpress Default', 'wp-ultimo'), 'customer_site' => __('Send To Customer Site', 'wp-ultimo'), 'main_site' => __('Send To Main Site', 'wp-ultimo'), - ), - ); + ], + ]; - $fields['customer_redirect_path'] = array( + $fields['customer_redirect_path'] = [ 'type' => 'text', 'title' => __('Customer Redirect Path', 'wp-ultimo'), 'value' => __('/wp-admin', 'wp-ultimo'), 'desc' => __('e.g. /wp-admin', 'wp-ultimo'), 'tooltip' => '', - 'required' => array( + 'required' => [ 'redirect_type' => 'customer_site', - ), - ); + ], + ]; - $fields['main_redirect_path'] = array( + $fields['main_redirect_path'] = [ 'type' => 'text', 'title' => __('Main Site Redirect Path', 'wp-ultimo'), 'value' => __('/wp-admin', 'wp-ultimo'), 'desc' => __('e.g. /wp-admin', 'wp-ultimo'), 'tooltip' => '', - 'required' => array( + 'required' => [ 'redirect_type' => 'main_site', - ), - ); + ], + ]; - $fields['header_username'] = array( + $fields['header_username'] = [ 'title' => __('Username Field', 'wp-ultimo'), 'desc' => __('Username Field', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['label_username'] = array( + $fields['label_username'] = [ 'type' => 'text', 'title' => __('Username Field Label', 'wp-ultimo'), 'value' => __('Username or Email Address', 'wp-ultimo'), 'desc' => __('Leave blank to hide.', 'wp-ultimo'), 'tooltip' => '', - ); + ]; - $fields['placeholder_username'] = array( + $fields['placeholder_username'] = [ 'type' => 'text', 'title' => __('Username Field Placeholder', 'wp-ultimo'), 'desc' => __('e.g. Username Here', 'wp-ultimo'), 'value' => '', 'tooltip' => '', - ); + ]; - $fields['header_password'] = array( + $fields['header_password'] = [ 'title' => __('Password Field', 'wp-ultimo'), 'desc' => __('Password Field', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['label_password'] = array( + $fields['label_password'] = [ 'type' => 'text', 'title' => __('Password Field Label', 'wp-ultimo'), 'value' => __('Password', 'wp-ultimo'), 'desc' => __('Leave blank to hide.', 'wp-ultimo'), 'tooltip' => '', - ); + ]; - $fields['placeholder_password'] = array( + $fields['placeholder_password'] = [ 'type' => 'text', 'title' => __('Password Field Placeholder', 'wp-ultimo'), 'desc' => __('e.g. Your Password', 'wp-ultimo'), 'value' => '', 'tooltip' => '', - ); + ]; - $fields['header_remember'] = array( + $fields['header_remember'] = [ 'title' => __('Remember Me', 'wp-ultimo'), 'desc' => __('Remember Me', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['remember'] = array( + $fields['remember'] = [ 'type' => 'toggle', 'title' => __('Display Remember Toggle?', 'wp-ultimo'), 'desc' => __('Toggle to show/hide the remember me checkbox.', 'wp-ultimo'), 'tooltip' => '', 'value' => 1, - ); + ]; - $fields['label_remember'] = array( + $fields['label_remember'] = [ 'type' => 'text', 'title' => __('Remember Me Label', 'wp-ultimo'), 'value' => __('Remember Me'), 'desc' => '', 'tooltip' => '', - 'required' => array( + 'required' => [ 'remember' => 1, - ), - ); + ], + ]; - $fields['desc_remember'] = array( + $fields['desc_remember'] = [ 'type' => 'text', 'title' => __('Remember Me Description', 'wp-ultimo'), 'value' => __('Keep me logged in for two weeks.', 'wp-ultimo'), 'desc' => '', 'tooltip' => '', - 'required' => array( + 'required' => [ 'remember' => 1, - ), - ); + ], + ]; - $fields['header_submit'] = array( + $fields['header_submit'] = [ 'title' => __('Submit Button', 'wp-ultimo'), 'desc' => __('Submit Button', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['label_log_in'] = array( + $fields['label_log_in'] = [ 'type' => 'text', 'title' => __('Submit Button Label', 'wp-ultimo'), 'value' => __('Log In', 'wp-ultimo'), 'tooltip' => '', - ); + ]; return $fields; } @@ -299,7 +299,7 @@ class Login_Form_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { wp_enqueue_style('wu-admin'); } @@ -323,12 +323,12 @@ class Login_Form_Element extends Base_Element { */ public function keywords() { - return array( + return [ 'WP Ultimo', 'WP Multisite WaaS', 'Login', 'Reset Password', - ); + ]; } /** @@ -350,7 +350,7 @@ class Login_Form_Element extends Base_Element { // Default 'redirect' value takes the user back to the request URI. $redirect_to = wu_get_current_url(); - return array( + return [ 'display_title' => 1, 'title' => __('Login', 'wp-ultimo'), @@ -379,7 +379,7 @@ class Login_Form_Element extends Base_Element { 'remember' => true, 'value_username' => '', 'value_remember' => false, // Set 'value_remember' to true to default the "Remember me" checkbox to checked. - ); + ]; } /** @@ -388,7 +388,7 @@ class Login_Form_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup() { + public function setup(): void { $this->logged = is_user_logged_in(); @@ -400,9 +400,19 @@ class Login_Form_Element extends Base_Element { if (isset($_GET['key']) && isset($_GET['login'])) { $value = sprintf('%s:%s', wp_unslash($_GET['login']), wp_unslash($_GET['key'])); - setcookie($rp_cookie, $value, 0, $rp_path, (string) COOKIE_DOMAIN, is_ssl(), true); + setcookie( + $rp_cookie, + $value, + [ + 'expires' => 0, + 'path' => $rp_path, + 'domain' => (string) COOKIE_DOMAIN, + 'secure' => is_ssl(), + 'httponly' => true, + ] + ); - wp_safe_redirect(remove_query_arg(array('key', 'login'))); + wp_safe_redirect(remove_query_arg(['key', 'login'])); exit; } @@ -518,7 +528,7 @@ class Login_Form_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup_preview() { + public function setup_preview(): void { $this->logged = false; } @@ -560,12 +570,12 @@ class Login_Form_Element extends Base_Element { * login URL so the user can re-login with the new password. */ if ($this->is_reset_confirmation_page()) { - $fields = array( - 'email-activation-instructions' => array( + $fields = [ + 'email-activation-instructions' => [ 'type' => 'note', 'desc' => __('Your password has been reset.') . ' ' . __('Log in') . '', - ), - ); + ], + ]; /* * Check if are in the email confirmation instructions page. @@ -573,16 +583,16 @@ class Login_Form_Element extends Base_Element { * If that's the case, we show the instructions. */ } elseif ($this->is_check_email_confirm()) { - $fields = array( - 'email-activation-instructions' => array( + $fields = [ + 'email-activation-instructions' => [ 'type' => 'note', 'desc' => sprintf( /* translators: %s: Link to the login page. */ __('Check your email for the confirmation link, then visit the login page.'), wp_login_url() ), - ), - ); + ], + ]; /* * Check if we are in the set new password page. @@ -594,7 +604,7 @@ class Login_Form_Element extends Base_Element { $rp_cookie = 'wp-resetpass-' . COOKIEHASH; if (isset($_COOKIE[ $rp_cookie ]) && 0 < strpos((string) $_COOKIE[ $rp_cookie ], ':')) { - list($rp_login, $rp_key) = explode(':', wp_unslash($_COOKIE[ $rp_cookie ]), 2); + [$rp_login, $rp_key] = explode(':', wp_unslash($_COOKIE[ $rp_cookie ]), 2); $user = check_password_reset_key($rp_key, $rp_login); @@ -605,58 +615,58 @@ class Login_Form_Element extends Base_Element { $user = false; } - $redirect_to = add_query_arg('password-reset', 'success', remove_query_arg(array('action', 'error'))); + $redirect_to = add_query_arg('password-reset', 'success', remove_query_arg(['action', 'error'])); - $fields = array( - 'pass1' => array( + $fields = [ + 'pass1' => [ 'type' => 'password', 'title' => __('New password'), 'placeholder' => '', 'value' => '', - 'html_attr' => array( + 'html_attr' => [ 'size' => 24, 'autocapitalize' => 'off', - ), - ), - 'pass2' => array( + ], + ], + 'pass2' => [ 'type' => 'password', 'title' => __('Confirm new password'), 'placeholder' => '', 'value' => '', - 'html_attr' => array( + 'html_attr' => [ 'size' => 24, 'autocapitalize' => 'off', - ), - ), - 'lost-password-instructions' => array( + ], + ], + 'lost-password-instructions' => [ 'type' => 'note', 'desc' => wp_get_password_hint(), 'tooltip' => '', - ), - 'action' => array( + ], + 'action' => [ 'type' => 'hidden', 'value' => 'resetpass', - ), - 'rp_key' => array( + ], + 'rp_key' => [ 'type' => 'hidden', 'value' => $rp_key, - ), - 'user_login' => array( + ], + 'user_login' => [ 'type' => 'hidden', 'value' => $rp_login, - ), - 'redirect_to' => array( + ], + 'redirect_to' => [ 'type' => 'hidden', 'value' => $redirect_to, - ), - 'wp-submit' => array( + ], + 'wp-submit' => [ 'type' => 'submit', 'title' => __('Save Password'), 'value' => __('Save Password'), 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end wu-bg-none', - ), - ); + ], + ]; /* * Checks if we are in the first reset password page, where the customer requests a reset. @@ -671,70 +681,70 @@ class Login_Form_Element extends Base_Element { $user_login = wp_unslash($user_login); } - $redirect_to = add_query_arg('checkemail', 'confirm', remove_query_arg(array('action', 'error'))); + $redirect_to = add_query_arg('checkemail', 'confirm', remove_query_arg(['action', 'error'])); - $fields = array( - 'lost-password-instructions' => array( + $fields = [ + 'lost-password-instructions' => [ 'type' => 'note', 'desc' => __('Please enter your username or email address. You will receive an email message with instructions on how to reset your password.'), 'tooltip' => '', - ), - 'user_login' => array( + ], + 'user_login' => [ 'type' => 'text', 'title' => __('Username or Email Address'), 'placeholder' => '', 'value' => $user_login, - 'html_attr' => array( + 'html_attr' => [ 'size' => 20, 'autocapitalize' => 'off', - ), - ), - 'action' => array( + ], + ], + 'action' => [ 'type' => 'hidden', 'value' => 'lostpassword', - ), - 'redirect_to' => array( + ], + 'redirect_to' => [ 'type' => 'hidden', 'value' => $redirect_to, - ), - 'wp-submit' => array( + ], + 'wp-submit' => [ 'type' => 'submit', 'title' => __('Get New Password'), 'value' => __('Get New Password'), 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end wu-bg-none', - ), - ); + ], + ]; } else { $view = 'dashboard-widgets/login-form'; - $fields = array( - 'log' => array( + $fields = [ + 'log' => [ 'type' => 'text', 'title' => $atts['label_username'], 'placeholder' => $atts['placeholder_username'], 'tooltip' => '', - ), - 'pwd' => array( + ], + 'pwd' => [ 'type' => 'password', 'title' => $atts['label_password'], 'placeholder' => $atts['placeholder_password'], 'tooltip' => '', - ), - ); + ], + ]; if ($atts['remember']) { - $fields['rememberme'] = array( + $fields['rememberme'] = [ 'type' => 'toggle', 'title' => $atts['label_remember'], 'desc' => $atts['desc_remember'], - ); + ]; } - $fields['redirect_to'] = array( + $fields['redirect_to'] = [ 'type' => 'hidden', 'value' => $atts['redirect'], - ); + ]; if (isset($_GET['redirect_to'])) { $atts['redirect_type'] = 'query_redirect'; @@ -745,25 +755,25 @@ class Login_Form_Element extends Base_Element { $fields['redirect_to']['value'] = $atts['main_redirect_path']; } - $fields['wu_login_form_redirect_type'] = array( + $fields['wu_login_form_redirect_type'] = [ 'type' => 'hidden', 'value' => $atts['redirect_type'], - ); + ]; - $fields['wp-submit'] = array( + $fields['wp-submit'] = [ 'type' => 'submit', 'title' => $atts['label_log_in'], 'value' => $atts['label_log_in'], 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end wu-bg-none', - ); + ]; - $fields['lost-password'] = array( + $fields['lost-password'] = [ 'type' => 'html', 'content' => sprintf('%s', esc_url(add_query_arg('action', 'lostpassword')), __('Lost your password?')), 'classes' => '', 'wrapper_classes' => 'wu-items-end wu-bg-none', - ); + ]; } /* @@ -775,20 +785,20 @@ class Login_Form_Element extends Base_Element { if (wu_request('error')) { $username = wu_request('username', ''); - $error_message_field = array( - 'error_message' => array( + $error_message_field = [ + 'error_message' => [ 'type' => 'note', 'desc' => Checkout_Pages::get_instance()->get_error_message(wu_request('error'), $username), - ), - ); + ], + ]; $fields = array_merge($error_message_field, $fields); } - $fields['wu_login_page_url'] = array( + $fields['wu_login_page_url'] = [ 'type' => 'hidden', 'value' => wu_get_current_url(), - ); + ]; /** * Instantiate the form for the order details. @@ -798,16 +808,16 @@ class Login_Form_Element extends Base_Element { $form = new \WP_Ultimo\UI\Form( $this->get_id(), $fields, - array( + [ 'action' => esc_url(site_url('wp-login.php', 'login_post')), 'wrap_in_form_tag' => true, 'views' => 'admin-pages/fields', 'classes' => 'wu-p-0 wu-m-0', 'field_wrapper_classes' => 'wu-box-border wu-items-center wu-flex wu-justify-between wu-py-4 wu-m-0', - 'html_attr' => array( + 'html_attr' => [ 'class' => 'wu-w-full', - ), - ) + ], + ] ); $atts['logged'] = $this->logged; diff --git a/inc/ui/class-my-sites-element.php b/inc/ui/class-my-sites-element.php index 1ef4372..c7fbffd 100644 --- a/inc/ui/class-my-sites-element.php +++ b/inc/ui/class-my-sites-element.php @@ -130,66 +130,66 @@ class My_Sites_Element extends Base_Element { */ public function fields() { - $fields = array(); + $fields = []; - $fields['header'] = array( + $fields['header'] = [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['site_manage_type'] = array( + $fields['site_manage_type'] = [ 'type' => 'select', 'title' => __('Site Manage Type', 'wp-ultimo'), 'desc' => __('The page to manage a site.', 'wp-ultimo'), 'tooltip' => '', 'default' => 'default', - 'options' => array( + 'options' => [ 'default' => __('Same Page', 'wp-ultimo'), 'wp_admin' => __('WP Admin', 'wp-ultimo'), 'custom_page' => __('Custom Page', 'wp-ultimo'), - ), - ); + ], + ]; - $fields['site_show'] = array( + $fields['site_show'] = [ 'type' => 'select', 'title' => __('Which sites to show?', 'wp-ultimo'), 'desc' => __('Select which sites should be listed for user.', 'wp-ultimo'), 'tooltip' => '', 'default' => 'all', - 'options' => array( + 'options' => [ 'all' => __('All', 'wp-ultimo'), 'owned' => __('Owned', 'wp-ultimo'), - ), - ); + ], + ]; $pages = get_pages( - array( - 'exclude' => array(get_the_ID()), - ) + [ + 'exclude' => [get_the_ID()], + ] ); - $pages = $pages ? $pages : array(); + $pages = $pages ?: []; - $pages_list = array(0 => __('Current Page', 'wp-ultimo')); + $pages_list = [0 => __('Current Page', 'wp-ultimo')]; foreach ($pages as $page) { $pages_list[ $page->ID ] = $page->post_title; } - $fields['custom_manage_page'] = array( + $fields['custom_manage_page'] = [ 'type' => 'select', 'title' => __('Manage Redirect Page', 'wp-ultimo'), 'value' => 0, 'desc' => __('The page to redirect user after select a site.', 'wp-ultimo'), 'tooltip' => '', - 'required' => array( + 'required' => [ 'site_manage_type' => 'custom_page', - ), + ], 'options' => $pages_list, - ); + ]; - $fields['columns'] = array( + $fields['columns'] = [ 'type' => 'number', 'title' => __('Columns', 'wp-ultimo'), 'desc' => __('How many columns to use.', 'wp-ultimo'), @@ -197,15 +197,15 @@ class My_Sites_Element extends Base_Element { 'value' => 4, 'min' => 1, 'max' => 5, - ); + ]; - $fields['display_images'] = array( + $fields['display_images'] = [ 'type' => 'toggle', 'title' => __('Display Site Screenshot?', 'wp-ultimo'), 'desc' => __('Toggle to show/hide the site screenshots on the element.', 'wp-ultimo'), 'tooltip' => '', 'value' => 1, - ); + ]; return $fields; } @@ -229,13 +229,13 @@ class My_Sites_Element extends Base_Element { */ public function keywords() { - return array( + return [ 'WP Ultimo', 'WP Multisite WaaS', 'Site', 'Form', 'Cart', - ); + ]; } /** @@ -254,13 +254,13 @@ class My_Sites_Element extends Base_Element { */ public function defaults() { - return array( + return [ 'columns' => 4, 'display_images' => 1, 'site_manage_type' => 'default', 'custom_manage_page' => 0, 'site_show' => 'owned', - ); + ]; } /** @@ -269,7 +269,7 @@ class My_Sites_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { wp_enqueue_style('wu-admin'); } @@ -280,7 +280,7 @@ class My_Sites_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup() { + public function setup(): void { global $wpdb; @@ -299,14 +299,14 @@ class My_Sites_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup_preview() { + public function setup_preview(): void { $this->customer = wu_mock_customer(); - $this->sites = array( + $this->sites = [ wu_mock_site(1), wu_mock_site(2), - ); + ]; } /** @@ -343,14 +343,14 @@ class My_Sites_Element extends Base_Element { return $this->sites; } - $this->sites = apply_filters('wp_ultimo_pre_my_sites_sites', array(), $show); + $this->sites = apply_filters('wp_ultimo_pre_my_sites_sites', [], $show); if ( ! empty($this->sites)) { return $this->sites; } if ( ! empty($this->customer)) { - $pending_sites = \WP_Ultimo\Models\Site::get_all_by_type('pending', array('customer_id' => $this->customer->get_id())); + $pending_sites = \WP_Ultimo\Models\Site::get_all_by_type('pending', ['customer_id' => $this->customer->get_id()]); $customer_sites = array_reduce( $this->customer->get_sites(), @@ -367,7 +367,7 @@ class My_Sites_Element extends Base_Element { $user_sites = array_reduce( $wp_user_sites, function ($user_sites, $wp_site) use ($customer_sites) { - if ( ! array_key_exists($wp_site->userblog_id, $customer_sites ?? array()) && $wp_site->userblog_id !== get_main_site_id()) { + if ( ! array_key_exists($wp_site->userblog_id, $customer_sites ?? []) && $wp_site->userblog_id !== get_main_site_id()) { $wu_site = wu_get_site($wp_site->userblog_id); $wu_site->set_membership_id(0); $user_sites[ $wp_site->userblog_id ] = $wu_site; @@ -378,9 +378,9 @@ class My_Sites_Element extends Base_Element { } $sites = array_merge( - $pending_sites ?? array(), - $customer_sites ?? array(), - $user_sites ?? array(), + $pending_sites ?? [], + $customer_sites ?? [], + $user_sites ?? [], ); $this->sites = apply_filters('wp_ultimo_after_my_sites_sites', $sites, $show); @@ -413,9 +413,9 @@ class My_Sites_Element extends Base_Element { $site_hash = \WP_Ultimo\Helpers\Hash::encode($site_id, 'site'); return add_query_arg( - array( + [ $url_param => $site_hash, - ), + ], $custom_page ); } @@ -441,9 +441,9 @@ class My_Sites_Element extends Base_Element { if ($membership) { if ($url) { return add_query_arg( - array( + [ 'membership' => $membership->get_hash(), - ), + ], $url ); } @@ -453,9 +453,9 @@ class My_Sites_Element extends Base_Element { if ( ! empty($sites)) { return add_query_arg( - array( + [ 'page' => 'add-new-site', - ), + ], get_admin_url($sites[0]->get_id()) ); } diff --git a/inc/ui/class-payment-methods-element.php b/inc/ui/class-payment-methods-element.php index a20ab75..d519a3e 100644 --- a/inc/ui/class-payment-methods-element.php +++ b/inc/ui/class-payment-methods-element.php @@ -105,29 +105,29 @@ class Payment_Methods_Element extends Base_Element { */ public function fields() { - $fields = array(); + $fields = []; - $fields['header'] = array( + $fields['header'] = [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['password_strength'] = array( + $fields['password_strength'] = [ 'type' => 'toggle', 'title' => __('Password Strength Meter', 'wp-ultimo'), 'desc' => __('Set this customer as a VIP.', 'wp-ultimo'), 'tooltip' => '', 'value' => 1, - ); + ]; - $fields['apply_styles'] = array( + $fields['apply_styles'] = [ 'type' => 'toggle', 'title' => __('Apply Styles', 'wp-ultimo'), 'desc' => __('Set this customer as a VIP.', 'wp-ultimo'), 'tooltip' => '', 'value' => 1, - ); + ]; return $fields; } @@ -151,13 +151,13 @@ class Payment_Methods_Element extends Base_Element { */ public function keywords() { - return array( + return [ 'WP Ultimo', 'WP Multisite WaaS', 'Payment Methods', 'Form', 'Cart', - ); + ]; } /** @@ -176,7 +176,7 @@ class Payment_Methods_Element extends Base_Element { */ public function defaults() { - return array(); + return []; } /** diff --git a/inc/ui/class-simple-text-element.php b/inc/ui/class-simple-text-element.php index ae63839..06535de 100644 --- a/inc/ui/class-simple-text-element.php +++ b/inc/ui/class-simple-text-element.php @@ -121,24 +121,24 @@ class Simple_Text_Element extends Base_Element { */ public function fields() { - $fields = array(); + $fields = []; - $fields['header'] = array( + $fields['header'] = [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['simple_text'] = array( + $fields['simple_text'] = [ 'type' => 'textarea', 'title' => __('Content', 'wp-ultimo'), 'placeholder' => __('E.g. Text, HTML or shortcode.', 'wp-ultimo'), 'desc' => __('You can insert plain text, HTML or a shortcode in this block.', 'wp-ultimo'), 'tooltip' => '', - 'html_attr' => array( + 'html_attr' => [ 'rows' => 6, - ), - ); + ], + ]; return $fields; } @@ -149,7 +149,7 @@ class Simple_Text_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { wp_enqueue_style('wu-admin'); } @@ -173,14 +173,14 @@ class Simple_Text_Element extends Base_Element { */ public function keywords() { - return array( + return [ 'WP Ultimo', 'WP Multisite WaaS', 'text', 'simple text', 'shortcode', 'textarea', - ); + ]; } /** @@ -199,9 +199,9 @@ class Simple_Text_Element extends Base_Element { */ public function defaults() { - return array( + return [ 'simple_text' => __('Text, HTML or shortcode.', 'wp-ultimo'), - ); + ]; } /** diff --git a/inc/ui/class-site-actions-element.php b/inc/ui/class-site-actions-element.php index 7cc0aa9..3434b03 100644 --- a/inc/ui/class-site-actions-element.php +++ b/inc/ui/class-site-actions-element.php @@ -71,7 +71,7 @@ class Site_Actions_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { add_wubox(); } @@ -141,60 +141,60 @@ class Site_Actions_Element extends Base_Element { */ public function fields() { - $fields = array(); + $fields = []; - $fields['header'] = array( + $fields['header'] = [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['show_change_password'] = array( + $fields['show_change_password'] = [ 'type' => 'toggle', 'title' => __('Show Change Password', 'wp-ultimo'), 'desc' => __('Toggle to show/hide the password link.', 'wp-ultimo'), 'tooltip' => '', 'value' => 1, - ); + ]; - $fields['show_change_default_site'] = array( + $fields['show_change_default_site'] = [ 'type' => 'toggle', 'title' => __('Show Change Default Site', 'wp-ultimo'), 'desc' => __('Toggle to show/hide the change default site link.', 'wp-ultimo'), 'tooltip' => '', 'value' => 1, - ); + ]; - $fields['show_change_payment_method'] = array( + $fields['show_change_payment_method'] = [ 'type' => 'toggle', 'title' => __('Show Change Payment Method', 'wp-ultimo'), 'desc' => __('Toggle to show/hide the option to cancel the current payment method.', 'wp-ultimo'), 'tooltip' => '', 'value' => 1, - ); + ]; $pages = get_pages( - array( - 'exclude' => array(get_the_ID()), - ) + [ + 'exclude' => [get_the_ID()], + ] ); - $pages = $pages ? $pages : array(); + $pages = $pages ?: []; - $pages_list = array(0 => __('Default', 'wp-ultimo')); + $pages_list = [0 => __('Default', 'wp-ultimo')]; foreach ($pages as $page) { $pages_list[ $page->ID ] = $page->post_title; } - $fields['redirect_after_delete'] = array( + $fields['redirect_after_delete'] = [ 'type' => 'select', 'title' => __('Redirect After Delete', 'wp-ultimo'), 'value' => 0, 'desc' => __('The page to redirect user after delete current site.', 'wp-ultimo'), 'tooltip' => '', 'options' => $pages_list, - ); + ]; return $fields; } @@ -218,13 +218,13 @@ class Site_Actions_Element extends Base_Element { */ public function keywords() { - return array( + return [ 'WP Ultimo', 'WP Multisite WaaS', 'Actions', 'Form', 'Cart', - ); + ]; } /** @@ -243,12 +243,12 @@ class Site_Actions_Element extends Base_Element { */ public function defaults() { - return array( + return [ 'show_change_password' => 1, 'show_change_default_site' => 1, 'show_change_payment_method' => 1, 'redirect_after_delete' => 0, - ); + ]; } /** @@ -257,7 +257,7 @@ class Site_Actions_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup() { + public function setup(): void { $this->site = WP_Ultimo()->currents->get_site(); @@ -280,7 +280,7 @@ class Site_Actions_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup_preview() { + public function setup_preview(): void { $this->site = wu_mock_site(); @@ -293,7 +293,7 @@ class Site_Actions_Element extends Base_Element { * @since 2.0.21 * @return void */ - public function init() { + public function init(): void { parent::init(); @@ -306,51 +306,51 @@ class Site_Actions_Element extends Base_Element { * @since 2.0.21 * @return void */ - public function register_forms() { + public function register_forms(): void { wu_register_form( 'change_password', - array( - 'render' => array($this, 'render_change_password'), - 'handler' => array($this, 'handle_change_password'), + [ + 'render' => [$this, 'render_change_password'], + 'handler' => [$this, 'handle_change_password'], 'capability' => 'exist', - ) + ] ); wu_register_form( 'delete_site', - array( - 'render' => array($this, 'render_delete_site'), - 'handler' => array($this, 'handle_delete_site'), + [ + 'render' => [$this, 'render_delete_site'], + 'handler' => [$this, 'handle_delete_site'], 'capability' => 'exist', - ) + ] ); wu_register_form( 'change_default_site', - array( - 'render' => array($this, 'render_change_default_site'), - 'handler' => array($this, 'handle_change_default_site'), + [ + 'render' => [$this, 'render_change_default_site'], + 'handler' => [$this, 'handle_change_default_site'], 'capability' => 'exist', - ) + ] ); wu_register_form( 'cancel_payment_method', - array( - 'render' => array($this, 'render_cancel_payment_method'), - 'handler' => array($this, 'handle_cancel_payment_method'), + [ + 'render' => [$this, 'render_cancel_payment_method'], + 'handler' => [$this, 'handle_cancel_payment_method'], 'capability' => 'exist', - ) + ] ); wu_register_form( 'cancel_membership', - array( - 'render' => array($this, 'render_cancel_membership'), - 'handler' => array($this, 'handle_cancel_membership'), + [ + 'render' => [$this, 'render_cancel_membership'], + 'handler' => [$this, 'handle_cancel_membership'], 'capability' => 'exist', - ) + ] ); } @@ -363,58 +363,58 @@ class Site_Actions_Element extends Base_Element { */ public function get_actions($atts) { - $actions = array(); + $actions = []; $all_blogs = get_blogs_of_user(get_current_user_id()); $is_template_switching_enabled = wu_get_setting('allow_template_switching', true); if ($is_template_switching_enabled && $this->site) { - $actions['template_switching'] = array( + $actions['template_switching'] = [ 'label' => __('Change Site Template', 'wp-ultimo'), 'icon_classes' => 'dashicons-wu-edit wu-align-middle', 'href' => add_query_arg( - array( + [ 'page' => 'wu-template-switching', - ), + ], get_admin_url($this->site->get_id()) ), - ); + ]; } if (count($all_blogs) > 1 && wu_get_isset($atts, 'show_change_default_site')) { - $actions['default_site'] = array( + $actions['default_site'] = [ 'label' => __('Change Default Site', 'wp-ultimo'), 'icon_classes' => 'dashicons-wu-edit wu-align-middle', 'classes' => 'wubox', 'href' => wu_get_form_url('change_default_site'), - ); + ]; } if (wu_get_isset($atts, 'show_change_password')) { - $actions['change_password'] = array( + $actions['change_password'] = [ 'label' => __('Change Password', 'wp-ultimo'), 'icon_classes' => 'dashicons-wu-edit wu-align-middle', 'classes' => 'wubox', 'href' => wu_get_form_url('change_password'), - ); + ]; } $payment_gateway = $this->membership ? $this->membership->get_gateway() : false; if (wu_get_isset($atts, 'show_change_payment_method') && $payment_gateway) { - $actions['cancel_payment_method'] = array( + $actions['cancel_payment_method'] = [ 'label' => __('Cancel Current Payment Method', 'wp-ultimo'), 'icon_classes' => 'dashicons-wu-edit wu-align-middle', 'classes' => 'wubox', 'href' => wu_get_form_url( 'cancel_payment_method', - array( + [ 'membership' => $this->membership->get_hash(), 'redirect_url' => wu_get_current_url(), - ) + ] ), - ); + ]; } return apply_filters('wu_element_get_site_actions', $actions, $atts, $this->site, $this->membership); @@ -429,44 +429,44 @@ class Site_Actions_Element extends Base_Element { */ public function get_danger_zone_actions($atts) { - $actions = array(); + $actions = []; if ($this->site) { $actions = array_merge( - array( - 'delete_site' => array( + [ + 'delete_site' => [ 'label' => __('Delete Site', 'wp-ultimo'), 'icon_classes' => 'dashicons-wu-edit wu-align-middle', 'classes' => 'wubox wu-text-red-500', 'href' => wu_get_form_url( 'delete_site', - array( + [ 'site' => $this->site->get_hash(), 'redirect_url' => ! $atts['redirect_after_delete'] ? false : get_page_link($atts['redirect_after_delete']), - ) + ] ), - ), - ), + ], + ], $actions ); } if ($this->membership && $this->membership->is_recurring() && $this->membership->get_status() !== Membership_Status::CANCELLED) { $actions = array_merge( - array( - 'cancel_membership' => array( + [ + 'cancel_membership' => [ 'label' => __('Cancel Membership', 'wp-ultimo'), 'icon_classes' => 'dashicons-wu-edit wu-align-middle', 'classes' => 'wubox wu-text-red-500', 'href' => wu_get_form_url( 'cancel_membership', - array( + [ 'membership' => $this->membership->get_hash(), 'redirect_url' => wu_get_current_url(), - ) + ] ), - ), - ), + ], + ], $actions ); } @@ -480,7 +480,7 @@ class Site_Actions_Element extends Base_Element { * @since 2.0.21 * @return void */ - public function render_delete_site() { + public function render_delete_site(): void { $site = wu_get_site_by_hash(wu_request('site')); @@ -497,21 +497,21 @@ class Site_Actions_Element extends Base_Element { } if ( ! empty($error)) { - $error_field = array( - 'error_message' => array( + $error_field = [ + 'error_message' => [ 'type' => 'note', 'desc' => $error, - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'change_password', $error_field, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - ) + ] ); $form->render(); @@ -519,52 +519,52 @@ class Site_Actions_Element extends Base_Element { return; } - $fields = array( - 'site' => array( + $fields = [ + 'site' => [ 'type' => 'hidden', 'value' => wu_request('site'), - ), - 'redirect_url' => array( + ], + 'redirect_url' => [ 'type' => 'hidden', 'value' => wu_request('redirect_url'), - ), - 'confirm' => array( + ], + 'confirm' => [ 'type' => 'toggle', 'title' => __('Confirm Site Deletion', 'wp-ultimo'), 'desc' => __('This action can not be undone.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'confirmed', - ), - ), - 'submit_button' => array( + ], + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Delete Site', 'wp-ultimo'), 'placeholder' => __('Delete Site', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:disabled' => '!confirmed', - ), - ), - ); + ], + ], + ]; $form = new \WP_Ultimo\UI\Form( 'change_password', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'change_password', 'data-state' => wu_convert_to_state( - array( + [ 'confirmed' => false, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -614,16 +614,16 @@ class Site_Actions_Element extends Base_Element { $redirect_url = wu_request('redirect_url'); $redirect_url = add_query_arg( - array( + [ 'site_deleted' => true, - ), + ], wu_request('redirect_url') ?? user_admin_url() ); wp_send_json_success( - array( + [ 'redirect_url' => $redirect_url, - ) + ] ); } @@ -633,49 +633,49 @@ class Site_Actions_Element extends Base_Element { * @since 2.0.21 * @return void */ - public function render_change_password() { + public function render_change_password(): void { - $fields = array( - 'password' => array( + $fields = [ + 'password' => [ 'type' => 'password', 'title' => __('Current Password', 'wp-ultimo'), 'placeholder' => __('******', 'wp-ultimo'), - ), - 'new_password' => array( + ], + 'new_password' => [ 'type' => 'password', 'title' => __('New Password', 'wp-ultimo'), 'placeholder' => __('******', 'wp-ultimo'), 'meter' => true, - ), - 'new_password_conf' => array( + ], + 'new_password_conf' => [ 'type' => 'password', 'placeholder' => __('******', 'wp-ultimo'), 'title' => __('Confirm New Password', 'wp-ultimo'), - ), - 'submit_button' => array( + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Reset Password', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ // 'v-bind:disabled' => '!confirmed', - ), - ), - ); + ], + ], + ]; $form = new \WP_Ultimo\UI\Form( 'change_password', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'change_password', 'data-state' => wu_convert_to_state(), - ), - ) + ], + ] ); $form->render(); @@ -687,7 +687,7 @@ class Site_Actions_Element extends Base_Element { * @since 2.0.21 * @return void */ - public function handle_change_password() { + public function handle_change_password(): void { $user = wp_get_current_user(); @@ -728,9 +728,9 @@ class Site_Actions_Element extends Base_Element { do_action('wp_login', $user->user_login, $user); // PHPCS:ignore wp_send_json_success( - array( + [ 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']), - ) + ] ); } @@ -740,11 +740,11 @@ class Site_Actions_Element extends Base_Element { * @since 2.0.21 * @return void */ - public function render_change_default_site() { + public function render_change_default_site(): void { $all_blogs = get_blogs_of_user(get_current_user_id()); - $option_blogs = array(); + $option_blogs = []; foreach ($all_blogs as $key => $blog) { $option_blogs[ $blog->userblog_id ] = get_home_url($blog->userblog_id); @@ -752,45 +752,45 @@ class Site_Actions_Element extends Base_Element { $primary_blog = get_user_meta(get_current_user_id(), 'primary_blog', true); - $fields = array( - 'new_primary_site' => array( + $fields = [ + 'new_primary_site' => [ 'type' => 'select', 'title' => __('Primary Site', 'wp-ultimo'), 'desc' => __('Change the primary site of your network.', 'wp-ultimo'), 'options' => $option_blogs, 'value' => $primary_blog, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'new_primary_site', - ), - ), - 'submit_button' => array( + ], + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Change Default Site', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:disabled' => 'new_primary_site === "' . $primary_blog . '"', - ), - ), - ); + ], + ], + ]; $form = new \WP_Ultimo\UI\Form( 'change_default_site', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'change_default_site', 'data-state' => wu_convert_to_state( - array( + [ 'new_primary_site' => $primary_blog, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -802,7 +802,7 @@ class Site_Actions_Element extends Base_Element { * @since 2.0.21 * @return void */ - public function handle_change_default_site() { + public function handle_change_default_site(): void { $new_primary_site = wu_request('new_primary_site'); @@ -810,9 +810,9 @@ class Site_Actions_Element extends Base_Element { update_user_meta(get_current_user_id(), 'primary_blog', $new_primary_site); wp_send_json_success( - array( + [ 'redirect_url' => add_query_arg('updated', 1, $_SERVER['HTTP_REFERER']), - ) + ] ); } @@ -827,7 +827,7 @@ class Site_Actions_Element extends Base_Element { * @since 2.1.2 * @return void */ - public function render_cancel_payment_method() { + public function render_cancel_payment_method(): void { $membership = wu_get_membership_by_hash(wu_request('membership')); @@ -844,21 +844,21 @@ class Site_Actions_Element extends Base_Element { } if ( ! empty($error)) { - $error_field = array( - 'error_message' => array( + $error_field = [ + 'error_message' => [ 'type' => 'note', 'desc' => $error, - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'cancel_payment_method', $error_field, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - ) + ] ); $form->render(); @@ -866,52 +866,52 @@ class Site_Actions_Element extends Base_Element { return; } - $fields = array( - 'membership' => array( + $fields = [ + 'membership' => [ 'type' => 'hidden', 'value' => wu_request('membership'), - ), - 'redirect_url' => array( + ], + 'redirect_url' => [ 'type' => 'hidden', 'value' => wu_request('redirect_url'), - ), - 'confirm' => array( + ], + 'confirm' => [ 'type' => 'toggle', 'title' => __('Confirm Payment Method Cancellation', 'wp-ultimo'), 'desc' => __('This action can not be undone.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'confirmed', - ), - ), - 'submit_button' => array( + ], + ], + 'submit_button' => [ 'type' => 'submit', 'title' => __('Cancel Payment Method', 'wp-ultimo'), 'placeholder' => __('Cancel Payment Method', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:disabled' => '!confirmed', - ), - ), - ); + ], + ], + ]; $form = new \WP_Ultimo\UI\Form( 'cancel_payment_method', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'cancel_payment_method', 'data-state' => wu_convert_to_state( - array( + [ 'confirmed' => false, - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -923,7 +923,7 @@ class Site_Actions_Element extends Base_Element { * @since 2.1.2 * @return void */ - public function handle_cancel_payment_method() { + public function handle_cancel_payment_method(): void { $membership = wu_get_membership_by_hash(wu_request('membership')); @@ -955,16 +955,16 @@ class Site_Actions_Element extends Base_Element { $redirect_url = wu_request('redirect_url'); $redirect_url = add_query_arg( - array( + [ 'payment_gateway_cancelled' => true, - ), + ], $redirect_url ?? user_admin_url() ); wp_send_json_success( - array( + [ 'redirect_url' => $redirect_url, - ) + ] ); } @@ -974,7 +974,7 @@ class Site_Actions_Element extends Base_Element { * @since 2.1.2 * @return void */ - public function render_cancel_membership() { + public function render_cancel_membership(): void { $membership = wu_get_membership_by_hash(wu_request('membership')); @@ -991,21 +991,21 @@ class Site_Actions_Element extends Base_Element { } if ( ! empty($error)) { - $error_field = array( - 'error_message' => array( + $error_field = [ + 'error_message' => [ 'type' => 'note', 'desc' => $error, - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'cancel_membership', $error_field, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - ) + ] ); $form->render(); @@ -1013,24 +1013,24 @@ class Site_Actions_Element extends Base_Element { return; } - $fields = array( - 'membership' => array( + $fields = [ + 'membership' => [ 'type' => 'hidden', 'value' => wu_request('membership'), - ), - 'redirect_url' => array( + ], + 'redirect_url' => [ 'type' => 'hidden', 'value' => wu_request('redirect_url'), - ), - 'cancellation_reason' => array( + ], + 'cancellation_reason' => [ 'type' => 'select', 'title' => __('Please tell us why you are cancelling.', 'wp-ultimo'), 'desc' => __('We would love your feedback.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'cancellation_reason', - ), + ], 'default' => '', - 'options' => array( + 'options' => [ '' => __('Select a reason', 'wp-ultimo'), 'unused' => __('I no longer need it', 'wp-ultimo'), 'too_expensive' => __('It\'s too expensive', 'wp-ultimo'), @@ -1039,23 +1039,23 @@ class Site_Actions_Element extends Base_Element { 'customer_service' => __('Customer support is less than expected', 'wp-ultimo'), 'too_complex' => __('Too complex', 'wp-ultimo'), 'other' => __('Other', 'wp-ultimo'), - ), - ), - 'cancellation_explanation' => array( + ], + ], + 'cancellation_explanation' => [ 'type' => 'textarea', 'title' => __('Please provide additional details.', 'wp-ultimo'), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'cancellation_reason === "other"', - ), - ), - 'confirm' => array( + ], + ], + 'confirm' => [ 'type' => 'text', 'title' => __('Type CANCEL to confirm this membership cancellation.', 'wp-ultimo'), - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'confirmation', - ), - ), - ); + ], + ], + ]; $next_charge = false; @@ -1064,42 +1064,42 @@ class Site_Actions_Element extends Base_Element { } if ($next_charge && $next_charge > time()) { - $fields['next_charge'] = array( + $fields['next_charge'] = [ 'type' => 'note', // translators: %s: Next charge date. 'desc' => sprintf(__('Your sites will stay working until %s.', 'wp-ultimo'), date_i18n(get_option('date_format'), $next_charge)), - ); + ]; } - $fields['submit_button'] = array( + $fields['submit_button'] = [ 'type' => 'submit', 'title' => __('Cancel Membership', 'wp-ultimo'), 'placeholder' => __('Cancel Membership', 'wp-ultimo'), 'value' => 'save', 'classes' => 'button button-primary wu-w-full', 'wrapper_classes' => 'wu-items-end', - 'html_attr' => array( + 'html_attr' => [ 'v-bind:disabled' => 'confirmation !== "' . __('CANCEL', 'wp-ultimo') . '" || cancellation_reason === ""', - ), - ); + ], + ]; $form = new \WP_Ultimo\UI\Form( 'cancel_membership', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array( + 'html_attr' => [ 'data-wu-app' => 'cancel_membership', 'data-state' => wu_convert_to_state( - array( + [ 'confirmation' => '', 'cancellation_reason' => '', - ) + ] ), - ), - ) + ], + ] ); $form->render(); @@ -1111,7 +1111,7 @@ class Site_Actions_Element extends Base_Element { * @since 2.1.2 * @return void */ - public function handle_cancel_membership() { + public function handle_cancel_membership(): void { $membership = wu_get_membership_by_hash(wu_request('membership')); @@ -1133,7 +1133,7 @@ class Site_Actions_Element extends Base_Element { return; } - $cancellation_options = array( + $cancellation_options = [ 'unused' => __('I no longer need it', 'wp-ultimo'), 'too_expensive' => __('It\'s too expensive', 'wp-ultimo'), 'missing_features' => __('I need more features', 'wp-ultimo'), @@ -1141,7 +1141,7 @@ class Site_Actions_Element extends Base_Element { 'customer_service' => __('Customer support is less than expected', 'wp-ultimo'), 'too_complex' => __('Too complex', 'wp-ultimo'), 'other' => wu_request('cancellation_explanation'), - ); + ]; $reason = wu_get_isset($cancellation_options, wu_request('cancellation_reason'), ''); @@ -1150,16 +1150,16 @@ class Site_Actions_Element extends Base_Element { $redirect_url = wu_request('redirect_url'); $redirect_url = add_query_arg( - array( + [ 'payment_gateway_cancelled' => true, - ), + ], ! empty($redirect_url) ? $redirect_url : user_admin_url() ); wp_send_json_success( - array( + [ 'redirect_url' => $redirect_url, - ) + ] ); } diff --git a/inc/ui/class-site-maintenance-element.php b/inc/ui/class-site-maintenance-element.php index fa3a330..1a0ffb2 100644 --- a/inc/ui/class-site-maintenance-element.php +++ b/inc/ui/class-site-maintenance-element.php @@ -52,7 +52,7 @@ class Site_Maintenance_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { if (wu_get_setting('maintenance_mode')) { parent::init(); @@ -126,28 +126,28 @@ class Site_Maintenance_Element extends Base_Element { */ public function fields() { - $fields = array(); + $fields = []; - $fields['header'] = array( + $fields['header'] = [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['title'] = array( + $fields['title'] = [ 'type' => 'text', 'title' => __('Label', 'wp-ultimo'), 'value' => __('Toggle Maintenance Mode', 'wp-ultimo'), 'placeholder' => __('e.g. Toggle Maintenance Mode', 'wp-ultimo'), 'tooltip' => '', - ); + ]; - $fields['desc'] = array( + $fields['desc'] = [ 'type' => 'textarea', 'title' => __('Description', 'wp-ultimo'), 'value' => __('Put your site on maintenance mode. When activated, the front-end will only be accessible to logged users.', 'wp-ultimo'), 'tooltip' => '', - ); + ]; return $fields; } @@ -171,12 +171,12 @@ class Site_Maintenance_Element extends Base_Element { */ public function keywords() { - return array( + return [ 'WP Ultimo', 'WP Multisite WaaS', 'Login', 'Reset Password', - ); + ]; } /** @@ -195,10 +195,10 @@ class Site_Maintenance_Element extends Base_Element { */ public function defaults() { - return array( + return [ 'title' => __('Toggle Maintenance Mode', 'wp-ultimo'), 'desc' => __('Put your site on maintenance mode. When activated, the front-end will only be accessible to logged users.', 'wp-ultimo'), - ); + ]; } /** @@ -207,7 +207,7 @@ class Site_Maintenance_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup() { + public function setup(): void { $this->site = WP_Ultimo()->currents->get_site(); @@ -224,7 +224,7 @@ class Site_Maintenance_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup_preview() { + public function setup_preview(): void { $this->site = wu_mock_site(); } @@ -235,17 +235,17 @@ class Site_Maintenance_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { - wp_register_script('wu-site-maintenance', wu_get_asset('site-maintenance.js', 'js'), array('jquery', 'wu-functions'), wu_get_version()); + wp_register_script('wu-site-maintenance', wu_get_asset('site-maintenance.js', 'js'), ['jquery', 'wu-functions'], wu_get_version()); wp_localize_script( 'wu-site-maintenance', 'wu_site_maintenance', - array( + [ 'nonce' => wp_create_nonce('wu_toggle_maintenance_mode'), 'ajaxurl' => wu_ajax_url(), - ) + ] ); wp_enqueue_script('wu-site-maintenance'); @@ -266,18 +266,18 @@ class Site_Maintenance_Element extends Base_Element { */ public function output($atts, $content = null) { - $fields = array( - 'maintenance_mode' => array( + $fields = [ + 'maintenance_mode' => [ 'type' => 'toggle', 'title' => $atts['title'], 'desc' => $atts['desc'], 'value' => wu_string_to_bool($this->site->get_meta('wu_maintenance_mode')), - ), - 'site_hash' => array( + ], + 'site_hash' => [ 'type' => 'hidden', 'value' => $this->site->get_hash(), - ), - ); + ], + ]; /** * Instantiate the form for the order details. @@ -287,12 +287,12 @@ class Site_Maintenance_Element extends Base_Element { $form = new \WP_Ultimo\UI\Form( 'maintenance-mode', $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-widget-list wu-striped wu-modal-form wu-widget-list wu-striped wu-m-0 wu-mt-0 wu-list-none wu-p-0', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - 'html_attr' => array(), - ) + 'html_attr' => [], + ] ); $atts['form'] = $form; diff --git a/inc/ui/class-template-previewer.php b/inc/ui/class-template-previewer.php index 168d74d..c0dcc15 100644 --- a/inc/ui/class-template-previewer.php +++ b/inc/ui/class-template-previewer.php @@ -42,9 +42,9 @@ class Template_Previewer { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - add_action('wp_ultimo_load', array($this, 'hooks')); + add_action('wp_ultimo_load', [$this, 'hooks']); } /** @@ -53,7 +53,7 @@ class Template_Previewer { * @since 2.0.0 * @return void */ - public function hooks() { + public function hooks(): void { if ($this->is_preview()) { /* @@ -65,19 +65,19 @@ class Template_Previewer { add_filter('wu_is_toolbox_enabled', '__return_false'); - add_filter('home_url', array($this, 'append_preview_parameter'), 9999, 4); + add_filter('home_url', [$this, 'append_preview_parameter'], 9999, 4); - add_action('send_headers', array($this, 'send_cross_origin_headers'), 1000); + add_action('send_headers', [$this, 'send_cross_origin_headers'], 1000); return; } if ($this->is_template_previewer()) { - add_action('init', array($this, 'template_previewer')); + add_action('init', [$this, 'template_previewer']); - add_action('wp_enqueue_scripts', array($this, 'register_scripts')); + add_action('wp_enqueue_scripts', [$this, 'register_scripts']); - add_action('wp_print_styles', array($this, 'remove_unnecessary_styles'), 0); + add_action('wp_print_styles', [$this, 'remove_unnecessary_styles'], 0); /** * Runs when inside the template previewer context. @@ -95,7 +95,7 @@ class Template_Previewer { * @since 2.0.9 * @return void */ - public function send_cross_origin_headers() { + public function send_cross_origin_headers(): void { global $current_site; @@ -112,7 +112,7 @@ class Template_Previewer { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { global $current_site; @@ -122,31 +122,31 @@ class Template_Previewer { $button_bg_color = wu_color($settings['button_bg_color']); $button_bg_darker = wu_color($button_bg_color->darken(4)); - wp_register_script('wu-template-previewer', wu_get_asset('template-previewer.js', 'js'), array(), wu_get_version()); + wp_register_script('wu-template-previewer', wu_get_asset('template-previewer.js', 'js'), [], wu_get_version()); wp_localize_script( 'wu-template-previewer', 'wu_template_previewer', - array( + [ 'domain' => str_replace('www.', '', (string) $current_site->domain), 'current_template' => wu_request($this->get_preview_parameter(), false), 'current_url' => wu_get_current_url(), 'query_parameter' => $this->get_preview_parameter(), - ) + ] ); wp_enqueue_script('wu-template-previewer'); - wp_enqueue_style('wu-template-previewer', wu_get_asset('template-previewer.css', 'css'), array(), wu_get_version()); + wp_enqueue_style('wu-template-previewer', wu_get_asset('template-previewer.css', 'css'), [], wu_get_version()); wp_add_inline_style( 'wu-template-previewer', wu_get_template_contents( 'dynamic-styles/template-previewer', - array( + [ 'bg_color' => $bg_color, 'button_bg_color' => $button_bg_color, - ) + ] ) ); @@ -159,15 +159,15 @@ class Template_Previewer { * @since 2.0.0 * @return void */ - public function remove_unnecessary_styles() { + public function remove_unnecessary_styles(): void { global $wp_styles; - $wp_styles->queue = array( + $wp_styles->queue = [ 'wu-admin', 'wu-template-previewer', 'dashicons', - ); + ]; } /** @@ -184,11 +184,11 @@ class Template_Previewer { */ public function append_preview_parameter($url, $path, $orig_scheme, $blog_id) { - $allowed_schemes = array( + $allowed_schemes = [ null, 'http', 'https', - ); + ]; if (in_array($orig_scheme, $allowed_schemes, true) === false) { return $url; @@ -211,9 +211,9 @@ class Template_Previewer { */ public function get_preview_url($site_id) { - $args = array( + $args = [ $this->get_preview_parameter() => $site_id, - ); + ]; if (wu_request('open')) { $args['open'] = 1; @@ -228,7 +228,7 @@ class Template_Previewer { * @since 1.5.5 * @return void */ - public function template_previewer() { + public function template_previewer(): void { global $current_site; @@ -243,18 +243,18 @@ class Template_Previewer { wp_die(__('This template is not available', 'wp-ultimo')); } - $categories = array(); + $categories = []; $settings = $this->get_settings(); - $render_parameters = array( + $render_parameters = [ 'current_site' => $current_site, 'categories' => $categories, 'selected_template' => $selected_template, 'tp' => $this, - ); + ]; - $products_ids = isset($_COOKIE['wu_selected_products']) ? explode(',', (string) $_COOKIE['wu_selected_products']) : array(); + $products_ids = isset($_COOKIE['wu_selected_products']) ? explode(',', (string) $_COOKIE['wu_selected_products']) : []; $products = array_map('wu_get_product', $products_ids); @@ -264,9 +264,9 @@ class Template_Previewer { if ( ! empty($products)) { $limits = new \WP_Ultimo\Objects\Limitations(); - list($plan, $additional_products) = wu_segregate_products($products); + [$plan, $additional_products] = wu_segregate_products($products); - $products = array_merge(array($plan), $additional_products); + $products = array_merge([$plan], $additional_products); foreach ($products as $product) { $limits = $limits->merge($product->get_limitations()); @@ -356,7 +356,7 @@ class Template_Previewer { $initial_pagenow = $GLOBALS['pagenow'] ?? ''; $GLOBALS['pagenow'] = ''; - $default_settings = array( + $default_settings = [ 'bg_color' => '#f9f9f9', 'button_bg_color' => '#00a1ff', 'logo_url' => wu_get_network_logo(), @@ -366,9 +366,9 @@ class Template_Previewer { 'use_custom_logo' => false, 'custom_logo' => false, 'enabled' => true, - ); + ]; - $saved_settings = wu_get_option(self::KEY, array()); + $saved_settings = wu_get_option(self::KEY, []); $default_settings = array_merge($default_settings, $saved_settings); diff --git a/inc/ui/class-template-switching-element.php b/inc/ui/class-template-switching-element.php index 2c53699..2ff7d20 100644 --- a/inc/ui/class-template-switching-element.php +++ b/inc/ui/class-template-switching-element.php @@ -102,9 +102,9 @@ class Template_Switching_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { - add_action('wu_ajax_wu_switch_template', array($this, 'switch_template')); + add_action('wu_ajax_wu_switch_template', [$this, 'switch_template']); parent::init(); } @@ -116,16 +116,16 @@ class Template_Switching_Element extends Base_Element { * * @return void */ - public function register_scripts() { + public function register_scripts(): void { - wp_register_script('wu-template-switching', wu_get_asset('template-switching.js', 'js'), array('jquery', 'wu-vue-apps', 'wu-selectizer', 'wp-hooks', 'wu-cookie-helpers')); + wp_register_script('wu-template-switching', wu_get_asset('template-switching.js', 'js'), ['jquery', 'wu-vue-apps', 'wu-selectizer', 'wp-hooks', 'wu-cookie-helpers']); wp_localize_script( 'wu-template-switching', 'wu_template_switching_params', - array( + [ 'ajaxurl' => wu_ajax_url(), - ) + ] ); wp_enqueue_script('wu-template-switching'); @@ -139,39 +139,39 @@ class Template_Switching_Element extends Base_Element { */ public function fields() { - $fields = array(); + $fields = []; - $fields['header'] = array( + $fields['header'] = [ 'title' => __('Layout', 'wp-ultimo'), 'desc' => __('Layout', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['template_selection_template'] = array( + $fields['template_selection_template'] = [ 'type' => 'group', 'desc' => Field_Templates_Manager::get_instance()->render_preview_block('template_selection'), - 'fields' => array( - 'template_selection_template' => array( + 'fields' => [ + 'template_selection_template' => [ 'type' => 'select', 'title' => __('Template Selector Layout', 'wp-ultimo'), 'placeholder' => __('Select your Layout', 'wp-ultimo'), 'default' => 'clean', - 'options' => array($this, 'get_template_selection_templates'), + 'options' => [$this, 'get_template_selection_templates'], 'wrapper_classes' => 'wu-flex-grow', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'template_selection_template', - ), - ), - ), - ); + ], + ], + ], + ]; - $fields['_dev_note_develop_your_own_template_1'] = array( + $fields['_dev_note_develop_your_own_template_1'] = [ 'type' => 'note', 'order' => 99, 'wrapper_classes' => 'sm:wu-p-0 sm:wu-block', 'classes' => '', 'desc' => sprintf('
%s
', __('Want to add customized template selection templates?
See how you can do that here.', 'wp-ultimo')), - ); + ]; return $fields; } @@ -185,12 +185,12 @@ class Template_Switching_Element extends Base_Element { */ public function keywords() { - return array( + return [ 'WP Ultimo', 'WP Multisite WaaS', 'Template', 'Template Switching', - ); + ]; } /** @@ -202,16 +202,16 @@ class Template_Switching_Element extends Base_Element { public function defaults() { $site_template_ids = wu_get_site_templates( - array( + [ 'fields' => 'ids', - ) + ] ); - return array( + return [ 'slug' => 'template-switching', 'template_selection_template' => 'clean', 'template_selection_sites' => implode(',', $site_template_ids), - ); + ]; } /** @@ -220,7 +220,7 @@ class Template_Switching_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup() { + public function setup(): void { $this->site = wu_get_current_site(); @@ -232,9 +232,9 @@ class Template_Switching_Element extends Base_Element { $this->membership = $this->site->get_membership(); - $this->products = array(); + $this->products = []; - $all_membership_products = array(); + $all_membership_products = []; if ($this->membership) { $all_membership_products = $this->membership->get_all_products(); @@ -254,7 +254,7 @@ class Template_Switching_Element extends Base_Element { * * @return void */ - public function setup_preview() { + public function setup_preview(): void { $this->site = wu_mock_site(); } @@ -291,14 +291,14 @@ class Template_Switching_Element extends Base_Element { if ($switch) { wp_send_json_success( - array( + [ 'redirect_url' => add_query_arg( - array( + [ 'updated' => 1, - ), + ], $_SERVER['HTTP_REFERER'] ), - ) + ] ); } } @@ -326,7 +326,7 @@ class Template_Switching_Element extends Base_Element { $template_selection_field = $filter_template_limits->maybe_filter_template_selection_options($atts); if ( ! isset($template_selection_field['sites'])) { - $template_selection_field['sites'] = array(); + $template_selection_field['sites'] = []; } $atts['template_selection_sites'] = implode(',', $template_selection_field['sites']); @@ -339,11 +339,11 @@ class Template_Switching_Element extends Base_Element { $categories = \WP_Ultimo\Models\Site::get_all_categories($sites); - $template_attributes = array( + $template_attributes = [ 'sites' => $sites, 'name' => '', 'categories' => $categories, - ); + ]; $reducer_class = new \WP_Ultimo\Checkout\Signup_Fields\Signup_Field_Template_Selection(); @@ -351,74 +351,74 @@ class Template_Switching_Element extends Base_Element { $content = $template_class ? $template_class->render_container($template_attributes, $reducer_class) : __('Template does not exist.', 'wp-ultimo'); - $checkout_fields['back_to_template_selection'] = array( + $checkout_fields['back_to_template_selection'] = [ 'type' => 'note', 'order' => 0, 'desc' => sprintf('%s', __('← Back to Template Selection', 'wp-ultimo')), - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-init:original_template_id' => $this->site->get_template_id(), 'v-show' => 'template_id != original_template_id', 'v-cloak' => '1', - ), - ); + ], + ]; - $checkout_fields['template_element'] = array( + $checkout_fields['template_element'] = [ 'type' => 'note', 'wrapper_classes' => 'wu-w-full', 'classes' => 'wu-w-full', 'desc' => $content, - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-show' => 'template_id == original_template_id', 'v-cloak' => '1', - ), - ); + ], + ]; - $checkout_fields['confirm_switch'] = array( + $checkout_fields['confirm_switch'] = [ 'type' => 'toggle', 'title' => __('Confirm template switch?', 'wp-ultimo'), 'desc' => __('Switching your current template completely overwrites the content of your site with the contents of the newly chosen template. All customizations will be lost. This action cannot be undone.', 'wp-ultimo'), 'tooltip' => '', 'wrapper_classes' => '', 'value' => 0, - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'confirm_switch', - ), - 'wrapper_html_attr' => array( + ], + 'wrapper_html_attr' => [ 'v-show' => 'template_id != 0 && template_id != original_template_id', 'v-cloak' => 1, - ), - ); + ], + ]; - $checkout_fields['submit_switch'] = array( + $checkout_fields['submit_switch'] = [ 'type' => 'link', 'display_value' => __('Process Switch', 'wp-ultimo'), 'wrapper_classes' => 'wu-text-right wu-bg-gray-100', 'classes' => 'button button-primary', - 'wrapper_html_attr' => array( + 'wrapper_html_attr' => [ 'v-cloak' => 1, 'v-show' => 'confirm_switch', 'v-on:click.prevent' => 'ready = true', - ), - ); + ], + ]; - $checkout_fields['template_id'] = array( + $checkout_fields['template_id'] = [ 'type' => 'hidden', - 'html_attr' => array( + 'html_attr' => [ 'v-model' => 'template_id', 'v-init:template_id' => $this->site->get_template_id(), - ), - ); + ], + ]; $section_slug = 'wu-template-switching-form'; $form = new Form( $section_slug, $checkout_fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-striped wu-widget-inset', 'field_wrapper_classes' => 'wu-w-full wu-box-border wu-items-center wu-flex wu-justify-between wu-p-4 wu-py-5 wu-m-0 wu-border-t wu-border-l-0 wu-border-r-0 wu-border-b-0 wu-border-gray-300 wu-border-solid', - ) + ] ); ob_start(); diff --git a/inc/ui/class-thank-you-element.php b/inc/ui/class-thank-you-element.php index 101748f..a66f397 100644 --- a/inc/ui/class-thank-you-element.php +++ b/inc/ui/class-thank-you-element.php @@ -84,7 +84,7 @@ class Thank_You_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function init() { + public function init(): void { parent::init(); } @@ -130,28 +130,28 @@ class Thank_You_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { $has_pending_site = $this->membership ? (bool) $this->membership->get_pending_site() : false; $is_publishing = $has_pending_site ? $this->membership->get_pending_site()->is_publishing() : false; - wp_register_script('wu-thank-you', wu_get_asset('thank-you.js', 'js'), array(), wu_get_version()); + wp_register_script('wu-thank-you', wu_get_asset('thank-you.js', 'js'), [], wu_get_version()); wp_localize_script( 'wu-thank-you', 'wu_thank_you', - array( + [ 'creating' => $is_publishing, 'has_pending_site' => $has_pending_site, 'next_queue' => wu_get_next_queue_run(), 'ajaxurl' => admin_url('admin-ajax.php'), 'resend_verification_email_nonce' => wp_create_nonce('wu_resend_verification_email_nonce'), 'membership_hash' => $this->membership ? $this->membership->get_hash() : false, - 'i18n' => array( + 'i18n' => [ 'resending_verification_email' => __('Resending verification email...', 'wp-ultimo'), 'email_sent' => __('Verification email sent!', 'wp-ultimo'), - ), - ) + ], + ] ); wp_enqueue_script('wu-thank-you'); @@ -207,62 +207,62 @@ class Thank_You_Element extends Base_Element { */ public function fields() { - $fields = array(); + $fields = []; - $fields['header'] = array( + $fields['header'] = [ 'title' => __('General', 'wp-ultimo'), 'desc' => __('General', 'wp-ultimo'), 'type' => 'header', - ); + ]; - $fields['title'] = array( + $fields['title'] = [ 'type' => 'text', 'title' => __('Title', 'wp-ultimo'), 'value' => __('Thank You', 'wp-ultimo'), 'desc' => __('Leave blank to hide the title completely.', 'wp-ultimo'), 'tooltip' => '', - ); + ]; - $fields['thank_you_message'] = array( + $fields['thank_you_message'] = [ 'type' => 'textarea', 'title' => __('Thank You Message', 'wp-ultimo'), 'desc' => __('Shortcodes are supported.', 'wp-ultimo'), 'value' => __('Thank you for your payment! Your transaction has been completed and a receipt for your purchase has been emailed to you.', 'wp-ultimo'), 'tooltip' => '', - 'html_attr' => array( + 'html_attr' => [ 'rows' => 4, - ), - ); + ], + ]; - $fields['title_pending'] = array( + $fields['title_pending'] = [ 'type' => 'text', 'title' => __('Title (Pending)', 'wp-ultimo'), 'value' => __('Thank You', 'wp-ultimo'), 'desc' => __('Leave blank to hide the title completely. This title is used when the payment was not yet confirmed.', 'wp-ultimo'), 'tooltip' => '', - ); + ]; - $fields['thank_you_message_pending'] = array( + $fields['thank_you_message_pending'] = [ 'type' => 'textarea', 'title' => __('Thank You Message (Pending)', 'wp-ultimo'), 'desc' => __('This content is used when the payment was not yet confirmed. Shortcodes are supported.', 'wp-ultimo'), 'value' => __('Thank you for your order! We are waiting on the payment processor to confirm your payment, which can take up to 5 minutes. We will notify you via email when your site is ready.', 'wp-ultimo'), 'tooltip' => '', - 'html_attr' => array( + 'html_attr' => [ 'rows' => 4, - ), - ); + ], + ]; - $fields['no_sites_message'] = array( + $fields['no_sites_message'] = [ 'type' => 'textarea', 'title' => __('No Sites Message', 'wp-ultimo'), 'desc' => __('A message to show if membership has no sites. Shortcodes are supported.', 'wp-ultimo'), 'value' => __('No sites found', 'wp-ultimo'), 'tooltip' => '', - 'html_attr' => array( + 'html_attr' => [ 'rows' => 4, - ), - ); + ], + ]; return $fields; } @@ -286,13 +286,13 @@ class Thank_You_Element extends Base_Element { */ public function keywords() { - return array( + return [ 'WP Ultimo', 'WP Multisite WaaS', 'Thank You', 'Form', 'Cart', - ); + ]; } /** @@ -311,13 +311,13 @@ class Thank_You_Element extends Base_Element { */ public function defaults() { - return array( + return [ 'title' => __('Thank You', 'wp-ultimo'), 'thank_you_message' => __('Thank you for your payment! Your transaction has been completed and a receipt for your purchase has been emailed to you.', 'wp-ultimo'), 'title_pending' => __('Thank You', 'wp-ultimo'), 'thank_you_message_pending' => __('Thank you for your order! We are waiting on the payment processor to confirm your payment, which can take up to 5 minutes. We will notify you via email when your site is ready.', 'wp-ultimo'), 'no_sites_message' => __('No sites found', 'wp-ultimo'), - ); + ]; } /** @@ -326,7 +326,7 @@ class Thank_You_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup() { + public function setup(): void { $this->payment = wu_get_payment_by_hash(wu_request('payment')); @@ -346,9 +346,9 @@ class Thank_You_Element extends Base_Element { $this->customer = $this->membership->get_customer(); - add_filter('document_title_parts', array($this, 'replace_page_title')); + add_filter('document_title_parts', [$this, 'replace_page_title']); - add_filter('the_title', array($this, 'maybe_replace_page_title'), 10, 2); + add_filter('the_title', [$this, 'maybe_replace_page_title'], 10, 2); } /** @@ -357,7 +357,7 @@ class Thank_You_Element extends Base_Element { * @since 2.0.0 * @return void */ - public function setup_preview() { + public function setup_preview(): void { $this->payment = wu_mock_payment(); @@ -395,7 +395,7 @@ class Thank_You_Element extends Base_Element { $conversion_snippets = $atts['checkout_form']->get_conversion_snippets(); if ( ! empty($conversion_snippets)) { - $product_ids = array(); + $product_ids = []; foreach ($this->payment->get_line_items() as $line_item) { if ($line_item->get_product_id()) { @@ -405,7 +405,7 @@ class Thank_You_Element extends Base_Element { $conversion_placeholders = apply_filters( 'wu_conversion_placeholders', - array( + [ 'CUSTOMER_ID' => $this->customer->get_id(), 'CUSTOMER_EMAIL' => $this->customer->get_email_address(), 'MEMBERSHIP_DURATION' => $this->membership->get_recurring_description(), @@ -415,7 +415,7 @@ class Thank_You_Element extends Base_Element { 'ORDER_CURRENCY' => $this->payment->get_currency(), 'ORDER_PRODUCTS' => array_values($product_ids), 'ORDER_AMOUNT' => $this->payment->get_total(), - ) + ] ); foreach ($conversion_placeholders as $placeholder => $value) { diff --git a/inc/ui/class-toolbox.php b/inc/ui/class-toolbox.php index 450afc6..7802852 100644 --- a/inc/ui/class-toolbox.php +++ b/inc/ui/class-toolbox.php @@ -28,7 +28,7 @@ class Toolbox { */ public function __construct() { - add_action('init', array($this, 'load_toolbox')); + add_action('init', [$this, 'load_toolbox']); } /** @@ -56,14 +56,14 @@ class Toolbox { * @since 2.0.0 * @return void */ - public function load_toolbox() { + public function load_toolbox(): void { if ($this->is_toolbox_enabled()) { - add_action('wp_footer', array($this, 'output')); + add_action('wp_footer', [$this, 'output']); - add_action('admin_footer', array($this, 'output')); + add_action('admin_footer', [$this, 'output']); - add_action('wp_enqueue_scripts', array($this, 'enqueue_styles')); + add_action('wp_enqueue_scripts', [$this, 'enqueue_styles']); } } @@ -73,7 +73,7 @@ class Toolbox { * @since 2.0.0 * @return void */ - public function enqueue_styles() { + public function enqueue_styles(): void { wp_enqueue_style('wu-admin'); } @@ -84,18 +84,18 @@ class Toolbox { * @since 2.0.0 * @return void */ - public function output() { + public function output(): void { $current_site = wu_get_current_site(); wu_get_template( 'ui/toolbox', - array( + [ 'toolbox' => $this, 'current_site' => $current_site, 'customer' => $current_site ? $current_site->get_customer() : false, 'membership' => $current_site ? $current_site->get_membership() : false, - ) + ] ); } } diff --git a/inc/ui/class-tours.php b/inc/ui/class-tours.php index 2bf067a..4834e5d 100644 --- a/inc/ui/class-tours.php +++ b/inc/ui/class-tours.php @@ -27,7 +27,7 @@ class Tours { * @since 2.0.0 * @var array */ - protected $tours = array(); + protected $tours = []; /** * Element construct. @@ -36,11 +36,11 @@ class Tours { */ public function __construct() { - add_action('wp_ajax_wu_mark_tour_as_finished', array($this, 'mark_as_finished')); + add_action('wp_ajax_wu_mark_tour_as_finished', [$this, 'mark_as_finished']); - add_action('admin_enqueue_scripts', array($this, 'register_scripts')); + add_action('admin_enqueue_scripts', [$this, 'register_scripts']); - add_action('in_admin_footer', array($this, 'enqueue_scripts')); + add_action('in_admin_footer', [$this, 'enqueue_scripts']); } /** @@ -49,7 +49,7 @@ class Tours { * @since 2.0.0 * @return void */ - public function mark_as_finished() { + public function mark_as_finished(): void { check_ajax_referer('wu_tour_finished', 'nonce'); @@ -70,11 +70,11 @@ class Tours { * @since 2.0.0 * @return void */ - public function register_scripts() { + public function register_scripts(): void { - WP_Ultimo()->scripts->register_script('wu-shepherd', wu_get_asset('lib/shepherd.js', 'js'), array()); + WP_Ultimo()->scripts->register_script('wu-shepherd', wu_get_asset('lib/shepherd.js', 'js'), []); - WP_Ultimo()->scripts->register_script('wu-tours', wu_get_asset('tours.js', 'js'), array('wu-shepherd', 'underscore')); + WP_Ultimo()->scripts->register_script('wu-tours', wu_get_asset('tours.js', 'js'), ['wu-shepherd', 'underscore']); } /** @@ -83,7 +83,7 @@ class Tours { * @since 2.0.0 * @return void */ - public function enqueue_scripts() { + public function enqueue_scripts(): void { if ($this->has_tours()) { wp_localize_script('wu-tours', 'wu_tours', $this->tours); @@ -91,14 +91,14 @@ class Tours { wp_localize_script( 'wu-tours', 'wu_tours_vars', - array( + [ 'ajaxurl' => wu_ajax_url(), 'nonce' => wp_create_nonce('wu_tour_finished'), - 'i18n' => array( + 'i18n' => [ 'next' => __('Next', 'wp-ultimo'), 'finish' => __('Close', 'wp-ultimo'), - ), - ) + ], + ] ); wp_enqueue_script('wu-tours'); @@ -128,7 +128,7 @@ class Tours { * @param boolean $once Whether or not we will show this more than once. * @return void */ - public function create_tour($id, $steps = array(), $once = true) { + public function create_tour($id, $steps = [], $once = true): void { if (did_action('in_admin_header')) { return; diff --git a/phpstan.neon.dist b/phpstan.neon.dist index e69de29..e2048b3 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -0,0 +1,12 @@ +includes: + - vendor/szepeviktor/phpstan-wordpress/extension.neon +parameters: + level: max + inferPrivatePropertyTypeFromConstructor: true + checkMissingIterableValueType: false + treatPhpDocTypesAsCertain: false + paths: + - / + ignoreErrors: + # Uses func_get_args() + - '/^Function apply_filters(_ref_array)? invoked with [34567] parameters, 2 required\.$/' \ No newline at end of file diff --git a/rector.php b/rector.php index e69de29..573ff7a 100644 --- a/rector.php +++ b/rector.php @@ -0,0 +1,26 @@ +withPaths( + [ + __DIR__ . '/inc', + __DIR__ . '/views', + ] + ) + ->withAutoloadPaths( + [ + __DIR__ . '/vendor/squizlabs/php_codesniffer/autoload.php', + __DIR__ . '/vendor/php-stubs/wordpress-stubs/wordpress-stubs.php', + ] + ) + ->withSkipPath(__DIR__ . '/vendor',) + ->withImportNames(false) + ->withPhpSets() + ->withRules( + [ + AddVoidReturnTypeWhereNoReturnRector::class, + ] + ); diff --git a/sunrise.php b/sunrise.php index 74e4ce6..8bd3d8f 100644 --- a/sunrise.php +++ b/sunrise.php @@ -42,7 +42,7 @@ $wu_mu_sunrise = defined('WPMU_PLUGIN_DIR') * @since 2.0.0.3 Sunrise Version. */ -foreach (array($wu_sunrise, $wu_mu_sunrise) as $wu_sunrise_file) { +foreach ([$wu_sunrise, $wu_mu_sunrise] as $wu_sunrise_file) { if (file_exists($wu_sunrise_file)) { if ($wu_sunrise_file === $wu_mu_sunrise) { diff --git a/tests/Admin_Pages/Dashboard_Admin_Page_Test.php b/tests/Admin_Pages/Dashboard_Admin_Page_Test.php index 605a79b..530460e 100644 --- a/tests/Admin_Pages/Dashboard_Admin_Page_Test.php +++ b/tests/Admin_Pages/Dashboard_Admin_Page_Test.php @@ -9,11 +9,11 @@ class Dashboard_Admin_Page_Test extends WP_UnitTestCase { /** * Test the register_scripts method enqueues the necessary scripts and styles. */ - public function test_register_scripts() { + public function test_register_scripts(): void { // Create a mock instance of Dashboard_Admin_Page and call the register_scripts method $dashboard_admin_page = $this->getMockBuilder(Dashboard_Admin_Page::class) ->disableOriginalConstructor() - ->setMethods(array('output')) + ->setMethods(['output']) ->getMock(); // Fake dates for testing diff --git a/tests/Admin_Pages/Membership_Edit_Admin_Page_Test.php b/tests/Admin_Pages/Membership_Edit_Admin_Page_Test.php index 0caaf43..d48bf71 100644 --- a/tests/Admin_Pages/Membership_Edit_Admin_Page_Test.php +++ b/tests/Admin_Pages/Membership_Edit_Admin_Page_Test.php @@ -33,7 +33,7 @@ class Membership_Edit_Admin_Page_Test extends WP_UnitTestCase { $this->swap_time = strtotime('+100 days'); $this->membership = current($faker->get_fake_data_generated('memberships')); - $cart = new Cart(array()); + $cart = new Cart([]); $this->membership->schedule_swap($cart, gmdate('Y-m-d H:i:s', $this->swap_time)); // Mock Membership_Edit_Admin_Page with dependencies and methods. $this->membership_edit_admin_page = new Membership_Edit_Admin_Page(); @@ -43,7 +43,7 @@ class Membership_Edit_Admin_Page_Test extends WP_UnitTestCase { /** * Tests that page_loaded calls add_swap_notices. */ - public function test_page_loaded_calls_add_swap_notices() { + public function test_page_loaded_calls_add_swap_notices(): void { $_REQUEST['id'] = $this->membership->get_id(); $this->membership_edit_admin_page->page_loaded(); diff --git a/tests/Gateway_Functions_Test.php b/tests/Gateway_Functions_Test.php index baacab9..f9fefb8 100644 --- a/tests/Gateway_Functions_Test.php +++ b/tests/Gateway_Functions_Test.php @@ -7,7 +7,7 @@ use WP_Ultimo\Managers\Gateway_Manager; class Gateway_Functions_Test extends \WP_UnitTestCase { - public function test_wu_get_gateway_returns_false_for_invalid_id() { + public function test_wu_get_gateway_returns_false_for_invalid_id(): void { $invalid_gateway_id = 'non_existent_gateway'; $result = wu_get_gateway($invalid_gateway_id); @@ -15,7 +15,7 @@ class Gateway_Functions_Test extends \WP_UnitTestCase { $this->assertFalse($result); } - public function test_wu_get_gateway_returns_instance_for_valid_id() { + public function test_wu_get_gateway_returns_instance_for_valid_id(): void { $valid_gateway_id = 'manual'; $gateway = wu_get_gateway($valid_gateway_id); diff --git a/tests/WP_Ultimo/Date_Functions_Test.php b/tests/WP_Ultimo/Date_Functions_Test.php index 4ca50cf..80d405f 100644 --- a/tests/WP_Ultimo/Date_Functions_Test.php +++ b/tests/WP_Ultimo/Date_Functions_Test.php @@ -3,7 +3,7 @@ namespace WP_Ultimo; class Date_Functions_Test extends \WP_UnitTestCase { - public function test_wu_get_days_ago() { + public function test_wu_get_days_ago(): void { $days = wu_get_days_ago('2024-01-01 00:00:00', '2024-01-31 00:00:00'); $this->assertEquals(-30, $days); diff --git a/tests/WP_Ultimo/Models/Discount_Code_Test.php b/tests/WP_Ultimo/Models/Discount_Code_Test.php index 4c6bf93..0838ea6 100644 --- a/tests/WP_Ultimo/Models/Discount_Code_Test.php +++ b/tests/WP_Ultimo/Models/Discount_Code_Test.php @@ -10,7 +10,7 @@ class Discount_Code_Test extends WP_UnitTestCase { /** * Tests that a valid discount code returns true. */ - public function test_is_valid_active_discount_code() { + public function test_is_valid_active_discount_code(): void { $discount_code = new Discount_Code(); $discount_code->set_active(true); @@ -22,7 +22,7 @@ class Discount_Code_Test extends WP_UnitTestCase { /** * Tests that an inactive discount code returns an error. */ - public function test_is_valid_inactive_discount_code() { + public function test_is_valid_inactive_discount_code(): void { $discount_code = new Discount_Code(); $discount_code->set_active(false); @@ -36,7 +36,7 @@ class Discount_Code_Test extends WP_UnitTestCase { /** * Tests that a discount code with max uses returns an error after being used maximum times. */ - public function test_is_valid_max_uses_exceeded() { + public function test_is_valid_max_uses_exceeded(): void { $discount_code = new Discount_Code(); $discount_code->set_active(true); $discount_code->set_max_uses(5); @@ -55,7 +55,7 @@ class Discount_Code_Test extends WP_UnitTestCase { /** * Tests that a discount code before the start date is invalid. */ - public function test_is_valid_before_start_date() { + public function test_is_valid_before_start_date(): void { $discount_code = new Discount_Code(); $discount_code->set_active(true); $discount_code->set_date_start(date('Y-m-d H:i:s', strtotime('+1 day'))); @@ -70,7 +70,7 @@ class Discount_Code_Test extends WP_UnitTestCase { /** * Tests that a discount code after the expiration date is invalid. */ - public function test_is_valid_after_expiration_date() { + public function test_is_valid_after_expiration_date(): void { $discount_code = new Discount_Code(); $discount_code->set_active(true); $discount_code->set_date_expiration(date('Y-m-d H:i:s', strtotime('-1 day'))); @@ -85,12 +85,12 @@ class Discount_Code_Test extends WP_UnitTestCase { /** * Tests that a discount code limited to specific products returns true for allowed products. */ - public function test_is_valid_for_allowed_product() { + public function test_is_valid_for_allowed_product(): void { $product_id = 123; $discount_code = new Discount_Code(); $discount_code->set_active(true); $discount_code->set_limit_products(true); - $discount_code->set_allowed_products(array($product_id)); + $discount_code->set_allowed_products([$product_id]); $result = $discount_code->is_valid($product_id); @@ -100,13 +100,13 @@ class Discount_Code_Test extends WP_UnitTestCase { /** * Tests that a discount code limited to specific products returns an error for disallowed products. */ - public function test_is_valid_for_disallowed_product() { + public function test_is_valid_for_disallowed_product(): void { $allowed_product_id = 123; $disallowed_product_id = 456; $discount_code = new Discount_Code(); $discount_code->set_active(true); $discount_code->set_limit_products(true); - $discount_code->set_allowed_products(array($allowed_product_id)); + $discount_code->set_allowed_products([$allowed_product_id]); $result = $discount_code->is_valid($disallowed_product_id); @@ -118,7 +118,7 @@ class Discount_Code_Test extends WP_UnitTestCase { /** * Tests that a discount code with no product limits returns true. */ - public function test_is_valid_no_product_limits() { + public function test_is_valid_no_product_limits(): void { $discount_code = new Discount_Code(); $discount_code->set_active(true); $discount_code->set_limit_products(false); diff --git a/tests/WP_Ultimo/Models/Domain_Test.php b/tests/WP_Ultimo/Models/Domain_Test.php index 312fa9f..730a1c3 100644 --- a/tests/WP_Ultimo/Models/Domain_Test.php +++ b/tests/WP_Ultimo/Models/Domain_Test.php @@ -9,7 +9,7 @@ class Domain_Test extends WP_UnitTestCase { /** * Test that has_valid_ssl_certificate returns true for valid SSL certificates. */ - public function test_has_valid_ssl_certificate_with_valid_certificate() { + public function test_has_valid_ssl_certificate_with_valid_certificate(): void { // Mocking a domain with a valid SSL certificate. $domain = new Domain(); $domain->set_domain('dogs.4thelols.uk'); @@ -21,7 +21,7 @@ class Domain_Test extends WP_UnitTestCase { /** * Test that has_valid_ssl_certificate returns false when the SSL certificate is invalid. */ - public function test_has_valid_ssl_certificate_with_invalid_certificate() { + public function test_has_valid_ssl_certificate_with_invalid_certificate(): void { // Mocking a domain with an invalid SSL certificate. $domain = new Domain(); $domain->set_domain('eeeeeeeeeeeeeeeeauauexample.com'); @@ -33,7 +33,7 @@ class Domain_Test extends WP_UnitTestCase { /** * Test that has_valid_ssl_certificate handles empty domain. */ - public function test_has_valid_ssl_certificate_with_empty_domain() { + public function test_has_valid_ssl_certificate_with_empty_domain(): void { // Mocking a domain with an empty value. $domain = new Domain(); $domain->set_domain(''); diff --git a/tests/WP_Ultimo/Models/Membership_Test.php b/tests/WP_Ultimo/Models/Membership_Test.php index 7ffcb42..2503efa 100644 --- a/tests/WP_Ultimo/Models/Membership_Test.php +++ b/tests/WP_Ultimo/Models/Membership_Test.php @@ -32,9 +32,9 @@ class Membership_Test extends \WP_UnitTestCase { /** * Test if the customer is allowed access to the membership. */ - public function test_is_customer_allowed() { + public function test_is_customer_allowed(): void { // Admins with 'manage_network' capability should always return true. - $admin_user_id = $this->factory()->user->create(array('role' => 'administrator')); + $admin_user_id = $this->factory()->user->create(['role' => 'administrator']); grant_super_admin($admin_user_id); wp_set_current_user($admin_user_id); $this->assertTrue($this->membership->is_customer_allowed(), 'Failed asserting that admin is allowed.'); @@ -58,7 +58,7 @@ class Membership_Test extends \WP_UnitTestCase { /** * Test adding a product to the membership. */ - public function test_add_product() { + public function test_add_product(): void { // Add a product with a specific ID and quantity. $quantity = 2; $faker = new Faker(); @@ -92,7 +92,7 @@ class Membership_Test extends \WP_UnitTestCase { /** * Test removing a product from the membership. */ - public function test_remove_product() { + public function test_remove_product(): void { // Add a product with a specific quantity. $quantity = 5; $faker = new Faker(); @@ -123,7 +123,7 @@ class Membership_Test extends \WP_UnitTestCase { /** * Test get_remaining_days_in_cycle() method. */ - public function test_get_remaining_days_in_cycle() { + public function test_get_remaining_days_in_cycle(): void { $this->membership->set_amount(12.99); // Case 1: Non-recurring membership should return 10000. $this->membership->set_recurring(false); diff --git a/tests/WP_Ultimo/Tax/Dashboard_Taxes_Tab_Test.php b/tests/WP_Ultimo/Tax/Dashboard_Taxes_Tab_Test.php index 5e53202..e987667 100644 --- a/tests/WP_Ultimo/Tax/Dashboard_Taxes_Tab_Test.php +++ b/tests/WP_Ultimo/Tax/Dashboard_Taxes_Tab_Test.php @@ -9,11 +9,11 @@ class Dashboard_Taxes_Tab_Test extends WP_UnitTestCase { /** * Test that register_scripts method registers the correct scripts. */ - public function test_register_scripts_registers_scripts() { + public function test_register_scripts_registers_scripts(): void { // Create a mock instance of Dashboard_Admin_Page and call the register_scripts method. $dashboard_admin_page = $this->getMockBuilder(Dashboard_Taxes_Tab::class) ->disableOriginalConstructor() - ->setMethods(array('output')) + ->setMethods(['output']) ->getMock(); // Execute register_scripts method. diff --git a/tests/WP_Ultimo_Test.php b/tests/WP_Ultimo_Test.php index 505c210..2fd3400 100644 --- a/tests/WP_Ultimo_Test.php +++ b/tests/WP_Ultimo_Test.php @@ -11,7 +11,7 @@ class WP_Ultimo_Test extends \WP_UnitTestCase { * * @return void */ - public function testLoadAllHelperFunctionsCorrectly() { + public function testLoadAllHelperFunctionsCorrectly(): void { // Assert that all helper functions are loaded correctly. // This is all done in the bootstrap. $this->assertTrue(function_exists('wu_to_float')); @@ -19,13 +19,13 @@ class WP_Ultimo_Test extends \WP_UnitTestCase { $this->assertTrue(function_exists('wu_get_initials')); } - public function testLoaded() { + public function testLoaded(): void { $wpUltimo = \WP_Ultimo(); $this->assertTrue($wpUltimo->version === \WP_Ultimo::VERSION); $this->assertTrue($wpUltimo->is_loaded()); } - public function testPublicProperties() { + public function testPublicProperties(): void { $wpUltimo = \WP_Ultimo(); $this->assertTrue($wpUltimo->settings instanceof Settings); $this->assertTrue($wpUltimo->helper instanceof Helper); diff --git a/uninstall.php b/uninstall.php index b74d157..d721a5d 100644 --- a/uninstall.php +++ b/uninstall.php @@ -22,13 +22,13 @@ $wu_settings = get_network_option(null, "wp-ultimo_{$wu_settings_key}"); /* * Check if we want to wipe things clean on uninstall... */ -$wu_settings_uninstall_wipe_tables = isset($wu_settings['uninstall_wipe_tables']) ? $wu_settings['uninstall_wipe_tables'] : false; +$wu_settings_uninstall_wipe_tables = $wu_settings['uninstall_wipe_tables'] ?? false; /* * Let's do it. */ if ($wu_settings_uninstall_wipe_tables) { - $wu_tables = array( + $wu_tables = [ 'customers', 'customermeta', 'discount_codes', @@ -44,7 +44,7 @@ if ($wu_settings_uninstall_wipe_tables) { 'productmeta', 'products', 'webhooks', - ); + ]; $wu_prefix_table = "{$wpdb->prefix}wu_"; diff --git a/views/about.php b/views/about.php index 066a6b8..5d00822 100644 --- a/views/about.php +++ b/views/about.php @@ -54,7 +54,6 @@ We also added a bunch of improvements and fixes that go from more translated strings for Spanish, Brazilian Portuguese, and French, to better PHP 8.2 compatibility, to webhook triggering.

- Gilberto Gil

@@ -90,9 +89,9 @@ 64, '', 'Arindo Duque', - array( + [ 'class' => 'wu-rounded-full', - ) + ] ); ?> @@ -108,50 +107,50 @@ array( + $key_people = [ + 'arindo' => [ 'email' => 'arindo@wpultimo.com', 'signature' => 'arindo.png', 'name' => 'Arindo Duque', 'position' => 'Founder and CEO', - ), - 'allyson' => array( + ], + 'allyson' => [ 'email' => 'allyson@wpultimo.com', 'signature' => '', 'name' => 'Allyson Souza', 'position' => 'Developer', - ), - 'anyssa' => array( + ], + 'anyssa' => [ 'email' => 'anyssa@wpultimo.com', 'signature' => '', 'name' => 'Anyssa Ferreira', 'position' => 'Designer', - ), - 'gustavo' => array( + ], + 'gustavo' => [ 'email' => 'gustavo@wpultimo.com', 'signature' => '', 'name' => 'Gustavo Modesto', 'position' => 'Developer', - ), - 'juliana' => array( + ], + 'juliana' => [ 'email' => 'juliana@wpultimo.com', 'signature' => '', 'name' => 'Juliana Dias Gomes', 'position' => 'Do-it-all', - ), - 'lucas-carvalho' => array( + ], + 'lucas-carvalho' => [ 'email' => 'lucas@wpultimo.com', 'signature' => '', 'name' => 'Lucas Carvalho', 'position' => 'Developer', - ), - 'yan' => array( + ], + 'yan' => [ 'email' => 'yan@wpultimo.com', 'signature' => '', 'name' => 'Yan Kairalla', 'position' => 'Developer', - ), - ); + ], + ]; ?> @@ -167,9 +166,9 @@ 64, '', 'Arindo Duque', - array( + [ 'class' => 'wu-rounded-full', - ) + ] ); ?> diff --git a/views/admin-notices.php b/views/admin-notices.php index a3f18d1..7830437 100644 --- a/views/admin-notices.php +++ b/views/admin-notices.php @@ -11,7 +11,7 @@ foreach ($notices as $key => $notice) : ?>

- ') !== false) : ?> + ')) : ?> diff --git a/views/admin-pages/fields/field-code-editor.php b/views/admin-pages/fields/field-code-editor.php index 1c4deed..8c98319 100644 --- a/views/admin-pages/fields/field-code-editor.php +++ b/views/admin-pages/fields/field-code-editor.php @@ -18,9 +18,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); ?> @@ -36,9 +36,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-description', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/admin-pages/fields/field-color-picker.php b/views/admin-pages/fields/field-color-picker.php index 2fd1683..3fa9d9c 100644 --- a/views/admin-pages/fields/field-color-picker.php +++ b/views/admin-pages/fields/field-color-picker.php @@ -18,9 +18,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); ?> @@ -40,9 +40,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-description', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/admin-pages/fields/field-dashicon.php b/views/admin-pages/fields/field-dashicon.php index d403483..b2ebfe4 100644 --- a/views/admin-pages/fields/field-dashicon.php +++ b/views/admin-pages/fields/field-dashicon.php @@ -19,9 +19,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); ?> @@ -60,9 +60,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-description', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/admin-pages/fields/field-group.php b/views/admin-pages/fields/field-group.php index c8c743e..9686f25 100644 --- a/views/admin-pages/fields/field-group.php +++ b/views/admin-pages/fields/field-group.php @@ -18,9 +18,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); ?> @@ -35,11 +35,11 @@ $form = new \WP_Ultimo\UI\Form( $field->id, $field->fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => trim('wu-flex ' . esc_attr($field->classes)), 'field_wrapper_classes' => 'wu-bg-transparent', - ) + ] ); $form->render(); diff --git a/views/admin-pages/fields/field-html.php b/views/admin-pages/fields/field-html.php index da00473..5f7050d 100644 --- a/views/admin-pages/fields/field-html.php +++ b/views/admin-pages/fields/field-html.php @@ -18,9 +18,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); /** @@ -30,9 +30,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-description', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/admin-pages/fields/field-image.php b/views/admin-pages/fields/field-image.php index 8fc51a6..807c9fc 100644 --- a/views/admin-pages/fields/field-image.php +++ b/views/admin-pages/fields/field-image.php @@ -35,9 +35,9 @@ $content_wrapper_classes = $field->content_wrapper_classes */ wu_get_template( 'admin-pages/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); ?> @@ -53,9 +53,9 @@ $content_wrapper_classes = $field->content_wrapper_classes */ wu_get_template( 'admin-pages/fields/partials/field-description', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/admin-pages/fields/field-link.php b/views/admin-pages/fields/field-link.php index 437a180..d6fab7c 100644 --- a/views/admin-pages/fields/field-link.php +++ b/views/admin-pages/fields/field-link.php @@ -18,9 +18,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); ?> @@ -40,9 +40,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-description', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/admin-pages/fields/field-multiselect.php b/views/admin-pages/fields/field-multiselect.php index f93546a..5a1b8a7 100644 --- a/views/admin-pages/fields/field-multiselect.php +++ b/views/admin-pages/fields/field-multiselect.php @@ -21,9 +21,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); /** @@ -33,9 +33,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-description', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/admin-pages/fields/field-note.php b/views/admin-pages/fields/field-note.php index 3468807..8b7900d 100644 --- a/views/admin-pages/fields/field-note.php +++ b/views/admin-pages/fields/field-note.php @@ -16,9 +16,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/admin-pages/fields/field-repeater.php b/views/admin-pages/fields/field-repeater.php index 50d1905..2568d11 100644 --- a/views/admin-pages/fields/field-repeater.php +++ b/views/admin-pages/fields/field-repeater.php @@ -22,7 +22,7 @@ */ wu_get_template( 'admin-pages/fields/partials/field-title', - array('field' => $field) + ['field' => $field] ); ?> @@ -35,9 +35,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-description', - array( + [ 'field' => $field, - ) + ] ); ?> @@ -51,7 +51,7 @@ values && $field->value) { - $_values = array(); + $_values = []; $columns = array_keys($field->value); $values = $field->value; @@ -65,7 +65,7 @@ if (! $field->values && $field->value) { $field->values = $_values; } -$fields = array(); +$fields = []; foreach ($field->fields as $key => $value) { $fields[ $key . '[]' ] = $field->fields[ $key ]; @@ -91,11 +91,11 @@ if (is_array($field->values)) { (new \WP_Ultimo\UI\Form( $field->id, $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-flex', 'field_wrapper_classes' => 'wu-bg-transparent', - ) + ] ))->render(); ?>
@@ -118,11 +118,11 @@ if (is_array($field->values)) { (new \WP_Ultimo\UI\Form( $field->id, $fields, - array( + [ 'views' => 'admin-pages/fields', 'classes' => 'wu-flex', 'field_wrapper_classes' => 'wu-bg-transparent', - ) + ] ))->render(); ?> diff --git a/views/admin-pages/fields/field-select-icon.php b/views/admin-pages/fields/field-select-icon.php index 6b12ab3..659aa5d 100644 --- a/views/admin-pages/fields/field-select-icon.php +++ b/views/admin-pages/fields/field-select-icon.php @@ -18,9 +18,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); /** @@ -30,9 +30,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-description', - array( + [ 'field' => $field, - ) + ] ); ?> @@ -48,9 +48,9 @@ */ $option = wp_parse_args( $option, - array( + [ 'tooltip' => '', - ) + ] ); ?> diff --git a/views/admin-pages/fields/field-select.php b/views/admin-pages/fields/field-select.php index db56e1e..b815b80 100644 --- a/views/admin-pages/fields/field-select.php +++ b/views/admin-pages/fields/field-select.php @@ -18,9 +18,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); ?> @@ -54,9 +54,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-description', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/admin-pages/fields/field-small-header.php b/views/admin-pages/fields/field-small-header.php index 10c76d4..30f8694 100644 --- a/views/admin-pages/fields/field-small-header.php +++ b/views/admin-pages/fields/field-small-header.php @@ -18,9 +18,9 @@ */ wu_get_template( 'admin-pages/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/admin-pages/fields/field-submit.php b/views/admin-pages/fields/field-submit.php index 04dbbb6..d7d5c36 100644 --- a/views/admin-pages/fields/field-submit.php +++ b/views/admin-pages/fields/field-submit.php @@ -5,7 +5,7 @@ * @since 2.0.0 */ ?> -
  • get_wrapper_html_attributes(); ?>> +
  • get_wrapper_html_attributes(); ?>>
  • @@ -101,7 +101,7 @@ get_memberships())) { ?> - + %s', __('Switch To', 'wp-ultimo'), $is_modal_switch_to, \WP_Ultimo\User_Switching::get_instance()->render($item->get_user_id()), __('Switch To', 'wp-ultimo')); - $actions = array( + $actions = [ 'switch-to' => $item->get_user_id() !== get_current_user_id() ? $url_switch_to : __('None', 'wp-ultimo'), - ); + ]; echo implode('
    ', $actions); @@ -144,7 +144,7 @@ - +
    diff --git a/views/base/dash.php b/views/base/dash.php index 6ab73ea..253559d 100644 --- a/views/base/dash.php +++ b/views/base/dash.php @@ -18,7 +18,7 @@ * @since 1.8.2 */ foreach ($page->get_title_links() as $action_link) : - $action_classes = isset($action_link['classes']) ? $action_link['classes'] : ''; + $action_classes = $action_link['classes'] ?? ''; ?> diff --git a/views/base/edit.php b/views/base/edit.php index dce0e3d..a9027a5 100644 --- a/views/base/edit.php +++ b/views/base/edit.php @@ -18,9 +18,9 @@ * @since 1.8.2 */ foreach ($page->get_title_links() as $action_link) : - $action_classes = isset($action_link['classes']) ? $action_link['classes'] : ''; + $action_classes = $action_link['classes'] ?? ''; - $attrs = isset($action_link['attrs']) ? $action_link['attrs'] : ''; + $attrs = $action_link['attrs'] ?? ''; ?> @@ -133,9 +133,9 @@ wp_editor( html_entity_decode($content), 'content', - array( + [ 'height' => 500, - ) + ] ); ?> diff --git a/views/base/edit/display-notes.php b/views/base/edit/display-notes.php index f40cc6d..54aef2e 100644 --- a/views/base/edit/display-notes.php +++ b/views/base/edit/display-notes.php @@ -10,12 +10,12 @@ __('No notes yet.', 'wp-ultimo'), 'sub_message' => __('Use the "Add new Note" to create the first one.', 'wp-ultimo'), 'link_url' => false, 'display_background_image' => false, - ) + ] ); ?> @@ -44,10 +44,10 @@ 20, 'identicon', '', - array( + [ 'force_display' => true, 'class' => 'wu-rounded-full wu-mr-2', - ) + ] ) ); ?> @@ -66,12 +66,12 @@ wu_request('id'), 'model' => $model, 'note_id' => $note->note_id, 'height' => 306, - ); + ]; ?> diff --git a/views/base/empty-state.php b/views/base/empty-state.php index d4e7dd8..dbc6428 100644 --- a/views/base/empty-state.php +++ b/views/base/empty-state.php @@ -7,7 +7,7 @@ ?>
    diff --git a/views/base/filter.php b/views/base/filter.php index 71ca6f6..2f8e50e 100644 --- a/views/base/filter.php +++ b/views/base/filter.php @@ -75,7 +75,7 @@ get_title_links() as $action_link) : - $action_classes = isset($action_link['classes']) ? $action_link['classes'] : ''; + $action_classes = $action_link['classes'] ?? ''; ?> diff --git a/views/base/products/grid-item.php b/views/base/products/grid-item.php index 94b0c3e..717d6b0 100644 --- a/views/base/products/grid-item.php +++ b/views/base/products/grid-item.php @@ -64,7 +64,7 @@ --> - + diff --git a/views/base/settings.php b/views/base/settings.php index dfd4a12..8585898 100644 --- a/views/base/settings.php +++ b/views/base/settings.php @@ -18,7 +18,7 @@ * @since 1.8.2 */ foreach ($page->get_title_links() as $action_link) : - $action_classes = isset($action_link['classes']) ? $action_link['classes'] : ''; + $action_classes = $action_link['classes'] ?? ''; ?> @@ -103,7 +103,7 @@ /** * Holds add-on menus */ - $addons = array(); + $addons = []; ?> diff --git a/views/base/sites/grid-item.php b/views/base/sites/grid-item.php index 92eeafd..ceee0e4 100644 --- a/views/base/sites/grid-item.php +++ b/views/base/sites/grid-item.php @@ -52,7 +52,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -73,7 +73,7 @@   - + diff --git a/views/broadcast/emails/base.php b/views/broadcast/emails/base.php index 0628737..2af4326 100644 --- a/views/broadcast/emails/base.php +++ b/views/broadcast/emails/base.php @@ -91,7 +91,7 @@ if ( ! defined('ABSPATH')) {


    - +

    diff --git a/views/checkout/fields/field-checkbox-multi.php b/views/checkout/fields/field-checkbox-multi.php index 11c6426..37e53a3 100644 --- a/views/checkout/fields/field-checkbox-multi.php +++ b/views/checkout/fields/field-checkbox-multi.php @@ -16,9 +16,9 @@ */ wu_get_template( 'checkout/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); ?> @@ -44,9 +44,9 @@ */ wu_get_template( 'checkout/fields/partials/field-errors', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/checkout/fields/field-checkbox.php b/views/checkout/fields/field-checkbox.php index 29a33c0..6ff28af 100644 --- a/views/checkout/fields/field-checkbox.php +++ b/views/checkout/fields/field-checkbox.php @@ -28,9 +28,9 @@ */ wu_get_template( 'checkout/fields/partials/field-errors', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/checkout/fields/field-group.php b/views/checkout/fields/field-group.php index b4b582b..e9c7bfe 100644 --- a/views/checkout/fields/field-group.php +++ b/views/checkout/fields/field-group.php @@ -18,9 +18,9 @@ */ wu_get_template( 'checkout/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); ?> @@ -34,15 +34,15 @@ $form = new \WP_Ultimo\UI\Form( $field->id, $field->fields, - array( + [ 'views' => 'checkout/fields', 'classes' => 'wu-flex wu-my-1', 'field_wrapper_classes' => 'wu-bg-transparent', 'wrap_tag' => 'span', - 'step' => (object) array( + 'step' => (object) [ 'classes' => '', - ), - ) + ], + ] ); $form->render(); @@ -54,9 +54,9 @@ */ wu_get_template( 'checkout/fields/partials/field-errors', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/checkout/fields/field-hidden.php b/views/checkout/fields/field-hidden.php index 3e0c3e2..d436e47 100644 --- a/views/checkout/fields/field-hidden.php +++ b/views/checkout/fields/field-hidden.php @@ -29,9 +29,9 @@ */ wu_get_template( 'checkout/fields/partials/field-errors', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/checkout/fields/field-html.php b/views/checkout/fields/field-html.php index 3aea589..713e6ea 100644 --- a/views/checkout/fields/field-html.php +++ b/views/checkout/fields/field-html.php @@ -19,9 +19,9 @@ */ wu_get_template( 'checkout/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); /** @@ -31,9 +31,9 @@ */ wu_get_template( 'checkout/fields/partials/field-description', - array( + [ 'field' => $field, - ) + ] ); ?> @@ -53,9 +53,9 @@ */ wu_get_template( 'checkout/fields/partials/field-errors', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/checkout/fields/field-password.php b/views/checkout/fields/field-password.php index 1b64841..35883fb 100644 --- a/views/checkout/fields/field-password.php +++ b/views/checkout/fields/field-password.php @@ -16,9 +16,9 @@ */ wu_get_template( 'checkout/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); ?> @@ -48,9 +48,9 @@ */ wu_get_template( 'checkout/fields/partials/field-errors', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/checkout/fields/field-payment-methods.php b/views/checkout/fields/field-payment-methods.php index 9d10bbd..dedb8ff 100644 --- a/views/checkout/fields/field-payment-methods.php +++ b/views/checkout/fields/field-payment-methods.php @@ -19,9 +19,9 @@ $active_gateways = wu_get_active_gateway_as_options(); */ wu_get_template( 'checkout/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); ?> @@ -71,9 +71,9 @@ $active_gateways = wu_get_active_gateway_as_options(); */ wu_get_template( 'checkout/fields/partials/field-errors', - array( + [ 'field' => $field, - ) + ] ); /** diff --git a/views/checkout/fields/field-products.php b/views/checkout/fields/field-products.php index 8b5b98a..7601d0c 100644 --- a/views/checkout/fields/field-products.php +++ b/views/checkout/fields/field-products.php @@ -16,9 +16,9 @@ */ wu_get_template( 'checkout/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); ?> @@ -44,9 +44,9 @@ */ wu_get_template( 'checkout/fields/partials/field-errors', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/checkout/fields/field-radio.php b/views/checkout/fields/field-radio.php index b10b139..522ae88 100644 --- a/views/checkout/fields/field-radio.php +++ b/views/checkout/fields/field-radio.php @@ -16,9 +16,9 @@ */ wu_get_template( 'checkout/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); ?> @@ -44,9 +44,9 @@ */ wu_get_template( 'checkout/fields/partials/field-errors', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/checkout/fields/field-select.php b/views/checkout/fields/field-select.php index 6bf61ce..a37ea64 100644 --- a/views/checkout/fields/field-select.php +++ b/views/checkout/fields/field-select.php @@ -16,9 +16,9 @@ */ wu_get_template( 'checkout/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); ?> @@ -65,9 +65,9 @@ */ wu_get_template( 'checkout/fields/partials/field-errors', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/checkout/fields/field-text.php b/views/checkout/fields/field-text.php index d990c36..e92ce6f 100644 --- a/views/checkout/fields/field-text.php +++ b/views/checkout/fields/field-text.php @@ -16,9 +16,9 @@ */ wu_get_template( 'checkout/fields/partials/field-title', - array( + [ 'field' => $field, - ) + ] ); ?> @@ -27,7 +27,7 @@
    -
    prefix_html_attr ?? array()); ?>> +
    prefix_html_attr ?? []); ?>> prefix; ?>
    @@ -37,7 +37,7 @@ suffix) : ?> -
    suffix_html_attr ?? array()); ?>> +
    suffix_html_attr ?? []); ?>> suffix; ?>
    @@ -58,9 +58,9 @@ */ wu_get_template( 'checkout/fields/partials/field-errors', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/checkout/fields/field-toggle.php b/views/checkout/fields/field-toggle.php index 29a33c0..6ff28af 100644 --- a/views/checkout/fields/field-toggle.php +++ b/views/checkout/fields/field-toggle.php @@ -28,9 +28,9 @@ */ wu_get_template( 'checkout/fields/partials/field-errors', - array( + [ 'field' => $field, - ) + ] ); ?> diff --git a/views/checkout/form.php b/views/checkout/form.php index 737229d..a7f1ef5 100644 --- a/views/checkout/form.php +++ b/views/checkout/form.php @@ -28,18 +28,18 @@ $form = new \WP_Ultimo\UI\Form( "checkout-{$step_name}", $final_fields, - array( + [ 'title' => $display_title ? $step['name'] : '', 'views' => 'checkout/fields', 'classes' => wu_get_isset($step, 'classes', '') . ' wu-grid wu-grid-cols-2 wu-gap-4', 'field_wrapper_classes' => 'wu-col-span-2', - 'html_attr' => array( - 'id' => wu_get_isset($step, 'element_id') ? wu_get_isset($step, 'element_id') : "wu-step-{$step_name}", - ), - 'variables' => array( + 'html_attr' => [ + 'id' => wu_get_isset($step, 'element_id') ?: "wu-step-{$step_name}", + ], + 'variables' => [ 'step' => (object) $step, - ), - ) + ], + ] ); /** diff --git a/views/checkout/paypal/confirm.php b/views/checkout/paypal/confirm.php index 246b248..08ff8c1 100644 --- a/views/checkout/paypal/confirm.php +++ b/views/checkout/paypal/confirm.php @@ -7,7 +7,7 @@ $is_trial_setup = $membership->is_trialing() && empty($payment->get_total()); -$notes = array(); +$notes = []; if ($is_trial_setup) { $desc = $membership->get_recurring_description(); @@ -24,7 +24,7 @@ $should_auto_renew = ! empty($original_cart) ? $original_cart->should_auto_renew $recurring_total = $membership->get_amount(); if ($membership->is_recurring() && $should_auto_renew) { - $payment_total = $payment->get_total() ? $payment->get_total() : $membership->get_initial_amount(); + $payment_total = $payment->get_total() ?: $membership->get_initial_amount(); $desc = $membership->get_recurring_description(); diff --git a/views/checkout/register.php b/views/checkout/register.php index 24369e2..199fcad 100644 --- a/views/checkout/register.php +++ b/views/checkout/register.php @@ -10,10 +10,10 @@ $order_form = new \WP_Ultimo\UI\Form( 'product-fields', $product_fields, - array( + [ 'title' => __('Products', 'wp-ultimo'), 'views' => 'checkout/fields', - ) + ] ); /** @@ -29,7 +29,7 @@ * * @since 2.0.0 */ - $submit = new \WP_Ultimo\UI\Form('submit-fields', $submit_fields, array('views' => 'checkout/fields')); + $submit = new \WP_Ultimo\UI\Form('submit-fields', $submit_fields, ['views' => 'checkout/fields']); /** * Render form fields. diff --git a/views/checkout/templates/pricing-table/legacy.php b/views/checkout/templates/pricing-table/legacy.php index 72e2d80..356d929 100644 --- a/views/checkout/templates/pricing-table/legacy.php +++ b/views/checkout/templates/pricing-table/legacy.php @@ -13,7 +13,7 @@ * @param string $label The field label. */ -$products_to_reduce = array_merge(array(false), $products); +$products_to_reduce = array_merge([false], $products); $first_recurring_product = array_reduce( $products_to_reduce, @@ -195,7 +195,7 @@ if ($first_recurring_product !== null) { * Price display. */ - $symbol_left = in_array(wu_get_setting('currency_position', '%s%v'), array('%s%v', '%s %v')); + $symbol_left = in_array(wu_get_setting('currency_position', '%s%v'), ['%s%v', '%s %v']); ?> @@ -222,7 +222,7 @@ if ($first_recurring_product !== null) { get_price_variation($freq, 'month'); if ( ! $price_variation) { @@ -303,10 +303,10 @@ if ($first_recurring_product !== null) { * * Display quarterly and Annually plans, to be hidden. */ - $prices_total = array( + $prices_total = [ 3 => __('every 3 months', 'wp-ultimo'), 12 => __('yearly', 'wp-ultimo'), - ); + ]; foreach ($prices_total as $freq => $string) { $price_variation = $product->get_price_variation($freq, 'month'); diff --git a/views/checkout/templates/template-selection/clean.php b/views/checkout/templates/template-selection/clean.php index b45ceda..8a586f3 100644 --- a/views/checkout/templates/template-selection/clean.php +++ b/views/checkout/templates/template-selection/clean.php @@ -25,13 +25,13 @@ if (isset($should_display) && ! $should_display) { return; } // end if; -$sites = array_map('wu_get_site', isset($sites) ? $sites : array()); +$sites = array_map('wu_get_site', $sites ?? []); -$categories = isset($categories) ? $categories : array(); +$categories ??= []; $customer_sites_category = __('Your Sites', 'wp_ultimo'); -$customer_sites = isset($customer_sites) ? array_map('intval', $customer_sites) : array(); +$customer_sites = isset($customer_sites) ? array_map('intval', $customer_sites) : []; ?> @@ -82,7 +82,7 @@ $customer_sites = isset($customer_sites) ? array_map('intval', $customer_sites) -
    +
    @@ -93,7 +93,7 @@ $customer_sites = isset($customer_sites) ? array_map('intval', $customer_sites) get_type() === 'site_template'; ?> - get_categories(), ! $is_template ? array($customer_sites_category) : array()); ?> + get_categories(), ! $is_template ? [$customer_sites_category] : []); ?>
    @@ -181,7 +181,7 @@ $customer_sites = isset($customer_sites) ? array_map('intval', $customer_sites) get_type() === 'site_template'; ?> - get_categories(), ! $is_template ? array($customer_sites_category) : array()); ?> + get_categories(), ! $is_template ? [$customer_sites_category] : []); ?>
    @@ -89,7 +89,7 @@ $customer_sites = isset($customer_sites) ? array_map('intval', $customer_sites) get_type() === 'site_template'; ?> - get_categories(), ! $is_template ? array($customer_sites_category) : array()); ?> + get_categories(), ! $is_template ? [$customer_sites_category] : []); ?>
    ID, - array( + [ 'force_display' => true, 'size' => 300, 'default' => 'identicon', - ) + ] ); ?> ');"> @@ -32,10 +32,10 @@ 86, 'identicon', '', - array( + [ 'force_display' => true, 'class' => 'wu-rounded-full wu-border wu-border-solid wu-border-gray-300 wu-relative', - ) + ] ); ?> diff --git a/views/dashboard-statistics/filter.php b/views/dashboard-statistics/filter.php index 4b054da..f611ade 100644 --- a/views/dashboard-statistics/filter.php +++ b/views/dashboard-statistics/filter.php @@ -41,11 +41,11 @@ $preset['start_date'], 'end_date' => $preset['end_date'], 'preset' => $slug, - ) + ] ); $request_slug = wu_request('preset', 'none'); diff --git a/views/dashboard-statistics/widget-countries.php b/views/dashboard-statistics/widget-countries.php index 738d118..af5de8b 100644 --- a/views/dashboard-statistics/widget-countries.php +++ b/views/dashboard-statistics/widget-countries.php @@ -11,28 +11,28 @@ $count) { - $line = array( + $line = [ wu_get_country_name($country_code), $count, - ); + ]; $data[] = $line; } // end foreach; $page->render_csv_button( - array( + [ 'headers' => $headers, 'data' => $data, 'slug' => $slug, - ) + ] ); ?> diff --git a/views/dashboard-statistics/widget-forms.php b/views/dashboard-statistics/widget-forms.php index bf6029c..11034a1 100644 --- a/views/dashboard-statistics/widget-forms.php +++ b/views/dashboard-statistics/widget-forms.php @@ -12,28 +12,28 @@ signup_form, $form->count, - ); + ]; $data[] = $line; } // end foreach; $page->render_csv_button( - array( + [ 'headers' => $headers, 'data' => $data, 'slug' => $slug, - ) + ] ); ?> diff --git a/views/dashboard-statistics/widget-most-visited-sites.php b/views/dashboard-statistics/widget-most-visited-sites.php index 03352f2..fb231c8 100644 --- a/views/dashboard-statistics/widget-most-visited-sites.php +++ b/views/dashboard-statistics/widget-most-visited-sites.php @@ -12,30 +12,30 @@ site->get_title() . ' ' . get_admin_url($site_visits->site->get_id()); - $line = array( + $line = [ $site_line, $site_visits->count, - ); + ]; $data[] = $line; } // end foreach; $page->render_csv_button( - array( + [ 'headers' => $headers, 'data' => $data, 'slug' => $slug, - ) + ] ); ?> diff --git a/views/dashboard-statistics/widget-tax-by-code.php b/views/dashboard-statistics/widget-tax-by-code.php index 8893fde..3d8b5d1 100644 --- a/views/dashboard-statistics/widget-tax-by-code.php +++ b/views/dashboard-statistics/widget-tax-by-code.php @@ -11,32 +11,32 @@ render_csv_button( - array( + [ 'headers' => $headers, 'data' => $data, 'slug' => $slug, - ) + ] ); ?> diff --git a/views/dashboard-statistics/widget-tax-by-day.php b/views/dashboard-statistics/widget-tax-by-day.php index e8cbb60..752ce52 100644 --- a/views/dashboard-statistics/widget-tax-by-day.php +++ b/views/dashboard-statistics/widget-tax-by-day.php @@ -11,34 +11,34 @@ $tax_line) { - $line = array( + $line = [ date_i18n(get_option('date_format'), strtotime($day)), $tax_line['order_count'], wu_format_currency($tax_line['total']), wu_format_currency($tax_line['tax_total']), wu_format_currency($tax_line['net_profit']), - ); + ]; $data[] = $line; } // end foreach; $page->render_csv_button( - array( + [ 'headers' => $headers, 'data' => $data, 'slug' => $slug, - ) + ] ); ?> diff --git a/views/dashboard-widgets/activity-stream.php b/views/dashboard-widgets/activity-stream.php index 6e863e7..ebfa360 100644 --- a/views/dashboard-widgets/activity-stream.php +++ b/views/dashboard-widgets/activity-stream.php @@ -27,7 +27,7 @@ :class="index > 0 ? 'wu-border-solid wu-border-0 wu-border-t wu-border-gray-300' : ''" v-for="(event, index) in queried.events" > - +
    diff --git a/views/dashboard-widgets/current-membership.php b/views/dashboard-widgets/current-membership.php index e96b2b1..0d67308 100644 --- a/views/dashboard-widgets/current-membership.php +++ b/views/dashboard-widgets/current-membership.php @@ -274,10 +274,10 @@ echo esc_attr( wu_get_form_url( 'see_product_details', - array( + [ 'product' => $addon['product']->get_slug(), 'width' => 500, - ) + ] ) ); ?> @@ -298,11 +298,11 @@ echo esc_attr( wu_get_form_url( 'edit_membership_product_modal', - array( + [ 'membership' => $membership->get_hash(), 'product' => $addon['product']->get_slug(), 'width' => 500, - ) + ] ) ); ?> diff --git a/views/dashboard-widgets/domain-mapping.php b/views/dashboard-widgets/domain-mapping.php index 288f92e..739059c 100644 --- a/views/dashboard-widgets/domain-mapping.php +++ b/views/dashboard-widgets/domain-mapping.php @@ -64,47 +64,47 @@ $status = "{$label}"; - $second_row_actions = array(); + $second_row_actions = []; if ( ! $item->is_primary_domain()) { - $second_row_actions['make_primary'] = array( + $second_row_actions['make_primary'] = [ 'wrapper_classes' => 'wubox', 'icon' => 'dashicons-wu-edit1 wu-align-middle wu-mr-1', 'label' => '', 'url' => $domain['primary_link'], 'value' => __('Make Primary', 'wp-ultimo'), - ); + ]; } // end if; - $second_row_actions['remove'] = array( + $second_row_actions['remove'] = [ 'wrapper_classes' => 'wu-text-red-500 wubox', 'icon' => 'dashicons-wu-trash-2 wu-align-middle wu-mr-1', 'label' => '', 'value' => __('Delete', 'wp-ultimo'), 'url' => $domain['delete_link'], - ); + ]; echo wu_responsive_table_row( - array( + [ 'id' => false, 'title' => strtolower($item->get_domain()), 'url' => false, 'status' => $status, - ), - array( - 'primary' => array( + ], + [ + 'primary' => [ 'wrapper_classes' => $item->is_primary_domain() ? 'wu-text-blue-600' : '', 'icon' => $item->is_primary_domain() ? 'dashicons-wu-filter_1 wu-align-text-bottom wu-mr-1' : 'dashicons-wu-plus-square wu-align-text-bottom wu-mr-1', 'label' => '', 'value' => $item->is_primary_domain() ? __('Primary', 'wp-ultimo') . wu_tooltip(__('All other mapped domains will redirect to the primary domain.', 'wp-ultimo'), 'dashicons-editor-help wu-align-middle wu-ml-1') : __('Alias', 'wp-ultimo'), - ), - 'secure' => array( + ], + 'secure' => [ 'wrapper_classes' => $item->is_secure() ? 'wu-text-green-500' : '', 'icon' => $item->is_secure() ? 'dashicons-wu-lock1 wu-align-text-bottom wu-mr-1' : 'dashicons-wu-lock1 wu-align-text-bottom wu-mr-1', 'label' => '', 'value' => $item->is_secure() ? __('Secure (HTTPS)', 'wp-ultimo') : __('Not Secure (HTTP)', 'wp-ultimo'), - ), - ), + ], + ], $second_row_actions ); diff --git a/views/dashboard-widgets/invoices.php b/views/dashboard-widgets/invoices.php index cf06c7c..2bbd4e2 100644 --- a/views/dashboard-widgets/invoices.php +++ b/views/dashboard-widgets/invoices.php @@ -31,7 +31,7 @@ - get_payments(array('number' => ! empty($limit) ? $limit : null)) as $payment) : ?> + get_payments(['number' => ! empty($limit) ? $limit : null]) as $payment) : ?> @@ -50,39 +50,39 @@ esc_attr__('Download Invoice', 'wp-ultimo') ); - $payment_column = $payment->get_status() === 'pending' ? array( - 'pay_now' => array( - 'url' => add_query_arg(array('payment' => $payment->get_hash()), wu_get_registration_url()), + $payment_column = $payment->get_status() === 'pending' ? [ + 'pay_now' => [ + 'url' => add_query_arg(['payment' => $payment->get_hash()], wu_get_registration_url()), 'icon' => 'dashicons-wu-credit-card wu-align-middle wu-mr-1', 'label' => __('Go to payment', 'wp-ultimo'), 'value' => __('Pay Now', 'wp-ultimo'), - ), - ) : array(); + ], + ] : []; echo wu_responsive_table_row( - array( + [ 'url' => false, 'title' => $payment->get_invoice_number() . $download_link, 'status' => wu_format_currency($payment->get_total(), $payment->get_currency()), - ), + ], array_merge( - array( - 'status' => array( + [ + 'status' => [ 'url' => false, 'icon' => wu_get_payment_icon_classes($payment->get_status()) . ' wu-mr-1', 'value' => $payment->get_status_label(), - ), - ), + ], + ], $payment_column ), - array( - 'date_created' => array( + [ + 'date_created' => [ 'url' => false, 'icon' => 'dashicons-wu-calendar1 wu-align-middle wu-mr-1', 'label' => '', 'value' => $payment->get_formatted_date('date_created'), - ), - ) + ], + ] ); ?> diff --git a/views/dashboard-widgets/my-sites.php b/views/dashboard-widgets/my-sites.php index 7114272..b4de063 100644 --- a/views/dashboard-widgets/my-sites.php +++ b/views/dashboard-widgets/my-sites.php @@ -11,9 +11,9 @@ $add_new_url = wu_get_setting('enable_multiple_sites') ? $element->get_new_site_ // Redirect back to this page after create the site $add_new_url = add_query_arg( - array( + [ 'redirect_url' => urlencode(wu_get_current_url()), - ), + ], $add_new_url ); @@ -113,7 +113,7 @@ $show_add_new = apply_filters('wp_ultimo_my_sites_show_add_new', $show_add_new); - get_active_site_url()); ?> + get_active_site_url()); ?> diff --git a/views/dashboard-widgets/thank-you.php b/views/dashboard-widgets/thank-you.php index c587537..bcdd6ea 100644 --- a/views/dashboard-widgets/thank-you.php +++ b/views/dashboard-widgets/thank-you.php @@ -9,7 +9,7 @@
    - get_status(), array('completed'))) : ?> + get_status(), ['completed'])) : ?>
    diff --git a/views/events/widget-initiator.php b/views/events/widget-initiator.php index a23d264..98ff56c 100644 --- a/views/events/widget-initiator.php +++ b/views/events/widget-initiator.php @@ -15,7 +15,7 @@ get_initiator() == 'manual') : ?> - $object->get_author_id())); ?>' class='wu-table-card wu-text-gray-700 wu-p-2 wu-flex wu-flex-grow wu-rounded wu-items-center wu-border wu-border-solid wu-border-gray-300 wu-no-underline'> + $object->get_author_id()]); ?>' class='wu-table-card wu-text-gray-700 wu-p-2 wu-flex wu-flex-grow wu-rounded wu-items-center wu-border wu-border-solid wu-border-gray-300 wu-no-underline'>
    @@ -26,10 +26,10 @@ 32, 'identicon', '', - array( + [ 'force_display' => true, 'class' => 'wu-rounded-full', - ) + ] ); echo $avatar; diff --git a/views/legacy/signup/pricing-table/frequency-selector.php b/views/legacy/signup/pricing-table/frequency-selector.php index ed2ad98..f98f1c1 100644 --- a/views/legacy/signup/pricing-table/frequency-selector.php +++ b/views/legacy/signup/pricing-table/frequency-selector.php @@ -27,11 +27,11 @@ if ( ! defined('ABSPATH')) { __('Monthly', 'wp-ultimo'), 3 => __('Quarterly', 'wp-ultimo'), 12 => __('Yearly', 'wp-ultimo'), - ); + ]; $first = true; diff --git a/views/legacy/signup/pricing-table/plan.php b/views/legacy/signup/pricing-table/plan.php index 5631030..0b6cd6e 100644 --- a/views/legacy/signup/pricing-table/plan.php +++ b/views/legacy/signup/pricing-table/plan.php @@ -30,7 +30,7 @@ if ( ! defined('ABSPATH')) { */ $plan_attrs = ''; -foreach (array(1, 3, 12) as $type) { +foreach ([1, 3, 12] as $type) { $price = $plan->free ? __('Free!', 'wp-ultimo') : str_replace(wu_get_currency_symbol(), '', wu_format_currency((((float) $plan->{'price_' . $type}) / $type))); $plan_attrs .= " data-price-$type='$price'"; } // end foreach; @@ -65,7 +65,7 @@ $plan_attrs = apply_filters('wu_pricing_table_plan', $plan_attrs, $plan);
    - + @@ -88,10 +88,10 @@ $plan_attrs = apply_filters('wu_pricing_table_plan', $plan_attrs, $plan); * * Display quarterly and Annually plans, to be hidden */ - $prices_total = array( + $prices_total = [ 3 => __('every 3 months', 'wp-ultimo'), 12 => __('yearly', 'wp-ultimo'), - ); + ]; foreach ($prices_total as $freq => $string) { $text = sprintf(__('%1$s, billed %2$s', 'wp-ultimo'), wu_format_currency($plan->{"price_$freq"}), $string); diff --git a/views/legacy/signup/pricing-table/pricing-table.php b/views/legacy/signup/pricing-table/pricing-table.php index 526872f..1b18889 100644 --- a/views/legacy/signup/pricing-table/pricing-table.php +++ b/views/legacy/signup/pricing-table/pricing-table.php @@ -96,12 +96,12 @@ if (empty($plans)) { foreach ($plans as $plan) { wu_get_template( 'legacy/signup/pricing-table/plan', - array( + [ 'plan' => $plan, 'count' => $count, 'columns' => $columns, 'current_plan' => $current_plan, - ) + ] ); } // end foreach; diff --git a/views/legacy/signup/signup-main.php b/views/legacy/signup/signup-main.php index 0ae69ec..563e7fa 100644 --- a/views/legacy/signup/signup-main.php +++ b/views/legacy/signup/signup-main.php @@ -23,23 +23,23 @@ require_once ABSPATH . 'wp-admin/includes/class-wp-screen.php'; require_once ABSPATH . 'wp-admin/includes/screen.php'; // Load the admin actions removed in WordPress 6.0 -$admin_actions = array( - 'admin_print_scripts' => array( +$admin_actions = [ + 'admin_print_scripts' => [ 'print_head_scripts' => 20, - ), - 'admin_print_styles' => array( + ], + 'admin_print_styles' => [ 'print_admin_styles' => 20, - ), - 'admin_head' => array( + ], + 'admin_head' => [ 'wp_color_scheme_settings' => 10, 'wp_admin_canonical_url' => 10, 'wp_site_icon' => 10, 'wp_admin_viewport_meta' => 10, - ), - 'admin_print_footer_scripts' => array( + ], + 'admin_print_footer_scripts' => [ '_wp_footer_scripts' => 10, - ), -); + ], +]; foreach ($admin_actions as $action => $handlers) { foreach ($handlers as $handler => $priority) { @@ -109,7 +109,7 @@ do_action('wu_checkout_scripts'); ?> -
    +
    @@ -131,7 +131,7 @@ do_action('wu_checkout_scripts'); /** * Nav Links */ - wu_get_template('legacy/signup/signup-nav-links', array('signup' => $signup)); + wu_get_template('legacy/signup/signup-nav-links', ['signup' => $signup]); ?>
    @@ -140,7 +140,7 @@ do_action('wu_checkout_scripts'); /** * Navigation Steps */ - wu_get_template('legacy/signup/signup-steps-navigation', array('signup' => $signup)); + wu_get_template('legacy/signup/signup-steps-navigation', ['signup' => $signup]); ?> __('Return to Home', 'wp-ultimo'), wp_login_url() => sprintf('%s', __('Log In', 'wp-ultimo')), - ) + ] ); if ( ! isset($signup->step)) { diff --git a/views/legacy/signup/steps/step-domain-url-preview.php b/views/legacy/signup/steps/step-domain-url-preview.php index a89789f..4c39263 100644 --- a/views/legacy/signup/steps/step-domain-url-preview.php +++ b/views/legacy/signup/steps/step-domain-url-preview.php @@ -31,7 +31,7 @@ if ( ! defined('ABSPATH')) { */ $dynamic_part = ''; // This is used on the yoursite.network.com during sign-up - $dynamic_part .= isset($signup->results['blogname']) ? $signup->results['blogname'] : __('yoursite', 'wp-ultimo'); + $dynamic_part .= $signup->results['blogname'] ?? __('yoursite', 'wp-ultimo'); $dynamic_part .= ''; $site_url = preg_replace('#^https?://#', '', WU_Signup()->get_site_url_for_previewer()); diff --git a/views/legacy/signup/steps/step-plans.php b/views/legacy/signup/steps/step-plans.php index cbe968a..413d23c 100644 --- a/views/legacy/signup/steps/step-plans.php +++ b/views/legacy/signup/steps/step-plans.php @@ -21,24 +21,24 @@ if ( ! defined('ABSPATH')) { // Get all available plans $plans = wu_get_products( - array( + [ 'type' => 'plan', - ) + ] ); // Render the selector wu_get_template( 'legacy/signup/pricing-table/pricing-table', - array( + [ 'plans' => $plans, 'signup' => $signup, 'current_plan' => false, 'is_shortcode' => false, - 'atts' => array( + 'atts' => [ 'primary_color' => '#00a1ff', // wu_get_setting('primary-color', '#00a1ff'), 'accent_color' => '#78b336', // wu_get_setting('accent-color', '#78b336'), 'default_pricing_option' => 1, // wu_get_setting('default_pricing_option', 1), 'show_selector' => true, - ), - ) + ], + ] ); diff --git a/views/memberships/product-list.php b/views/memberships/product-list.php index 55d5995..4aea022 100644 --- a/views/memberships/product-list.php +++ b/views/memberships/product-list.php @@ -14,7 +14,7 @@
    diff --git a/views/settings/fields/field-color.php b/views/settings/fields/field-color.php index f5e28b8..be802f2 100644 --- a/views/settings/fields/field-color.php +++ b/views/settings/fields/field-color.php @@ -21,7 +21,7 @@
    - + desc) : ?> diff --git a/views/settings/fields/field-image.php b/views/settings/fields/field-image.php index e60373b..90dedca 100644 --- a/views/settings/fields/field-image.php +++ b/views/settings/fields/field-image.php @@ -55,7 +55,7 @@ wp_enqueue_script('wu-field-button-upload', WP_Ultimo()->get_asset("wu-field-ima

    - + diff --git a/views/settings/fields/field-multi_checkbox.php b/views/settings/fields/field-multi_checkbox.php index 90133b0..c1ee4a9 100644 --- a/views/settings/fields/field-multi_checkbox.php +++ b/views/settings/fields/field-multi_checkbox.php @@ -15,7 +15,7 @@ $settings = wu_get_setting($field_slug); if ($settings === false) { - $settings = isset($field['default']) ? $field['default'] : false; + $settings = $field['default'] ?? false; } /** @@ -54,7 +54,7 @@ foreach ($field['options'] as $field_value => $field_name) : // Check this setting - $this_settings = isset($settings[ $field_value ]) ? $settings[ $field_value ] : false; + $this_settings = $settings[ $field_value ] ?? false; ?> diff --git a/views/settings/fields/field-select2.php b/views/settings/fields/field-select2.php index dddf2e1..4ad8e41 100644 --- a/views/settings/fields/field-select2.php +++ b/views/settings/fields/field-select2.php @@ -9,9 +9,9 @@ $setting = wu_get_setting($field_slug); -$setting = is_array($setting) ? $setting : array(); +$setting = is_array($setting) ? $setting : []; -$placeholder = isset($field['placeholder']) ? $field['placeholder'] : ''; +$placeholder = $field['placeholder'] ?? ''; // WU_Scripts()->enqueue_select2(); diff --git a/views/settings/fields/field-text.php b/views/settings/fields/field-text.php index e628219..4eca8b9 100644 --- a/views/settings/fields/field-text.php +++ b/views/settings/fields/field-text.php @@ -21,7 +21,7 @@
    - html_attr ? $field->get_html_attributes() : ''; ?> disabled ? 'disabled="disabled"' : ''; ?> name="id); ?>" type="type); ?>" id="id); ?>" class="regular-text" value="id); ?>" placeholder="placeholder ? $field->placeholder : ''; ?>"> + html_attr ? $field->get_html_attributes() : ''; ?> disabled ? 'disabled="disabled"' : ''; ?> name="id); ?>" type="type); ?>" id="id); ?>" class="regular-text" value="id); ?>" placeholder="placeholder ?: ''; ?>"> append) && ! empty($field->append)) : ?> diff --git a/views/ui/toolbox.php b/views/ui/toolbox.php index d3b9f55..3c47710 100644 --- a/views/ui/toolbox.php +++ b/views/ui/toolbox.php @@ -24,7 +24,7 @@
  • - @@ -39,7 +39,7 @@
  • - @@ -56,7 +56,7 @@
  • - diff --git a/views/wizards/host-integrations/configuration.php b/views/wizards/host-integrations/configuration.php index a82f371..b441a1a 100644 --- a/views/wizards/host-integrations/configuration.php +++ b/views/wizards/host-integrations/configuration.php @@ -30,7 +30,7 @@
  • .

    - +

    .

    diff --git a/views/wizards/host-integrations/serverpilot-instructions.php b/views/wizards/host-integrations/serverpilot-instructions.php index 2a4c8b4..e14f3d8 100644 --- a/views/wizards/host-integrations/serverpilot-instructions.php +++ b/views/wizards/host-integrations/serverpilot-instructions.php @@ -9,18 +9,18 @@

    Step 1: Getting the API Key and the Client ID

    In Your ServerPilot admin panel, first go to the Account Settings page and navigate to the API link, there you can get the API Key and Client ID (if the API Key field is empty, click the New API Key button). Paste those values somewhere as we'll need them in a later step.

    - +

    Step 2: Getting the App ID

    Next, we’ll need to get the App ID for your WordPress site. To find that ID, navigate to your app’s manage page:

    - +

    Then, take a look at the URL at the top of your browser. The APP ID is the portion between the app/ and the /settings segments of the URL.

    - +

    After this you can proceed to the next integration step where you can paste these values in the related fields.

    diff --git a/views/wizards/setup/installation_steps.php b/views/wizards/setup/installation_steps.php index d087f60..f249955 100644 --- a/views/wizards/setup/installation_steps.php +++ b/views/wizards/setup/installation_steps.php @@ -21,7 +21,7 @@ - + > @@ -44,7 +44,7 @@ - + diff --git a/views/wizards/setup/ready.php b/views/wizards/setup/ready.php index 0b615ec..5b68a28 100644 --- a/views/wizards/setup/ready.php +++ b/views/wizards/setup/ready.php @@ -12,7 +12,7 @@

    - customer->first) ? $page->customer->first : __('my friend', 'wp-ultimo'))); ?> + customer->first ?? __('my friend', 'wp-ultimo'))); ?>