Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

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: 780 lines (26 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.

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

extractCalcs()   X-Ref
Replace all `calc()` occurrences.


canImportBySize($path)   X-Ref
Check if file is small enough to be imported.

param: string $path The path to the file
return: bool

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