builders
1 year ago
documents
1 year ago
builder-content.php
1 year ago
class-helper.php
1 year ago
class-loader.php
1 year ago
class-panel-options.php
1 year ago
conditions-file.php
1 year ago
conditions-rules.php
1 year ago
elementor-document.php
1 year ago
theme-builder.php
1 year ago
widgets-passing-lists.php
1 year ago
conditions-rules.php
77 lines
| 1 | <?php |
| 2 | defined('ABSPATH') || die(); |
| 3 | |
| 4 | class Ecafe_Condition_Rules { |
| 5 | public static $_instance = null; |
| 6 | |
| 7 | private $storage; |
| 8 | |
| 9 | public function __construct() { |
| 10 | $this->storage = new Ecafe_Conditions_Data(); |
| 11 | } |
| 12 | |
| 13 | public static function get_instance() { |
| 14 | if (is_null(self::$_instance)) { |
| 15 | self::$_instance = new self(); |
| 16 | } |
| 17 | |
| 18 | return self::$_instance; |
| 19 | } |
| 20 | |
| 21 | public function ec_get_templates_ids( $location ) { |
| 22 | $templates = $this->get_templates_location( $location ); |
| 23 | return $templates; |
| 24 | } |
| 25 | |
| 26 | public function get_templates_location($location) { |
| 27 | $result = []; |
| 28 | |
| 29 | $ec_get_location_data = $this->storage->ec_get_location_data($location); |
| 30 | |
| 31 | if (empty($ec_get_location_data)) { |
| 32 | return $result; |
| 33 | } |
| 34 | |
| 35 | foreach ($ec_get_location_data as $template_id => $conditions) { |
| 36 | if( ($location =='header' || $location=='footer') && $conditions === 'entire'){ |
| 37 | $result[$template_id] = 10; |
| 38 | }else if( $location =='singular' ){ |
| 39 | if(get_post_type() === $conditions){ |
| 40 | $result[$template_id] = 10; |
| 41 | } |
| 42 | }else if( $location =='archives' ){ |
| 43 | if ( is_category() && in_array('category', $conditions) ) { |
| 44 | $result[$template_id] = 10; |
| 45 | }else if ( is_tag() && in_array('post_tag', $conditions) ) { |
| 46 | $result[$template_id] = 10; |
| 47 | }else if(is_tax()){ |
| 48 | foreach( $conditions as $tax ){ |
| 49 | if(is_tax($tax)){ |
| 50 | $result[$template_id] = 10; |
| 51 | break; |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | }else if( $location =='page404' && is_404() ){ |
| 56 | $result[$template_id] = 10; |
| 57 | } |
| 58 | } |
| 59 | asort($result); |
| 60 | |
| 61 | return $result; |
| 62 | } |
| 63 | |
| 64 | public function ec_get_location_type( $location ) { |
| 65 | $templates_ids = $this->ec_get_templates_ids( $location ); |
| 66 | |
| 67 | $template_ids = []; |
| 68 | foreach ($templates_ids as $templates_id => $priority) { |
| 69 | $template_ids[] = $templates_id; |
| 70 | } |
| 71 | |
| 72 | return $template_ids; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | Ecafe_Condition_Rules::get_instance(); |
| 77 |