1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @package WordPress Dynamic CSS |
4
|
|
|
* @version 1.0.4 |
5
|
|
|
* @author Askupa Software <[email protected]> |
6
|
|
|
* @link https://github.com/askupasoftware/wp-dynamic-css |
7
|
|
|
* @copyright 2016 Askupa Software |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
if( !function_exists('wp_dynamic_css_enqueue') ) |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Enqueue a dynamic stylesheet |
14
|
|
|
* |
15
|
|
|
* This will either print the compiled version of the stylesheet to the |
16
|
|
|
* document's <head> section, or load it as an external stylesheet if $print |
17
|
|
|
* is set to false |
18
|
|
|
* |
19
|
|
|
* @param string $handle The stylesheet's name/id |
20
|
|
|
* @param string $path The absolute path to the dynamic CSS file |
21
|
|
|
* @paran boolean $print Whether to print the compiled CSS to the document |
22
|
|
|
* head, or include it as an external CSS file |
23
|
|
|
* @param boolean $minify Whether to minify the CSS output |
24
|
|
|
*/ |
25
|
|
|
function wp_dynamic_css_enqueue( $handle, $path, $print = true, $minify = false ) |
26
|
|
|
{ |
27
|
|
|
$dcss = DynamicCSSCompiler::get_instance(); |
28
|
|
|
$dcss->enqueue_style( $handle, $path, $print, $minify ); |
29
|
|
|
} |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
if( !function_exists('wp_dynamic_css_set_callback') ) |
33
|
|
|
{ |
34
|
|
|
/** |
35
|
|
|
* Set the value retrieval callback function |
36
|
|
|
* |
37
|
|
|
* Set a callback function that will be used to get the values of the |
38
|
|
|
* variables when the dynamic CSS file is compiled. The function accepts 1 |
39
|
|
|
* parameter which is the name of the variable, without the $ sign |
40
|
|
|
* |
41
|
|
|
* @param string $handle The name of the stylesheet to be associated with this |
42
|
|
|
* callback function |
43
|
|
|
* @param string|array $callback A callback (or "callable" as of PHP 5.4) |
44
|
|
|
* can either be a reference to a function name or method within an |
45
|
|
|
* class/object. |
46
|
|
|
*/ |
47
|
|
|
function wp_dynamic_css_set_callback( $handle, $callback ) |
48
|
|
|
{ |
49
|
|
|
$dcss = DynamicCSSCompiler::get_instance(); |
50
|
|
|
$dcss->register_callback( $handle, $callback ); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|