@@ -71,7 +71,9 @@ |
||
71 | 71 | $styles = array_filter($this->stylesheets, array( $this, 'filter_print' ) ); |
72 | 72 | |
73 | 73 | // Bail if there are no styles to be printed |
74 | - if( count( $styles ) === 0 ) return; |
|
74 | + if( count( $styles ) === 0 ) { |
|
75 | + return; |
|
76 | + } |
|
75 | 77 | |
76 | 78 | foreach( $styles as $style ) |
77 | 79 | { |
@@ -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 | |
@@ -73,15 +73,15 @@ discard block |
||
73 | 73 | public function compile_printed_styles() |
74 | 74 | { |
75 | 75 | $compiled_css = ''; |
76 | - $styles = array_filter($this->stylesheets, array( $this, 'filter_print' ) ); |
|
76 | + $styles = array_filter($this->stylesheets, array($this, 'filter_print')); |
|
77 | 77 | |
78 | 78 | // Bail if there are no styles to be printed |
79 | - if( count( $styles ) === 0 ) return; |
|
79 | + if (count($styles) === 0) return; |
|
80 | 80 | |
81 | - foreach( $styles as $style ) |
|
81 | + foreach ($styles as $style) |
|
82 | 82 | { |
83 | - $css = file_get_contents( $style['path'] ); |
|
84 | - $compiled_css .= $this->compile_css( $css, $this->callbacks[$style['handle']] )."\n"; |
|
83 | + $css = file_get_contents($style['path']); |
|
84 | + $compiled_css .= $this->compile_css($css, $this->callbacks[$style['handle']]) . "\n"; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | echo "<style id=\"wp-dynamic-css\">\n"; |
@@ -95,14 +95,14 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function compile_external_styles() |
97 | 97 | { |
98 | - header( "Content-type: text/css; charset: UTF-8" ); |
|
98 | + header("Content-type: text/css; charset: UTF-8"); |
|
99 | 99 | $compiled_css = ''; |
100 | - $styles = array_filter($this->stylesheets, array( $this, 'filter_external' ) ); |
|
100 | + $styles = array_filter($this->stylesheets, array($this, 'filter_external')); |
|
101 | 101 | |
102 | - foreach( $styles as $style ) |
|
102 | + foreach ($styles as $style) |
|
103 | 103 | { |
104 | - $css = file_get_contents( $style['path'] ); |
|
105 | - $compiled_css .= $this->compile_css( $css, $this->callbacks[$style['handle']] )."\n"; |
|
104 | + $css = file_get_contents($style['path']); |
|
105 | + $compiled_css .= $this->compile_css($css, $this->callbacks[$style['handle']]) . "\n"; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | include 'style.phtml'; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @param boolean $print Whether to print the compiled CSS to the document |
118 | 118 | * head, or include it as an external CSS file |
119 | 119 | */ |
120 | - public function enqueue_style( $handle, $path, $print ) |
|
120 | + public function enqueue_style($handle, $path, $print) |
|
121 | 121 | { |
122 | 122 | $this->stylesheets[] = array( |
123 | 123 | 'handle'=> $handle, |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * @param type $handle The stylesheet's name/id |
133 | 133 | * @param type $callback |
134 | 134 | */ |
135 | - public function register_callback( $handle, $callback ) |
|
135 | + public function register_callback($handle, $callback) |
|
136 | 136 | { |
137 | 137 | $this->callbacks[$handle] = $callback; |
138 | 138 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @param array $style |
145 | 145 | * @return boolean |
146 | 146 | */ |
147 | - protected function filter_print( $style ) |
|
147 | + protected function filter_print($style) |
|
148 | 148 | { |
149 | 149 | return true === $style['print']; |
150 | 150 | } |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * @param array $style |
157 | 157 | * @return boolean |
158 | 158 | */ |
159 | - protected function filter_external( $style ) |
|
159 | + protected function filter_external($style) |
|
160 | 160 | { |
161 | 161 | return true !== $style['print']; |
162 | 162 | } |
@@ -172,10 +172,10 @@ discard block |
||
172 | 172 | * @return string The compiled CSS after converting the variables to their |
173 | 173 | * corresponding values |
174 | 174 | */ |
175 | - protected function compile_css( $css, $callback ) |
|
175 | + protected function compile_css($css, $callback) |
|
176 | 176 | { |
177 | - return preg_replace_callback( '#\$([\w]+)#', function( $matches ) use ( $callback ) { |
|
178 | - return call_user_func_array( $callback, array($matches[1]) ); |
|
177 | + return preg_replace_callback('#\$([\w]+)#', function($matches) use ($callback) { |
|
178 | + return call_user_func_array($callback, array($matches[1])); |
|
179 | 179 | }, $css); |
180 | 180 | } |
181 | 181 | } |
@@ -20,14 +20,14 @@ discard block |
||
20 | 20 | * Domain Path: /languages |
21 | 21 | */ |
22 | 22 | |
23 | -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
|
23 | +defined('ABSPATH') or die('No script kiddies please!'); |
|
24 | 24 | |
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Prevent loading the library more than once |
28 | 28 | */ |
29 | -if( defined( 'WP_DYNAMIC_CSS' ) ) return; |
|
30 | -define( 'WP_DYNAMIC_CSS', true ); |
|
29 | +if (defined('WP_DYNAMIC_CSS')) return; |
|
30 | +define('WP_DYNAMIC_CSS', true); |
|
31 | 31 | |
32 | 32 | /** |
33 | 33 | * Load required files |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | * stylesheets externally. |
41 | 41 | */ |
42 | 42 | $dcss = DynamicCSSCompiler::get_instance(); |
43 | -add_action( 'wp_print_styles', array( $dcss, 'compile_printed_styles' ) ); |
|
44 | -add_action( 'wp_enqueue_scripts', array( $dcss, 'wp_enqueue_style' ) ); |
|
45 | -add_action( 'wp_ajax_wp_dynamic_css', array( $dcss, 'compile_external_styles' ) ); |
|
46 | -add_action( 'wp_ajax_nopriv_wp_dynamic_css', array( $dcss, 'compile_external_styles' ) ); |
|
47 | 43 | \ No newline at end of file |
44 | +add_action('wp_print_styles', array($dcss, 'compile_printed_styles')); |
|
45 | +add_action('wp_enqueue_scripts', array($dcss, 'wp_enqueue_style')); |
|
46 | +add_action('wp_ajax_wp_dynamic_css', array($dcss, 'compile_external_styles')); |
|
47 | +add_action('wp_ajax_nopriv_wp_dynamic_css', array($dcss, 'compile_external_styles')); |
|
48 | 48 | \ No newline at end of file |
@@ -26,7 +26,9 @@ |
||
26 | 26 | /** |
27 | 27 | * Prevent loading the library more than once |
28 | 28 | */ |
29 | -if( defined( 'WP_DYNAMIC_CSS' ) ) return; |
|
29 | +if( defined( 'WP_DYNAMIC_CSS' ) ) { |
|
30 | + return; |
|
31 | +} |
|
30 | 32 | define( 'WP_DYNAMIC_CSS', true ); |
31 | 33 | |
32 | 34 | /** |
@@ -1,24 +1,24 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Dynamic CSS |
|
4 | - * |
|
5 | - * Dynamic CSS compiler for WordPress |
|
6 | - * |
|
7 | - * @package wp-dynamic-css |
|
8 | - * @author Askupa Software <[email protected]> |
|
9 | - * @link https://github.com/askupasoftware/wp-dynamic-css |
|
10 | - * @copyright 2016 Askupa Software |
|
11 | - * |
|
12 | - * @wordpress-plugin |
|
13 | - * Plugin Name: WordPress Dynamic CSS |
|
14 | - * Plugin URI: https://github.com/askupasoftware/wp-dynamic-css |
|
15 | - * Description: Dynamic CSS compiler for WordPress |
|
16 | - * Version: 1.0.2 |
|
17 | - * Author: Askupa Software |
|
18 | - * Author URI: http://www.askupasoftware.com |
|
19 | - * Text Domain: wp-dynamic-css |
|
20 | - * Domain Path: /languages |
|
21 | - */ |
|
3 | + * WordPress Dynamic CSS |
|
4 | + * |
|
5 | + * Dynamic CSS compiler for WordPress |
|
6 | + * |
|
7 | + * @package wp-dynamic-css |
|
8 | + * @author Askupa Software <[email protected]> |
|
9 | + * @link https://github.com/askupasoftware/wp-dynamic-css |
|
10 | + * @copyright 2016 Askupa Software |
|
11 | + * |
|
12 | + * @wordpress-plugin |
|
13 | + * Plugin Name: WordPress Dynamic CSS |
|
14 | + * Plugin URI: https://github.com/askupasoftware/wp-dynamic-css |
|
15 | + * Description: Dynamic CSS compiler for WordPress |
|
16 | + * Version: 1.0.2 |
|
17 | + * Author: Askupa Software |
|
18 | + * Author URI: http://www.askupasoftware.com |
|
19 | + * Text Domain: wp-dynamic-css |
|
20 | + * Domain Path: /languages |
|
21 | + */ |
|
22 | 22 | |
23 | 23 | defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
24 | 24 |
@@ -1,11 +1,11 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * @package WordPress Dynamic CSS |
|
4 | - * @version 1.0.2 |
|
5 | - * @author Askupa Software <[email protected]> |
|
6 | - * @link https://github.com/askupasoftware/wp-dynamic-css |
|
7 | - * @copyright 2016 Askupa Software |
|
8 | - */ |
|
3 | + * @package WordPress Dynamic CSS |
|
4 | + * @version 1.0.2 |
|
5 | + * @author Askupa Software <[email protected]> |
|
6 | + * @link https://github.com/askupasoftware/wp-dynamic-css |
|
7 | + * @copyright 2016 Askupa Software |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | if( !function_exists('wp_dynamic_css_enqueue') ) |
11 | 11 | { |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @copyright 2016 Askupa Software |
8 | 8 | */ |
9 | 9 | |
10 | -if( !function_exists('wp_dynamic_css_enqueue') ) |
|
10 | +if (!function_exists('wp_dynamic_css_enqueue')) |
|
11 | 11 | { |
12 | 12 | /** |
13 | 13 | * Enqueue a dynamic stylesheet |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * @paran boolean $print Whether to print the compiled CSS to the document |
22 | 22 | * head, or include it as an external CSS file |
23 | 23 | */ |
24 | - function wp_dynamic_css_enqueue( $handle, $path, $print = true ) |
|
24 | + function wp_dynamic_css_enqueue($handle, $path, $print = true) |
|
25 | 25 | { |
26 | 26 | $dcss = DynamicCSSCompiler::get_instance(); |
27 | - $dcss->enqueue_style( $handle, $path, $print ); |
|
27 | + $dcss->enqueue_style($handle, $path, $print); |
|
28 | 28 | } |
29 | 29 | } |
30 | 30 | |
31 | -if( !function_exists('wp_dynamic_css_set_callback') ) |
|
31 | +if (!function_exists('wp_dynamic_css_set_callback')) |
|
32 | 32 | { |
33 | 33 | /** |
34 | 34 | * Set the value retrieval callback function |
@@ -43,9 +43,9 @@ discard block |
||
43 | 43 | * can either be a reference to a function name or method within an |
44 | 44 | * class/object. |
45 | 45 | */ |
46 | - function wp_dynamic_css_set_callback( $handle, $callback ) |
|
46 | + function wp_dynamic_css_set_callback($handle, $callback) |
|
47 | 47 | { |
48 | 48 | $dcss = DynamicCSSCompiler::get_instance(); |
49 | - $dcss->register_callback( $handle, $callback ); |
|
49 | + $dcss->register_callback($handle, $callback); |
|
50 | 50 | } |
51 | 51 | } |