-
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?
Conversation
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. Thanks for integrating Codecov - We've got you covered ☂️ |
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.
Pull Request Overview
This PR adds functionality to skip authors and terms (categories, tags, custom taxonomy terms, and nav menu terms) from WordPress export files. The implementation follows the existing pattern used by the --skip_comments flag.
Key Changes:
- Added
--skip_authorsand--skip_termscommand-line flags - Implemented exclusion mechanism in
WP_Export_Split_Files_Writerto filter out specified sections - Modified
before_posts()method signature to accept available sections parameter
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/Export_Command.php | Added CLI parameters and validation methods for --skip_authors and --skip_terms flags, populating the $exclude array based on user input |
| src/WP_Export_Split_Files_Writer.php | Implemented section exclusion logic and updated before_posts() call to pass filtered sections |
| features/export.feature | Added test scenarios for the new skip flags |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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 ] ); | ||
| } | ||
| } | ||
| } |
Copilot
AI
Nov 2, 2025
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 exclusion logic removes sections from $this->available_sections after it has already been used to calculate $this->subsequent_sections (line 45). This means excluded sections will still be present in subsequent files when using --include_once. The exclusion logic should be moved before line 44 to ensure excluded sections are properly removed from both $this->available_sections and $this->subsequent_sections.
| if ( $this->export_args['skip_authors'] ) { | ||
| $this->exclude[] = 'authors'; | ||
| } | ||
|
|
Copilot
AI
Nov 2, 2025
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 --skip_terms flag excludes sections but does not update $this->export_args['skip_terms'] at the point of exclusion. The validation method check_skip_terms() (line 514-525) will set this value later during validation, but this creates a potential inconsistency if validation order changes. Additionally, the --stdout mode uses WP_Export_File_Writer which doesn't support the exclusion mechanism. When --stdout is used with --skip_authors or --skip_terms, the sections will still be included in the output since WP_Export_File_Writer calls before_posts() without parameters.
| 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'; | |
| } |
| """ | ||
| And the {EXPORT_FILE} file should not contain: | ||
| """ | ||
| <wp:tags> |
Copilot
AI
Nov 2, 2025
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.
| <wp:tags> | |
| <wp:tag> |
This PR introduces
--skip_authorsand--skip_termsflags forwp exportcommand.Fixes: #72