-
Notifications
You must be signed in to change notification settings - Fork 26
Add --skip_authors and --skip_terms as additional flags #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
69ca167
d8b81f6
a08d2e8
e0fd98c
84aea85
3775bc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -31,6 +31,7 @@ | |||||||||||||||||
| private $max_file_size; | ||||||||||||||||||
| private $include_once; | ||||||||||||||||||
| private $wxr_path; | ||||||||||||||||||
| private $exclude = []; | ||||||||||||||||||
|
|
||||||||||||||||||
| /** | ||||||||||||||||||
| * Exports WordPress content to a WXR file. | ||||||||||||||||||
|
|
@@ -51,6 +52,12 @@ | |||||||||||||||||
| * [--skip_comments] | ||||||||||||||||||
| * : Don't include comments in the WXR export file. | ||||||||||||||||||
| * | ||||||||||||||||||
| * [--skip_authors] | ||||||||||||||||||
| * : Don't include authors in the WXR export file. | ||||||||||||||||||
| * | ||||||||||||||||||
| * [--skip_terms] | ||||||||||||||||||
| * : Don't include terms (categories, tags, custom taxonomy terms and nav menu terms) in the WXR export file. | ||||||||||||||||||
| * | ||||||||||||||||||
| * [--max_file_size=<MB>] | ||||||||||||||||||
| * : A single export file should have this many megabytes. -1 for unlimited. | ||||||||||||||||||
| * --- | ||||||||||||||||||
|
|
@@ -145,6 +152,8 @@ | |||||||||||||||||
| 'with_attachments' => true, // or FALSE if user requested some post__in | ||||||||||||||||||
| 'start_id' => null, | ||||||||||||||||||
| 'skip_comments' => null, | ||||||||||||||||||
| 'skip_authors' => null, | ||||||||||||||||||
| 'skip_terms' => null, | ||||||||||||||||||
| 'max_file_size' => 15, | ||||||||||||||||||
| 'filename_format' => '{site}.wordpress.{date}.{n}.xml', | ||||||||||||||||||
| 'include_once' => null, | ||||||||||||||||||
|
|
@@ -169,6 +178,26 @@ | |||||||||||||||||
| $defaults['with_attachments'] | ||||||||||||||||||
| ); | ||||||||||||||||||
|
|
||||||||||||||||||
| $this->export_args['skip_authors'] = Utils\get_flag_value( | ||||||||||||||||||
| $assoc_args, | ||||||||||||||||||
| 'skip_authors', | ||||||||||||||||||
| $defaults['skip_authors'] | ||||||||||||||||||
| ); | ||||||||||||||||||
|
|
||||||||||||||||||
| $this->export_args['skip_terms'] = Utils\get_flag_value( | ||||||||||||||||||
| $assoc_args, | ||||||||||||||||||
| 'skip_terms', | ||||||||||||||||||
| $defaults['skip_terms'] | ||||||||||||||||||
| ); | ||||||||||||||||||
|
|
||||||||||||||||||
| if ( $this->export_args['skip_authors'] ) { | ||||||||||||||||||
| $this->exclude[] = 'authors'; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
Comment on lines
+193
to
+196
|
||||||||||||||||||
| if ( $this->export_args['skip_authors'] ) { | |
| $this->exclude[] = 'authors'; | |
| } | |
| // Re-calculate exclusions after validation to ensure consistency. | |
| $this->exclude = []; | |
| if ( $this->export_args['skip_authors'] ) { | |
| $this->exclude[] = 'authors'; | |
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,9 +45,18 @@ public function __construct( $formatter, $writer_args = [] ) { | |
| $this->subsequent_sections = array_diff( $this->available_sections, $writer_args['include_once'] ); | ||
| } | ||
|
|
||
| if ( ! empty( $writer_args['exclude'] ) ) { | ||
| foreach ( $writer_args['exclude'] as $exclude ) { | ||
| $key = array_search( $exclude, $this->available_sections, true ); | ||
| if ( false !== $key ) { | ||
| unset( $this->available_sections[ $key ] ); | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+48
to
+55
|
||
|
|
||
| $this->destination_directory = $writer_args['destination_directory']; | ||
| $this->filename_template = $writer_args['filename_template']; | ||
| $this->before_posts_xml = $this->formatter->before_posts(); | ||
| $this->before_posts_xml = $this->formatter->before_posts( $this->available_sections ); | ||
| $this->after_posts_xml = $this->formatter->after_posts(); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The XML tag
<wp:tags>appears to be incorrect. Based on WordPress WXR format standards, tags are typically represented as<wp:tag>, not<wp:tags>(note the singular form). This test assertion may not work as expected.