PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.1
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.1
4.0.2 4.0.1 4.0.0 3.10.02 3.10.01 3.9.10 3.9.9 3.9.8 3.9.7 3.9.5 3.9.6 3.9.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.1 2.3.1.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.4.0 2.5.0 2.5.1 2.5.10 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.2 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.6.0 3.6.1 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.8.1 3.8.2 3.9.0 3.9.1 3.9.2 trunk 1.2.6 1.2.7 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.0.9.1 2.0.9.2 2.0.9.3
elementskit-lite / modules / header-footer / activator.php
elementskit-lite / modules / header-footer Last commit date
assets 3 weeks ago theme-hooks 4 years ago views 1 year ago activator.php 2 years ago cpt-api.php 4 years ago cpt-hooks.php 2 years ago cpt.php 1 year ago init.php 3 weeks ago
activator.php
199 lines
1 <?php
2 namespace ElementsKit_Lite\Modules\Header_Footer;
3
4 defined( 'ABSPATH' ) || exit;
5
6 class Activator {
7 public static $instance = null;
8
9 protected $templates;
10 public $header_template;
11 public $footer_template;
12
13 protected $current_theme;
14 protected $current_template;
15
16 protected $post_type = 'elementskit_template';
17
18 public function __construct() {
19 add_action( 'wp', array( $this, 'hooks' ) );
20 }
21
22 public function hooks() {
23 $this->current_template = basename( get_page_template_slug() );
24 if ( $this->current_template == 'elementor_canvas' ) {
25 return;
26 }
27
28 $this->current_theme = get_template();
29
30 switch ( $this->current_theme ) {
31 case 'astra':
32 new Theme_Hooks\Astra( self::template_ids() );
33 break;
34
35 case 'neve':
36 new Theme_Hooks\Neve( self::template_ids() );
37 break;
38
39 case 'generatepress':
40 case 'generatepress-child':
41 new Theme_Hooks\Generatepress( self::template_ids() );
42 break;
43
44 case 'oceanwp':
45 case 'oceanwp-child':
46 new Theme_Hooks\Oceanwp( self::template_ids() );
47 break;
48
49 case 'bb-theme':
50 case 'bb-theme-child':
51 new Theme_Hooks\Bbtheme( self::template_ids() );
52 break;
53
54 case 'genesis':
55 case 'genesis-child':
56 new Theme_Hooks\Genesis( self::template_ids() );
57 break;
58
59 case 'twentynineteen':
60 new Theme_Hooks\TwentyNineteen( self::template_ids() );
61 break;
62
63 case 'my-listing':
64 case 'my-listing-child':
65 new Theme_Hooks\MyListing( self::template_ids() );
66 break;
67
68 default:
69 new Theme_Hooks\Theme_Support( self::template_ids() );
70 break;
71 }
72 }
73
74 public static function template_ids() {
75 $cached = wp_cache_get( 'elementskit_template_ids' );
76 if ( false !== $cached ) {
77 return $cached;
78 }
79
80 $instance = self::instance();
81 $instance->the_filter();
82
83 $ids = array(
84 $instance->header_template,
85 $instance->footer_template,
86 );
87
88 if ( $instance->header_template != null ) {
89 \ElementsKit_Lite\Utils::render_elementor_content_css( $instance->header_template );
90 }
91
92 if ( $instance->footer_template != null ) {
93 \ElementsKit_Lite\Utils::render_elementor_content_css( $instance->footer_template );
94 }
95
96 wp_cache_set( 'elementskit_template_ids', $ids );
97 return $ids;
98 }
99
100
101 protected function the_filter() {
102 $arg = array(
103 'posts_per_page' => -1,
104 'orderby' => 'id',
105 'order' => 'DESC',
106 'post_status' => 'publish',
107 'post_type' => $this->post_type,
108 'meta_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
109 array(
110 'key' => 'elementskit_template_activation',
111 'value' => 'yes',
112 'compare' => '=',
113 ),
114 ),
115 );
116 $this->templates = get_posts( $arg );
117
118 // more conditions can be triggered at once
119 // don't use switch case
120 // may impliment and callable by dynamic class in future
121
122 // entire site
123 if ( ! is_admin() ) {
124 $filters = array(
125 array(
126 'key' => 'condition_a',
127 'value' => 'entire_site',
128 ),
129 );
130 $this->get_header_footer( $filters );
131 }
132 }
133
134 protected function get_header_footer( $filters ) {
135 $template_id = array();
136
137 if ( $this->templates != null ) {
138 foreach ( $this->templates as $template ) {
139 $template = $this->get_full_data( $template );
140 $match_found = true;
141
142 // WPML Language Check
143 if ( defined( 'ICL_LANGUAGE_CODE' ) ) :
144 $current_lang = apply_filters( 'wpml_post_language_details', null, $template['ID'] );
145
146 if ( ! empty( $current_lang ) && ! $current_lang['different_language'] && ( $current_lang['language_code'] == ICL_LANGUAGE_CODE ) ) :
147 $template_id[ $template['type'] ] = $template['ID'];
148 endif;
149 endif;
150
151 foreach ( $filters as $filter ) {
152 if ( $filter['key'] == 'condition_singular_id' ) {
153 $ids = explode( ',', $template[ $filter['key'] ] );
154 if ( ! in_array( $filter['value'], $ids ) ) {
155 $match_found = false;
156 }
157 } elseif ( $template[ $filter['key'] ] != $filter['value'] ) {
158 $match_found = false;
159 }
160 if ( $filter['key'] == 'condition_a' && $template[ $filter['key'] ] == 'singular' && count( $filters ) < 2 ) {
161 $match_found = false;
162 }
163 }
164
165 if ( $match_found == true ) {
166 if ( $template['type'] == 'header' ) {
167 $this->header_template = isset( $template_id['header'] ) ? $template_id['header'] : $template['ID'];
168 }
169 if ( $template['type'] == 'footer' ) {
170 $this->footer_template = isset( $template_id['footer'] ) ? $template_id['footer'] : $template['ID'];
171 }
172 }
173 }
174 }
175 }
176
177 protected function get_full_data( $post ) {
178 if ( $post != null ) {
179 return array_merge(
180 (array) $post,
181 array(
182 'type' => get_post_meta( $post->ID, 'elementskit_template_type', true ),
183 'condition_a' => get_post_meta( $post->ID, 'elementskit_template_condition_a', true ),
184 'condition_singular' => get_post_meta( $post->ID, 'elementskit_template_condition_singular', true ),
185 'condition_singular_id' => get_post_meta( $post->ID, 'elementskit_template_condition_singular_id', true ),
186 )
187 );
188 }
189 }
190
191 public static function instance() {
192 if ( is_null( self::$instance ) ) {
193 self::$instance = new self();
194 }
195
196 return self::$instance;
197 }
198 }
199