oberonlai/wp-router

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

Adding router for WordPress.

dev-master 2021-07-22 03:04 UTC

This package is auto-updated.

Last update: 2021-07-22 10:33:33 UTC


README

Easily add custom URL endpoints in WordPress. Map a url to a function. Modifed from wordpress-dispatcher

Requirements

Installation

Install with composer

Run the following in your terminal to install with Composer.

$ composer require oberonlai/wp-router

WP Router PSR-4 autoloading and can be used with the Composer's autoloader. Below is a basic example of getting started, though your setup may be different depending on how you are using Composer.

require __DIR__ . '/vendor/autoload.php';

use ODS\Router;

Router::routes( array() );

See Composer's basic usage guide for details on working with Composer and autoloading.

Example

use ODS\Router;

Router::routes( 
	array (
		'testing-a-url' => function(){
		    echo 'Hello Ted';
		},

		'hello-([a-z]+)' => function($request, $name){
		    echo "Hello $name";
		}
	)
);

/testing-a-url & /hello-dougle will now be accessable in your WordPress site.