| @@ -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 | 
| @@ -20,14 +20,14 @@ discard block | ||
| 20 | 20 | * @paran boolean $print Whether to print the compiled CSS to the document | 
| 21 | 21 | * head, or include it as an external CSS file | 
| 22 | 22 | */ | 
| 23 | - function wp_dynamic_css_enqueue( $path, $print = true ) | |
| 23 | + function wp_dynamic_css_enqueue($path, $print = true) | |
| 24 | 24 |      { | 
| 25 | 25 | $dcss = DynamicCSSCompiler::get_instance(); | 
| 26 | - $dcss->enqueue_style( $path, $print ); | |
| 26 | + $dcss->enqueue_style($path, $print); | |
| 27 | 27 | } | 
| 28 | 28 | } | 
| 29 | 29 | |
| 30 | -if( !function_exists('wp_dynamic_css_set_callback') ) | |
| 30 | +if (!function_exists('wp_dynamic_css_set_callback')) | |
| 31 | 31 |  { | 
| 32 | 32 | /** | 
| 33 | 33 | * Set the value retrieval callback function | 
| @@ -40,8 +40,8 @@ discard block | ||
| 40 | 40 | * can either be a reference to a function name or method within an | 
| 41 | 41 | * class/object. | 
| 42 | 42 | */ | 
| 43 | - function wp_dynamic_css_set_callback( $callback ) | |
| 43 | + function wp_dynamic_css_set_callback($callback) | |
| 44 | 44 |      { | 
| 45 | - add_filter( 'wp_dynamic_css_get_variable_value', $callback ); | |
| 45 | +        add_filter('wp_dynamic_css_get_variable_value', $callback); | |
| 46 | 46 | } | 
| 47 | 47 | } | 
| 48 | 48 | \ No newline at end of file | 
| @@ -1,11 +1,11 @@ | ||
| 1 | 1 | <?php | 
| 2 | 2 | /** | 
| 3 | - * @package WordPress Dynamic CSS | |
| 4 | - * @version 1.0.1 | |
| 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.1 | |
| 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 | /** | 
| 11 | 11 | * Dynamic CSS Compiler Utility Class | 
| @@ -55,9 +55,9 @@ discard block | ||
| 55 | 55 |      { | 
| 56 | 56 | // Only enqueue if there is at least one dynamic stylesheet that is | 
| 57 | 57 | // set to be loaded externally | 
| 58 | - if( 0 < count( array_filter($this->stylesheets, array( $this, 'filter_external' ) ) ) ) | |
| 58 | + if (0 < count(array_filter($this->stylesheets, array($this, 'filter_external')))) | |
| 59 | 59 |          { | 
| 60 | - wp_enqueue_style( 'wp-dynamic-css', admin_url( 'admin-ajax.php?action=wp_dynamic_css' ) ); | |
| 60 | +            wp_enqueue_style('wp-dynamic-css', admin_url('admin-ajax.php?action=wp_dynamic_css')); | |
| 61 | 61 | } | 
| 62 | 62 | } | 
| 63 | 63 | |
| @@ -68,16 +68,16 @@ discard block | ||
| 68 | 68 | public function compile_printed_styles() | 
| 69 | 69 |      { | 
| 70 | 70 | $precompiled_css = ''; | 
| 71 | - $styles = array_filter($this->stylesheets, array( $this, 'filter_print' ) ); | |
| 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) return; | |
| 75 | 75 | |
| 76 | - foreach( $styles as $style ) | |
| 76 | + foreach ($styles as $style) | |
| 77 | 77 |          { | 
| 78 | - $precompiled_css .= $this->get_file_contents( $style['path'] )."\n"; | |
| 78 | + $precompiled_css .= $this->get_file_contents($style['path']) . "\n"; | |
| 79 | 79 | } | 
| 80 | - $css = $this->compile_css( $precompiled_css ); | |
| 80 | + $css = $this->compile_css($precompiled_css); | |
| 81 | 81 | echo "<style id=\"wp-dynamic-css\">\n"; | 
| 82 | 82 | include 'style.phtml'; | 
| 83 | 83 | echo "</style>"; | 
| @@ -89,15 +89,15 @@ discard block | ||
| 89 | 89 | */ | 
| 90 | 90 | public function compile_external_styles() | 
| 91 | 91 |      { | 
| 92 | - header( "Content-type: text/css; charset: UTF-8" ); | |
| 92 | +        header("Content-type: text/css; charset: UTF-8"); | |
| 93 | 93 | $precompiled_css = ''; | 
| 94 | - $styles = array_filter($this->stylesheets, array( $this, 'filter_external' ) ); | |
| 94 | + $styles = array_filter($this->stylesheets, array($this, 'filter_external')); | |
| 95 | 95 | |
| 96 | - foreach( $styles as $style ) | |
| 96 | + foreach ($styles as $style) | |
| 97 | 97 |          { | 
| 98 | - $precompiled_css .= $this->get_file_contents( $style['path'] )."\n"; | |
| 98 | + $precompiled_css .= $this->get_file_contents($style['path']) . "\n"; | |
| 99 | 99 | } | 
| 100 | - $css = $this->compile_css( $precompiled_css ); | |
| 100 | + $css = $this->compile_css($precompiled_css); | |
| 101 | 101 | include 'style.phtml'; | 
| 102 | 102 | wp_die(); | 
| 103 | 103 | } | 
| @@ -109,7 +109,7 @@ discard block | ||
| 109 | 109 | * @param boolean $print Whether to print the compiled CSS to the document | 
| 110 | 110 | * head, or include it as an external CSS file | 
| 111 | 111 | */ | 
| 112 | - public function enqueue_style( $path, $print ) | |
| 112 | + public function enqueue_style($path, $print) | |
| 113 | 113 |      { | 
| 114 | 114 | $this->stylesheets[] = array( | 
| 115 | 115 | 'path' => $path, | 
| @@ -124,7 +124,7 @@ discard block | ||
| 124 | 124 | * @param array $style | 
| 125 | 125 | * @return boolean | 
| 126 | 126 | */ | 
| 127 | - protected function filter_print( $style ) | |
| 127 | + protected function filter_print($style) | |
| 128 | 128 |      { | 
| 129 | 129 | return true === $style['print']; | 
| 130 | 130 | } | 
| @@ -136,7 +136,7 @@ discard block | ||
| 136 | 136 | * @param array $style | 
| 137 | 137 | * @return boolean | 
| 138 | 138 | */ | 
| 139 | - protected function filter_external( $style ) | |
| 139 | + protected function filter_external($style) | |
| 140 | 140 |      { | 
| 141 | 141 | return true !== $style['print']; | 
| 142 | 142 | } | 
| @@ -147,7 +147,7 @@ discard block | ||
| 147 | 147 | * @param string $path The absolute path to the file | 
| 148 | 148 | * @return string The file contents | 
| 149 | 149 | */ | 
| 150 | - protected function get_file_contents( $path ) | |
| 150 | + protected function get_file_contents($path) | |
| 151 | 151 |      { | 
| 152 | 152 | ob_start(); | 
| 153 | 153 | include $path; | 
| @@ -165,10 +165,10 @@ discard block | ||
| 165 | 165 | * @return string The compiled CSS after converting the variables to their | 
| 166 | 166 | * corresponding values | 
| 167 | 167 | */ | 
| 168 | - protected function compile_css( $css ) | |
| 168 | + protected function compile_css($css) | |
| 169 | 169 |      {    | 
| 170 | -        return preg_replace_callback( '#\$([\w]+)#', function( $matches ) { | |
| 171 | - return apply_filters( 'wp_dynamic_css_get_variable_value', $matches[1] ); | |
| 170 | +        return preg_replace_callback('#\$([\w]+)#', function($matches) { | |
| 171 | +            return apply_filters('wp_dynamic_css_get_variable_value', $matches[1]); | |
| 172 | 172 | }, $css); | 
| 173 | 173 | } | 
| 174 | 174 | } | 
| @@ -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 |          { | 
| @@ -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.1 | |
| 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.1 | |
| 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 | require_once 'compiler.php'; | 
| 24 | 24 | require_once 'functions.php'; | 
| @@ -28,7 +28,7 @@ | ||
| 28 | 28 | * stylesheets externally. | 
| 29 | 29 | */ | 
| 30 | 30 | $dcss = DynamicCSSCompiler::get_instance(); | 
| 31 | -add_action( 'wp_print_styles', array( $dcss, 'compile_printed_styles' ) ); | |
| 32 | -add_action( 'wp_enqueue_scripts', array( $dcss, 'wp_enqueue_style' ) ); | |
| 33 | -add_action( 'wp_ajax_wp_dynamic_css', array( $dcss, 'compile_external_styles' ) ); | |
| 34 | -add_action( 'wp_ajax_nopriv_wp_dynamic_css', array( $dcss, 'compile_external_styles' ) ); | |
| 35 | 31 | \ No newline at end of file | 
| 32 | +add_action('wp_print_styles', array($dcss, 'compile_printed_styles')); | |
| 33 | +add_action('wp_enqueue_scripts', array($dcss, 'wp_enqueue_style')); | |
| 34 | +add_action('wp_ajax_wp_dynamic_css', array($dcss, 'compile_external_styles')); | |
| 35 | +add_action('wp_ajax_nopriv_wp_dynamic_css', array($dcss, 'compile_external_styles')); | |
| 36 | 36 | \ No newline at end of file |