post_access_checker = $post_access_checker; } /** * Returns, for each given post ID, whether the current user may edit it. * * @param array $post_ids The post IDs on the current page. * * @return array A map of post ID to whether the current user may edit it. */ public function resolve( array $post_ids ): array { if ( $post_ids === [] ) { return []; } // Prime the post cache once so the per-post edit check does not run a query per post. \_prime_post_caches( $post_ids, false, false ); $editability = []; foreach ( $post_ids as $post_id ) { $editability[ $post_id ] = $this->post_access_checker->can_edit( $post_id ); } return $editability; } }