Yoast\WP\SEO\AI\Content_Planner\User_Interface
Get_Suggestions_Route::check_permissions
Checks if the user is logged in and can edit posts of the requested post type.
The requested post_type is caller-controlled, so the permission must be evaluated against that post type's own edit_posts meta-capability — not the generic 'edit_posts' string, which would let a user with edit_posts but no edit_pages (e.g. an Author) pull metadata for pages or arbitrary CPTs.
Метод класса: Get_Suggestions_Route{}
Хуков нет.
Возвращает
true|false. Whether the user can edit posts of the requested post type.
Использование
$Get_Suggestions_Route = new Get_Suggestions_Route(); $Get_Suggestions_Route->check_permissions( $request ): bool;
- $request(WP_REST_Request) (обязательный)
- The request object.
Код Get_Suggestions_Route::check_permissions() Get Suggestions Route::check permissions Yoast 28.3
public function check_permissions( WP_REST_Request $request ): bool {
$user = \wp_get_current_user();
if ( $user === null || $user->ID < 1 ) {
return false;
}
$post_type = $request->get_param( 'post_type' );
$post_type_object = \get_post_type_object( $post_type );
if ( $post_type_object === null ) {
return false;
}
return \user_can( $user, $post_type_object->cap->edit_posts );
}