fix: verify Guest Authors when running CLI commands #1090
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Co-authors-plus allows developers to use the filter
add_filter( 'coauthors_guest_authors_enabled', '__return_false' ), but when developers implement this filter, many of the Co-Authors-Plus CLI commands will then throw FATAL PHP errors.This PR will verify that when a developers uses the filter
add_filter( 'coauthors_guest_authors_enabled', '__return_false' ), that the CLI commands that need Guest Authors will display an error and die gracefully as opposed to throwing a fatal error in the debug.log.This PR may not be inclusive of all the Co-Authors-Plus CLI commands that need to verified. I simply searched for
$coauthors_plus->guest_authorsin each command; and if found, I added$this->verify_guest_authors_or_die();.I did not fully test all commands nor all edge cases as I'm not a Co-Authors-Plus expert.
Example fatal error (without this PR) when running CLI commands:
Deploy Notes
No new dependencies were added.
Steps to Test
add_filter( 'coauthors_guest_authors_enabled', '__return_false' )in a separate plugin.