PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 3.1.0
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v3.1.0
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 3 years ago screens 3 years ago page-templates.php 3 years ago
page-templates.php
111 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 $shop_url = get_permalink(wc_get_page_id('shop'));
65 $shop_url = (strpos($shop_url, '?page_id') !== false ? get_home_url() . '?post_type=product' : $shop_url);
66
67 return [
68 'shop' => [
69 'title' => esc_html__('Shop', 'shopengine'),
70 'package' => 'free',
71 'class' => 'ShopEngine\Core\Page_Templates\Hooks\Shop',
72 'opt_key' => 'shop',
73 'css' => 'shop',
74 'url' => $shop_url,
75 ],
76 'archive' => [
77 'title' => esc_html__('Archive', 'shopengine'),
78 'package' => 'free',
79 'class' => 'ShopEngine\Core\Page_Templates\Hooks\Archive',
80 'opt_key' => 'archive',
81 'css' => 'archive',
82 'url' => $shop_url,
83 ],
84 'single' => [
85 'title' => esc_html__('Single', 'shopengine'),
86 'package' => 'free',
87 'class' => 'ShopEngine\Core\Page_Templates\Hooks\Single',
88 'opt_key' => 'single',
89 'css' => 'single',
90 'url' => get_permalink(Products::instance()->get_preview_product()),
91 ],
92 'cart' => [
93 'title' => esc_html__('Cart', 'shopengine'),
94 'package' => 'free',
95 'class' => 'ShopEngine\Core\Page_Templates\Hooks\Cart',
96 'opt_key' => 'cart',
97 'css' => 'cart',
98 'url' => get_permalink(wc_get_page_id('cart')),
99 ],
100 'checkout' => [
101 'title' => esc_html__('Checkout', 'shopengine'),
102 'package' => 'free',
103 'class' => 'ShopEngine\Core\Page_Templates\Hooks\Checkout',
104 'opt_key' => 'checkout',
105 'css' => 'checkout',
106 'url' => get_permalink(wc_get_page_id('checkout')),
107 ],
108 ];
109 }
110 }
111