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