builders
2 months ago
documents
2 months ago
builder-content.php
2 months ago
class-helper.php
2 months ago
class-loader.php
2 months ago
class-panel-options.php
2 months ago
conditions-file.php
2 months ago
conditions-rules.php
2 months ago
elementor-document.php
2 months ago
theme-builder.php
2 months ago
widgets-passing-lists.php
2 months ago
conditions-file.php
62 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) { |
| 3 | exit; // Exit if accessed directly |
| 4 | } |
| 5 | |
| 6 | class Ecafe_Conditions_Data { |
| 7 | |
| 8 | protected $conditions = []; |
| 9 | |
| 10 | public function __construct() { |
| 11 | $this->init(); |
| 12 | } |
| 13 | |
| 14 | public function ec_add_condition($location, $post_id, $conditions = '') { |
| 15 | if ($location) { |
| 16 | if (is_array($this->conditions) && !isset($this->conditions[$location])) { |
| 17 | $this->conditions[$location] = []; |
| 18 | } |
| 19 | $this->conditions[$location][$post_id] = $conditions; |
| 20 | } |
| 21 | |
| 22 | return $this; |
| 23 | } |
| 24 | |
| 25 | public function ec_get_location_data($location) { |
| 26 | if (isset($this->conditions[$location])) { |
| 27 | return $this->conditions[$location]; |
| 28 | } |
| 29 | |
| 30 | return []; |
| 31 | } |
| 32 | |
| 33 | public function init() { |
| 34 | |
| 35 | $query = new \WP_Query([ |
| 36 | 'posts_per_page' => -1, |
| 37 | 'post_type' => ECAFE_POST, |
| 38 | 'post_status' => 'publish' |
| 39 | ]); |
| 40 | if( !empty($query) ){ |
| 41 | if ( $query->have_posts() ) { |
| 42 | foreach ($query->posts as $post_id) { |
| 43 | $template_type = get_post_meta($post_id->ID,'ecafe_build_template_type',true); |
| 44 | $conditions = ''; |
| 45 | if($template_type === 'header' || $template_type === 'footer'){ |
| 46 | $conditions = get_post_meta($post_id->ID,'ecafe_build_template_display',true); |
| 47 | }else if($template_type === 'singular'){ |
| 48 | $conditions = get_post_meta($post_id->ID,'ecafe_build_display_singular',true); |
| 49 | }else if($template_type === 'archives'){ |
| 50 | $conditions = get_post_meta($post_id->ID,'ecafe_build_display_archives',true); |
| 51 | }else if($template_type === 'page404'){ |
| 52 | $conditions = '404page'; |
| 53 | } |
| 54 | |
| 55 | $this->ec_add_condition($template_type, $post_id->ID, $conditions); |
| 56 | } |
| 57 | } |
| 58 | } |
| 59 | return $this; |
| 60 | } |
| 61 | } |
| 62 |