Skip to content

Commit

Permalink
Added readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mareksriska committed Mar 19, 2018
1 parent 00df204 commit 75de693
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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'));
});```

0 comments on commit 75de693

Please sign in to comment.