endpoints[ $endpoint_instance->get_name() ] = $endpoint_instance; } public function __construct() { add_action( 'rest_api_init', function () { $this->register_endpoints(); // Because 'register_endpoints' is protected. } ); } }