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

Assets urls wrong if ... #1566

Closed
cfoellmann opened this issue Aug 15, 2014 · 16 comments
Closed

Assets urls wrong if ... #1566

cfoellmann opened this issue Aug 15, 2014 · 16 comments

Comments

@cfoellmann
Copy link

I have a modified WP_CONTENT_DIR for my wp installation which breaks the framework (as_plugin and is_plugin (packaged)
My wp-config.php modifier

<?php
// wp-content folder is one level up from the wp install
define( 'WP_CONTENT_DIR', dirname( __FILE__ ) . '/../wp-content' );

resulting in (example from the paid plugin SeedProd Coming Soon Pro):

"NetworkError: 404 Not Found - https://site8.wpmu-trunk.dev/wp-content//srv/www/wp-content/plugins/coming-soon-pro/ReduxCore/assets/js/media/media.min.js?ver=1407836363"

.... for all the assets

spliting up this broken url:

  • https://site8.wpmu-trunk.dev/wp-content/ WP_CONTENT_URL (core default) - ok
  • /srv/www/wp-content WP_CONTENT_DIR (modified in wp-config.php) - WHY?
  • plugins/coming-soon-pro/ReduxCore/* - ok

Fix started with #1564

@dovy
Copy link
Contributor

dovy commented Aug 15, 2014

Dude, if you define WP_CONTENT_DIR don't you need to also set WP_CONTENT_URL?

Just realized this...

@dovy dovy closed this as completed Aug 15, 2014
@cfoellmann
Copy link
Author

No.
The directory is not dependent on the URL. You need to configure you http server accordingly.

@dovy
Copy link
Contributor

dovy commented Aug 15, 2014

You are correct! If you don't define the content_url though then the assets will fail as you are getting my friend.

You can't just define WP_CONTENT_DIR and expect it to work. ;)

@cfoellmann
Copy link
Author

WP core functionality is working like it should. Your init function is doing things that do not work for non-standard setups

@dovy
Copy link
Contributor

dovy commented Aug 15, 2014

If you move the WP_CONTENT_DIR then there's no way to detect the new WP_CONTENT_URL. You need to set them both.

http://wordpress.org/support/topic/renaming-moving-wp-content?replies=9

Look across the web my friend. You have to define both or the WP_CONTENT_URL is set to the default, which does not exist.

@cfoellmann
Copy link
Author

That is wrong. How would you define an URL that is outside of the path of the vhost?
You need to define the rewrite rule for the url accordingly to the path you have changed.

@dovy
Copy link
Contributor

dovy commented Aug 15, 2014

Exactly...

if ( !defined('WP_CONTENT_URL') )
    define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR 

Change it to match your needs.

@cfoellmann
Copy link
Author

I do not want to change that. Why would I?
I want to move the path not the change the URL.
If you depend on core functionality it works. Your function for _url is mixing URL with path which is completely independent from one another

@dovy
Copy link
Contributor

dovy commented Aug 15, 2014

If the redux folder is not accessible via the web then JS/CSS will never work. If you move the WP_CONTENT folder you have to specify the new URL or again, the JS/CSS will not work.

@cfoellmann
Copy link
Author

The assets are accessible via the normal urls (same as in core) but you use paths to create URLs.
Your way of generating urls for asset files is wrong

@dovy
Copy link
Contributor

dovy commented Aug 15, 2014

I'm sorry sir, but I think you don't understand WordPress. You're welcome to fork your own stuff, but this will break things for everyone else.

Best of luck.

@cfoellmann
Copy link
Author

You should have a look at how WP core handles wp_content_url and wp_content_dir. URL is not using the dir constant. They are in the standard installation the same at the end but not equal.

@cfoellmann
Copy link
Author

Why is it that plugins using proper core functions handle my config?
Please have a look at the config I described in my first post. It shows that an absolute path is in the URL, right?
I don't want to be disrespectful. Sorry if it sounds like that.

dovy added a commit that referenced this issue Aug 15, 2014
@dovy
Copy link
Contributor

dovy commented Aug 15, 2014

I did some manual massaging and made our path detection much more robust. See version 3.3.6.3. Thanks for the suggestions.

I don't think the old way was wrong by any means, but I took what you suggested a bit further. ;)

@dovy
Copy link
Contributor

dovy commented Aug 15, 2014

See commit: 93a4277 for further details.

@michaelmohamed
Copy link

I have 3.3.6.8 included in a plugin, and have an wp installation that has a modified WP_CONTENT_DIR. I am having the problem where the assets url is incorrect for redux.

I noticed the code you added in 93a4277:

if ( self::$_is_plugin == true || self::$_as_plugin == true ) {
self::$_url = plugin_dir_url( __FILE__ );
}

This code never executes for me; however, if it did, my assets urls would be correct. Is there a way i can make self::$_as_plugin == true when i initialize redux? Or is there some other way that I can make this logic pass?

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

3 participants