[wp-hackers] Re: template_redirect for non-template users?

Kimmo Suominen kimmo at global-wire.fi
Thu Jan 31 08:28:24 GMT 2008


On Wed, Jan 30, 2008 at 12:52:58PM -0600, Jess Planck wrote:
> I believe you could also use the template_redirect action using some  
> sort of unique request token. Then exit the function once your ajax  
> job is complete.

This works very well -- I use it to "highjack" control based on the
requested URL as well.

And because template_redirect is (ab)used like this due to the lack of
a better option, I've patched the non-template case to call the action
hooks as well.  Otherwise many plugins won't work in an embedded WP
installation.

But maybe there should be a common action hook and a private one for
each branch?  But template_redirect probably should become the common
one in that case, to preserve current functionality of plugins.

Best regards,
+ Kimmo
-- 
<A HREF="http://kimmo.suominen.com/">Kimmo Suominen</A>


Index: wp-includes/template-loader.php
===================================================================
--- wp-includes/template-loader.php	(revision 6693)
+++ wp-includes/template-loader.php	(working copy)
@@ -64,6 +64,7 @@
 		return;
 	}
 } else {
+	do_action('template_redirect');
 	// Process feeds and trackbacks even if not using themes.
 	if ( is_robots() ) {
 		do_action('do_robots');



More information about the wp-hackers mailing list