[wp-hackers] wp-config.php, wp-load.php, and ABSPATH

Rics ricardo.cezar at gmail.com
Tue Sep 15 12:08:08 UTC 2009


You can tell the server to interpret the CSS file as a normal PHP file. You
do that in .htaccess, but I can't remember now the exactly sintax. Google
will tell you in no time though!

When your server thinks the CSS is a PHP you can write PHP code as usually
and the file will still be a .css WP Aware, like you need it to be.

Just remember to tell the browser that the file content is a CSS, with
header() function as the first line, before anything was sent to the
browser, like this:

<?php

header('Content-type: text/css');

Get it?
---
Rics
http://www.pensarics.com
http://www.meadiciona.com/rics
Maringá, PR - Brasil


2009/9/15 Dion Hulse (dd32) <wordpress at dd32.id.au>

> That still loads WordPress Twice for every  request, And doesnt work for a
> custom WP_CONTENT_DIR
>
> Best method is a normal Style.css file, and:
> add_action('wp_head', 'custom_css');
> function custom_css() {
> echo '<style>';
> echo '.textColor1 { color:' . get_option('theme_colour1') . '; }';
> echo '.textColor2 { color:' . get_option('theme_colour2') . '; }';
> ....
> echo '</style>';
> }
>
> Remember, that you can have multiple .class's , ie.
> style.css:
> .textColor1 {
> font-weight: bold;
> }
>
> and the above code, End result is that you get bolded coloured text.
>
> The Monotone theme is the first theme which comes to mind which shows that
> system in use.
>
>
>
> On Tue, 15 Sep 2009 18:58:48 +1000, Jörn Röder <kontakt at joernroeder.de>
> wrote:
>
>  Hi,
>> I think, you can…
>>
>> i try this:
>> - create style.css.php
>>
>> -embed new styles
>> - style.css:
>>        @import url(style.css.php);
>>
>> - style.css.php:
>>
>> <?php
>> require_once("../../../wp-blog-header.php");
>> header("Content-type: text/css");
>> ?>
>> @charset '<?php bloginfo('charset') ?>';
>>
>> #header:after,
>> .header:after {
>>        content:'<?php bloginfo('name'); ?>'
>> }
>>
>> I don't now if there are any problems with caching, but you can read
>> this article on smashingmagazine about php and css. Maybee it will
>> help you.
>>
>> http://www.smashingmagazine.com/2009/09/10/css-wishlist-new-ideas-debates-and-solutions/
>>
>>
>>
>> Am 15.09.2009 um 08:13 schrieb Andrew Ozz:
>>
>>  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).
>>> _______________________________________________
>>> wp-hackers mailing list
>>> wp-hackers at lists.automattic.com
>>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>>
>>
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>>
>
> --
> --
> Dion Hulse
> e: contact at dd32.id.au
> w: http://dd32.id.au/
> m: 04 6621 9112 (+614 6621 9112)
> WordPressQI: http://wordpressqi.com/
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list