PluginProbe
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder / 2.0.5
Ultimate Store Kit – Store Builder Addons for Elementor, WooCommerce Store Builder, EDD Store Builder v2.0.5
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 2.0.5, at includes/builder/builder-template-helper.php

122 lines 2.8 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 $shop_item = [
23 'shop' => 'Shop Page',
24 'archive' => 'Archive Page',
25 'single' => 'Single Page',
26 'cart' => 'Cart Page',
27 'checkout' => 'Checkout',
28 'order-received' => 'Order Received',
29 ];
30
31 $my_account = [
32 'myaccount' => 'Dashboard',
33 'orders' => 'Orders',
34 'downloads' => 'Downloads',
35 'edit-address' => 'Address',
36 'edit-account' => 'Account Details',
37 'wishlist' => 'Wishlist',
38 'logout' => 'Customer Logout',
39 ];
40
41 if ( $wcItems = WC()->query->get_query_vars() ) {
42 array_walk( $wcItems, function ($item, $key) use (&$shop_item) {
43 $shop_item[ $key ] = ucwords( str_replace( '-', ' ', $key ) );
44 } );
45 }
46
47 $product = [
48 'product' => $shop_item,
49 'account' => $my_account,
50 ];
51
52 $templates = apply_filters(
53 'ultimate_store_kit_builder_templates',
54 $product
55 );
56
57 if ( $single ) {
58 $separator = static::separator();
59 $return = [];
60 if ( is_array( $templates ) && ! empty( $templates ) ) {
61 foreach ( $templates as $keys => $items ) {
62 if ( is_array( $items ) ) {
63 foreach ( $items as $itemKey => $item ) {
64 $return[ "{$keys}{$separator}{$itemKey}" ] = $item;
65 }
66 }
67 }
68 }
69
70 return apply_filters(
71 'ultimate_store_kit_builder_all_templates',
72 $return
73 );
74 }
75
76 return $templates;
77 }
78
79 public static function templateForSelectDropdown() {
80 return static::templates();
81 }
82
83 public static function getTemplateByIndex( $index ) {
84 $index = trim( $index );
85 $templates = static::templates( true );
86
87 return array_key_exists( $index, $templates ) ? $templates[ $index ] : false;
88 }
89
90 public static function getTemplatePostTypeByIndex( $index ) {
91 $index = trim( $index );
92 if ( $item = explode( static::separator(), $index ) ) {
93 return get_post_type_object( $item[0] );
94 }
95 }
96
97 public static function is_elementor_active() {
98 return did_action( 'elementor/loaded' );
99 }
100
101 public static function getTemplate( $slug, $postType = false ) {
102 if ( ! $postType ) {
103 $postType = get_post_type();
104 }
105
106 $separator = static::separator();
107 $template = strtolower( "{$postType}{$separator}{$slug}" );
108 $enabledTemplate = strtolower( Meta::TEMPLATE_ID . $template );
109
110 /**
111 * important area for debugging
112 */
113
114 return get_option( $enabledTemplate );
115 }
116
117 public static function getTemplateId( $templateType ) {
118 $metaIndex = strtolower( Meta::TEMPLATE_ID . $templateType );
119 return intval( get_option( $metaIndex ) );
120 }
121 }
122