forbidden_error(); } /** * Builds the 403 error for posts the current user may not edit. * * Mirrors WP core's rest_cannot_edit wording. * * @return WP_Error The forbidden error. */ public function forbidden_error(): WP_Error { return new WP_Error( 'yoast_seo_cannot_edit_post', \__( 'Sorry, you are not allowed to edit this post.', 'wordpress-seo' ), [ 'status' => 403 ], ); } /** * Filters a list of post indexables down to the ones the current user may edit. * * @param Indexable[] $indexables The post indexables. * * @return Indexable[] The editable indexables, reindexed. */ public function filter_editable( array $indexables ): array { $editable = \array_filter( $indexables, static function ( $indexable ) { return \current_user_can( 'edit_post', (int) $indexable->object_id ); }, ); return \array_values( $editable ); } }