PluginProbe
Event Post / 6.0.0
Event Post v6.0.0
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 6.0.0, at inc/class-icons.php

52 lines 1.6 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 6.0.0
7 * @since 5.4
8 */
9
10 namespace EventPost;
11
12 if ( ! defined( 'ABSPATH' ) ) exit;
13
14 class Icons{
15 public $icons;
16 public $icons_html_entities;
17 public $transient_name;
18 public $transient_name_html_entities;
19
20 function __construct(){
21 $this->icons = [];
22 $this->icons_html_entities = [];
23 $this->transient_name = "dashicons_list";
24 $this->transient_name_html_entities = "dashicons_list_html_entities";
25 add_action('init', array(&$this,'init_icons'));
26 }
27 function init_icons() {
28 if(get_transient($this->transient_name) && get_transient($this->transient_name_html_entities)){
29 $this->icons = get_transient($this->transient_name);
30 $this->icons_html_entities = get_transient($this->transient_name_html_entities);
31 }else{
32 $css_file = file_get_contents(ABSPATH. 'wp-includes/css/dashicons.css');
33 $css_array = explode('}',$css_file);
34 foreach ($css_array as $rule) {
35 $matches = [];
36 if(preg_match( "/\.dashicons-((?:\w+-?)+\w+):before {\s*content:\s*[\"\']\\\(\w+)[\"\'];/m",
37 $rule,
38 $matches))
39 {
40 if(isset($matches[1]) && isset($matches[2])){
41 $this->icons[$matches[1]] = $matches[2];
42 $this->icons_html_entities[$matches[1]] = '&#x'.$matches[2].'; '.$matches[1];
43 }
44 }
45 }
46 set_transient($this->transient_name , $this->icons, MONTH_IN_SECONDS );
47 set_transient($this->transient_name_html_entities , $this->icons_html_entities, MONTH_IN_SECONDS );
48 }
49 }
50
51 }
52