PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / trunk
JetFormBuilder — Dynamic Blocks Form Builder vtrunk
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / modules / framework / blocks-style-manager / style-cache.php
jetformbuilder / modules / framework / blocks-style-manager Last commit date
assets 2 months ago field-handlers 2 months ago migrator 2 months ago block.php 2 months ago editor.php 2 months ago path-url-trait.php 2 months ago proxy.php 2 months ago registry.php 2 months ago style-cache.php 2 months ago style-engine.php 2 months ago style-inserter.php 2 months ago style-manager.php 2 months ago webpack.config.js 2 months ago
style-cache.php
100 lines
1 <?php
2 /**
3 * CSS caching class
4 */
5 namespace Crocoblock\Blocks_Style;
6
7 class Style_Cache {
8
9 /**
10 * Class instance
11 *
12 * @var Style_Cache
13 */
14 private static $instance = null;
15
16 /**
17 * Cached styles by classes
18 *
19 * @var array
20 */
21 protected $generated_css = array();
22
23 /**
24 * List of already printed CSS classes
25 *
26 * @var array
27 */
28 protected $printed_css = array();
29
30 /**
31 * Check if the class is already printed
32 *
33 * @param string $class_name
34 * @return boolean
35 */
36 public function is_printed( $class_name ) {
37
38 if ( ! is_string( $class_name ) || empty( $class_name ) ) {
39 return false;
40 }
41
42 return in_array( $class_name, $this->printed_css, true );
43 }
44
45 /**
46 * Get cached or generated styles.
47 *
48 * @param Style_Engine $style_engine
49 * @return void
50 */
51 public function get_cached( $style_engine ) {
52
53 if ( ! $style_engine instanceof Style_Engine ) {
54 return array();
55 }
56
57 $class_name = $style_engine->get_class_name();
58
59 if ( isset( $this->generated_css[ $class_name ] ) ) {
60 return $this->generated_css[ $class_name ];
61 }
62
63 $styles_data = $style_engine->get_styles();
64
65 if ( ! empty( $styles_data ) ) {
66 $this->generated_css[ $class_name ] = $styles_data;
67 }
68
69 return $styles_data;
70 }
71
72 /**
73 * Add a class to the printed CSS classes list
74 *
75 * @param string $class_name
76 */
77 public function add_printed( $class_name ) {
78
79 if ( ! is_string( $class_name ) || empty( $class_name ) ) {
80 return;
81 }
82 if ( ! in_array( $class_name, $this->printed_css, true ) ) {
83 $this->printed_css[] = $class_name;
84 }
85 }
86
87 /**
88 * Get the instance of the Style_Cache class
89 *
90 * @return Style_Cache
91 */
92 public static function get_instance() {
93
94 if ( null === self::$instance ) {
95 self::$instance = new self();
96 }
97
98 return self::$instance;
99 }
100 }