service = $service; } /** * Register the REST endpoint to WordPress. */ public function register() { register_rest_route( self::REST_NAMESPACE, self::ENDPOINT_QUERY, array( 'methods' => 'GET', 'callback' => array( $this->service, 'reindex', ), 'permission_callback' => array( $this, 'can_retrieve_data', ), ) ); } /** * Determines if the current user is allowed to use this endpoint. * * @return bool */ public function can_retrieve_data() { return current_user_can( self::CAPABILITY_RETRIEVE ); } }