stylesplugin / styles

Change colors and fonts in WordPress themes using the built-in theme customizer.
http://stylesplugin.com
17 stars 9 forks source link

CSS/JS 404's with Symlinked Plugin Directory #49

Closed logoscreative closed 10 years ago

logoscreative commented 10 years ago

In my setup, I've got core and the plugins directory both moved around (in "approved" fashion) and symlinked. So, for instance:

When I load up the customizer, it tries to enqueue files from this URL:

http://example.com/wp/{full-path-to}/plugins/styles/classes/styles-font-menu/css/styles-font-menu.css?ver=1.0.1

But the plugins directory is neither in the 'wp' directory, nor would that URL work anyway, because it re-injects the full path as well.

This is definitely a result of assumptions baked into setting the variables in init() in sfm-plugin.php (starting around line 109).

Now, I can make the files enqueue properly by using plugins_url( '/whatever.js', dirname(__FILE__) ) instead of $this->plugin_url . '/whatever.js', but then all the Google Fonts PNG's start 404ing. :)

Any suggestions?

logoscreative commented 10 years ago

As well, wrapping the enqueue path in realpath() gets rid of the 404's, but the Google Fonts menus no longer populate.

logoscreative commented 10 years ago

Even better: if I override $this->plugin_url to use plugins_url( '' , dirname(__FILE__) );, everything else works properly.

pdclark commented 10 years ago

It's always nice to hear from you Cliff. Congratulations on the Evermore release! :)

So... I was admittedly a bit zealous with the styles-font-menu library. I wrote it for Styles, but wanted it to be available for other developers to use as an include in their own plugins and themes. Thus, the craziness in determining the plugin's URL and path.

I think I have this resolved. I couldn't duplicate the issue with Google Font previews not loading, but that might be just because I didn't duplicate how you used realpath() correctly. All the same, I'd like to verify I didn't miss an environment issue. Can you verify the version in f/symlinks (zip) works for you before I deploy to wordpress.org?

Have you been using Styles much in your system with clients? I'd be interested to hear your input if you have some time.

logoscreative commented 10 years ago

Sorry for the delay, @pdclark! Thanks for the kind words.

I applied this patch and all seems well! Thanks so much for taking a look at this.

We just deployed Styles recently, thanks to the more general Genesis extension coming out. We were looking to strike a balance with the amount of options offered and preferred to use the customizer, so this is working out well so far.

You know I'm always happy to help. :smile: My business partner, Kyle, used it recently to help a customer, so he might have some valuable input as well.

pdclark commented 10 years ago

Great! Merged and deployed to .org.