(update Oct 2, 2013 at the bottom of the page. I haven’t found a solution, yet)
I’m looking for a bit of help from any XAMPP, WordPress or PressBooks folks.
I’ve been trying to get a development version of PressBooks running on my Windows laptop and have run into an annoying little problem. I am not sure if this is a PressBooks thing or a XAMPP thing (although I’ve brought it up with PB and they believe it is a XAMPP/Apache issue), but I can’t figure it out & am hoping that there might be someone out there who can help.
The problem has to do with the path to the PressBooks themes.
I’ve installed WordPress, setup a multi-site instance and activated the PressBooks plugin as per the install instructions. I’ve done this a few times on hosted servers & the install is fairly straightforward to get working.
Not so with XAMPP on my Windows laptop. When I activate the PressBooks plugin I see an unstyled PressBooks homepage that looks like this:
Instead of the default theme that should look like this:
When I use Firebug and take a look at the code, I can see right away that the paths are wonky to the theme stylesheet.
That path should begin with http://localhost/pressbooks and not with c:\xampp\htdocs etc etc.
What is confusing is that some of the paths are being rewritten correctly. It just appears to be the style and favicon link that isn’t correct.
It looks to me like there is an issue between Unix & Windows file paths getting mixed together. When I brought this up with PressBooks, they didn’t think it was a problem with their code, which has me heading down the XAMPP path.
Now, I’ve installed many software packages locally using XAMPP before, including numerous WordPress installs and haven’t had a problem. But this has been frustrating me as I can’t quite figure out why the path is being rewritten to be incorrect.
Could it be an htaccess issue?
If you have an idea where I might start looking to solve this path issue, I’d appreciate it if you could pop a note into the comments.
Update October 2, 2013
Spent the morning looking into this. Short story, it is still broken. Here’s what I’ve done so far and where I’ve looked (in case Google brings you here with the same problem).
The file that is generating the link to the stylesheet in the PressBooks default theme is called header.php and is located in the pressbooks\themes-root folder. I open the header.php file. These are the 2 suspect lines of code that seems to be returning the wrong code to both the stylesheet and favicon (lines 13 & 14)
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); echo '?' . filemtime( get_stylesheet_directory() . '/style.css'); ?>" media="screen" /> <link rel="shortcut icon" href="<?php bloginfo('stylesheet_directory'); ?>/favicon.ico" />
It’s the bloginfo function that looks like it is returning the wrong path. So I test out and in the body of the document I write:
<?php echo bloginfo('stylesheet_url'); ?>
and sure enough, it returns the incorrect path
C:\xampp\htdocs\pressbooks\wp-content\plugins\pressbooks/themes-root/pressbooks-publisher-one/style.css
This blog post suggests using a different WP function other than bloginfo to find paths, so I try to use the get_stylesheet_directory() to see if it returns a different path, but it returns the same C:\xampp… path
The WP codex suggests yet another function: get_stylesheet_uri()
Same result.
So I dig deeper.
Where is the code to the bloginfo function? WP codex says it is in the file wp-includes/general-template.php. So I open that file up in Aptana and start digging. Turns out, the function is actually called get_bloginfo(). The code snippet I am interested is on line 483:
case 'stylesheet_url': $output = get_stylesheet_uri(); break;
Look, there is that get_stylesheet_uri() function again.
So, now I am seeing that a number of functions are returning the wrong path, but still not sure why or where to turn to next. My wafer thin coding skills are showing.. So, I have posted to the WordPress forums and hope I can find some help. Problem is, I don’t know if this is a WP problem, PressBooks problem, or a XAMPP problem.
In the meantime, I have hardcoded the path to the stylsheet into the header.php file and that is working. But what a hack. I am loath to do this without knowing the root of the problem because there could be other incorrect paths that could screw things up. But until I can find a willing soul who can help give me some leads as to why this is happening, I need to do this and get on with the tasks I have at hand.
Technology. Bah!
Hello, Clint,
I ran into this same issue yesterday, and for me it was a .htaccess issue – I had failed to save my changes to the .htaccess file (the changes that are recommended during the Pressbooks install).
Once I saved the .htaccess changes, logged out of the pressbooks instance, restarted apache, and logged back in, the problem was fixed.
Ok, last one, I promise. I activated the custom theme, then in the theme’s editor, one can copy the css from the other installed themes – which then work. So a bit of a kludgy workaround…?
One last note – I used the ‘pressbook custom theme’, for rolling one’s own pb theme, and that loads up correctly. So there’s a clue?
Sorry, typo – WAMP. Here was the info on local subdomains that I tried fiddling with two, for what it’s worth. http://wpdreamer.com/2013/08/how-to-setup-a-localhost-wordpress-sub-domain-multisite-environment/
Hi Clint,
I’ve run into the same problem, using LAMP. I looked in the sql tables created for the book blogs on my local pressbook install, and eventually found an entry with the path to the theme in it. This had the full c:\wampwwwpressbook etc path. I tried fiddling with that entry, but any change there broke everything. I wondered if I had things arranged for local subdomains, if that would somehow make a difference (I’ll admit, I was thinking magically at this point), but no joy. Anyway, just wondered if you’d made any headway.
Thanks,
Shawn