From 75de6937471e42c42d9f7388a27a3938fdaaa172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mareks=20D=C4=81vis=20Ri=C5=A1ka?= Date: Mon, 19 Mar 2018 11:11:15 +0200 Subject: [PATCH] Added readme --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..c9a5ff5 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# Wordpress virtual routes + +### How to use +1. Add an action to wp_virtual_routes that recieves RouterInterface as a parameter. +2. Add new route with $router->addRoute(); As a param pass RouteInterface type. + * new Route(); + * First param ir route url. Example: '/users/login' + * Second param is of type RouteHandlerInterface. You can extend the RequestHandler class to create your own handler or just pass in RequestHandler + with a defined template param to create a simple page that renders your specified template. + * Third is page title. Example: 'User login form' +``` +add_action('wp_virtual_routes', function (RouterInterface $router) { + $router->addRoute(new Route('/users/login', new LoginHandler(), 'User login')); + $router->addRoute(new Route('/users/profile', new RequestHandler('views/user-profile.blade.php'), 'User profile')); +});``` \ No newline at end of file