PluginProbe
Event Post / 5.10.4
Event Post v5.10.4
6.1.1 6.1.0 6.0.1 6.0.0 5.12.0 trunk 3.9 4.0 4.2 4.3 4.4 4.5 5.0 5.1 5.10.0 5.10.1 5.10.2 5.10.3 5.10.4 5.11.0 5.11.1 5.2 5.5 5.6 5.6.1 All 46 releases
event-post / inc / class-icons.php

class-icons.php in Event Post 5.10.4, at inc/class-icons.php

50 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Icons
4 *
5 * @package event-post
6 * @version 5.10.4
7 * @since 5.4
8 */
9
10 namespace EventPost;
11
12 class Icons{
13 public $icons;
14 public $icons_html_entities;
15 public $transient_name;
16 public $transient_name_html_entities;
17
18 function __construct(){
19 $this->icons = [];
20 $this->icons_html_entities = [];
21 $this->transient_name = "dashicons_list";
22 $this->transient_name_html_entities = "dashicons_list_html_entities";
23 add_action('init', array(&$this,'init_icons'));
24 }
25 function init_icons() {
26 if(get_transient($this->transient_name) && get_transient($this->transient_name_html_entities)){
27 $this->icons = get_transient($this->transient_name);
28 $this->icons_html_entities = get_transient($this->transient_name_html_entities);
29 }else{
30 $css_file = file_get_contents(ABSPATH. 'wp-includes/css/dashicons.css');
31 $css_array = explode('}',$css_file);
32 foreach ($css_array as $rule) {
33 $matches = [];
34 if(preg_match( "/\.dashicons-((?:\w+-?)+\w+):before {\s*content:\s*[\"\']\\\(\w+)[\"\'];/m",
35 $rule,
36 $matches))
37 {
38 if(isset($matches[1]) && isset($matches[2])){
39 $this->icons[$matches[1]] = $matches[2];
40 $this->icons_html_entities[$matches[1]] = '&#x'.$matches[2].'; '.$matches[1];
41 }
42 }
43 }
44 set_transient($this->transient_name , $this->icons, MONTH_IN_SECONDS );
45 set_transient($this->transient_name_html_entities , $this->icons_html_entities, MONTH_IN_SECONDS );
46 }
47 }
48
49 }
50