Skip to content

Commit 30d5da4

Browse files
authored
Merge pull request #4 from RRZE-Webteam/dev
Dev
2 parents e61e428 + dc6f1c6 commit 30d5da4

File tree

297 files changed

+21936
-21316
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

297 files changed

+21936
-21316
lines changed

README.md

+26-28
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,62 @@
11
# RRZE-CLI
22

3-
WP-CLI Erweiterung für die CMS-Verwaltung des RRZE.
3+
WP-CLI extension for RRZE's CMS management.
44

5-
## Anforderungen
5+
## Requirements
66

7-
- PHP >= 8.0
8-
- WP-CLI >= 2.7.1
7+
- PHP >= 8.2
8+
- WP-CLI >= 2.11.0
99

1010
## Migration
1111

12-
Diese WP-CLI-Erweiterung macht den Prozess der Migration von Websites von einzelnen Wordpress-Instanzen zu einer Multisite-Instanz (oder umgekehrt) viel einfacher. Es exportiert alles in ein ZIP-Paket, das verwendet werden kann, um es automatisch in die gewünschte Multisite-Installation zu importieren.
12+
This WP-CLI extension simplifies the process of migrating websites on a WordPress multisite installation. It exports everything to a ZIP package, which can then be automatically imported into the desired multisite installation.
1313

14-
### Verwendung
14+
### Export
1515

16-
Der Befehl `rrze-migration export` exportiert eine ganze Website in ein Zip-Paket.
16+
The `rrze-migration export` command exports an entire website into a ZIP package.
1717

1818
```
19-
$ wp rrze-migration export all website.zip --plugins --themes --uploads
19+
$ wp rrze-migration export all
2020
```
2121

22-
Der obige Befehl exportiert Benutzer, Tabellen, Plugins-Ordner, Themes-Ordner und den Uploads-Ordner in eine ZIP-Datei, die man auf der Multisite-Instanz migrieren kann, um sie mit dem Befehl `import all` zu importieren. Die optionalen Flags `--plugins --themes --uploads` fügen den Plugins-Ordner, den Themes-Ordner bzw. den Uploads-Ordner zur ZIP-Datei hinzu.
23-
24-
Man kann auch Websites aus einer Multisite-Instanz exportieren, man muss dazu den Parameter `--blog_id` übergeben. Bspw:
22+
You can also export websites from a Multisite instance by passing the `--url` parameter. For example:
2523

2624
```
27-
$ wp rrze-migration export all website.zip --blog_id=2
25+
$ wp rrze-migration export all --url=website-url
2826
```
29-
30-
Der Befehl `rrze-migration import` kann verwendet werden, um eine Website aus einem ZIP-Paket zu importieren.
27+
In some special cases, `rrze-migration export` may not detect all custom tables when exporting a website to a Multisite instance. If you need to migrate non-standard tables, you can use the `--tables` or `--custom-tables` parameter. For example:
3128

3229
```
33-
$ wp rrze-migration import all website.zip
30+
$ wp rrze-migration export all --url=website-url --custom-tables=custom_table_1,custom_table_2
3431
```
3532

36-
Beim Importieren in eine Multisite-Instanz wird eine neue Website innerhalb der Multisite-Instanz erstellt, basierend auf der Website, die man gerade exportiert hat. Beim Importieren in eine einzelne Installation wird die aktuelle Website mit der exportierten Website überschrieben.
33+
If you pass `--tables`, only the specified tables will be exported. Therefore, when using this option, ensure that all necessary tables, including WordPress default tables, are included in the export.
3734

38-
Der Befehl `rrze-migration import all` kümmert sich um alles, was getan werden muss, wenn eine Website in der Multisite-Instanz migrieren wird (Ersetzen von Tabellenpräfixen, Aktualisieren von `post_author`-IDs usw.).
35+
If you pass `--uploads`, the files in the media library will also be exported. However, it is only recommended to use this option where the media library does not exceed 500 MB in total. Otherwise, it is recommended to use `rsync` for example.
3936

40-
Wenn man eine neue URL für die zu importierende Website einrichten muss, kann man diese an den Befehl `rrze-migration import all` übergeben.
37+
### Import
38+
39+
The `rrze-migration import` command can be used to import a website from a ZIP package.
4140

4241
```
43-
$ wp rrze-migration import all website.zip --new_url=new-website-domain
42+
$ wp rrze-migration import all website.zip
4443
```
44+
When importing into a Multisite instance, a new website within the Multisite network is created based on the exported website. When importing into a standalone installation, the current website is overwritten with the exported website.
4545

46-
Der Befehl `rrze-migration import` unterstützt auch den Parameter `--mysql-single-transaction`, der den SQL-Export in eine einzige Transaktion umschließt, um alle Änderungen aus dem Import auf einmal festzuschreiben und zu verhindern, dass der Schreibvorgang den Datenbankserver überlastet.
46+
The `rrze-migration import all` command handles everything required for migrating a website within a Multisite instance.
4747

48-
Man kann auch `--blog_id` an den Befehl `import all` übergeben, in diesem Fall überschreibt der Import eine vorhandene Website.
48+
If you need to set up a new URL for the imported website, you can pass it to the `rrze-migration import all` command.
4949

5050
```
51-
$ wp rrze-migration import all website.zip --new_url=new-website-domain --blog_id=2
51+
$ wp rrze-migration import all website.zip --new_url=new-website-url
5252
```
5353

54-
In einigen Sonderfällen ist es möglich, `rrze-migration export` nicht alle benutzerdefinierten Tabellen erkennen kann, während eine Website in eine Multisite-Instanz exportiert wird. Wenn man also nicht standardmäßige Tabellen migrieren muss, kann man das Parameter `--tables` oder `--custom-tables` verwenden. Bspw:
54+
The `rrze-migration import` command also supports the `--mysql-single-transaction` parameter, which wraps the SQL export into a single transaction to commit all import changes at once, preventing database server overload.
5555

5656
```
57-
$ wp rrze-migration export all website.zip --blog_id=1 --custom-tables=custom_table_1,custom_table_2
57+
$ wp rrze-migration import all website.zip --new_url=new-website-url --mysql-single-transaction
5858
```
5959

60-
Wenn man `--tables` übergeben, werden nur die übergebenen Tabellen exportiert. Wenn man es also verwendet, muss man sicher stellen, dass alle Tabellen übergibt, die man exportieren möchtet, einschließlich der Standardtabellen des WordPress.
61-
62-
### Anmerkungen
60+
### Notes
6361

64-
Wenn die Themes und die Plugins auf WordPress-Art erstellt wurden, sollte man nach der Migration keine größeren Probleme haben. Man muss daran denken, dass bei einigen Themes Inkompatibilitätsprobleme auftreten können (bspw. fest codierte Links wie '/kontakt' usw.). Abhängig von der Codebasis der Website, die man migriert, muss man möglicherweise einige Anpassungen an dem Code vornehmen.
62+
If themes and plugins are developed according to WordPress standards, migration should proceed without major issues. However, depending on the codebase of the website being migrated, you may need to make some adjustments to the code.

composer.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
{
22
"require": {
3-
"php": "^8.1.0",
4-
"alchemy/zippy": "^1.0.0"
3+
"php": "^8.2.0",
4+
"nelexa/zip": "^4.0"
5+
},
6+
"require-dev": {
7+
"wp-cli/wp-cli": "^v2.11.0"
58
},
69
"autoload": {
710
"psr-4": {
811
"RRZE\\CLI\\": "includes/"
912
}
1013
}
11-
}
14+
}

includes/Info.php

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
defined('ABSPATH') || exit;
66

77
use WP_CLI_Command;
8-
use function RRZE\CLI\plugin;
98

109
/**
1110
* @package RRZE\CLI

includes/Main.php

+28-3
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,43 @@
99
class Main
1010
{
1111
/**
12-
* __construct
12+
* @return void
13+
* @throws WP_CLI\ExitException
1314
*/
14-
public function __construct()
15+
public function loaded(): void
1516
{
16-
if (!class_exists('WP_CLI')) {
17+
// Check if WP_CLI is available
18+
if (!defined('WP_CLI') || !WP_CLI) {
1719
return;
1820
}
21+
22+
// Output the WP_CLI version
23+
$wpcliVersion = WP_CLI::runcommand('cli version', ['return' => true]);
24+
WP_CLI::log(trim($wpcliVersion));
25+
26+
// Get the current working directoryclear
27+
$currentDir = getcwd();
28+
if (false === $currentDir) {
29+
WP_CLI::error(__('Unable to determine the current working directory.', 'rrze-cli'));
30+
}
31+
32+
// Output the current directory
33+
WP_CLI::log("Current directory: " . $currentDir);
34+
35+
// Check if the command is running in the main directory of WordPress
36+
if (!file_exists($currentDir . '/wp-load.php')) {
37+
WP_CLI::error(__('This command must be run from the main directory of a WordPress installation.', 'rrze-cli'));
38+
}
39+
1940
// rrze-cli
2041
WP_CLI::add_command('rrze-cli info', __NAMESPACE__ . '\\Info');
42+
2143
// rrze-migration
2244
WP_CLI::add_command('rrze-migration export', __NAMESPACE__ . '\\Migration\\Export');
2345
WP_CLI::add_command('rrze-migration import', __NAMESPACE__ . '\\Migration\\Import');
2446
WP_CLI::add_command('rrze-migration posts', __NAMESPACE__ . '\\Migration\\Posts');
47+
48+
// rrze-multilang
49+
WP_CLI::add_command('rrze-multilang migration', __NAMESPACE__ . '\\Multilang\\Migration');
2550
}
2651
}

0 commit comments

Comments
 (0)