Skip to content

Commit

Permalink
Merge pull request #58 from IONOS-WordPress/feature/mu-plugin-support
Browse files Browse the repository at this point in the history
Feature/mu plugin support
  • Loading branch information
lgersman authored Feb 6, 2025
2 parents b957248 + b5b6b8c commit 3bb62fd
Show file tree
Hide file tree
Showing 18 changed files with 370 additions and 41 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ node_modules
/wp-env-home
/packages/*/*/node_modules
/packages/*/*/build
# exclude wp-mu-plugin build dirs
/packages/*/*/*/build
/packages/*/*/dist
# exclude wp-mu-plugin build dirs
/packages/*/*/*/dist
/packages/*/*/languages/*.json
/packages/*/*/languages/*.mo
/packages/*/*/languages/*.php
# exclude wp-mu-plugin generated language files
/packages/*/*/*/languages/*.json
/packages/*/*/*/languages/*.mo
/packages/*/*/*/languages/*.php
/.vscode/settings.json
/.vscode/launch.json
/.secrets
Expand All @@ -16,8 +24,10 @@ node_modules
/.wp-env.override.json
/bin/
build-info
build-info
packages/*/*/webpack.config.js
/build
/build
*storybook.log
/playwright/.cache
/playwright/storybook/.*
Expand Down
1 change: 1 addition & 0 deletions packages/docker/ecs-php/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<exclude name="WordPress.WhiteSpace.OperatorSpacing.NoSpaceBefore"/>
<exclude name="WordPress.WP.AlternativeFunctions.file_system_operations_mkdir"/>
<exclude name="WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents"/>
<exclude name="WordPress.WhiteSpace.OperatorSpacing.NoSpaceAfter"/>
</rule>

<rule ref="NormalizedArrays">
Expand Down
14 changes: 14 additions & 0 deletions packages/wp-mu-plugin/test-mu-plugin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@ionos-wordpress/test-mu-plugin",
"private": true,
"version": "0.0.1",
"dependencies": {
"@ionos-wordpress/test-lib": "workspace:*"
},
"devDependencies": {
"@wordpress/components": "catalog:",
"@ionos-wordpress/rector-php": "workspace:*",
"@ionos-wordpress/ecs-php": "workspace:*",
"@ionos-wordpress/dennis-i18n": "workspace:*"
}
}
52 changes: 52 additions & 0 deletions packages/wp-mu-plugin/test-mu-plugin/test-mu-plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

/**
* Plugin Name: ionos-wordpress/test-mu-plugin
* Description: a test mu plugin
* Requires at least: 6.6
* Requires Plugins:
* Requires PHP: 8.3
* Version: 0.0.1
* License: GPL-2.0-or-later
* Author: IONOS Group
* Author URI: https://www.ionos-group.com/brands.html
* Domain Path: /languages
*/

namespace ionos_wordpress\test_mu_plugin;

defined('ABSPATH') || exit();

const PLUGIN_FILE = __FILE__;

\add_action('init', function (): void {
\load_muplugin_textdomain(
domain: 'test-mu-plugin',
mu_plugin_rel_path: basename(__DIR__) . '/test-mu-plugin/languages/'
);

$translated_text = \__('hello.world', 'test-mu-plugin');
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
error_log($translated_text);
});

\add_action('admin_enqueue_scripts', function (): void {
$assets = include_once __DIR__ . '/test-mu-plugin/build/index.asset.php';
\wp_enqueue_script(
handle: 'test-mu-plugin-index',
src: \plugins_url('/test-mu-plugin/build/index.js', __FILE__),
deps: $assets['dependencies'],
ver: $assets['version'],
args: [
'in_footer' => true,
],
);
\wp_set_script_translations(
handle : 'test-test-mu-plugin-index',
domain : 'test-mu-plugin',
path : basename(__DIR__) . '/test-mu-plugin/languages'
);
});

require_once __DIR__ . '/test-mu-plugin/inc/feature-1.php';
require_once __DIR__ . '/test-mu-plugin/build/feature-2/index.php';
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace ionos_wordpress\test_mu_plugin\feature_1;

function feature_1(): void
{
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
error_log('hello from ionos_wordpress\test_mu_plugin\feature_1');
}

feature_1();
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
msgid ""
msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Language: de\n"
"Language-Team: none\n"
"Last-Translator: Automatically generated\n"
"MIME-Version: 1.0\n"
"PO-Revision-Date: 2025-02-05T12:26:16+00:00\n"
"POT-Creation-Date: 2025-02-05T12:26:16+00:00\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Project-Id-Version: ionos-wordpress/test-mu-plugin 0.0.1\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/html\n"
"X-Domain: test-mu-plugin\n"
"X-Generator: WP-CLI 2.11.0\n"

#. Plugin Name of the plugin
#: test-mu-plugin.php
msgid "ionos-wordpress/test-mu-plugin"
msgstr "ionos-wordpress/test-mu-plugin"

#. Description of the plugin
#: test-mu-plugin.php
msgid "a test mu plugin"
msgstr "ein Test-Mu-Plugin"

#. Author of the plugin
#: test-mu-plugin.php
msgid "IONOS Group"
msgstr "IONOS-Gruppe"

#. Author URI of the plugin
#: test-mu-plugin.php
msgid "https://www.ionos-group.com/brands.html"
msgstr "https://www.ionos-group.com/brands.html"

#: test-mu-plugin.php:25
msgid "hello.world"
msgstr "hallo.welt"

#: test-mu-plugin/build/feature-2/index.js:1
msgid "hello from packages/wp-mu-plugin/test-mu-plugin/src/feature-2/index.js"
msgstr "hallo von packages/wp-mu-plugin/test-mu-plugin/src/feature-2/index.js"

#: test-mu-plugin/build/index.js:1
msgid "hello from packages/wp-mu-plugin/test-mu-plugin/src/index.js"
msgstr "hallo von packages/wp-mu-plugin/test-mu-plugin/src/index.js"
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
msgid ""
msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Language: en_US\n"
"Language-Team: none\n"
"Last-Translator: Automatically generated\n"
"MIME-Version: 1.0\n"
"PO-Revision-Date: 2025-02-05T12:26:16+00:00\n"
"POT-Creation-Date: 2025-02-05T12:26:16+00:00\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Project-Id-Version: ionos-wordpress/test-mu-plugin 0.0.1\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/html\n"
"X-Domain: test-mu-plugin\n"
"X-Generator: WP-CLI 2.11.0\n"

#. Plugin Name of the plugin
#: test-mu-plugin.php
msgid "ionos-wordpress/test-mu-plugin"
msgstr "ionos-wordpress/test-mu-plugin"

#. Description of the plugin
#: test-mu-plugin.php
msgid "a test mu plugin"
msgstr "a test mu plugin"

#. Author of the plugin
#: test-mu-plugin.php
msgid "IONOS Group"
msgstr "IONOS Group"

#. Author URI of the plugin
#: test-mu-plugin.php
msgid "https://www.ionos-group.com/brands.html"
msgstr "https://www.ionos-group.com/brands.html"

#: test-mu-plugin.php:25
msgid "hello.world"
msgstr "hello.world"

#: test-mu-plugin/build/feature-2/index.js:1
msgid "hello from packages/wp-mu-plugin/test-mu-plugin/src/feature-2/index.js"
msgstr "hello from packages/wp-mu-plugin/test-mu-plugin/src/feature-2/index.js"

#: test-mu-plugin/build/index.js:1
msgid "hello from packages/wp-mu-plugin/test-mu-plugin/src/index.js"
msgstr "hello from packages/wp-mu-plugin/test-mu-plugin/src/index.js"
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Copyright (C) 2025 IONOS Group
# This file is distributed under the GPL-2.0-or-later.
msgid ""
msgstr ""
"Project-Id-Version: ionos-wordpress/test-mu-plugin 0.0.1\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/html\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2025-02-05T14:52:37+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.11.0\n"
"X-Domain: test-mu-plugin\n"

#. Plugin Name of the plugin
#: test-mu-plugin.php
msgid "ionos-wordpress/test-mu-plugin"
msgstr ""

#. Description of the plugin
#: test-mu-plugin.php
msgid "a test mu plugin"
msgstr ""

#. Author of the plugin
#: test-mu-plugin.php
msgid "IONOS Group"
msgstr ""

#. Author URI of the plugin
#: test-mu-plugin.php
msgid "https://www.ionos-group.com/brands.html"
msgstr ""

#: test-mu-plugin.php:25
msgid "hello.world"
msgstr ""

#: test-mu-plugin/build/feature-2/index.js:1
msgid "hello from packages/wp-mu-plugin/test-mu-plugin/src/feature-2/index.js"
msgstr ""

#: test-mu-plugin/build/index.js:1
msgid "hello from packages/wp-mu-plugin/test-mu-plugin/src/index.js"
msgstr ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { __ } from '@wordpress/i18n';
// eslint-disable-next-line no-console
console.log(__('hello from packages/wp-mu-plugin/test-mu-plugin/src/feature-2/index.js', 'test-mu-plugin'));
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace ionos_wordpress\test_mu_plugin\feature_2;

use const ionos_wordpress\test_mu_plugin\PLUGIN_FILE;

function feature_2(): void
{
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
error_log('hello from ionos_wordpress\test_mu_plugin\feature_2');
}

feature_2();

\add_action('admin_enqueue_scripts', function (): void {
$assets = include_once __DIR__ . '/index.asset.php';
\wp_enqueue_script(
handle: 'test-mu-plugin-feature-2-index',
src: \plugins_url('test-mu-plugin/build/feature-2/index.js', PLUGIN_FILE),
deps: $assets['dependencies'],
ver: $assets['version'],
args: [
'in_footer' => true,
],
);
\wp_set_script_translations('test-mu-plugin-feature-2-index', 'test-mu-plugin', PLUGIN_FILE . '/languages');
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { __ } from '@wordpress/i18n';
// eslint-disable-next-line no-console
console.log(__('hello from packages/wp-mu-plugin/test-mu-plugin/src/index.js', 'test-mu-plugin'));
2 changes: 1 addition & 1 deletion packages/wp-plugin/essentials/essentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
* see https://gist.github.com/CruelDrool/4cc70b819a33793396456c5ddb81781d
*/
\add_filter('plugins_api', function (\stdClass|false $result, string $action, \stdClass $args): \stdClass|false {
if ("{$args->slug}" !== \plugin_basename(__FILE__)) {
if (! isset($args->slug) || "{$args->slug}" !== \plugin_basename(__FILE__)) {
return $result;
}

Expand Down
Loading

0 comments on commit 3bb62fd

Please sign in to comment.