wpemerge
wpemerge copied to clipboard
feat: wordpress conditional routing
Discussion
Hi there!
As it is WordPress Framework, I'm using a lot of WordPress pages and conditional tags like is_front_page()
, is_singular()
etc. So I thought maybe it is a good idea to implement shortcuts for WordPress conditional routing and instead of this
\App::route()->get()->where('is_front_page')->handle(/** callback */);
\App::route()->get()->where('is_page', 17)->handle(/** callback */);
\App::route()->get()->where('is_singular', 'book')->handle(/** callback */);
call it like
\App::route()->is_front_page()->handle(/** callback */);
\App::route()->is_page(17)->handle(/** callback */);
\App::route()->is_singular('book')->handle(/** callback */);
Also this PR gives shortcut for calling ajax route
\App::route()->get()->where('ajax', 'action', true, true)->handle(/** callback */);
\App::route()->get()->ajax('action', true, true)->handle(/** callback */);
What this PR does
Simplifies syntax of routing condition for built-in WordPress callables