@@ -60,9 +60,9 @@ discard block |
||
| 60 | 60 | { |
| 61 | 61 | // Only enqueue if there is at least one dynamic stylesheet that is |
| 62 | 62 | // set to be loaded externally |
| 63 | - if( 0 < count( array_filter($this->stylesheets, array( $this, 'filter_external' ) ) ) ) |
|
| 63 | + if (0 < count(array_filter($this->stylesheets, array($this, 'filter_external')))) |
|
| 64 | 64 | { |
| 65 | - wp_enqueue_style( 'wp-dynamic-css', admin_url( 'admin-ajax.php?action=wp_dynamic_css' ) ); |
|
| 65 | + wp_enqueue_style('wp-dynamic-css', admin_url('admin-ajax.php?action=wp_dynamic_css')); |
|
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | |
@@ -72,12 +72,12 @@ discard block |
||
| 72 | 72 | */ |
| 73 | 73 | public function compile_printed_styles() |
| 74 | 74 | { |
| 75 | - $styles = array_filter($this->stylesheets, array( $this, 'filter_print' ) ); |
|
| 75 | + $styles = array_filter($this->stylesheets, array($this, 'filter_print')); |
|
| 76 | 76 | |
| 77 | 77 | // Bail if there are no styles to be printed |
| 78 | - if( count( $styles ) === 0 ) return; |
|
| 78 | + if (count($styles) === 0) return; |
|
| 79 | 79 | |
| 80 | - $compiled_css = $this->compile_styles( $styles ); |
|
| 80 | + $compiled_css = $this->compile_styles($styles); |
|
| 81 | 81 | |
| 82 | 82 | echo "<style id=\"wp-dynamic-css\">\n"; |
| 83 | 83 | include 'style.phtml'; |
@@ -90,10 +90,10 @@ discard block |
||
| 90 | 90 | */ |
| 91 | 91 | public function compile_external_styles() |
| 92 | 92 | { |
| 93 | - header( "Content-type: text/css; charset: UTF-8" ); |
|
| 94 | - header( "Cache-Control: no-cache, must-revalidate" ); //set headers to NOT cache a page so that changes to options are reflected immediately |
|
| 93 | + header("Content-type: text/css; charset: UTF-8"); |
|
| 94 | + header("Cache-Control: no-cache, must-revalidate"); //set headers to NOT cache a page so that changes to options are reflected immediately |
|
| 95 | 95 | |
| 96 | - $compiled_css = $this->compile_styles( array_filter($this->stylesheets, array( $this, 'filter_external' ) ) ); |
|
| 96 | + $compiled_css = $this->compile_styles(array_filter($this->stylesheets, array($this, 'filter_external'))); |
|
| 97 | 97 | |
| 98 | 98 | include 'style.phtml'; |
| 99 | 99 | wp_die(); |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * @param boolean $print Whether to print the compiled CSS to the document |
| 108 | 108 | * head, or include it as an external CSS file |
| 109 | 109 | */ |
| 110 | - public function enqueue_style( $handle, $path, $print ) |
|
| 110 | + public function enqueue_style($handle, $path, $print) |
|
| 111 | 111 | { |
| 112 | 112 | $this->stylesheets[] = array( |
| 113 | 113 | 'handle'=> $handle, |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | * @param type $handle The stylesheet's name/id |
| 123 | 123 | * @param type $callback |
| 124 | 124 | */ |
| 125 | - public function register_callback( $handle, $callback ) |
|
| 125 | + public function register_callback($handle, $callback) |
|
| 126 | 126 | { |
| 127 | 127 | $this->callbacks[$handle] = $callback; |
| 128 | 128 | } |
@@ -134,13 +134,13 @@ discard block |
||
| 134 | 134 | * stored in $this->stylesheets |
| 135 | 135 | * @return string Compiled CSS |
| 136 | 136 | */ |
| 137 | - protected function compile_styles( $styles ) |
|
| 137 | + protected function compile_styles($styles) |
|
| 138 | 138 | { |
| 139 | 139 | $compiled_css = ''; |
| 140 | - foreach( $styles as $style ) |
|
| 140 | + foreach ($styles as $style) |
|
| 141 | 141 | { |
| 142 | - $css = file_get_contents( $style['path'] ); |
|
| 143 | - $compiled_css .= $this->compile_css( $css, $this->callbacks[$style['handle']] )."\n"; |
|
| 142 | + $css = file_get_contents($style['path']); |
|
| 143 | + $compiled_css .= $this->compile_css($css, $this->callbacks[$style['handle']])."\n"; |
|
| 144 | 144 | } |
| 145 | 145 | return $compiled_css; |
| 146 | 146 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @param array $style |
| 153 | 153 | * @return boolean |
| 154 | 154 | */ |
| 155 | - protected function filter_print( $style ) |
|
| 155 | + protected function filter_print($style) |
|
| 156 | 156 | { |
| 157 | 157 | return true === $style['print']; |
| 158 | 158 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | * @param array $style |
| 165 | 165 | * @return boolean |
| 166 | 166 | */ |
| 167 | - protected function filter_external( $style ) |
|
| 167 | + protected function filter_external($style) |
|
| 168 | 168 | { |
| 169 | 169 | return true !== $style['print']; |
| 170 | 170 | } |
@@ -180,15 +180,15 @@ discard block |
||
| 180 | 180 | * @return string The compiled CSS after converting the variables to their |
| 181 | 181 | * corresponding values |
| 182 | 182 | */ |
| 183 | - protected function compile_css( $css, $callback ) |
|
| 183 | + protected function compile_css($css, $callback) |
|
| 184 | 184 | { |
| 185 | - return preg_replace_callback( "#\\$([\\w-]+)((?:\\['?[\\w-]+'?\\])*)#", function( $matches ) use ( $callback ) { |
|
| 185 | + return preg_replace_callback("#\\$([\\w-]+)((?:\\['?[\\w-]+'?\\])*)#", function($matches) use ($callback) { |
|
| 186 | 186 | // If this variable is an array, get the subscripts |
| 187 | - if( '' !== $matches[2] ) |
|
| 187 | + if ('' !== $matches[2]) |
|
| 188 | 188 | { |
| 189 | 189 | preg_match_all('/[\w-]+/i', $matches[2], $subscripts); |
| 190 | 190 | } |
| 191 | - return call_user_func_array( $callback, array($matches[1],@$subscripts[0]) ); |
|
| 191 | + return call_user_func_array($callback, array($matches[1], @$subscripts[0])); |
|
| 192 | 192 | }, $css); |
| 193 | 193 | } |
| 194 | 194 | } |