[wp-testers] Permalinks, Plugins, and Mod Rewrite

Dan Milward dan at instinct.co.nz
Fri Aug 17 02:03:42 GMT 2007


Hey Andy,

What we wanted to do was give each item / product a page of its own and 
we wanted it to be permalink friendly. So what we did was stuck the 
rewrite rule at the end of the rewrite array rather than the beginning 
so the page rewrite rules take precedence.

It all works now!!  Next thing to do is write a page on how we did it so 
that everybody can benefit from this nightmare experience - actually it 
wasn't that bad looking back. It was just sensitive and reasonably complex.

Do you guys want a link to see it working?

Cheers,

Dan


Andy Skelton wrote:
> On 8/15/07, Dan Milward <dan at instinct.co.nz> wrote:
>   
>> I have a question about how to best utilize permalinks and plugins
>>     
>
> It depends! Most of the performance degradation caused by large
> rewrite arrays is incurred during the foreach/preg_match loop of
> WP::parse_query (wp-includes/classes.php) so if you want to cheat the
> devil, you have to do it before this loop. You should set up a test
> dataset with thousands of your items to see if it's really worth
> subverting this part of core.
>
> There is not a ready-made way to short-circuit parse_query. However,
> it's not hard to use different hooks to accomplish this.
>
> Here's one possibility: Keep an array of all "podcast" sub-tokens and
> their related ID's in an option row. Apply a filter on
> pre_option_rewrite_rules that checks whether the REQUEST_URI looks
> like a "podcast" request, checks whether the sub-token is in the saved
> array, returns a specially-crafted rewrite array of found, else
> returns false so that the rewrite rules will be checked normally.
>
> And another possibility: Keep the same token/ID lookup array as above
> and use the 'init' action hook to check for one of your tokens and
> hijack the page load. That is, if token found, output and die during
> the init action, before control returns to wp-blog-header.php, which
> is where wp() is called and rewrite happens.
>
> So there are lots of ways to do something like you've described. Of
> course I don't know what you want to do once you know you have one of
> your special token requests so I can't tell you the best way to do it.
> :-)
>
> Cheers,
> Andy
> _______________________________________________
> wp-testers mailing list
> wp-testers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-testers
>
>   

-- 
Dan Milward
Director
Instinct Entertainment
Direct Dial +64-4-385 8082
Mobile +64-21-44 9901
PO Box 12519, Wellington, New Zealand
www.instinct.co.nz



More information about the wp-testers mailing list