WordPress Rewrite Rules <ul><li>Rewrite rules are what translates the path of current URL into query_vars that get passed ...
Each rewrite rule consisst of a regular expression mapped to a single endpoint, usually index.php + a query string </li></ul>
WordPress Rewrite Rules <ul><li>General flow of URL to query_vars processing </li><ul><li>WP class loops through each rewr...
public_query_vars can be filtered through 'query_vars' filter </li></ul></ul></ul>
WordPress Rewrite Rules <ul><li>General flow of URL to query_vars processing cont. </li><ul><li>The 'request' filter is ru...
The parse_request action is run on the WP class, also allowing the query_vars to be altered
Upcoming SlideShare
Loading in …5
×

Local Project Rewrite Rules

1,017 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,017
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Local Project Rewrite Rules

  1. 1. WordPress Rewrite Rules <ul><li>Rewrite rules are what translates the path of current URL into query_vars that get passed into the global WP_Query instance, ie, it lets the site have pretty URLs.
  2. 2. Each rewrite rule consisst of a regular expression mapped to a single endpoint, usually index.php + a query string </li></ul>
  3. 3. WordPress Rewrite Rules <ul><li>General flow of URL to query_vars processing </li><ul><li>WP class loops through each rewrite rule until it finds a match </li><ul><li>Works from top to bottom, first match wins </li></ul><li>The query string part of the matching endpoint is then filtered through the public query vars, any non-public query vars are removed </li><ul><li>Default public query vars are set in the public_query_vars declaration of the WP class
  4. 4. public_query_vars can be filtered through 'query_vars' filter </li></ul></ul></ul>
  5. 5. WordPress Rewrite Rules <ul><li>General flow of URL to query_vars processing cont. </li><ul><li>The 'request' filter is run on the remaining query_vars array, allowing it to be altered
  6. 6. The parse_request action is run on the WP class, also allowing the query_vars to be altered
  7. 7. Global WP_Query instance is created with the resulting query_vars array </li></ul></ul>
  8. 8. WordPress Rewrite Rules <ul><li>Rewrite Rules on WordPress VIP </li><ul><li>Unlike normal WordPress installs, VIP's rewrite rules are hardcoded instead of being in the DB
  9. 9. To add new rewrite rules, you should send them to [email_address] attached in a plain text document format to avoid any copy paste issues, ie:
  10. 10. 'top-lists/([^/]+)(/[0-9]+)?/?$' => 'index.php?top-list=$matches[1]&page=$matches[2]', </li></ul></ul>
  11. 11. WordPress Rewrite Rules <ul><li>For the Local Project </li><ul><li>We created the vip-rewrites plugin to simplify the matching of rewrite rules on VIP with those setup locally </li></ul></ul>
  12. 12. WordPress Rewrite Rules <ul><li>Process for adding rewrite rules (cont.) </li><ul><li>Process for adding a rewrite rule </li><ul><li>Add the rules to vip-rewrite/rules.php
  13. 13. Flush the rewrite rules locally by going to wp-admin -> settings -> permalinks and saving
  14. 14. Test
  15. 15. Repeat until all needed endpoints are correct
  16. 16. Increment the $rules_version so other installs are automatically flushed
  17. 17. Send the new rewrite rules to vip along with where they should be included in the list </li></ul></ul></ul>

×