Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added hook system for plugins

Plugins split into seperate files
Aliases and Plugins files renamed with '.ini' file extensions to be editor friendly
Fix for issue #14
  • Loading branch information...
commit 3e94a4b639f26658602352279c08b6675f64e4d5 1 parent f2c144b
@peteboere authored
View
0  CssCrush.aliases → Aliases.ini
File renamed without changes
View
6 CssCrush.php
@@ -4,7 +4,7 @@
* CSS Crush
* Extensible CSS preprocessor
*
- * @version 1.3.4
+ * @version 1.3.5
* @license http://www.opensource.org/licenses/mit-license.php (MIT)
* @copyright Copyright 2010-2011 Pete Boere
*
@@ -25,9 +25,13 @@
CssCrush::init( dirname( __FILE__ ) );
require_once 'lib/Rule.php';
+
require_once 'lib/Function.php';
+CssCrush_Function::init();
+
require_once 'lib/Importer.php';
require_once 'lib/Color.php';
+require_once 'lib/Hook.php';
View
10 CssCrush.plugins → Plugins.ini
@@ -14,8 +14,14 @@ plugins[] = ie-clip.php
; IE filter shorthand
plugins[] = ie-filter.php
-; Opaque fallback colors for clients that don't support RGBA
+; Opaque fallback colors for clients that don't support RGBA
plugins[] = rgba-fallback.php
-; HSL shim - converts HSL values to hex codes
+; HSL shim - converts HSL values to hex codes
plugins[] = hsl-to-hex.php
+
+; Compiles pseudo element double colon syntax to single colon for backwards compatibility
+plugins[] = double-colon.php
+
+; Non-standard composite pseudo classes
+plugins[] = hocus-pocus.php
View
2  lib/Color.php
@@ -12,7 +12,7 @@ class CssCrush_Color {
public static function getKeywords () {
// Load the keywords if necessary
if ( empty( self::$keywords ) ) {
- $path = CssCrush::$location . '/misc/color.keywords';
+ $path = CssCrush::$location . '/misc/color-keywords.ini';
if ( $keywords = parse_ini_file( $path ) ) {
foreach ( $keywords as $word => $rgb ) {
$rgb = array_map( 'intval', explode( ',', $rgb ) );
View
159 lib/Core.php
@@ -1,8 +1,8 @@
<?php
/**
- *
+ *
* Main script. Includes core public API
- *
+ *
*/
class CssCrush {
@@ -62,7 +62,6 @@ class CssCrush {
|
\$\(\s*([a-z0-9_-]+)\s*\) # Dollar syntax
)!ix',
- 'custom' => '!(^|[^a-z0-9_-])(<functions>)?(___p\d+___)!i',
'match' => '!(^|[^a-z0-9_-])([a-z_-]+)(___p\d+___)!i',
),
'vendorPrefix' => '!^-([a-z]+)-([a-z-]+)!',
@@ -103,7 +102,7 @@ public static function init ( $current_dir ) {
protected static function loadAssets () {
// Load aliases file if it exists
- $aliases_file = self::$location . '/' . __CLASS__ . '.aliases';
+ $aliases_file = self::$location . '/Aliases.ini';
if ( file_exists( $aliases_file ) ) {
if ( $result = parse_ini_file( $aliases_file, true ) ) {
self::$aliasesRaw = $result;
@@ -127,7 +126,7 @@ protected static function loadAssets () {
}
// Load plugins
- $plugins_file = self::$location . '/' . __CLASS__ . '.plugins';
+ $plugins_file = self::$location . '/Plugins.ini';
if ( file_exists( $plugins_file ) ) {
if ( $result = parse_ini_file( $plugins_file ) ) {
foreach ( $result[ 'plugins' ] as $plugin_file ) {
@@ -278,7 +277,7 @@ public static function file ( $file, $options = null ) {
// Collate hostfile and imports
$stream = CssCrush_Importer::hostfile( $hostfile );
-
+
// Compile
$stream = self::compile( $stream );
@@ -388,7 +387,7 @@ public static function clearCache ( $dir = '' ) {
#####################
# Developer
-
+
// Enable logging
public static $logging = false;
@@ -482,16 +481,16 @@ protected static function parseOptions ( $options ) {
}
protected static function pruneAliases () {
-
+
// If a vendor target is given, we prune the aliases array
$vendor = self::$options[ 'vendor_target' ];
-
+
// For expicit 'none' argument turn off aliases
if ( 'none' === $vendor ) {
self::$aliases = null;
return;
}
-
+
// Default vendor argument, use all aliases as normal
if ( 'all' === $vendor ) {
return;
@@ -500,7 +499,7 @@ protected static function pruneAliases () {
// Normalize vendor_target argument
$vendor = str_replace( '-', '', self::$options[ 'vendor_target' ] );
$vendor = "-$vendor-";
-
+
// Loop the aliases array, filter down to the target vendor
foreach ( self::$aliases as $group_name => $group_array ) {
// Property/value aliases are a special case
@@ -538,9 +537,9 @@ protected static function pruneAliases () {
}
protected static function calculateVariables () {
-
+
$regex = self::$regex;
-
+
// In-file variables override global variables
// Runtime variables override in-file variables
self::$storage->variables = array_merge(
@@ -553,22 +552,14 @@ protected static function calculateVariables () {
// Place variables referenced inside variables
// Excecute any custom functions
foreach ( self::$storage->variables as $name => &$value ) {
-
+
// Referenced variables
$value = preg_replace_callback(
$regex->function->var, array( 'self', 'cb_placeVariables' ), $value );
// Custom functions
- $parens = self::matchAllParens( $value );
- if ( count( $parens->matches ) ) {
- CssCrush::$storage->tmpParens = $parens->matches;
- $value = preg_replace_callback(
- $regex->function->custom, array( 'CssCrush_Function', 'css_fn' ), $parens->string );
- // Fold matches back in
- $value = str_replace( array_keys( $parens->matches ), array_values( $parens->matches ), $value );
- }
+ $value = CssCrush_Function::parseAndExecuteValue( $value );
}
-
}
protected static function placeVariables ( $stream ) {
@@ -604,16 +595,11 @@ protected static function compile ( $stream ) {
self::loadAssets();
self::$assetsLoaded = true;
}
-
+
// Set aliases. May be pruned if a vendor target is set
self::$aliases = self::$aliasesRaw;
self::pruneAliases();
- // Set the custom function regular expression
- $css_functions = CssCrush_Function::getFunctions();
- $regex->function->custom = str_replace(
- '<functions>', implode( '|', $css_functions ), $regex->function->custom );
-
// Extract comments
$stream = preg_replace_callback( $regex->comment, array( 'self', 'cb_extractComments' ), $stream );
@@ -928,18 +914,31 @@ protected static function cb_restoreComments ( $match ) {
protected static function cb_extractRules ( $match ) {
- $rule = new CssCrush_Rule( $match[1], $match[2] );
+ $rule = new stdClass;
+ $rule->selector_raw = $match[1];
+ $rule->declaration_raw = $match[2];
+
+ CssCrush_Hook::run( 'rule_preprocess', $rule );
+
+ $rule = new CssCrush_Rule( $rule->selector_raw, $rule->declaration_raw );
// Only store rules with declarations
if ( !empty( $rule->declarations ) ) {
+
+ CssCrush_Hook::run( 'rule_prealias', $rule );
+
if ( !empty( self::$aliases ) ) {
$rule->addPropertyAliases();
$rule->addFunctionAliases();
$rule->addValueAliases();
}
- $rule->applyMacros();
+
+ CssCrush_Hook::run( 'rule_postalias', $rule );
+
$rule->expandSelectors();
+ CssCrush_Hook::run( 'rule_postprocess', $rule );
+
$label = self::createTokenLabel( 'r' );
self::$storage->tokens->rules[ $label ] = $rule;
return $label . "\n";
@@ -957,6 +956,7 @@ protected static function cb_extractVariables ( $match ) {
// Strip comment markers
$block = preg_replace( $regex->token->comment, '', $block );
+ // Need to split safely as there are semi-colons in data-uris
$variables_match = self::splitDelimList( $block, ';', true );
// Loop through the pairs, restore parens
@@ -1032,7 +1032,7 @@ protected static function cb_printRule ( $match ) {
# Utilities
public static function splitDelimList ( $str, $delim, $fold_in = false, $allow_empty = false ) {
- $match_obj = self::matchAllParens( $str );
+ $match_obj = self::matchAllBrackets( $str );
$match_obj->list = explode( $delim, $match_obj->string );
if ( false === $allow_empty ) {
$match_obj->list = array_filter( $match_obj->list );
@@ -1063,21 +1063,21 @@ public static function normalizeWhiteSpace ( $str ) {
}
public static function matchBrackets ( $str, $brackets = array( '(', ')' ), $search_pos = 0 ) {
- $open_token = $brackets[0];
- $close_token = $brackets[1];
+
+ list( $opener, $closer ) = $brackets;
$openings = array();
$closings = array();
$brake = 50; // Set a limit in the case of errors
$match = new stdClass;
- $start_index = strpos( $str, $open_token, $search_pos );
- $close_index = strpos( $str, $close_token, $search_pos );
+ $start_index = strpos( $str, $opener, $search_pos );
+ $close_index = strpos( $str, $closer, $search_pos );
if ( $start_index === false ) {
return false;
}
- if ( substr_count( $str, $open_token ) !== substr_count( $str, $close_token ) ) {
+ if ( substr_count( $str, $opener ) !== substr_count( $str, $closer ) ) {
$sample = substr( $str, 0, 15 );
trigger_error( __METHOD__ . ": Unmatched token near '$sample'.\n", E_USER_WARNING );
return false;
@@ -1112,34 +1112,77 @@ public static function matchBrackets ( $str, $brackets = array( '(', ')' ), $sea
$match->end = $closings[ count( $closings ) - 1 ] + 1;
return $match;
}
- $start_index = strpos( $str, $open_token, $search_pos );
- $close_index = strpos( $str, $close_token, $search_pos );
+ $start_index = strpos( $str, $opener, $search_pos );
+ $close_index = strpos( $str, $closer, $search_pos );
}
trigger_error( __METHOD__ . ": Reached brake limit of '$brake'. Exiting.\n", E_USER_WARNING );
return false;
}
- public static function matchAllParens ( $str ) {
- $storage = array();
- $brackets = array( '(', ')' );
- $match = self::matchBrackets( $str );
- $matches = array();
- while ( $match ) {
+ public static function matchAllBrackets ( $str, $pair = '()', $offset = 0 ) {
+
+ $match_obj = new stdClass;
+ $match_obj->string = $str;
+ $match_obj->raw = $str;
+ $match_obj->matches = array();
+
+ list( $opener, $closer ) = str_split( $pair, 1 );
+
+ // Return early if there's no match
+ if ( false === ( $first_offset = strpos( $str, $opener, $offset ) ) ) {
+ return $match_obj;
+ }
+
+ // Step through the string one character at a time storing offsets
+ $paren_score = -1;
+ $inside_paren = false;
+ $match_start = 0;
+ $offsets = array();
+
+ for ( $index = $first_offset; $index < strlen( $str ); $index++ ) {
+ $char = $str[ $index ];
+
+ if ( $opener === $char ) {
+ if ( !$inside_paren ) {
+ $paren_score = 1;
+ $match_start = $index;
+ }
+ else {
+ $paren_score++;
+ }
+ $inside_paren = true;
+ }
+ elseif ( $closer === $char ) {
+ $paren_score--;
+ }
+
+ if ( 0 === $paren_score ) {
+ $inside_paren = false;
+ $paren_score = -1;
+ $offsets[] = array( $match_start, $index + 1 );
+ }
+ }
+
+ // Step backwards through the matches
+ while ( $offset = array_pop( $offsets ) ) {
+ list( $start, $finish ) = $offset;
+
+ $before = substr( $str, 0, $start );
+ $content = substr( $str, $start, $finish - $start );
+ $after = substr( $str, $finish );
+
$label = self::createTokenLabel( 'p' );
- $capture = substr( $str, $match->start, $match->end - $match->start );
- self::$storage->tokens->parens[ $label ] = $capture;
- $matches[ $label ] = $capture;
- $str =
- substr( $str, 0, $match->start ) .
- $label .
- substr( $str, $match->end );
- $match = self::matchBrackets( $str, $brackets );
- }
- return (object) array(
- 'matches' => $matches,
- 'string' => str_replace( $brackets, '', $str ),
- );
+ $str = $before . $label . $after;
+ $match_obj->matches[ $label ] = $content;
+
+ // Parens will be folded in later
+ self::$storage->tokens->parens[ $label ] = $content;
+ }
+
+ $match_obj->string = $str;
+
+ return $match_obj;
}
public static function addRuleMacro ( $fn ) {
View
136 lib/Function.php
@@ -1,12 +1,24 @@
<?php
/**
- *
+ *
* Custom CSS functions
- *
+ *
*/
class CssCrush_Function {
+ // Regex pattern for finding custom functions
+ public static $functionPatt;
+
+ // Cache for function names
+ public static $functionList;
+
+ public static function init () {
+ // Set the custom function regex pattern
+ self::$functionList = self::getFunctions();
+ self::$functionPatt = '!(^|[^a-z0-9_-])(' . implode( '|', self::$functionList ) . ')?\(!i';
+ }
+
public static function getFunctions () {
// Fetch custom function names
@@ -22,6 +34,89 @@ public static function getFunctions () {
return $fn_methods;
}
+ public static function parseAndExecuteValue ( $str ) {
+
+ $patt = self::$functionPatt;
+
+ // No bracketed expressions, early return
+ if ( false === strpos( $str, '(' ) ) {
+ return $str;
+ }
+
+ // No custom functions, early return
+ if ( !preg_match( $patt, $str ) ) {
+ return $str;
+ }
+
+ // Need a space inside the front function paren for the following match_all to be reliable
+ $str = preg_replace( '!\(([^\s])!', '( $1', $str, -1, $spacing_count );
+
+ // Find custom function matches
+ $match_count = preg_match_all( $patt, $str, $m, PREG_OFFSET_CAPTURE | PREG_SET_ORDER );
+
+ // Step through the matches from last to first
+ while ( $match = array_pop( $m ) ) {
+
+ $offset = $match[0][1];
+ $before_char = $match[1][0];
+ $before_char_len = strlen( $before_char );
+
+ // No function name default to math expression
+ // Store the raw function name match
+ $raw_fn_name = isset( $match[2] ) ? $match[2][0] : '';
+ $fn_name = $raw_fn_name ? $raw_fn_name : 'math';
+ if ( '-' === $fn_name ) {
+ $fn_name = 'math';
+ }
+
+ // Loop throught the string
+ $first_paren_offset = strpos( $str, '(', $offset );
+ $paren_score = 0;
+
+ for ( $index = $first_paren_offset; $index < strlen( $str ); $index++ ) {
+ $char = $str[ $index ];
+ if ( '(' === $char ) {
+ $paren_score++;
+ }
+ elseif ( ')' === $char ) {
+ $paren_score--;
+ }
+
+ if ( 0 === $paren_score ) {
+ // Get the function inards
+ $content_start = $offset + strlen( $before_char ) + strlen( $raw_fn_name ) + 1;
+ $content_finish = $index;
+ $content = substr( $str, $content_start, $content_finish - $content_start );
+ $content = trim( $content );
+
+ // Calculate offsets
+ $func_start = $offset + strlen( $before_char );
+ $func_end = $index + 1;
+
+ // Workaround the minus
+ $minus_before = '-' === $raw_fn_name ? '-' : '';
+
+ $result = '';
+ if ( in_array( $fn_name, self::$functionList ) ) {
+ $fn_name_clean = str_replace( '-', '_', $fn_name );
+ $result = call_user_func( array( 'self', "css_fn__$fn_name_clean" ), $content );
+ }
+
+ // Join together the result
+ $str = substr( $str, 0, $func_start ) . $minus_before . $result . substr( $str, $func_end );
+ break;
+ }
+ }
+ } // while
+
+ // Restore the whitespace
+ if ( $spacing_count ) {
+ $str = str_replace( '( ', '(', $str );
+ }
+
+ return $str;
+ }
+
############
# Helpers
@@ -52,7 +147,7 @@ protected static function colorAdjust ( $color, array $adjustments ) {
// Support for Hex, RGB, RGBa and keywords
// HSL and HSLa are passed over
if ( $fn_matched or array_key_exists( $color, $keywords ) ) {
-
+
$alpha = null;
$rgb = null;
@@ -77,7 +172,7 @@ protected static function colorAdjust ( $color, array $adjustments ) {
else {
$rgb = $keywords[ $color ];
}
-
+
$hsl = CssCrush_Color::rgbToHsl( $rgb );
// Clean up adjustment parameters to floating point numbers
@@ -110,42 +205,12 @@ protected static function colorAdjust ( $color, array $adjustments ) {
############
-
- public static function css_fn ( $match ) {
-
- $before_char = $match[1];
- $fn_name_css = $match[2];
- $fn_name_clean = str_replace( '-', '', $fn_name_css );
- $fn_name = str_replace( '-', '_', $fn_name_css );
-
- $paren_id = $match[3];
-
- if ( !isset( CssCrush::$storage->tmpParens[ $paren_id ] ) ) {
- return $before_char;
- }
-
- // Get input value and trim parens
- $input = CssCrush::$storage->tmpParens[ $paren_id ];
- $input = trim( substr( $input, 1, strlen( $input ) - 2 ) );
-
- // An empty function name defaults to math
- if ( empty( $fn_name_clean ) ) {
- $fn_name = 'math';
- }
-
- // Capture a negative sign e.g -( 20 * 2 )
- if ( $fn_name_css === '-' ) {
- $before_char .= '-';
- }
- return $before_char . call_user_func( array( 'self', "css_fn__$fn_name" ), $input );
- }
public static function css_fn__math ( $input ) {
// Whitelist allowed characters
$input = preg_replace( '![^\.0-9\*\/\+\-\(\)]!', '', $input );
$result = 0;
try {
- // CssCrush::log( $input )
$result = eval( "return $input;" );
}
catch ( Exception $e ) {};
@@ -259,3 +324,6 @@ public static function css_fn__l_adjust ( $input ) {
}
}
+
+
+
View
27 lib/Hook.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ *
+ * Access to the execution flow for plugins
+ *
+ */
+class CssCrush_Hook {
+
+ static public $record = array();
+
+ static public function add ( $hook, $fn_name ) {
+ // Store in associative array so no duplicates
+ if ( function_exists( $fn_name ) ) {
+ self::$record[ $hook ][ $fn_name ] = true;
+ }
+ }
+
+ static public function run ( $hook, $arg_obj ) {
+ // Run all callbacks attached to the hook
+ if ( !isset( self::$record[ $hook ] ) ) {
+ return;
+ }
+ foreach ( array_keys( self::$record[ $hook ] ) as $fn_name ) {
+ call_user_func( $fn_name, $arg_obj );
+ }
+ }
+}
View
45 lib/Rule.php
@@ -21,16 +21,6 @@ public function __construct ( $selector_string = null, $declarations_string ) {
// Parse the selectors chunk
if ( !empty( $selector_string ) ) {
- $selector_adjustments = array(
- // 'hocus' and 'pocus' pseudo class shorthand
- '!:hocus([^a-z0-9_-])!' => ':any(:hover,:focus)$1',
- '!:pocus([^a-z0-9_-])!' => ':any(:hover,:focus,:active)$1',
- // Reduce double colon syntax for backwards compatability
- '!::(after|before|first-letter|first-line)!' => ':$1',
- );
- $selector_string = preg_replace(
- array_keys( $selector_adjustments ), array_values( $selector_adjustments ), $selector_string );
-
$selectors_match = CssCrush::splitDelimList( $selector_string, ',' );
$this->parens += $selectors_match->matches;
@@ -45,13 +35,16 @@ public function __construct ( $selector_string = null, $declarations_string ) {
$this->selectors = $selectors_match->list;
}
+ // Apply any custom functions
+ $declarations_string = CssCrush_Function::parseAndExecuteValue( $declarations_string );
+
// Parse the declarations chunk
+ // Need to split safely as there are semi-colons in data-uris
$declarations_match = CssCrush::splitDelimList( $declarations_string, ';' );
$this->parens += $declarations_match->matches;
// Parse declarations in to property/value pairs
foreach ( $declarations_match->list as $declaration ) {
-
// Strip comments around the property
$declaration = preg_replace( $regex->token->comment, '', $declaration );
@@ -67,21 +60,6 @@ public function __construct ( $selector_string = null, $declarations_string ) {
$this->addProperty( $prop );
}
- // Extract the value part of the declaration
- $value = substr( $declaration, $colonPos + 1 );
- $value = $value !== false ? trim( $value ) : $value;
- if ( $value === false or $value === '' ) {
- // We'll ignore declarations with empty values
- continue;
- }
-
- // If are parenthesised expressions in the value
- // Search for any custom functions so we can apply them
- if ( count( $declarations_match->matches ) ) {
- CssCrush::$storage->tmpParens = $declarations_match->matches;
- $value = preg_replace_callback( $regex->function->custom, array( 'CssCrush_Function', 'css_fn' ), $value );
- }
-
// Store the property family
// Store the vendor id, if one is present
if ( preg_match( $regex->vendorPrefix, $prop, $vendor ) ) {
@@ -93,8 +71,17 @@ public function __construct ( $selector_string = null, $declarations_string ) {
$family = $prop;
}
+ // Extract the value part of the declaration
+ $value = substr( $declaration, $colonPos + 1 );
+ $value = $value !== false ? trim( $value ) : $value;
+ if ( $value === false or $value === '' ) {
+ // We'll ignore declarations with empty values
+ continue;
+ }
+
// Create an index of all functions in the current declaration
if ( preg_match_all( $regex->function->match, $value, $functions ) > 0 ) {
+ // CssCrush::log( $functions );
$out = array();
foreach ( $functions[2] as $index => $fn_name ) {
$out[] = $fn_name;
@@ -271,12 +258,6 @@ public function addValueAliases () {
$this->declarations = $new_set;
}
- public function applyMacros () {
- foreach ( CssCrush::$macros as $fn ) {
- call_user_func( $fn, $this );
- }
- }
-
public function expandSelectors () {
$new_set = array();
View
0  misc/color.keywords → misc/color-keywords.ini
File renamed without changes
View
18 plugins/double-colon.php
@@ -0,0 +1,18 @@
+<?php
+/**
+ * Double Colon
+ * Compile pseudo element double colon syntax to single colon syntax for backwards compatibility
+ *
+ * @before
+ * p::after { content: '!'; }
+ *
+ * @after
+ * p:after { content: '!'; }
+ *
+ */
+
+CssCrush_Hook::add( 'rule_preprocess', 'csscrush_doublecolon' );
+
+function csscrush_doublecolon ( $rule ) {
+ $rule->selector_raw = preg_replace( '!::(after|before|first-letter|first-line)!', ':$1', $rule->selector_raw );
+}
View
24 plugins/hocus-pocus.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Hocus Pocus
+ * Non-standard composite pseudo classes
+ *
+ * @before
+ * a:hocus { color: red; }
+ * a:pocus { color: red; }
+ *
+ * @after
+ * a:hover, a:focus { color: red; }
+ * a:hover, a:focus, a:active { color: red; }
+ *
+ */
+
+CssCrush_Hook::add( 'rule_preprocess', 'csscrush_hocuspocus' );
+
+function csscrush_hocuspocus ( $rule ) {
+ $adjustments = array(
+ '!:hocus([^a-z0-9_-])!' => ':any(:hover,:focus)$1',
+ '!:pocus([^a-z0-9_-])!' => ':any(:hover,:focus,:active)$1',
+ );
+ $rule->selector_raw = preg_replace( array_keys( $adjustments ), array_values( $adjustments ), $rule->selector_raw );
+}
View
6 plugins/hsl-to-hex.php
@@ -3,14 +3,14 @@
* HSL shim
* Converts HSL values into hex code that works in all browsers
*
- * Before:
+ * @before
* color: hsl( 100, 50%, 50% )
*
- * After:
+ * @after
* color: #6abf40
*/
-CssCrush::addRuleMacro( 'csscrush_hsl' );
+CssCrush_Hook::add( 'rule_postalias', 'csscrush_hsl' );
function csscrush_hsl ( CssCrush_Rule $rule ) {
foreach ( $rule as &$declaration ) {
View
6 plugins/ie-clip.php
@@ -2,15 +2,15 @@
/**
* Fix clip syntax for IE < 8
*
- * Before:
+ * @before
* clip: rect(1px,1px,1px,1px);
*
- * After:
+ * @after
* clip: rect(1px,1px,1px,1px);
* *clip: rect(1px 1px 1px 1px);
*/
-CssCrush::addRuleMacro( 'csscrush_clip' );
+CssCrush_Hook::add( 'rule_postalias', 'csscrush_clip' );
function csscrush_clip ( CssCrush_Rule $rule ) {
// Assume it's been dealt with if the property occurs more than once
View
2  plugins/ie-filter.php
@@ -3,7 +3,7 @@
* IE filter without the cruft
*/
-CssCrush::addRuleMacro( 'csscrush_filter' );
+CssCrush_Hook::add( 'rule_postalias', 'csscrush_filter' );
function csscrush_filter ( CssCrush_Rule $rule ) {
if ( $rule->propertyCount( 'filter' ) < 1 ) {
View
6 plugins/ie-inline-block.php
@@ -2,16 +2,16 @@
/**
* Simulate inline-block in IE < 8
*
- * Before:
+ * @before
* display: inline-block;
*
- * After:
+ * @after
* display: inline-block;
* *display: inline;
* *zoom: 1;
*/
-CssCrush::addRuleMacro( 'csscrush_display_inlineblock' );
+CssCrush_Hook::add( 'rule_postalias', 'csscrush_display_inlineblock' );
function csscrush_display_inlineblock ( CssCrush_Rule $rule ) {
if ( $rule->propertyCount( 'display' ) < 1 ) {
View
6 plugins/ie-min-height.php
@@ -2,15 +2,15 @@
/**
* Fix min-height in IE 6
*
- * Before:
+ * @before
* min-height: 100px;
*
- * After:
+ * @after
* min-height: 100px;
* _height: 100px;
*/
-CssCrush::addRuleMacro( 'csscrush_minheight' );
+CssCrush_Hook::add( 'rule_postalias', 'csscrush_minheight' );
function csscrush_minheight ( CssCrush_Rule $rule ) {
if ( $rule->propertyCount( 'min-height' ) < 1 ) {
View
6 plugins/rgba-fallback.php
@@ -4,15 +4,15 @@
* Only works with background shorthand IE < 8
* (http://css-tricks.com/2151-rgba-browser-support/)
*
- * Before:
+ * @before
* background: rgba(0,0,0,.5);
*
- * After:
+ * @after
* background: rgb(0,0,0);
* background: rgba(0,0,0,.5);
*/
-CssCrush::addRuleMacro( 'csscrush_rgba' );
+CssCrush_Hook::add( 'rule_postalias', 'csscrush_rgba' );
function csscrush_rgba ( CssCrush_Rule $rule ) {
$props = array_keys( $rule->properties );
Please sign in to comment.
Something went wrong with that request. Please try again.