[wp-hackers] One CMS to Rule Them All (was This was painful to read...)
Christopher O'Connell
jwriteclub at gmail.com
Thu Dec 3 19:25:26 UTC 2009
Code to do it for ALL arbitrary whatever's:
> function plugin_add_custom_urls() {
> add_rewrite_rule('products/(.*)[/]?$', 'index.php?product=$matches[1]',
> 'top');
> add_rewrite_tag('%product%','.*');
> }
> add_action('init', 'plugin_add_custom_urls');
>
> function plugin_add_template() {
> $product = get_query_var('product');
> if (!empty($product)) {
> locate_template(array("products/$product.php","products/index.php"),
> true);
> exit;
> }
> }
> add_action('template_redirect', 'plugin_add_template');
>
> Just that easy.
>
Still going with not easy enough, especially since there are clearly
superior ways of doing this.
> > Insane? It's nice to see you can be condescending without saying
> anything of substance. I'll try to refrain from doing this same.
>
> Hey, I calls 'em like I sees 'em. I think it is slightly insane to go
> to extreme lengths to wrap things and make them more complicated and
> less capable in the process.
>
> > It already exists, and is too complex for the average person to use in a
> theme.
>
> This is only your opinion. Please stop treating it like some kind of
> Truth handed down from up on high, when it is no such thing. Thanks.
>
Umm, yeah, your opinion of insanity == clear truth, while a reasoned comment
about complexity == just your opinion? QED.
>
> >> - Layers make things slower. This is just a fact. More code = more
> >> memory used = slower.
> >
> > Not necessarily. It depends on how the layer is implemented.
>
> False. Layers *ALWAYS* make things slower. This is easy to prove.
> Method 1: I execute code A.
> Method 2: I call layer B which in turn executes code A.
>
> Method 2 is always slower than method 1. Furthermore. Method 2
> implements code designed to abstract portions of the underlying code,
> which takes time to run. Making it even slower.
>
> ALL layers are slower than bypassing them, by definition. That's just
> one argument though, it's not a critical indictment against layers as
> a concept.
>
>
Dear Otto: This is a silly argument: we're writing in a language that gets
translated through many steps into machine code. One extra function call to
simplify the code isn't going to have any appreciable effect. Furthermore,
there's already lots of abstraction that could be taken out if this was
really that important.
> > So we are enforcing an orthodoxy, are we?
>
> No, we're just not encouraging one. That was sort of my point.
>
A bad one!
~ Christopher
More information about the wp-hackers
mailing list