From 24639557aa4934a3c6d656b82a6bf6abd166deef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Thu, 20 Nov 2025 11:54:42 +0000 Subject: [PATCH 1/4] Support MakeCommerce payment --- composer.json | 2 +- src/Plugin.php | 29 ++++++++++++++--- src/ThirdPartyModules/MakeCommerce.php | 45 ++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 5 deletions(-) create mode 100644 src/ThirdPartyModules/MakeCommerce.php diff --git a/composer.json b/composer.json index 618b1eb..cce3d6c 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ } ], "require": { - "php": "~7.4.0 || ~8.0.0", + "php": "~7.4.0 || ^8.0", "composer-runtime-api": "^2.2" }, "require-dev": { diff --git a/src/Plugin.php b/src/Plugin.php index 0641611..cce8ea7 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -12,6 +12,9 @@ namespace SzepeViktor\TestMode; +use SzepeViktor\TestMode\ThirdPartyModules\Modules as ThirdParties; + +use function add_filter; use function current_user_can; use function esc_html__; use function esc_url; @@ -34,7 +37,7 @@ public static function loadTextDomain() { /** @var string */ $pluginBasename = Config::get('baseName'); - load_plugin_textdomain('plugin-slug', false, sprintf('%s/%s', dirname($pluginBasename), 'languages')); + load_plugin_textdomain('szv-test-mode', false, sprintf('%s/%s', dirname($pluginBasename), 'languages')); } /** @@ -77,10 +80,26 @@ public static function printRequirementsNotice() printf( '

%1$s %3$s %4$s

', - esc_html__('Plugin Name activation failed! Please read', 'plugin-slug'), + esc_html__('Plugin Name activation failed! Please read', 'szv-test-mode'), esc_url('https://github.com/szepeviktor/starter-plugin#installation'), - esc_html__('the Installation instructions', 'plugin-slug'), - esc_html__('for list of requirements.', 'plugin-slug') + esc_html__('the Installation instructions', 'szv-test-mode'), + esc_html__('for list of requirements.', 'szv-test-mode') + ); + } + + public static function loadThirdParties(): void + { + add_filter( + 'szepeviktor/test-mode/modules', + static function (array $modules) { + if (class_exists(\MakeCommerce::class)) { + $modules[] = ThirdParties\MakeCommerce::class; + } + + return $modules; + }, + 10, + 1 ); } @@ -89,6 +108,8 @@ public static function printRequirementsNotice() */ public static function boot(): void { + self::loadThirdParties(); + foreach (ModuleLoader::getInstances() as $instance) { $instance->activate(); } diff --git a/src/ThirdPartyModules/MakeCommerce.php b/src/ThirdPartyModules/MakeCommerce.php new file mode 100644 index 0000000..d809135 --- /dev/null +++ b/src/ThirdPartyModules/MakeCommerce.php @@ -0,0 +1,45 @@ + Date: Thu, 20 Nov 2025 11:58:32 +0000 Subject: [PATCH 2/4] Fix namespace --- src/ThirdPartyModules/MakeCommerce.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ThirdPartyModules/MakeCommerce.php b/src/ThirdPartyModules/MakeCommerce.php index d809135..c094074 100644 --- a/src/ThirdPartyModules/MakeCommerce.php +++ b/src/ThirdPartyModules/MakeCommerce.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace SzepeViktor\TestMode\ThirdPartyModules\Modules; +namespace SzepeViktor\TestMode\ThirdPartyModules; use SzepeViktor\TestMode\Modules\BaseModule; use SzepeViktor\TestMode\Modules\Module; From 90fed130c86970ba04f91724aea0bbaf31cbb6f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Thu, 20 Nov 2025 12:01:07 +0000 Subject: [PATCH 3/4] Fix namespace again --- src/Plugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugin.php b/src/Plugin.php index cce8ea7..ad971d1 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -12,7 +12,7 @@ namespace SzepeViktor\TestMode; -use SzepeViktor\TestMode\ThirdPartyModules\Modules as ThirdParties; +use SzepeViktor\TestMode\ThirdPartyModules as ThirdParties; use function add_filter; use function current_user_can; From c84fb96e0564fcb1d86759c271ecdb5a48e14750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Sz=C3=A9pe?= Date: Thu, 20 Nov 2025 12:34:13 +0000 Subject: [PATCH 4/4] Restructure 3rd-parties --- src/ModuleLoader.php | 20 +++++++++++++++++++- src/Plugin.php | 21 --------------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/src/ModuleLoader.php b/src/ModuleLoader.php index 098bcef..05e1271 100644 --- a/src/ModuleLoader.php +++ b/src/ModuleLoader.php @@ -6,6 +6,7 @@ use RuntimeException; use SzepeViktor\TestMode\Modules\Module; +use SzepeViktor\TestMode\ThirdPartyModules as ThirdParties; use function apply_filters; @@ -37,12 +38,29 @@ static function (string $fqcn): bool { ); } + /** + * @return list + */ + public static function getThirdParties(): array + { + $modules = []; + + if (class_exists(\MakeCommerce::class)) { + $modules[] = ThirdParties\MakeCommerce::class; + } + + return $modules; + } + /** * @return list */ public static function getAll(): array { - $modules = apply_filters('szepeviktor/test-mode/modules', self::getBuiltins()); + $modules = apply_filters( + 'szepeviktor/test-mode/modules', + array_merge(self::getBuiltins(), self::getThirdParties()) + ); return array_filter( $modules, diff --git a/src/Plugin.php b/src/Plugin.php index ad971d1..96cb43b 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -12,9 +12,6 @@ namespace SzepeViktor\TestMode; -use SzepeViktor\TestMode\ThirdPartyModules as ThirdParties; - -use function add_filter; use function current_user_can; use function esc_html__; use function esc_url; @@ -87,29 +84,11 @@ public static function printRequirementsNotice() ); } - public static function loadThirdParties(): void - { - add_filter( - 'szepeviktor/test-mode/modules', - static function (array $modules) { - if (class_exists(\MakeCommerce::class)) { - $modules[] = ThirdParties\MakeCommerce::class; - } - - return $modules; - }, - 10, - 1 - ); - } - /** * Start! */ public static function boot(): void { - self::loadThirdParties(); - foreach (ModuleLoader::getInstances() as $instance) { $instance->activate(); }