PluginProbe
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder / 1.6.3
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder v1.6.3
3.1.4 3.0.8 3.0.9 3.1.0 3.1.2 3.1.3 3.0.7 3.0.5 3.0.4 3.0.3 3.0.2 trunk 1.5.0 1.5.1 1.5.2 1.6.1 1.6.2 1.6.3 1.6.4 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 All 93 releases
ultimate-store-kit / includes / builder / builder-template-helper.php

builder-template-helper.php in Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder 1.6.3, at includes/builder/builder-template-helper.php

107 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace UltimateStoreKit\Includes\Builder;
4
5 class Builder_Template_Helper {
6
7 public static function isTemplateEditMode() {
8 if (get_post_type() == Meta::POST_TYPE) {
9 return true;
10 }
11
12 if (isset($_REQUEST[Meta::POST_TYPE])) {
13 return true;
14 }
15 }
16
17 public static function separator() {
18 return '|';
19 }
20
21 public static function templates($single = false) {
22 $shopItem = [
23 'shop' => 'Shop Page',
24 'archive' => 'Archive Page',
25 'single' => 'Single Page',
26 'cart' => 'Cart Page',
27 'checkout' => 'Checkout',
28 'myaccount' => 'My Account',
29 // 'wishlist' => 'Wishlist',
30 ];
31
32 if ($wcItems = WC()->query->get_query_vars()) {
33 array_walk($wcItems, function ($item, $key) use (&$shopItem) {
34 $shopItem[$key] = ucwords(str_replace('-', ' ', $key));
35 });
36 }
37
38 $product = [
39 'product' => $shopItem,
40 ];
41
42 $templates = apply_filters(
43 'ultimate_store_kit_builder_templates',
44 $product
45 );
46
47 if ($single) {
48 $separator = static::separator();
49 $return = [];
50 if (is_array($templates) && !empty($templates)) {
51 foreach ($templates as $keys => $items) {
52 if (is_array($items)) {
53 foreach ($items as $itemKey => $item) {
54 $return["{$keys}{$separator}{$itemKey}"] = $item;
55 }
56 }
57 }
58 }
59
60 return apply_filters(
61 'ultimate_store_kit_builder_all_templates',
62 $return
63 );
64 }
65
66 return $templates;
67 }
68
69 public static function templateForSelectDropdown() {
70 return static::templates();
71 }
72
73 public static function getTemplateByIndex($index) {
74 $index = trim($index);
75 $templates = static::templates(true);
76
77 return array_key_exists($index, $templates) ? $templates[$index] : false;
78 }
79
80 public static function getTemplatePostTypeByIndex($index) {
81 $index = trim($index);
82 if ($item = explode(static::separator(), $index)) {
83 return get_post_type_object($item[0]);
84 }
85 }
86
87 public static function is_elementor_active() {
88 return did_action('elementor/loaded');
89 }
90
91 public static function getTemplate($slug, $postType = false) {
92 if (!$postType) {
93 $postType = get_post_type();
94 }
95 $separator = static::separator();
96 $template = strtolower("{$postType}{$separator}{$slug}");
97 $enabledTemplate = strtolower(Meta::TEMPLATE_ID . $template);
98
99 return get_option($enabledTemplate);
100 }
101
102 public static function getTemplateId($templateType) {
103 $metaIndex = strtolower(Meta::TEMPLATE_ID . $templateType);
104 return intval(get_option($metaIndex));
105 }
106 }
107