banner
2 years ago
notice
2 years ago
pro-awareness
2 years ago
stories
2 years ago
controls-helper.php
4 years ago
elementor-data-map.php
4 years ago
global-helper.php
3 years ago
helper.php
2 years ago
notice.php
2 years ago
shipping-calculation.php
3 years ago
util.php
2 years ago
elementor-data-map.php
58 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ShopEngine\Utils; |
| 4 | |
| 5 | class Elementor_Data_Map { |
| 6 | |
| 7 | private $_el = []; |
| 8 | |
| 9 | public function get_elementor_data($post_id) { |
| 10 | |
| 11 | $dt = get_post_meta($post_id, '_elementor_data', true); |
| 12 | |
| 13 | return json_decode($dt); |
| 14 | } |
| 15 | |
| 16 | public function get_widget_data($widget_name, $data = false, $post_id = null) { |
| 17 | |
| 18 | if($data === false && !empty($post_id)) { |
| 19 | |
| 20 | $data = $this->get_elementor_data($post_id); |
| 21 | } |
| 22 | |
| 23 | if(!empty($data) && is_array($data)) { |
| 24 | |
| 25 | $this->_el = []; |
| 26 | |
| 27 | $this->search_el($data, $widget_name); |
| 28 | |
| 29 | return $this->_el; |
| 30 | } |
| 31 | |
| 32 | return []; |
| 33 | } |
| 34 | |
| 35 | private function search_el($data, $name) { |
| 36 | |
| 37 | if(!is_array($data)) { |
| 38 | |
| 39 | return; |
| 40 | } |
| 41 | |
| 42 | foreach($data as $k => $v) { |
| 43 | |
| 44 | if(!empty($v->elements) && is_array($v->elements)) { |
| 45 | |
| 46 | $this->search_el($v->elements, $name); |
| 47 | |
| 48 | } else { |
| 49 | |
| 50 | if($v->elType == 'widget' && $v->widgetType == $name) { |
| 51 | |
| 52 | $this->_el[] = $v; |
| 53 | } |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 |