PluginProbe
UiCore Elements – Free widgets and templates for Elementor / 1.3.17
UiCore Elements – Free widgets and templates for Elementor v1.3.17
1.3.17 1.3.16 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 All 41 releases
← All changes | includes/class-widget-base.php +37 -23 1.2.31.3.17 View file →
@@ -1,10 +1,13 @@
1 1 <?php
2 +
2 3 namespace UiCoreElements;
4 +
3 5 use Elementor\Widget_Base;
4 6 use UiCoreElements\Helper;
5 7
6 -abstract class UiCoreWidget extends Widget_Base {
8 +abstract class UiCoreWidget extends Widget_Base
9 +{
7 10
8 11 /**
9 12 * Get widget categories.
10 13 *
@@ -23,9 +26,9 @@
23 26
24 27 public function get_style_depends()
25 28 {
26 29 $assets = $this->get_styles();
27 - $final_list = $this->parse_asset_list($assets,'style');
30 + $final_list = $this->parse_asset_list($assets, 'style');
28 31
29 32 //TODO: combine all the styles into one file and return it
30 33 return $final_list;
31 34 }
@@ -32,9 +35,9 @@
32 35
33 36 public function get_script_depends()
34 37 {
35 38 $assets = $this->get_scripts();
36 - $final_list = $this->parse_asset_list($assets,'script');
39 + $final_list = $this->parse_asset_list($assets, 'script');
37 40
38 41 //TODO: combine all the styles into one file and return it
39 42 return $final_list;
40 43 }
@@ -40,51 +43,53 @@
40 43 }
41 44
42 45
43 46
44 - private function parse_asset_list($list,$type='style'){
47 + private function parse_asset_list($list, $type = 'style')
48 + {
45 49 $final_list = [];
46 50 foreach ($list as $key => $value) {
47 51 $deps = (isset($value) && isset($value['deps'])) ? $value['deps'] : [];
48 52 $external = (isset($value) && isset($value['external'])) ? $value['external'] : false;
49 - $name = $this->get_asset_name($key,$value);
53 + $name = $this->get_asset_name($key, $value);
50 54
51 55 //if name is not empty then we need to add it to the list
52 - if($name){
56 + if ($name) {
53 57 $method_name = "register_widget_$type";
54 - $final_list[] = Helper::$method_name($name,$deps,$external);
58 + $final_list[] = Helper::$method_name($name, $deps, $external);
55 59 }
56 60 }
57 61 return $final_list;
58 62 }
59 63
60 - private function get_asset_name($key,$value){
64 + private function get_asset_name($key, $value)
65 + {
61 66 //check the condition/s
62 67 if (\is_array($value) && !empty($value)) {
63 68
64 69 //custom condition
65 - if(isset($value['custom_condition'])){
66 - if($value['custom_condition']){
70 + if (isset($value['custom_condition'])) {
71 + if ($value['custom_condition']) {
67 72 return $key;
68 - }else{
73 + } else {
69 74 return '';
70 75 }
71 76 }
72 77
73 78 //check if the condition is true using elementor's function (always return true if we are in edit mode)
74 - if($this->is_edit_mode() || $this->is_control_visible($value,$this->get_settings())){
79 + if ($this->is_edit_mode() || $this->is_control_visible($value, $this->get_settings())) {
75 80 return $key;
76 - }else{
81 + } else {
77 82 return '';
78 83 }
79 84 }
80 85 // if list is only declaring the assets without any condition then we need to return the key
81 86 return $value;
82 -
83 87 }
84 - protected function is_edit_mode() {
88 + protected function is_edit_mode()
89 + {
85 90 $elementor_instance = \Elementor\Plugin::instance();
86 - if ( $elementor_instance->preview->is_preview_mode() || $elementor_instance->editor->is_edit_mode() ) {
91 + if ($elementor_instance->preview->is_preview_mode() || $elementor_instance->editor->is_edit_mode()) {
87 92 return true;
88 93 }
89 94
90 95 return false;
@@ -98,21 +103,21 @@
98 103 * @param string|null $value Optional. The value to check against.
99 104 * @param string $operator Optional. The operator to use for comparing `control` and `value`. Default is '==='.
100 105 *
101 106 * @return bool
102 - * @since 1.2.3
107 + * @since 1.0.15
103 108 */
104 - protected function is_option( string $control, $value = null, $operator = '==='): bool
109 + protected function is_option(string $control, $value = null, $operator = '==='): bool
105 110 {
106 111 $option = $this->get_settings_for_display($control);
107 112
108 - if( isset($option) ){
113 + if (isset($option)) {
109 114
110 - if( !isset($value) ){
115 + if (!isset($value)) {
111 116 return true;
112 117 }
113 118
114 - switch($operator){
119 + switch ($operator) {
115 120 case '===':
116 121 return $option === $value;
117 122 case '!==':
118 123 return $option !== $value;
@@ -139,15 +144,15 @@
139 144 * @param array $fallback The fallback value to return if the control does not exist. Should have `size` and, if requested, `unit` keys.
140 145 * @param bool $use_unit If true, the unit will also be checked and returned.
141 146 *
142 147 * @return string `size` and, if requested, `unit` values from the control or the fallback value.
143 - * @since 1.2.3
148 + * @since 1.0.15
144 149 */
145 150 public function get_option_size($control, array $fallback, $use_unit = false)
146 151 {
147 152 $option = $this->get_settings_for_display($control);
148 153
149 - if ( isset($option) && ! empty($option['size']) ) {
154 + if (isset($option) && ! empty($option['size'])) {
150 155 $size = $control['size'];
151 156 $unit = $use_unit && isset($option['unit']) ? $option['unit'] : '';
152 157 return $size . $unit;
153 158 }
@@ -154,6 +159,15 @@
154 159
155 160 $fallback_size = $fallback['size'];
156 161 $fallback_unit = $use_unit ? $fallback['unit'] : '';
157 162 return $fallback_size . $fallback_unit;
163 + }
164 +
165 + /**
166 + * Determine if the widget content is dynamic. Dynamic widgets always have
167 + * their render content refreshed on each page load.
168 + */
169 + protected function is_dynamic_content(): bool
170 + {
171 + return true;
158 172 }
159 173 }