PluginProbe
WP Directory Kit / 1.4.8
WP Directory Kit v1.4.8
1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 1.4.0 1.4.1 All 35 releases
wpdirectorykit / application / helpers / Get_element_settings.php

Get_element_settings.php in WP Directory Kit 1.4.8, at application/helpers/Get_element_settings.php

124 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class WdkGetElementSettings
4 {
5 public $postid = null;
6 public $widget_id = null;
7 public $widget_type = null;
8 public $widget = null;
9 public $widgets = [];
10
11 public function __construct($postid, $widget_id = NULL, $widget_type = NULL, $parse = TRUE)
12 {
13 $this->postid = $postid;
14 $this->widget_id = $widget_id;
15 $this->widget_type = $widget_type;
16 $this->widget = null;
17
18 if ($parse)
19 $this->parse();
20 }
21
22 public function elementor()
23 {
24 return \Elementor\Plugin::$instance;
25 }
26
27 public function get_settings()
28 {
29 if (!$this->widget) return false;
30 return $this->widget;
31 }
32
33 private function parse()
34 {
35 $data = $this->read_data();
36 $this->parse_options($data);
37 }
38
39 public function get_widgets()
40 {
41 $this->parse();
42 return $this->widgets;
43 }
44
45 private function read_data()
46 {
47 if(is_object($this->elementor()->documents->get($this->postid)))
48 return $this->elementor()->documents->get($this->postid)->get_elements_data();
49 }
50
51 private function parse_options($data)
52 {
53
54 if (!is_array($data) || empty($data)) {
55 return;
56 }
57
58 foreach ($data as $item) {
59
60 if (empty($item)) {
61 continue;
62 }
63
64 if ('section' === $item['elType'] || 'column' === $item['elType'] || 'container' === $item['elType']) {
65
66 $this->parse_options($item['elements']);
67 } else {
68
69 $this->parse_options_simple($item);
70 }
71 }
72 }
73
74 private function parse_options_simple($item)
75 {
76
77 if (
78
79 (empty($this->widget_id) || $item['id'] === $this->widget_id) &&
80 $item['widgetType'] === $this->widget_type
81
82 ) {
83 $this->widget = $item;
84 $this->widgets[] = $item;
85 }
86 }
87
88 public function generate_icon($icon, $attributes = [], $tag = 'i')
89 {
90 if (empty($icon['library'])) {
91 return false;
92 }
93 $output = '';
94
95 // handler SVG Icon
96 if ('svg' === $icon['library']) {
97 $output = \Elementor\Icons_Manager::render_uploaded_svg_icon($icon['value']);
98 } else {
99 $output = $this->render_icon_html($icon, $attributes, $tag);
100 }
101
102 return $output;
103 }
104
105 public function render_icon_html($icon, $attributes = [], $tag = 'i')
106 {
107 $icon_types = \Elementor\Icons_Manager::get_icon_manager_tabs();
108 if (isset($icon_types[$icon['library']]['render_callback']) && is_callable($icon_types[$icon['library']]['render_callback'])) {
109 return call_user_func_array($icon_types[$icon['library']]['render_callback'], [$icon, $attributes, $tag]);
110 }
111
112 if (empty($attributes['class'])) {
113 $attributes['class'] = $icon['value'];
114 } else {
115 if (is_array($attributes['class'])) {
116 $attributes['class'][] = $icon['value'];
117 } else {
118 $attributes['class'] .= ' ' . $icon['value'];
119 }
120 }
121 return '<' . $tag . ' ' . \Elementor\Utils::render_html_attributes($attributes) . '></' . $tag . '>';
122 }
123 }
124