1 | <?php |
||
24 | class DynamicCSSCompiler |
||
|
|||
25 | { |
||
26 | /** |
||
27 | * @var Singleton The reference to *Singleton* instance of this class |
||
28 | */ |
||
29 | private static $instance; |
||
30 | |||
31 | /** |
||
32 | * @var array The list of dynamic styles paths to compile |
||
33 | */ |
||
34 | private $stylesheets = array(); |
||
35 | |||
36 | /** |
||
37 | * Returns the *Singleton* instance of this class. |
||
38 | * |
||
39 | * @return Singleton The *Singleton* instance. |
||
40 | */ |
||
41 | public static function get_instance() |
||
49 | |||
50 | /** |
||
51 | * Enqueue the PHP script used for compiling dynamic stylesheets that are |
||
52 | * loaded externally |
||
53 | */ |
||
54 | public function wp_enqueue_style() |
||
63 | |||
64 | /** |
||
65 | * Parse all styles in $this->stylesheets and print them if the flag 'print' |
||
66 | * is set to true. Used for printing styles to the document head. |
||
67 | */ |
||
68 | public function compile_printed_styles() |
||
85 | |||
86 | /** |
||
87 | * Parse all styles in $this->stylesheets and print them if the flag 'print' |
||
88 | * is not set to true. Used for loading styles externally via an http request. |
||
89 | */ |
||
90 | public function compile_external_styles() |
||
104 | |||
105 | /** |
||
106 | * Add a style path to the pool of styles to be compiled |
||
107 | * |
||
108 | * @param string $path The absolute path to the dynamic style |
||
109 | * @param boolean $print Whether to print the compiled CSS to the document |
||
110 | * head, or include it as an external CSS file |
||
111 | */ |
||
112 | public function enqueue_style( $path, $print ) |
||
119 | |||
120 | /** |
||
121 | * This filter is used to return only the styles that are set to be printed |
||
122 | * in the document head |
||
123 | * |
||
124 | * @param array $style |
||
125 | * @return boolean |
||
126 | */ |
||
127 | protected function filter_print( $style ) |
||
131 | |||
132 | /** |
||
133 | * This filter is used to return only the styles that are set to be loaded |
||
134 | * externally |
||
135 | * |
||
136 | * @param array $style |
||
137 | * @return boolean |
||
138 | */ |
||
139 | protected function filter_external( $style ) |
||
143 | |||
144 | /** |
||
145 | * Get the contents of a given file |
||
146 | * |
||
147 | * @param string $path The absolute path to the file |
||
148 | * @return string The file contents |
||
149 | */ |
||
150 | protected function get_file_contents( $path ) |
||
156 | |||
157 | /** |
||
158 | * Parse the given CSS string by converting the variables to their |
||
159 | * corresponding values retrieved by applying the filter |
||
160 | * wp_dynamic_css_get_variable_value. |
||
161 | * |
||
162 | * @param string $css A string containing dynamic CSS (pre-compiled CSS with |
||
163 | * variables) |
||
164 | * @uses wp_dynamic_css_get_variable_value filter |
||
165 | * @return string The compiled CSS after converting the variables to their |
||
166 | * corresponding values |
||
167 | */ |
||
168 | protected function compile_css( $css ) |
||
174 | } |
||
175 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.