Discussion:
About using WordPress as service and themes
Filippo Pisano
2013-07-18 07:08:17 UTC
Permalink
Hi,

I was trying to figure out a good way to prevent themes from being included
when calling WordPress with a particular query string.

Here's an example of what I'm trying to do:

/pages/my-page -> Classic page.php from my_theme_directory
/xml/my-xml-page -> XML page served to external script through custom plugin


I want to exclude the XML generating routine from themes because I want to
speed up things avoiding to load theme's callbacks and functions.

I've tried to set the WP_USE_THEMES constant to false but the functions.php
file belonging to the active theme is still included.
I think that a possible solution could be to add an additional xml-only
theme and change active theme on the fly accordingly to the query string.

IMO such a solution could have an unwanted overhead because all formatting
and templating libraries are also included (despite I need to render a
simple XML only).


Could you suggest me a better way?


Thank you
Nate Divine
2013-07-18 13:59:42 UTC
Permalink
Not sure if this is exactly what you're looking for - but you could
hook template_include and based on the particular query load a specific
template (or don't load a template at all).
Post by Filippo Pisano
Hi,
I was trying to figure out a good way to prevent themes from being included
when calling WordPress with a particular query string.
/pages/my-page -> Classic page.php from my_theme_directory
/xml/my-xml-page -> XML page served to external script through custom plugin
I want to exclude the XML generating routine from themes because I want to
speed up things avoiding to load theme's callbacks and functions.
I've tried to set the WP_USE_THEMES constant to false but the functions.php
file belonging to the active theme is still included.
I think that a possible solution could be to add an additional xml-only
theme and change active theme on the fly accordingly to the query string.
IMO such a solution could have an unwanted overhead because all formatting
and templating libraries are also included (despite I need to render a
simple XML only).
Could you suggest me a better way?
Thank you
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Jamie Currie
2013-07-18 20:31:21 UTC
Permalink
You might be able to use the setup_theme hook. If you look in
wp-settings.php at line 262 it's called before WP loads in the theme's
functions.php file. So if you add an action to that hook you could check
for a query var and then load your XML only theme.


Jamie Currie
Founder / CEO
wunderdojo
wunderdojo.com
tel: 949-734-0758
23 Corporate Plaza Drive, Suite 100
Newport Beach, CA 92660
Master web & app developers




------ Original Message ------
From: "Filippo Pisano" <***@gmail.com>
To: wp-***@lists.automattic.com
Sent: 7/18/2013 12:08:17 AM
Subject: [wp-hackers] About using WordPress as service and themes
Post by Filippo Pisano
Hi,
I was trying to figure out a good way to prevent themes from being included
when calling WordPress with a particular query string.
/pages/my-page -> Classic page.php from my_theme_directory
/xml/my-xml-page -> XML page served to external script through custom plugin
I want to exclude the XML generating routine from themes because I want to
speed up things avoiding to load theme's callbacks and functions.
I've tried to set the WP_USE_THEMES constant to false but the
functions.php
file belonging to the active theme is still included.
I think that a possible solution could be to add an additional xml-only
theme and change active theme on the fly accordingly to the query string.
IMO such a solution could have an unwanted overhead because all
formatting
and templating libraries are also included (despite I need to render a
simple XML only).
Could you suggest me a better way?
Thank you
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Loading...