@@ -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 | /** |
@@ -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 |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | * styles. |
| 44 | 44 | */ |
| 45 | 45 | $dcss = DynamicCSSCompiler::get_instance(); |
| 46 | -add_action( 'wp_print_styles', array( $dcss, 'print_styles' ), 100 ); |
|
| 47 | -add_action( 'wp_enqueue_scripts', array( $dcss, 'enqueue_styles' ), 100 ); |
|
| 48 | -add_action( 'wp_ajax_wp_dynamic_css', array( $dcss, 'ajax_callback' ) ); |
|
| 49 | -add_action( 'wp_ajax_nopriv_wp_dynamic_css', array( $dcss, 'ajax_callback' ) ); |
|
| 50 | 46 | \ No newline at end of file |
| 47 | +add_action('wp_print_styles', array($dcss, 'print_styles'), 100); |
|
| 48 | +add_action('wp_enqueue_scripts', array($dcss, 'enqueue_styles'), 100); |
|
| 49 | +add_action('wp_ajax_wp_dynamic_css', array($dcss, 'ajax_callback')); |
|
| 50 | +add_action('wp_ajax_nopriv_wp_dynamic_css', array($dcss, 'ajax_callback')); |
|
| 51 | 51 | \ No newline at end of file |
@@ -44,9 +44,9 @@ discard block |
||
| 44 | 44 | * @param string $handle The handle of the stylesheet |
| 45 | 45 | * @return boolean|string |
| 46 | 46 | */ |
| 47 | - public function get( $handle ) |
|
| 47 | + public function get($handle) |
|
| 48 | 48 | { |
| 49 | - if( array_key_exists( $handle, self::$cache ) ) |
|
| 49 | + if (array_key_exists($handle, self::$cache)) |
|
| 50 | 50 | { |
| 51 | 51 | return self::$cache[$handle]; |
| 52 | 52 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @param string $handle The handle of the stylesheet |
| 60 | 60 | * @param type $compiled_css |
| 61 | 61 | */ |
| 62 | - public function update( $handle, $compiled_css ) |
|
| 62 | + public function update($handle, $compiled_css) |
|
| 63 | 63 | { |
| 64 | 64 | self::$cache[$handle] = $compiled_css; |
| 65 | 65 | $this->update_option(); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * |
| 71 | 71 | * @param string $handle The handle of the stylesheet |
| 72 | 72 | */ |
| 73 | - public function clear( $handle ) |
|
| 73 | + public function clear($handle) |
|
| 74 | 74 | { |
| 75 | 75 | unset(self::$cache[$handle]); |
| 76 | 76 | $this->update_option(); |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | { |
| 85 | 85 | self::$cache = get_option('wp-dynamic-css-cache'); |
| 86 | 86 | |
| 87 | - if( false === self::$cache ) |
|
| 87 | + if (false === self::$cache) |
|
| 88 | 88 | { |
| 89 | 89 | self::$cache = array(); |
| 90 | 90 | } |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | * Update the compiled CSS for the given handle. |
| 58 | 58 | * |
| 59 | 59 | * @param string $handle The handle of the stylesheet |
| 60 | - * @param type $compiled_css |
|
| 60 | + * @param string $compiled_css |
|
| 61 | 61 | */ |
| 62 | 62 | public function update( $handle, $compiled_css ) |
| 63 | 63 | { |
@@ -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 |
@@ -24,14 +24,14 @@ discard block |
||
| 24 | 24 | * @param boolean $cache Whether to store the compiled version of this |
| 25 | 25 | * stylesheet in cache to avoid compilation on every page load. |
| 26 | 26 | */ |
| 27 | - function wp_dynamic_css_enqueue( $handle, $path, $print = true, $minify = false, $cache = false ) |
|
| 27 | + function wp_dynamic_css_enqueue($handle, $path, $print = true, $minify = false, $cache = false) |
|
| 28 | 28 | { |
| 29 | 29 | $dcss = DynamicCSSCompiler::get_instance(); |
| 30 | - $dcss->enqueue_style( $handle, $path, $print, $minify, $cache ); |
|
| 30 | + $dcss->enqueue_style($handle, $path, $print, $minify, $cache); |
|
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | -if( !function_exists('wp_dynamic_css_set_callback') ) |
|
| 34 | +if (!function_exists('wp_dynamic_css_set_callback')) |
|
| 35 | 35 | { |
| 36 | 36 | /** |
| 37 | 37 | * Set the value retrieval callback function |
@@ -46,14 +46,14 @@ discard block |
||
| 46 | 46 | * can either be a reference to a function name or method within an |
| 47 | 47 | * class/object. |
| 48 | 48 | */ |
| 49 | - function wp_dynamic_css_set_callback( $handle, $callback ) |
|
| 49 | + function wp_dynamic_css_set_callback($handle, $callback) |
|
| 50 | 50 | { |
| 51 | 51 | $dcss = DynamicCSSCompiler::get_instance(); |
| 52 | - $dcss->register_callback( $handle, $callback ); |
|
| 52 | + $dcss->register_callback($handle, $callback); |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | -if( !function_exists('wp_dynamic_css_clear_cache') ) |
|
| 56 | +if (!function_exists('wp_dynamic_css_clear_cache')) |
|
| 57 | 57 | { |
| 58 | 58 | /** |
| 59 | 59 | * Clear the cached compiled CSS for the given handle. |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | * |
| 66 | 66 | * @param string $handle The name of the stylesheet to be cleared from cache |
| 67 | 67 | */ |
| 68 | - function wp_dynamic_css_clear_cache( $handle ) |
|
| 68 | + function wp_dynamic_css_clear_cache($handle) |
|
| 69 | 69 | { |
| 70 | 70 | $cache = DynamicCSSCache::get_instance(); |
| 71 | - $cache->clear( $handle ); |
|
| 71 | + $cache->clear($handle); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | -if( !function_exists('wp_dynamic_css_register_filter') ) |
|
| 75 | +if (!function_exists('wp_dynamic_css_register_filter')) |
|
| 76 | 76 | { |
| 77 | 77 | /** |
| 78 | 78 | * Register a filter function for a given stylesheet handle. |
@@ -109,9 +109,9 @@ discard block |
||
| 109 | 109 | * @param Callable $callback The actual filter function. Accepts the $value |
| 110 | 110 | * as an argument. Should return the filtered value. |
| 111 | 111 | */ |
| 112 | - function wp_dynamic_css_register_filter( $handle, $filter_name, $callback ) |
|
| 112 | + function wp_dynamic_css_register_filter($handle, $filter_name, $callback) |
|
| 113 | 113 | { |
| 114 | 114 | $dcss = DynamicCSSCompiler::get_instance(); |
| 115 | - $dcss->register_filter( $handle, $filter_name, $callback ); |
|
| 115 | + $dcss->register_filter($handle, $filter_name, $callback); |
|
| 116 | 116 | } |
| 117 | 117 | } |
@@ -184,7 +184,9 @@ discard block |
||
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | $css = file_get_contents( $style['path'] ); |
| 187 | - if( $style['minify'] ) $css = $this->minify_css( $css ); |
|
| 187 | + if( $style['minify'] ) { |
|
| 188 | + $css = $this->minify_css( $css ); |
|
| 189 | + } |
|
| 188 | 190 | |
| 189 | 191 | // Compile the dynamic CSS |
| 190 | 192 | $compiled_css = $this->compile_css( |
@@ -310,9 +312,17 @@ discard block |
||
| 310 | 312 | */ |
| 311 | 313 | protected function strtoval( &$str ) |
| 312 | 314 | { |
| 313 | - if( 'false' === strtolower($str) ) $str = false; |
|
| 314 | - if( 'true' === strtolower($str) ) $str = true; |
|
| 315 | - if( false !== strrpos( $str, "'" ) ) $str = str_replace ( "'", "", $str ); |
|
| 316 | - if( is_numeric( $str ) ) $str = floatval( $str ); |
|
| 315 | + if( 'false' === strtolower($str) ) { |
|
| 316 | + $str = false; |
|
| 317 | + } |
|
| 318 | + if( 'true' === strtolower($str) ) { |
|
| 319 | + $str = true; |
|
| 320 | + } |
|
| 321 | + if( false !== strrpos( $str, "'" ) ) { |
|
| 322 | + $str = str_replace ( "'", "", $str ); |
|
| 323 | + } |
|
| 324 | + if( is_numeric( $str ) ) { |
|
| 325 | + $str = floatval( $str ); |
|
| 326 | + } |
|
| 317 | 327 | } |
| 318 | 328 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | /** |
| 142 | 142 | * Register a value retrieval function and associate it with the given handle |
| 143 | 143 | * |
| 144 | - * @param type $handle The stylesheet's name/id |
|
| 144 | + * @param string $handle The stylesheet's name/id |
|
| 145 | 145 | * @param type $callback |
| 146 | 146 | */ |
| 147 | 147 | public function register_callback( $handle, $callback ) |
@@ -151,6 +151,9 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | /** |
| 153 | 153 | * Register a filter function for a given stylesheet handle. |
| 154 | + * @param string $handle |
|
| 155 | + * @param string $filter_name |
|
| 156 | + * @param callable $callback |
|
| 154 | 157 | */ |
| 155 | 158 | public function register_filter( $handle, $filter_name, $callback ) |
| 156 | 159 | { |
@@ -62,16 +62,16 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | public function enqueue_styles() |
| 64 | 64 | { |
| 65 | - foreach( $this->stylesheets as $stylesheet ) |
|
| 65 | + foreach ($this->stylesheets as $stylesheet) |
|
| 66 | 66 | { |
| 67 | - if( !$stylesheet['print'] && $this->callback_exists( $stylesheet['handle'] ) ) |
|
| 67 | + if (!$stylesheet['print'] && $this->callback_exists($stylesheet['handle'])) |
|
| 68 | 68 | { |
| 69 | 69 | wp_enqueue_style( |
| 70 | 70 | 'wp-dynamic-css-'.$stylesheet['handle'], |
| 71 | - esc_url_raw( add_query_arg(array( |
|
| 71 | + esc_url_raw(add_query_arg(array( |
|
| 72 | 72 | 'action' => 'wp_dynamic_css', |
| 73 | 73 | 'handle' => $stylesheet['handle'] |
| 74 | - ), admin_url( 'admin-ajax.php'))) |
|
| 74 | + ), admin_url('admin-ajax.php'))) |
|
| 75 | 75 | ); |
| 76 | 76 | } |
| 77 | 77 | } |
@@ -82,11 +82,11 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | public function print_styles() |
| 84 | 84 | { |
| 85 | - foreach( $this->stylesheets as $stylesheet ) |
|
| 85 | + foreach ($this->stylesheets as $stylesheet) |
|
| 86 | 86 | { |
| 87 | - if( $stylesheet['print'] && $this->callback_exists( $stylesheet['handle'] ) ) |
|
| 87 | + if ($stylesheet['print'] && $this->callback_exists($stylesheet['handle'])) |
|
| 88 | 88 | { |
| 89 | - $compiled_css = $this->get_compiled_style( $stylesheet ); |
|
| 89 | + $compiled_css = $this->get_compiled_style($stylesheet); |
|
| 90 | 90 | |
| 91 | 91 | echo "<style id=\"wp-dynamic-css-".$stylesheet['handle']."\">\n"; |
| 92 | 92 | include 'style.phtml'; |
@@ -101,14 +101,14 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function ajax_callback() |
| 103 | 103 | { |
| 104 | - header( "Content-type: text/css; charset: UTF-8" ); |
|
| 105 | - $handle = filter_input( INPUT_GET, 'handle' ); |
|
| 104 | + header("Content-type: text/css; charset: UTF-8"); |
|
| 105 | + $handle = filter_input(INPUT_GET, 'handle'); |
|
| 106 | 106 | |
| 107 | - foreach( $this->stylesheets as $stylesheet ) |
|
| 107 | + foreach ($this->stylesheets as $stylesheet) |
|
| 108 | 108 | { |
| 109 | - if( $handle === $stylesheet['handle'] ) |
|
| 109 | + if ($handle === $stylesheet['handle']) |
|
| 110 | 110 | { |
| 111 | - $compiled_css = $this->get_compiled_style( $stylesheet ); |
|
| 111 | + $compiled_css = $this->get_compiled_style($stylesheet); |
|
| 112 | 112 | include 'style.phtml'; |
| 113 | 113 | } |
| 114 | 114 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @param boolean $cache Whether to store the compiled version of this |
| 128 | 128 | * stylesheet in cache to avoid compilation on every page load. |
| 129 | 129 | */ |
| 130 | - public function enqueue_style( $handle, $path, $print, $minify, $cache ) |
|
| 130 | + public function enqueue_style($handle, $path, $print, $minify, $cache) |
|
| 131 | 131 | { |
| 132 | 132 | $this->stylesheets[] = array( |
| 133 | 133 | 'handle'=> $handle, |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | * @param type $handle The stylesheet's name/id |
| 145 | 145 | * @param type $callback |
| 146 | 146 | */ |
| 147 | - public function register_callback( $handle, $callback ) |
|
| 147 | + public function register_callback($handle, $callback) |
|
| 148 | 148 | { |
| 149 | 149 | $this->callbacks[$handle] = $callback; |
| 150 | 150 | } |
@@ -152,9 +152,9 @@ discard block |
||
| 152 | 152 | /** |
| 153 | 153 | * Register a filter function for a given stylesheet handle. |
| 154 | 154 | */ |
| 155 | - public function register_filter( $handle, $filter_name, $callback ) |
|
| 155 | + public function register_filter($handle, $filter_name, $callback) |
|
| 156 | 156 | { |
| 157 | - if( !array_key_exists( $handle, $this->filters ) ) |
|
| 157 | + if (!array_key_exists($handle, $this->filters)) |
|
| 158 | 158 | { |
| 159 | 159 | $this->filters[$handle] = array(); |
| 160 | 160 | } |
@@ -169,31 +169,31 @@ discard block |
||
| 169 | 169 | * stored in $this->stylesheets |
| 170 | 170 | * @return string The compiled CSS for this stylesheet |
| 171 | 171 | */ |
| 172 | - protected function get_compiled_style( $style ) |
|
| 172 | + protected function get_compiled_style($style) |
|
| 173 | 173 | { |
| 174 | 174 | $cache = DynamicCSSCache::get_instance(); |
| 175 | 175 | |
| 176 | 176 | // Use cached compiled CSS if applicable |
| 177 | - if( $style['cache'] ) |
|
| 177 | + if ($style['cache']) |
|
| 178 | 178 | { |
| 179 | - $cached_css = $cache->get( $style['handle'] ); |
|
| 180 | - if( false !== $cached_css ) |
|
| 179 | + $cached_css = $cache->get($style['handle']); |
|
| 180 | + if (false !== $cached_css) |
|
| 181 | 181 | { |
| 182 | 182 | return $cached_css; |
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - $css = file_get_contents( $style['path'] ); |
|
| 187 | - if( $style['minify'] ) $css = $this->minify_css( $css ); |
|
| 186 | + $css = file_get_contents($style['path']); |
|
| 187 | + if ($style['minify']) $css = $this->minify_css($css); |
|
| 188 | 188 | |
| 189 | 189 | // Compile the dynamic CSS |
| 190 | 190 | $compiled_css = $this->compile_css( |
| 191 | 191 | $css, |
| 192 | 192 | $this->callbacks[$style['handle']], |
| 193 | - key_exists( $style['handle'], $this->filters ) ? $this->filters[$style['handle']] : array() |
|
| 193 | + key_exists($style['handle'], $this->filters) ? $this->filters[$style['handle']] : array() |
|
| 194 | 194 | ); |
| 195 | 195 | |
| 196 | - $cache->update( $style['handle'], $compiled_css ); |
|
| 196 | + $cache->update($style['handle'], $compiled_css); |
|
| 197 | 197 | return $compiled_css; |
| 198 | 198 | } |
| 199 | 199 | |
@@ -204,9 +204,9 @@ discard block |
||
| 204 | 204 | * @param string $css CSS style to minify |
| 205 | 205 | * @return string Minified CSS |
| 206 | 206 | */ |
| 207 | - protected function minify_css( $css ) |
|
| 207 | + protected function minify_css($css) |
|
| 208 | 208 | { |
| 209 | - return preg_replace( '@({)\s+|(\;)\s+|/\*.+?\*\/|\R@is', '$1$2 ', $css ); |
|
| 209 | + return preg_replace('@({)\s+|(\;)\s+|/\*.+?\*\/|\R@is', '$1$2 ', $css); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -215,9 +215,9 @@ discard block |
||
| 215 | 215 | * @param string $handle |
| 216 | 216 | * @return boolean |
| 217 | 217 | */ |
| 218 | - protected function callback_exists( $handle ) |
|
| 218 | + protected function callback_exists($handle) |
|
| 219 | 219 | { |
| 220 | - if( array_key_exists( $handle, $this->callbacks ) ) |
|
| 220 | + if (array_key_exists($handle, $this->callbacks)) |
|
| 221 | 221 | { |
| 222 | 222 | return true; |
| 223 | 223 | } |
@@ -239,36 +239,36 @@ discard block |
||
| 239 | 239 | * @return string The compiled CSS after converting the variables to their |
| 240 | 240 | * corresponding values |
| 241 | 241 | */ |
| 242 | - protected function compile_css( $css, $callback, $filters ) |
|
| 242 | + protected function compile_css($css, $callback, $filters) |
|
| 243 | 243 | { |
| 244 | 244 | return preg_replace_callback( |
| 245 | 245 | |
| 246 | - "#". // Begin |
|
| 247 | - "\\$". // Must start with $ |
|
| 248 | - "([\\w-]+)". // Match alphanumeric characters and dashes |
|
| 249 | - "((?:\\['?[\\w-]+'?\\])*)". // Optionally match array subscripts i.e. $myVar['index'] |
|
| 250 | - "((?:". // Optionally match pipe filters i.e. $myVar|myFilter |
|
| 251 | - "\\|[\\w-]+". // Starting with the | character |
|
| 252 | - "(\([\w\.,']+\))?". // Filters can have strings and numbers i.e myFilter('string',1,2.5) |
|
| 253 | - ")*)". // Allow for 0 or more piped filters |
|
| 254 | - "#", // End |
|
| 246 | + "#".// Begin |
|
| 247 | + "\\$".// Must start with $ |
|
| 248 | + "([\\w-]+)".// Match alphanumeric characters and dashes |
|
| 249 | + "((?:\\['?[\\w-]+'?\\])*)".// Optionally match array subscripts i.e. $myVar['index'] |
|
| 250 | + "((?:".// Optionally match pipe filters i.e. $myVar|myFilter |
|
| 251 | + "\\|[\\w-]+".// Starting with the | character |
|
| 252 | + "(\([\w\.,']+\))?".// Filters can have strings and numbers i.e myFilter('string',1,2.5) |
|
| 253 | + ")*)".// Allow for 0 or more piped filters |
|
| 254 | + "#", // End |
|
| 255 | 255 | |
| 256 | - function( $matches ) use ( $callback, $filters ) |
|
| 256 | + function($matches) use ($callback, $filters) |
|
| 257 | 257 | { |
| 258 | 258 | $subscripts = array(); |
| 259 | 259 | |
| 260 | 260 | // If this variable is an array, get the subscripts |
| 261 | - if( '' !== $matches[2] ) |
|
| 261 | + if ('' !== $matches[2]) |
|
| 262 | 262 | { |
| 263 | 263 | preg_match_all('/[\w-]+/i', $matches[2], $subscripts); |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - $val = call_user_func_array( $callback, array( $matches[1],@$subscripts[0] ) ); |
|
| 266 | + $val = call_user_func_array($callback, array($matches[1], @$subscripts[0])); |
|
| 267 | 267 | |
| 268 | 268 | // Apply custom filters |
| 269 | - if( '' !== $matches[3] ) |
|
| 269 | + if ('' !== $matches[3]) |
|
| 270 | 270 | { |
| 271 | - $val = $this->apply_filters( substr( $matches[3], 1 ), $val, $filters ); |
|
| 271 | + $val = $this->apply_filters(substr($matches[3], 1), $val, $filters); |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | return $val; |
@@ -284,24 +284,24 @@ discard block |
||
| 284 | 284 | * @param array $filters Array of callback functions |
| 285 | 285 | * @return string The value after all filters have been applied |
| 286 | 286 | */ |
| 287 | - protected function apply_filters( $filters_string, $value, $filters ) |
|
| 287 | + protected function apply_filters($filters_string, $value, $filters) |
|
| 288 | 288 | { |
| 289 | - foreach( explode( '|', $filters_string) as $filter ) |
|
| 289 | + foreach (explode('|', $filters_string) as $filter) |
|
| 290 | 290 | { |
| 291 | - $args = array( $value ); |
|
| 291 | + $args = array($value); |
|
| 292 | 292 | |
| 293 | - if( false !== strrpos( $filters_string, "(" ) ) |
|
| 293 | + if (false !== strrpos($filters_string, "(")) |
|
| 294 | 294 | { |
| 295 | - $pieces = explode( '(', $filter ); |
|
| 295 | + $pieces = explode('(', $filter); |
|
| 296 | 296 | $filter = $pieces[0]; |
| 297 | - $params = explode( ',', str_replace( ')', '', $pieces[1] ) ); |
|
| 298 | - array_walk( $params, array( $this, 'strtoval' ) ); // Convert string values to actual values |
|
| 299 | - $args = array_merge( $args, $params ); |
|
| 297 | + $params = explode(',', str_replace(')', '', $pieces[1])); |
|
| 298 | + array_walk($params, array($this, 'strtoval')); // Convert string values to actual values |
|
| 299 | + $args = array_merge($args, $params); |
|
| 300 | 300 | } |
| 301 | 301 | |
| 302 | - if( key_exists( $filter, $filters ) ) |
|
| 302 | + if (key_exists($filter, $filters)) |
|
| 303 | 303 | { |
| 304 | - $value = call_user_func_array( $filters[$filter], $args ); |
|
| 304 | + $value = call_user_func_array($filters[$filter], $args); |
|
| 305 | 305 | } |
| 306 | 306 | } |
| 307 | 307 | return $value; |
@@ -312,11 +312,11 @@ discard block |
||
| 312 | 312 | * |
| 313 | 313 | * @param string $str The string to be converted (passed by reference) |
| 314 | 314 | */ |
| 315 | - protected function strtoval( &$str ) |
|
| 315 | + protected function strtoval(&$str) |
|
| 316 | 316 | { |
| 317 | - if( 'false' === strtolower($str) ) $str = false; |
|
| 318 | - if( 'true' === strtolower($str) ) $str = true; |
|
| 319 | - if( false !== strrpos( $str, "'" ) ) $str = str_replace ( "'", "", $str ); |
|
| 320 | - if( is_numeric( $str ) ) $str = floatval( $str ); |
|
| 317 | + if ('false' === strtolower($str)) $str = false; |
|
| 318 | + if ('true' === strtolower($str)) $str = true; |
|
| 319 | + if (false !== strrpos($str, "'")) $str = str_replace("'", "", $str); |
|
| 320 | + if (is_numeric($str)) $str = floatval($str); |
|
| 321 | 321 | } |
| 322 | 322 | } |