-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7662 from Automattic/release/4.24.2
Release 4.24.2
- Loading branch information
Showing
22 changed files
with
983 additions
and
917 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
includes/rest-api/class-sensei-rest-api-sensei-emails-controller.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
/** | ||
* Sensei REST API: Sensei_REST_API_Sensei_Emails_Controller class. | ||
* | ||
* @package sensei-lms | ||
* @since 4.24.2 | ||
*/ | ||
|
||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
/** | ||
* A REST controller for Sensei Emails CPT. | ||
* | ||
* @since 4.24.2 | ||
* | ||
* @see WP_REST_Posts_Controller | ||
*/ | ||
class Sensei_REST_API_Sensei_Emails_Controller extends WP_REST_Posts_Controller { | ||
/** | ||
* Checks if a given request has access to read posts. | ||
* | ||
* @param WP_REST_Request $request Full details about the request. | ||
* | ||
* @return true|WP_Error True if the request has read access, WP_Error object otherwise. | ||
*/ | ||
public function get_items_permissions_check( $request ) { | ||
$parent_check = parent::get_items_permissions_check( $request ); | ||
|
||
if ( is_wp_error( $parent_check ) ) { | ||
return $parent_check; | ||
} | ||
|
||
if ( ! current_user_can( 'manage_sensei' ) ) { | ||
return new WP_Error( | ||
'rest_forbidden_context', | ||
__( 'Sorry, you are not allowed to view posts in this post type.', 'sensei-lms' ), | ||
array( 'status' => rest_authorization_required_code() ) | ||
); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
/** | ||
* Checks if the logged-in user should have access to a specific sensei email. | ||
* | ||
* @param WP_REST_Request $request Full details about the request. | ||
* | ||
* @return true|WP_Error True if the request has read access, WP_Error object otherwise. | ||
*/ | ||
public function get_item_permissions_check( $request ) { | ||
$parent_check = parent::get_item_permissions_check( $request ); | ||
|
||
if ( is_wp_error( $parent_check ) ) { | ||
return $parent_check; | ||
} | ||
|
||
if ( ! current_user_can( 'edit_post', $request['id'] ) ) { | ||
return new WP_Error( | ||
'rest_forbidden_context', | ||
__( 'Sorry, you are not allowed to view this item.', 'sensei-lms' ), | ||
array( 'status' => rest_authorization_required_code() ) | ||
); | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.