Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Atahualpa 3 Wordpress theme (http://forum.bytesforall.com/forumdisplay.php?f=2)
-   -   PHP include in CSS Inserts (http://forum.bytesforall.com/showthread.php?t=13674)

sawyerjw Apr 6, 2011 02:35 PM

PHP include in CSS Inserts
 
I like to edit my custom CSS as a separate file and include it in the HTML/CSS inserts section with a line similar to the following:

PHP Code:

include_once get_template_directory_uri() . '/custom.css'

This works great on my web host. One of my clients has a site hosted by the same web hosting company and the above does not work on his site. To get the custom CSS to be recognized on his site, I have to copy the contents of 'custom.css' and paste it into the HTML/CSS inserts section in place of the above insert.

Obviously, there's something different about his account, but I've yet to figure it out. Has anyone encountered this and found a solution for it?

WP version is 3.1.1
Atahualpa version is 3.6.4

Thanks,

John

lmilesw Apr 7, 2011 10:35 AM

Why not just put something like the following in the CSS Inserts: Header box and put your style sheet in the root folder of your site or change the path and put it anywhere you want?
HTML Code:

<link rel="stylesheet" type="text/css" href="custom.css" />

sawyerjw Apr 7, 2011 08:18 PM

Hi, Larry,

Thanks for the response. You're right, that seems a much more straightforward way of doing it. It works fine on my server. Now to try the customer's site...

It still baffles me that my original method works on one server but not another. Assuming your suggestion works on the client's site, though, it shall remain a mystery.

Thanks, again,

John

lmilesw Apr 7, 2011 09:29 PM

There were some changes make to the theme code in later versions because of some requirements by WordPress which cause problems with some code.

sawyerjw Apr 7, 2011 09:40 PM

Hi, Larry,

Well, both the development site on my server and the client's site were created from the same download of Atahualpa 3.6.4, so they are identical in that regard. Whatever's causing the problem is likely a server configuration issue of some kind. I have noticed that despite us both being on the same hosting company, his account is set up differently than mine. Mine is considerably older than his, which is likely why.

In any case, I noticed that when I implemented your suggestion the resulting link showed up near the top of the source code in the above site (v3.6.4). I did the same thing on another site running Atahualpa 3.5.3 and the link showed up just above the ending head tag after all the generated CSS code, etc. That brings up a question.

Some of the custom.css code overrides styles in plugins and/or areas of Atahualpa that aren't addressed in the theme options. That being the case, I would think I would want it at the bottom of the header after all the other CSS due to the "cascading" nature of CSS. Perhaps this shows my ignorance of CSS, but it would seem that things would work differently depending on whether the custom.css link is at the top of the head area or the bottom of it, or more accurately whether it appears before or after the CSS it's intended to override.

What am I missing?

Thanks,

John

lmilesw Apr 7, 2011 09:59 PM

There are rules for CSS precedence such as you mentioned in that a rule that comes later in a style sheet will override an earlier one. Inline styling will override that as well as style set in the header of the page. etc etc. Plus you can use !important after CSS code to jump it to the top but of course if you have two items in the same style sheet with !important after them the later will take precedence.

I say all this to say that I don't think too much about precedence as it makes me crazy. I use Firebug with Firefox to do some virtual testing and use what works. Since I have worked with this stuff for awhile I sort of know what will and won't work but I don's spend a lot of time thinking about whether to put something here or there.

As for why you are seeing differences in the different version of Atahualpa I am not sure except to say there have been coding changes for bug fixes and to comply with guidelines set by WordPress.

sawyerjw Apr 7, 2011 10:06 PM

Hi, Larry,

I hear you regarding CSS precedence. A lot about CSS causes my head to hurt. :-)

For whatever reason it seems to be working as expected on my test site despite the apparent contradiction. I'll try it on the client's site tomorrow or over the weekend and see what happens.

I use Firebug/Firefox, as well. I don't know how I lived without it. :-)

Thanks,

John

juggledad Apr 8, 2011 04:41 AM

One other thing. Just because you have two sites at a host, doesn't mean they are on the same server. They could be on two different boxes which are configured differently. I have seen this at my own host.

sawyerjw Apr 8, 2011 07:32 AM

Yes, I understand that the chances of two accounts on the same host being on the same server are virtually nil, especially when one account is years older than the other. :) Evidently, the "standard" configuration has evolved and they haven't gone back and retrofitted the older servers, which is probably just as well.

Thanks,

John

sawyerjw Apr 8, 2011 12:09 PM

Hi, Larry,

I just discovered that inserting the HTML link tag in the Header section caused a bit of heartburn in the site running 3.5.3. An override of the list-style-image property of the li tag on posts disappeared. Putting the custom.css back as an include at the bottom of CSS inserts fixed it.

Given that the 3.5.3 code puts the custom.css link at the bottom of the head section, I would have expected the override to work, but obviously it's backward from my expectation.

Another thing I noticed is that changes made to custom.css are instantaneous on page reload with the include, but require a Ctrl-F5 reload with the link.

So, bottom line, when the include works correctly, it's preferable (for me) to the link technique.

Thanks,

John

lmilesw Apr 8, 2011 02:41 PM

This could be Suhosin related. The include works fine for me as well.


All times are GMT -6. The time now is 10:10 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.