PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 4.9.1
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v4.9.1
4.9.2 4.9.1 4.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.1 3.0.0 3.1.0 3.1.1 4.0.0 4.0.1 4.1.0 4.1.1 4.2.0 4.2.1 4.3.0 4.3.1 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.6.8 4.6.9 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.8.9 trunk 0.1.2-beta 0.1.3-beta 0.1.4-beta 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.5.0 1.5.1 1.6.0 1.6.1 1.7.0 1.8.0 1.8.1 1.9.0
shopengine / core / page-templates / page-templates.php
shopengine / core / page-templates Last commit date
hooks 2 weeks ago screens 1 year ago page-templates.php 2 weeks ago
page-templates.php
238 lines
1 <?php
2
3 namespace ShopEngine\Core\PageTemplates;
4
5 defined('ABSPATH') || exit;
6
7 use ShopEngine\Traits\Singleton;
8 use ShopEngine\Widgets\Products;
9
10
11 class Page_Templates {
12 use Singleton;
13
14 private $templateList = [];
15 private $listedCollected = false;
16
17 public function init() {
18
19 add_filter('elementor/document/urls/edit', function($url) {
20 if(is_single()) {
21 global $wp;
22 $query = $wp->query_vars;
23 if(isset($query['name'])){
24 $product = get_page_by_path( $query['name'], OBJECT, 'product' );
25 if(!empty($product->ID)) {
26 return $url . "&shopengine_product_id=" . $product->ID;
27 }
28 }
29 }
30 return $url;
31 });
32
33 $templates = $this->getTemplates();
34
35 foreach($templates as $key => $template) {
36
37 if(isset($template['class']) && $template['class']) {
38
39 if ( class_exists( $template['class'] ) ) {
40 new $template['class']();
41 }
42
43 }
44 }
45 }
46
47
48 public function getTemplates() {
49
50 if(!$this->listedCollected) {
51 $this->templateList = apply_filters('shopengine/page_templates', $this->get_list());
52 $this->listedCollected = true;
53 }
54
55 return $this->templateList;
56 }
57
58 public function getTemplate($slug) {
59 $page_templates = $this->getTemplates();
60
61 return $page_templates[$slug] ?? [];
62 }
63
64
65 public function get_list() {
66
67 $product_id = Products::instance()->get_preview_product();
68
69 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Some other templates call it without nonce added.
70 if(isset($_GET['shopengine_product_id'])) {
71 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Some other templates call it without nonce added.
72 $product_id = sanitize_text_field(wp_unslash($_GET['shopengine_product_id']));
73 update_option('__shopengine_preview_product_id', $product_id);
74 } elseif(get_option('__shopengine_preview_product_id')) {
75 $product_id = get_option('__shopengine_preview_product_id');
76 }
77
78 $shop_url = get_permalink(wc_get_page_id('shop'));
79 $shop_url = (strpos($shop_url, '?page_id') !== false ? get_home_url() . '?post_type=product' : $shop_url);
80
81 return [
82 'shop' => [
83 'title' => esc_html__('Shop', 'shopengine'),
84 'package' => 'free',
85 'class' => 'ShopEngine\Core\Page_Templates\Hooks\Shop',
86 'opt_key' => 'shop',
87 'css' => 'shop',
88 'url' => $shop_url,
89 ],
90 'archive' => [
91 'title' => esc_html__('Archive', 'shopengine'),
92 'package' => 'free',
93 'class' => 'ShopEngine\Core\Page_Templates\Hooks\Archive',
94 'opt_key' => 'archive',
95 'css' => 'archive',
96 'url' => $shop_url,
97 ],
98 'single' => [
99 'title' => esc_html__('Single', 'shopengine'),
100 'package' => 'free',
101 'class' => 'ShopEngine\Core\Page_Templates\Hooks\Single',
102 'opt_key' => 'single',
103 'css' => 'single',
104 'url' => get_permalink($product_id),
105 ],
106 'cart' => [
107 'title' => esc_html__('Cart', 'shopengine'),
108 'package' => 'free',
109 'class' => 'ShopEngine\Core\Page_Templates\Hooks\Cart',
110 'opt_key' => 'cart',
111 'css' => 'cart',
112 'url' => get_permalink(wc_get_page_id('cart')),
113 ],
114 'checkout' => [
115 'title' => esc_html__('Checkout', 'shopengine'),
116 'package' => 'free',
117 'class' => 'ShopEngine\Core\Page_Templates\Hooks\Checkout',
118 'opt_key' => 'checkout',
119 'css' => 'checkout',
120 'url' => get_permalink(wc_get_page_id('checkout')),
121 ],
122 'order' => [
123 'title' => esc_html__('Order / Thank you', 'shopengine'),
124 'package' => 'pro',
125 'class' => 'ShopEngine_Pro\Templates\Hooks\Thank_You',
126 'opt_key' => 'order',
127 'css' => 'order',
128 'url' => get_permalink( wc_get_page_id( 'checkout' ) )
129 ],
130 'my_account_login' => [
131 'title' => esc_html__('My Account Login / Register', 'shopengine'),
132 'package' => 'pro',
133 'class' => 'ShopEngine_Pro\Templates\Hooks\Account_Login',
134 'opt_key' => 'my_account_login',
135 'css' => 'account-login-register',
136 ],
137 'my_account' => [
138 'title' => esc_html__('Account Dashboard', 'shopengine'),
139 'package' => 'pro',
140 'class' => 'ShopEngine_Pro\Templates\Hooks\Account',
141 'opt_key' => 'my_account',
142 'css' => 'account',
143 'url' => get_permalink( wc_get_page_id( 'myaccount' ) )
144 ],
145 'account_orders' => [
146 'title' => esc_html__('My Account Orders', 'shopengine'),
147 'package' => 'pro',
148 'class' => 'ShopEngine_Pro\Templates\Hooks\Account_Orders',
149 'opt_key' => 'account_orders',
150 'css' => 'account-orders',
151 'url' => get_permalink( wc_get_page_id( 'myaccount' ) )
152 ],
153 'account_wishlist' => [
154 'title' => esc_html__('My Account Wishlist', 'shopengine'),
155 'package' => 'pro',
156 'class' => 'ShopEngine_Pro\Templates\Hooks\Account_Wishlist',
157 'opt_key' => 'account_wishlist',
158 'css' => 'account-wishlist',
159 'url' => get_permalink( wc_get_page_id( 'myaccount' ) )
160 ],
161 'account_payment_methods' => [
162 'title' => esc_html__('My Account Payment Methods', 'shopengine'),
163 'package' => 'pro',
164 'class' => 'ShopEngine_Pro\Templates\Hooks\Account_Payment_Methods',
165 'opt_key' => 'account_payment_methods',
166 'css' => 'account-payment-methods',
167 'url' => get_permalink( wc_get_page_id( 'myaccount' ) )
168 ],
169 'account_downloads' => [
170 'title' => esc_html__('My Account Downloads', 'shopengine'),
171 'package' => 'pro',
172 'class' => 'ShopEngine_Pro\Templates\Hooks\Account_Downloads',
173 'opt_key' => 'account_downloads',
174 'css' => 'account-downloads',
175 'url' => get_permalink( wc_get_page_id( 'myaccount' ) )
176 ],
177 'account_orders_view' => [
178 'title' => esc_html__('My Account Order Details', 'shopengine'),
179 'package' => 'pro',
180 'class' => 'ShopEngine_Pro\Templates\Hooks\Account_Orders_View',
181 'opt_key' => 'account_orders_view',
182 'css' => 'account-orders-view',
183 'url' => get_permalink( wc_get_page_id( 'myaccount' ) )
184 ],
185 'account_edit_account' => [
186 'title' => esc_html__('My Account Details', 'shopengine'),
187 'package' => 'pro',
188 'class' => 'ShopEngine_Pro\Templates\Hooks\Account_Details',
189 'opt_key' => 'account_edit_account',
190 'css' => 'account-details',
191 'url' => get_permalink( wc_get_page_id( 'myaccount' ) )
192 ],
193 'account_edit_address' => [
194 'title' => esc_html__('My Account Address', 'shopengine'),
195 'package' => 'pro',
196 'class' => 'ShopEngine_Pro\Templates\Hooks\Account_Address',
197 'opt_key' => 'account_edit_address',
198 'css' => 'account-address',
199 'url' => get_permalink( wc_get_page_id( 'myaccount' ) )
200 ],
201 'lost-password' => [
202 'title' => esc_html__('Reset Password Form', 'shopengine'),
203 'package' => 'pro',
204 'class' => 'ShopEngine_Pro\Templates\Hooks\Lost_Password',
205 'opt_key' => 'lost-password',
206 'css' => 'lost-password',
207 'url' => get_permalink(wc_get_page_id('myaccount')),
208 ],
209 'reset-password' => [
210 'title' => esc_html__('New Password Form', 'shopengine'),
211 'package' => 'pro',
212 'class' => 'ShopEngine_Pro\Templates\Hooks\Reset_Password',
213 'opt_key' => 'reset-password',
214 'css' => 'reset-password',
215 'url' => get_permalink(wc_get_page_id('myaccount')),
216 ],
217 'empty-cart' => [
218 'title' => esc_html__('Empty Cart', 'shopengine'),
219 'package' => 'pro',
220 'class' => 'ShopEngine_Pro\Templates\Hooks\Empty_Cart',
221 'opt_key' => 'empty-cart',
222 'css' => 'empty-cart',
223 'url' => get_permalink(wc_get_page_id('cart')),
224 ],
225 'checkout-order-pay' => [
226 'title' => esc_html__('Checkout Order Pay', 'shopengine'),
227 'package' => 'pro',
228 'class' => 'ShopEngine_Pro\Templates\Hooks\Checkout_Order_Pay',
229 'opt_key' => 'checkout-order-pay',
230 'css' => 'checkout-order-pay',
231 'url' => get_permalink(wc_get_page_id('checkout')). '/order-pay',
232 ]
233 ];
234
235
236 }
237 }
238