PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 4.7.2
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v4.7.2
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 1 year ago screens 1 year ago page-templates.php 2 years ago
page-templates.php
125 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 new $template['class']();
40
41 }
42 }
43 }
44
45
46 public function getTemplates() {
47
48 if(!$this->listedCollected) {
49 $this->templateList = apply_filters('shopengine/page_templates', $this->get_list());
50 $this->listedCollected = true;
51 }
52
53 return $this->templateList;
54 }
55
56 public function getTemplate($slug) {
57 $page_templates = $this->getTemplates();
58
59 return $page_templates[$slug] ?? [];
60 }
61
62
63 public function get_list() {
64
65 $product_id = Products::instance()->get_preview_product();
66
67 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Some other templates call it without nonce added.
68 if(isset($_GET['shopengine_product_id'])) {
69 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Some other templates call it without nonce added.
70 $product_id = sanitize_text_field(wp_unslash($_GET['shopengine_product_id']));
71 update_option('__shopengine_preview_product_id', $product_id);
72 } elseif(get_option('__shopengine_preview_product_id')) {
73 $product_id = get_option('__shopengine_preview_product_id');
74 }
75
76 $shop_url = get_permalink(wc_get_page_id('shop'));
77 $shop_url = (strpos($shop_url, '?page_id') !== false ? get_home_url() . '?post_type=product' : $shop_url);
78
79 return [
80 'shop' => [
81 'title' => esc_html__('Shop', 'shopengine'),
82 'package' => 'free',
83 'class' => 'ShopEngine\Core\Page_Templates\Hooks\Shop',
84 'opt_key' => 'shop',
85 'css' => 'shop',
86 'url' => $shop_url,
87 ],
88 'archive' => [
89 'title' => esc_html__('Archive', 'shopengine'),
90 'package' => 'free',
91 'class' => 'ShopEngine\Core\Page_Templates\Hooks\Archive',
92 'opt_key' => 'archive',
93 'css' => 'archive',
94 'url' => $shop_url,
95 ],
96 'single' => [
97 'title' => esc_html__('Single', 'shopengine'),
98 'package' => 'free',
99 'class' => 'ShopEngine\Core\Page_Templates\Hooks\Single',
100 'opt_key' => 'single',
101 'css' => 'single',
102 'url' => get_permalink($product_id),
103 ],
104 'cart' => [
105 'title' => esc_html__('Cart', 'shopengine'),
106 'package' => 'free',
107 'class' => 'ShopEngine\Core\Page_Templates\Hooks\Cart',
108 'opt_key' => 'cart',
109 'css' => 'cart',
110 'url' => get_permalink(wc_get_page_id('cart')),
111 ],
112 'checkout' => [
113 'title' => esc_html__('Checkout', 'shopengine'),
114 'package' => 'free',
115 'class' => 'ShopEngine\Core\Page_Templates\Hooks\Checkout',
116 'opt_key' => 'checkout',
117 'css' => 'checkout',
118 'url' => get_permalink(wc_get_page_id('checkout')),
119 ],
120 ];
121
122
123 }
124 }
125