From f4c90d14caad795a998a18ff02e19b817606da12 Mon Sep 17 00:00:00 2001 From: Kader Bouyakoub Date: Mon, 28 May 2018 00:57:56 +0100 Subject: [PATCH] Added the possibility to chain named routes using forward slashes (e.g: named1/named2). --- skeleton/third_party/bkader/class-route.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/skeleton/third_party/bkader/class-route.php b/skeleton/third_party/bkader/class-route.php index 66c9b35..9b6b370 100644 --- a/skeleton/third_party/bkader/class-route.php +++ b/skeleton/third_party/bkader/class-route.php @@ -535,6 +535,19 @@ public static function get_prefix() */ public static function named($name) { + // In case of forward slashes. + if (false !== strpos($name, '/')) + { + // 1. Explode and clean elements. + $exp = array_clean(explode('/', $name)); + + // 2. Pass them to this method. + $exp = array_map(array('Route', 'named'), $exp); + + // 3. Put back element together and return them. + return implode('/', $exp); + } + // Make the method remember cached routes. static $cached = array();