-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Respect Posts Page #8259
Respect Posts Page #8259
Conversation
…ordPress (as per similar functionality from edit-form-advanced.php).
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.
Pending approach feedback at #3659 (comment)
lib/register.php
Outdated
@@ -269,6 +269,10 @@ function gutenberg_can_edit_post( $post ) { | |||
return false; | |||
} | |||
|
|||
if ( $post->ID == get_option( 'page_for_posts' ) && empty( $post->post_content ) ) { |
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.
- Needs Yoda condition (see failing build)
- Should ideally be using strict equality. This isn't codified in the standard, but if we expect it to take a particular value shape, we'd be better off than to allow leniency (prone to false positives)
- The condition is not self-explanatory, and could do for an inline code comment explaining why it exists.
… `page_for_posts` option as an integer. Added an inline comment.
…n the posts page has content and false when the posts page has no content.
'post_title' => 'Blog', | ||
'post_content' => '', | ||
) ); | ||
update_option( 'page_for_posts', $blog_page_without_content ); |
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.
Are these tests isolated from one another? Is this something which should be reverted in a tearDown
?
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.
@aduth All MySQL queries in WordPress unit tests use the COMMIT
and ROLLBACK
approach to ensure that things like update_option
are automatically rolled back. See https://github.com/WordPress/wordpress-develop/blob/master/tests/phpunit/includes/testcase.php#L155
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.
Looks good. E2E failures are unrelated and are being investigated separately. Will try restarting Travis to get a passing build.
Description
Ensure that Gutenberg is disabled when on the assigned blog page in WordPress. Provides feature parity as per functionality from https://github.com/WordPress/WordPress/blob/master/wp-admin/edit-form-advanced.php#L73).
Fixes #3659
How has this been tested?
Tested manually as follows:
Added unit tests to ensure the gutenberg_can_edit_post() function returns false when attempting to edit the posts page if it does not have content and returns true when it does have content.
Screenshots
Types of changes
Bug fix - adds a check to the
gutenberg_can_edit_post()
function and returns false if it is the posts page and has no content.Checklist: