thom4parisot / wp-less

WordPress plugin which seemlessly compiles, caches and rebuilds your LESS stylesheets.
https://wordpress.org/plugins/wp-less/
88 stars 40 forks source link

WP LESS breaks tinyMCE #94

Closed WillMuijrers closed 9 years ago

WillMuijrers commented 9 years ago

I don't know why or how. But using the latest version 1.8 of LESS with Wordpress 4.3.1 breaks all the tinyMCE editors in Wordpress. TinyMCE is unable to add styling.

Working locally using MAMP, im getting the following errors in Chrome:

http://localhost/XX/wp-includes/css/dashicons.min.css?wp-mce-4205-20150910 Failed to load resource: net::ERR_CONNECTION_REFUSED

http://localhost/XX/wp-includes/js/tinymce/skins/wordpress/wp-content.css?wp-mce-4205-20150910 Failed to load resource: net::ERR_CONNECTION_REFUSED

in Firefox: Use of Mutation Events is deprecated. Use MutationObserver instead.

It is not theme related (switching theme's will have same effect, even when theme is not supporting LESS). When deactivating WP LESS, the editor works again. Thanks!

fabrizim commented 9 years ago

The only hook that less has into the editor is the mce_css filter (https://github.com/oncletom/wp-less/blob/master/lib/Plugin.class.php#L287). Are you adding a '.less' stylesheet to the editor? If so, if there are errors in the less file, the html output might be ending at the editor.

The Firefox error is not relevant. The other errors indicate that core Wordpress files are not accessible. Can you see the css files if you paste those urls into your browser?

WillMuijrers commented 9 years ago

I figured out that this line doesn't seem to work nice when using regular localhost settings on MAMP:

$style_sheet = $parts['scheme'] . '://' . $parts['host'] . $parts['path'];

This is a quick fix for my problem:

$style_sheet = $parts['scheme'] . '://' . $parts['host'] . ':8888' . $parts['path'];

Not a big deal for development, I'll remove the "8888" addition in production.

thom4parisot commented 9 years ago

This could do the trick:

$style_sheet = $parts['scheme'] . '://' . $parts['host'] . (!$parts['port'] ?: ':' . $parts['port']) .  $parts['path'];
WillMuijrers commented 9 years ago

Worked great, thank you great Oncletom!

fabrizim commented 9 years ago

FYI - I just adjusted that new code a bit as it was breaking for sites on default ports (80,443). See be3fffedd1c0eba35642407d228a9976c7b08d5f