Make WordPress Core

Changes between Version 2 and Version 3 of Ticket #36292, comment 4


Ignore:
Timestamp:
03/22/2016 01:53:38 PM (9 years ago)
Author:
giuseppe.mazzapica
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #36292, comment 4

    v2 v3  
    6464This is quite an edge case, most of the rules won't require all this code.
    6565
    66 Maybe, internally the function can be used to generate a route class, but to require a class for each custom rule is far from ideal as a public API.
     66Maybe, internally the rule callback can be used to generate instances of a route class, but to require user to write a class for each custom rule is far from ideal as a public API.
    6767
    68 Regarding skipping the main query, if the callback would return anything that is not an array, then there's no variable to assign to the main query, so you can just skip the main query if the callback return anything but an array.
     68Regarding skipping the main query, if the callback would return anything that is not an array, then there are no variables to assign to the main query, so you can just skip the main query if the callback return anything but an array.
    6969
    70 Or maybe, would be possible to just `add_filter( 'skip_main_query', '__return_false' )` inside the callback.
     70Or maybe, would be possible to just `add_filter( 'skip_main_query', '__return_true' )` inside the callback.
    7171
    7272Also note that this approach easily allows for things like:
     
    103103And the two systems could live side-by-side without any issue I think.
    104104
    105 As a final thought, my Cortex (https://github.com/Brain-WP/Cortex) uses the library FastRoute (by Nikita Popov, one of the PHP devs who contributed more to PHP7) that is faster and less resources consuming of the WP system because it use a very clever approach described in this blog article http://nikic.github.io/2014/02/18/Fast-request-routing-using-regular-expressions.html
     105As a final thought, my Cortex (https://github.com/Brain-WP/Cortex) uses the library FastRoute (by Nikita Popov, one of the PHP devs who contributed more to PHP 7) that is faster and less resources consuming of the WP system because it use a very clever approach described in this blog article http://nikic.github.io/2014/02/18/Fast-request-routing-using-regular-expressions.html
    106106
    107107I think would be interesting explore the same concept for WordPress.