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

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