Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if ( ! function_exists( 'polygon_compress_internal_stylesheet' ) ) {
- /**
- * Compress dynamic stylesheet.
- *
- * Compress the internal stylesheet by stripping all comments, spaces and empty lines.
- * The function also places everything on the same line in order to make the source code
- * easy to scan.
- *
- * @since 1.0.0
- * @param string $buffer Stylesheet generated by the options from the customizer.
- * @return string The compressed stylesheet stored in $buffer.
- */
- function polygon_compress_internal_stylesheet( $buffer ) {
- // Remove comments.
- $buffer = preg_replace( '!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer );
- // Remove space before bracket.
- $buffer = str_replace( ' {', '{', $buffer );
- // Remove space after colons.
- $buffer = str_replace( ': ', ':', $buffer );
- // Remove tabs, spaces, newlines, etc.
- $buffer = str_replace( array( "\r\n", "\r", "\n", "\t", ' ', ' ', ' ' ), '', $buffer );
- return $buffer;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement