REST API: Add support for comments of password-protected posts.

Core requires the post password to view and create comments on password protected posts, so we must support a “password” param on the comments endpoint when fetch comments for a specific post and creating a comment on a password protected post.

Props flixos90, jnylen0.
Fixes #38692.

git-svn-id: https://develop.svn.wordpress.org/trunk@39349 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Joe Hoyle
2016-11-23 16:14:08 +00:00
parent 24abde4e54
commit 5d7118d63e
3 changed files with 172 additions and 19 deletions

View File

@@ -383,13 +383,13 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
* check in core with a filter.
*
* @since 4.7.0
* @access protected
* @access public
*
* @param WP_Post $post Post to check against.
* @param WP_REST_Request $request Request data to check.
* @return bool True if the user can access password-protected content, otherwise false.
*/
protected function can_access_password_content( $post, $request ) {
public function can_access_password_content( $post, $request ) {
if ( empty( $post->post_password ) ) {
// No filter required.
return false;