[wp-hackers] wp-config.php, wp-load.php, and ABSPATH
Stephen Rider
wp-hackers at striderweb.com
Tue Sep 15 13:02:27 UTC 2009
On Sep 15, 2009, at 1:13 AM, Andrew Ozz wrote:
> Stephen Rider wrote:
>> Okay then, here's an example that probably comes up a lot in plugins.
>> I want to make a CSS file that gets some of its stuff from PHP. So
>> "mystyles.css.php". Most of it is a simple echo, but a few things
>> in the stylesheet are pulled from settings on the wp_settings table
>> in the database.
>> The CSS/PHP file is pulled directly by the browser and is thus not
>> "WP Aware". How would I get that file to access the WP database?
>
> Short answer: you can't. Best option is to add a normal stylesheet
> and then output any bits that depend on the db in a <style> tag
> after that. This way WordPress won't run twice on each page load
> (once to generate the HTML, second time to generate the stylesheet).
Okay, that's kind of what I thought, and that's what I'm doing (okay,
in my actual case it's a JavaScript into which I'm passing variables,
but same principle).
What got me thinking about this is that lately every time I turn
around I've got some WP article or whatnot telling me I really really
really ought to be using the wp-enqueue functions, and that I'm
basically doing something wrong if I don't use them. But using them
there's no way to connect them to info from the database, **except**
for direct-loading wp-head.php or wp-config.php (or some other file
I'm not supposed to direct-load).
Soo... either do the "wrong" thing by not using enqueue, or do the
"wrong" thing by direct-loading wp-config.php. I don't personally
see any harm in bypassing enqueue in such cases, but there are some
seriously mixed signals going on.... :-\
Stephen
--
Stephen Rider
http://striderweb.com/
More information about the wp-hackers
mailing list