WP_Route
WP_Route copied to clipboard
This class doesn't work. A quick review of the many forks.
As stated in other issues this routing class simply doesn't work. The routing logic isn't actually implemented. No check is made to see if the requested URL matches any of the registered routes. There are also a few bugs such as using $this
in a non object context and annoyances such as non-standard capitalization of PHP keywords such as Self
, NULL
and FALSE
.
So don't use this class.
There are a number of forks however, and I thought I'd have a quick look at them to see if any one had taken the implementation of this class a step further. I hope my efforts will help someone save a few precious minutes. I haven't actually tested any of the forks yet, but most are an exact copy of the original and are therefore just as useless.
Samuel Tissot has made significant changes to the class. There is documentation and code comments. The code has been cleaned up and the methods handling the routing have been completely rewritten. There is also a test class. From a cursory glance this fork looks the most promising. It seems to be actively maintained.
- Fork by SamuelTissot
Snellcode has made significant changes to the routing method. The rest of the class is left untouched:
- Fork by snellcode
Minor code changes. However, no changes to the routing logic:
- Fork by panayotov
No changes to the code whatsoever. For now, they are just as useless as the original class:
- Fork by ajaynamdev
- Fork by alishannb
- Fork by chibuzoranyagha
- Fork by despierto0
- Fork by GeekHare
- Fork by haruncpi
- Fork by madebydaniz
- Fork by oyatek
- Fork by pharmarin
- Fork by piotras9000
- Fork by SaeedSoltoon
- Fork by sagar290
- Fork by Samuel-Pedraza
- Fork by SiroDiaz
- Fork by smdimagerie
- Fork by surajkhanal
- Fork by tzan
- Fork by uBazaarLimited
- Fork by vieterp-luc
Thanks for the info @tomas-eklund. If anyone sees this issue and is looking for an alternative, checkout https://github.com/Upstatement/routes.
It has not been updated in awhile, but last I used it it was working fine.
I have now tried out SamuelTissots fork and it worked (at least for some very simple stuff I was doing). I had to tweak the class a little bit (hooking into the wp-loaded
instead of the init
hook) to get it to play nice with some plugins (such as WPML), but it worked.
However, I wasn't aware that Jared from Upstatement had made a similar class. I'll definitely check it out. I really like his Timber plugin and use it from time to time. Thanks for the tip @zlove!