From 17c133e10c6158889d19b5594eaea8d29aa46b17 Mon Sep 17 00:00:00 2001 From: Florian Laabs Date: Fri, 30 Oct 2026 15:36:41 +0100 Subject: [PATCH] fix: address wordpress.org plugin review - Remove load_plugin_textdomain() and the Domain Path header; translations come from translate.wordpress.org. - Stop shipping languages/ (kept in the repo for importing). - WP-CLI export only prints to STDOUT instead of writing to a given path. --- .distignore | 1 + .gitattributes | 1 + CLAUDE.md | 6 +++--- README.md | 4 ++-- includes/class-wirecore-rc-cli.php | 18 +++++------------- wirecore-rest-control.php | 12 ------------ 6 files changed, 12 insertions(+), 30 deletions(-) diff --git a/.distignore b/.distignore index 0f6e6a3..2a16930 100644 --- a/.distignore +++ b/.distignore @@ -26,3 +26,4 @@ README.md CLAUDE.md CHANGELOG.md SECURITY.md +/languages diff --git a/.gitattributes b/.gitattributes index bea4959..7353eb2 100644 --- a/.gitattributes +++ b/.gitattributes @@ -23,6 +23,7 @@ /CLAUDE.md export-ignore /CHANGELOG.md export-ignore /SECURITY.md export-ignore +/languages export-ignore # Consistent line endings * text=auto eol=lf diff --git a/CLAUDE.md b/CLAUDE.md index cb730e0..a7d3eca 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -23,7 +23,7 @@ WordPress plugin, published on wordpress.org (slug `wirecore-rest-control`) and ## Translations -All UI strings are English in the code and translated in `languages/`: `de_DE` (informal) and `de_DE_formal` (formal). WP-CLI output stays English and untranslated. `load_plugin_textdomain()` is kept for the bundled translations until language packs exist on translate.wordpress.org. +All UI strings are English in the code. Translations are delivered as language packs from translate.wordpress.org, so there is no `load_plugin_textdomain()` and `languages/` is not shipped (wordpress.org review). `languages/` holds the template and the German translations `de_DE` (informal) and `de_DE_formal` (formal) for importing into translate.wordpress.org. WP-CLI output stays English and untranslated. After changing strings (inside the Docker container, `P=wp-content/plugins/wirecore-rest-control`): @@ -35,11 +35,11 @@ docker compose exec wordpress wp --allow-root i18n make-mo $P/languages docker compose exec wordpress wp --allow-root i18n make-php $P/languages ``` -`.po`, `.mo` and `.l10n.php` are part of the package. The files are created as root inside the container – `chown` them to your user if needed. +The files are created as root inside the container – `chown` them to your user if needed. ## Package contents -Only `wirecore-rest-control.php`, `uninstall.php`, `index.php`, `readme.txt`, `LICENSE`, `includes/`, `assets/` and `languages/` are shipped. New development or configuration files must be added to both `.distignore` and `.gitattributes` (`export-ignore`). +Only `wirecore-rest-control.php`, `uninstall.php`, `index.php`, `readme.txt`, `LICENSE`, `includes/` and `assets/` are shipped. New development or configuration files must be added to both `.distignore` and `.gitattributes` (`export-ignore`). ## Checks diff --git a/README.md b/README.md index 9336d48..ade50f6 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ wp wirecore-rest status wp wirecore-rest routes [--namespace=] [--source=] [--format=table|json|csv] wp wirecore-rest set [--read=] [--write=] wp wirecore-rest default [--read=] [--write=] -wp wirecore-rest export [] +wp wirecore-rest export > settings.json wp wirecore-rest import wp wirecore-rest log [--clear] [--format=table|json|csv] ``` @@ -120,7 +120,7 @@ Composer installs the dependencies for PHP 7.4 (`config.platform` in `composer.j ### Translations -All UI strings are English in the code (text domain `wirecore-rest-control`) and translated in `languages/`. After changing strings (`P=wp-content/plugins/wirecore-rest-control`): +All UI strings are English in the code (text domain `wirecore-rest-control`). Translations are delivered as language packs from translate.wordpress.org; `languages/` holds the template and the German translations for importing there and is not shipped. After changing strings (`P=wp-content/plugins/wirecore-rest-control`): ```bash docker compose exec wordpress wp --allow-root i18n make-pot $P $P/languages/wirecore-rest-control.pot --domain=wirecore-rest-control --exclude=node_modules,db-data,languages diff --git a/includes/class-wirecore-rc-cli.php b/includes/class-wirecore-rc-cli.php index 678f6ab..701d0f1 100644 --- a/includes/class-wirecore-rc-cli.php +++ b/includes/class-wirecore-rc-cli.php @@ -220,27 +220,19 @@ public function set_default($args, $assoc_args) } /** - * Exports the settings as JSON. + * Exports the settings as JSON to STDOUT. * - * ## OPTIONS + * ## EXAMPLES * - * [] - * : Target file. Prints to STDOUT if omitted. + * wp wirecore-rest export > settings.json */ - public function export($args) + public function export() { $json = wp_json_encode( WireCore_RC_Settings::export(), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); - if (!isset($args[0])) { - WP_CLI::line($json); - return; - } - if (file_put_contents($args[0], $json . "\n") === false) { - WP_CLI::error(sprintf('Could not write "%s".', $args[0])); - } - WP_CLI::success(sprintf('Exported to %s.', $args[0])); + WP_CLI::line($json); } /** diff --git a/wirecore-rest-control.php b/wirecore-rest-control.php index c543fdd..fdeb24a 100644 --- a/wirecore-rest-control.php +++ b/wirecore-rest-control.php @@ -10,7 +10,6 @@ License: GPL-2.0-or-later License URI: https://www.gnu.org/licenses/gpl-2.0.html Text Domain: wirecore-rest-control -Domain Path: /languages */ // Prevent direct access @@ -30,17 +29,6 @@ require_once __DIR__ . '/includes/class-wirecore-rc-guard.php'; require_once __DIR__ . '/includes/class-wirecore-rc-admin.php'; -add_action('init', function () { - // Needed for the bundled translations until language packs exist on - // translate.wordpress.org. - // phpcs:ignore PluginCheck.CodeAnalysis.DiscouragedFunctions.load_plugin_textdomainFound - load_plugin_textdomain( - 'wirecore-rest-control', - false, - dirname(plugin_basename(__FILE__)) . '/languages' - ); -}); - WireCore_RC_Guard::init(); WireCore_RC_Admin::rest_init(); if (is_admin()) {