Jetpack_Safe_CSS

The Jetpack by WordPress.com Jetpack Safe CSS class.

Defined (1)

The class is defined in the following location(s).

/modules/custom-css/custom-css.php  
  1. class Jetpack_Safe_CSS { 
  2. static function filter_attr( $css, $element = 'div' ) { 
  3. safecss_class(); 
  4.  
  5. $css = $element . ' {' . $css . '}'; 
  6.  
  7. $csstidy = new csstidy(); 
  8. $csstidy->optimise = new safecss( $csstidy ); 
  9. $csstidy->set_cfg( 'remove_bslash', false ); 
  10. $csstidy->set_cfg( 'compress_colors', false ); 
  11. $csstidy->set_cfg( 'compress_font-weight', false ); 
  12. $csstidy->set_cfg( 'discard_invalid_properties', true ); 
  13. $csstidy->set_cfg( 'merge_selectors', false ); 
  14. $csstidy->set_cfg( 'remove_last_;', false ); 
  15. $csstidy->set_cfg( 'css_level', 'CSS3.0' ); 
  16.  
  17. $css = preg_replace( '/\\\\([0-9a-fA-F]{4})/', '\\\\\\\\$1', $css ); 
  18. $css = wp_kses_split( $css, array(), array() ); 
  19. $csstidy->parse( $css ); 
  20.  
  21. $css = $csstidy->print->plain(); 
  22.  
  23. $css = str_replace( array( "\n", "\r", "\t" ), '', $css ); 
  24.  
  25. preg_match( "/^{$element}\s*{(.*)}\s*$/", $css, $matches ); 
  26.  
  27. if ( empty( $matches[1] ) ) 
  28. return ''; 
  29.  
  30. return $matches[1];