Skip to content

Instantly share code, notes, and snippets.

@fabrizim
Last active December 24, 2015 16:39
Show Gist options
  • Save fabrizim/6829389 to your computer and use it in GitHub Desktop.
Save fabrizim/6829389 to your computer and use it in GitHub Desktop.
Use wp-less to process editor stylesheets.
<?php
add_filter('mce_css', 'theme_mce_less');
function theme_mce_less($css)
{
$handle = 'editor';
$less_plugin = WPLessPlugin::getInstance();
wp_enqueue_style($handle, get_stylesheet_directory_uri()."/assets/stylesheets/editor.less");
$less_plugin->processStylesheets();
global $wp_styles;
$src = $wp_styles->registered[$handle]->src;
wp_dequeue_style($handle);
return $css ? $css.','.$src : $src;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment