Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS url values broken #159

Open
christianwach opened this issue Jul 5, 2013 · 11 comments
Open

CSS url values broken #159

christianwach opened this issue Jul 5, 2013 · 11 comments

Comments

@christianwach
Copy link
Collaborator

When cbox-theme is used on a subsite and WP Multisite uses subfolders, ICE_Files::document_root() incorrectly calculates self::$document_root. Please see the following thread for full details:

http://commonsinabox.org/groups/help-support/forum/topic/submenu-icons-iconsweets/

Cheers,

Christian

@christianwach
Copy link
Collaborator Author

@MrMaz
Copy link
Collaborator

MrMaz commented Jul 5, 2013

Thanks for this report. I have been battling this issue in other contexts for a week and have been stumped. I think the sub folder hint is going to put me over the top. Will make an Infinity fix soonish if this pans out.

@christianwach
Copy link
Collaborator Author

@MrMaz Um, "over the top"? I hope you mean in a good way :-)

@MrMaz
Copy link
Collaborator

MrMaz commented Jul 5, 2013

Yes, I meant in a good way ;)

@christianwach
Copy link
Collaborator Author

@MrMaz Okay, glad to hear it. Phew.

@MrMaz
Copy link
Collaborator

MrMaz commented Jul 5, 2013

@christianwach do you have a public site which shows CSS files being enqueued in the header with the sub-site slug before /wp-content? As in your example of "/cbox/wp-content/themes"

I don't have much sub-folder multisite experience, and I am trying to wrap my head around how WordPress resolves this. Does it do it with .htaccess or something?

@christianwach
Copy link
Collaborator Author

Sure, here you go:
http://www.paulschacht.net/brokencss

CSS is here:
http://www.paulschacht.net/brokencss/wp-content/uploads/sites/6/exports/cbox-theme/dynamic.css?ver=3.5.2

Don't know if it's useful, but here's some code to throw into ICE_Files:: document_root() if you have a subfolder WPMU setup:

print_r( array(

    'theme_root' => $theme_root,
    'theme_root_uri' => $theme_root_uri,
    'uri_parts' => $uri_parts,
    'path_length' => $path_length,
    'self::$document_root' => self::$document_root,
    'get_template_directory' => get_template_directory(),
    'get_template_directory_uri' => get_template_directory_uri(),
    'get_stylesheet_directory' => get_stylesheet_directory(),
    'get_stylesheet_directory_uri' => get_stylesheet_directory_uri(),
    'ABSPATH' => ABSPATH,
) ); die();

Also, FWIW, if you're sure you want to persist with the approach you're taking (ie strip scheme and domain from the CSS url value) I'd convert the paths to arrays and work with them (and implode once you're done) rather than using substr_replace().

Cheers,

Christian

@MrMaz
Copy link
Collaborator

MrMaz commented Jul 5, 2013

The domain and scheme can't be used in the dynamic stylesheet url() properties because of http vs https. The document root "gotcha" which you have reported is like the 6th or 7th one since Infinity's inception, and I expect there will still be more to come. Don't even get me started on Windows servers lol.

The document root length substr() strategy is used purely for performance because file_to_uri_path() can be called hundreds of times. I am definitely going to re-evaluate this decision, depending on what I find here.

Thanks for all of your help so far!

@christianwach
Copy link
Collaborator Author

@MrMaz Sorry, I was only trying to save you some typing, not questioning your capabilities ;-) I guess you're avoiding get_stylesheet_directory() etc because you're faking an infinite theme hierarchy. I'd have a go at a fix, but you're ahem infinitely more qualified than me to do so.

@MrMaz
Copy link
Collaborator

MrMaz commented Jul 5, 2013

I didn't take it that way at all, just explaining the reasoning behind the bass-ackwards way its handled.

Can you throw this bit into the document_root() function after the parse_url() line and paste the results?

global $current_blog;
var_dump( $current_blog, $theme_root, $theme_root_uri, $uri_parts );

@christianwach
Copy link
Collaborator Author

@MrMaz Sure thing, here you go:

object(stdClass)#10 (12) {
  ["blog_id"]=>
  string(1) "2"
  ["site_id"]=>
  string(1) "1"
  ["domain"]=>
  string(20) "my.domain.localhost"
  ["path"]=>
  string(6) "/cbox/"
  ["registered"]=>
  string(19) "2013-07-05 08:42:50"
  ["last_updated"]=>
  string(19) "2013-07-05 08:42:56"
  ["public"]=>
  string(1) "1"
  ["archived"]=>
  string(1) "0"
  ["mature"]=>
  string(1) "0"
  ["spam"]=>
  string(1) "0"
  ["deleted"]=>
  string(1) "0"
  ["lang_id"]=>
  string(1) "0"
}
string(75) "/path/from/root/to/my.domain.localhost/httpdocs/wp-content/themes"
string(50) "http://my.domain.localhost/cbox/wp-content/themes"
array(3) {
  ["scheme"]=>
  string(4) "http"
  ["host"]=>
  string(20) "my.domain.localhost"
  ["path"]=>
  string(23) "/cbox/wp-content/themes"
}

The subsite's path (as you can see) is '/cbox/', and there's a .htaccess file with the standard RewriteRules that WordPress auto-generates to parse requests into query vars. I can send that your way too if you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants