Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]

CSS Minifier. Please report bugs on https://github.com/matthiasmullie/minify/issues

Author: Matthias Mullie <minify@mullie.eu>
Copyright: Copyright (c) 2012, Matthias Mullie. All rights reserved
License: MIT License
File Size: 818 lines (28 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: CSS  - X-Ref

CSS minifier.

Please report bugs on https://github.com/matthiasmullie/minify/issues

setMaxImportSize($size)   X-Ref
Set the maximum size if files to be imported.

Files larger than this size (in kB) will not be imported into the CSS.
Importing files into the CSS as data-uri will save you some connections,
but we should only import relatively small decorative images so that our
CSS file doesn't get too bulky.

param: int $size Size in kB

setImportExtensions(array $extensions)   X-Ref
Set the type of extensions to be imported into the CSS (to save network
connections).
Keys of the array should be the file extensions & respective values
should be the data type.

param: string[] $extensions Array of file extensions

moveImportsToTop($content)   X-Ref
Move any import statements to the top.

param: string $content Nearly finished CSS content
return: string

combineImports($source, $content, $parents)   X-Ref
Combine CSS from import statements.

Import statements will be loaded and their content merged into the original
file, to save HTTP requests.

param: string   $source  The file to combine imports for
param: string   $content The CSS content to combine imports for
param: string[] $parents Parent paths, for circular reference checks
return: string

importFiles($source, $content)   X-Ref
Import files into the CSS, base64-ized.

param: string $source  The file to import files for
param: string $content The CSS content to import files for
return: string

execute($path = null, $parents = array()   X-Ref
Minify the data.
Perform CSS optimizations.

param: string[optional] $path    Path to write the data to
param: string[] $parents Parent paths, for circular reference checks
return: string The minified data

move(ConverterInterface $converter, $content)   X-Ref
Moving a css file should update all relative urls.
Relative references (e.g. ../images/image.gif) in a certain css file,
will have to be updated when a file is being saved at another location
(e.g. ../../images/image.gif, if the new CSS file is 1 folder deeper).

param: ConverterInterface $converter Relative path converter
param: string             $content   The CSS content to update relative urls for
return: string

shortenColors($content)   X-Ref
Shorthand hex color codes.
#FF0000 -> #F00.

param: string $content The CSS content to shorten the hex color codes for
return: string

shortenFontWeights($content)   X-Ref
No description

shortenZeroes($content)   X-Ref
Shorthand 0 values to plain 0, instead of e.g. -0em.

param: string $content The CSS content to shorten the zero values for
return: string

stripEmptyTags($content)   X-Ref
Strip empty tags from source code.

param: string $content
return: string

stripComments()   X-Ref
Strip comments from source code.


stripWhitespace($content)   X-Ref
Strip whitespace.

param: string $content The CSS content to strip the whitespace for
return: string

extractMath()   X-Ref
Replace all occurrences of functions that may contain math, where
whitespace around operators needs to be preserved (e.g. calc, clamp).


extractCustomProperties()   X-Ref
Replace custom properties, whose values may be used in scenarios where
we wouldn't want them to be minified (e.g. inside calc).


canImportBySize($path)   X-Ref
No description

canImportByPath($path)   X-Ref
Check if file a file can be imported, going by the path.

param: string $path
return: bool

getPathConverter($source, $target)   X-Ref
Return a converter to update relative paths to be relative to the new
destination.

param: string $source
param: string $target
return: ConverterInterface