PHP code example of themeplate / bridge

1. Go to this page and download the library: Download themeplate/bridge library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

themeplate / bridge example snippets


$router = new ThemePlate\Bridge\Router( 'test' );

// `<WP_HOME>/test/route`
$router->map(
	'route',
	function (): bool {
		// ...
	}
);

// `<WP_HOME>/test/[path]`
$router->any(
	'[path]',
	function ( string $path ): bool {
		// $path = [path]
	}
);

// `<WP_HOME>/test/[filename]`
$router->load( new Loader( __DIR__ . '/templates' ) );
// only handles .php files
$router->load( new Loader( __DIR__ . '/templates', 'action' ) );
// only handles .action.php files

add_action( 'init', array( $router, 'init' ) );