WPLessPlugin::processEditorStylesheets PHP Method

processEditorStylesheets() public method

Compile editor stylesheets registered via add_editor_style()
public processEditorStylesheets ( string $mce_css ) : string
$mce_css string Comma separated list of CSS file URLs
return string $mce_css New comma separated list of CSS file URLs
    public function processEditorStylesheets($mce_css)
    {
        if (!$mce_css) {
            return $mce_css;
        }
        // extract CSS file URLs
        $style_sheets = explode(",", $mce_css);
        if (count($style_sheets)) {
            $compiled_css = array();
            // loop through editor styles, any .less files will be compiled and the compiled URL returned
            foreach ($style_sheets as $style_sheet) {
                // Remove version from uri
                $parts = parse_url($style_sheet);
                $style_sheet = $parts['scheme'] . '://' . $parts['host'] . (!$parts['port'] ? '' : ':' . $parts['port']) . $parts['path'];
                // Get extension and set handle for wp_register_style()
                $pathinfo = pathinfo($style_sheet);
                $extension = $pathinfo['extension'];
                $handle = $pathinfo['filename'];
                // Only process less files
                if ($extension === 'less') {
                    // Register stylesheet as wp dependency
                    wp_register_style($handle, $style_sheet, array(), null);
                    // Process stylesheet
                    $stylesheet = $this->processStylesheet($handle, false);
                    // Add if successfull
                    if ($stylesheet) {
                        $compiled_css[] = $stylesheet->getTargetUri();
                    }
                } else {
                    $compiled_css[] = $style_sheet;
                }
            }
            $mce_css = implode(",", $compiled_css);
        }
        // return new URLs
        return $mce_css;
    }