PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 1.1.4
ShopBuilder – WooCommerce Builder For Elementor v1.1.4
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
shopbuilder / app / Helpers / BuilderFns.php

BuilderFns.php in ShopBuilder – WooCommerce Builder For Elementor 1.1.4, at app/Helpers/BuilderFns.php

367 lines 12.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * BuilderFns class
4 *
5 * The builder.
6 *
7 * @package RadiusTheme\SB
8 * @since 1.0.0
9 */
10
11 namespace RadiusTheme\SB\Helpers;
12
13 // Do not allow directly accessing this file.
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit( 'This script cannot be accessed directly.' );
16 }
17
18 /**
19 * BuilderFns class
20 */
21 class BuilderFns {
22
23 /**
24 * Template builder post type
25 *
26 * @var string
27 */
28 public static $post_type_tb = 'rtsb_builder';
29 /**
30 * Template builder
31 *
32 * @var string
33 */
34 public static $template_meta = 'rtsb_tb_template';
35 /**
36 * Template builder
37 *
38 * @var string
39 */
40 public static $product_template_meta = 'rtsb_selected_product_template';
41
42 /**
43 * Page builder id.
44 *
45 * @return init
46 */
47 public static function builder_page_id_by_type( $type ) {
48 if ( array_key_exists( $type, self::builder_page_types() ) ) {
49 $post_id = get_option( self::option_name( $type ) );
50 if ( 'publish' === get_post_status( $post_id ) && self::builder_type( $post_id ) === $type ) {
51 return $post_id;
52 }
53 }
54 return 0;
55 }
56
57 /**
58 * Page builder id.
59 *
60 * @return init
61 */
62 public static function builder_page_id_by_page() {
63 $type = apply_filters( 'rtsb/builder/set/current/page/type', '' );
64 return self::builder_page_id_by_type( $type );
65 }
66 /**
67 * Page builder Page for.
68 *
69 * @return array
70 */
71 public static function builder_page_types() {
72 $page_types = [
73 'shop' => esc_html__( 'Shop', 'shopbuilder' ),
74 'archive' => esc_html__( 'Archive', 'shopbuilder' ),
75 'product' => esc_html__( 'Product Page', 'shopbuilder' ),
76 'cart' => esc_html__( 'Cart', 'shopbuilder' ),
77 'checkout' => esc_html__( 'Checkout', 'shopbuilder' ),
78 ];
79 return apply_filters( 'rtsb/builder/page/types', $page_types );
80 }
81
82 /**
83 * Option name.
84 *
85 * @param string $type Builder type.
86 * @return string
87 */
88 public static function option_name( $type ) {
89 $type = str_replace( [ '-', ' ' ], '_', $type );
90 return self::$template_meta . '_default_' . $type;
91 }
92 /**
93 * Option name.
94 *
95 * @param string $type Builder type.
96 * @return string
97 */
98 /*
99 public static function option_name_by_product_id( $type, $product_id ) {
100 return self::option_name($type) . '_' . $product_id ;
101 }
102 */
103 /**
104 * Template builder
105 *
106 * @var string
107 */
108 public static function template_type_meta_key() {
109 return self::$template_meta . '_type';
110 }
111 /**
112 * Get builder type.
113 *
114 * @param [type] $post_id Post id.
115 * @return string
116 */
117 public static function builder_type( $post_id ) {
118 return get_post_meta( $post_id, self::template_type_meta_key(), true );
119 }
120 /**
121 * Template builder
122 *
123 * @var boolean
124 */
125 public static function is_builder_preview() {
126 return is_singular( self::$post_type_tb );
127 }
128 /**
129 * Template builder
130 *
131 * @var boolean
132 */
133 public static function is_archive() {
134 return self::is_page_builder( 'archive', is_product_taxonomy() );
135 }
136 /**
137 * Template builder
138 *
139 * @var boolean
140 */
141 public static function is_shop() {
142 return self::is_page_builder( 'shop', is_shop() );
143 }
144 /**
145 * Template builder
146 *
147 * @var boolean
148 */
149 public static function is_cart() {
150 return self::is_page_builder( 'cart', is_cart() );
151 }
152 /**
153 * Template builder
154 *
155 * @var boolean
156 */
157 public static function is_checkout() {
158 return self::is_page_builder( 'checkout', is_checkout() && ! is_wc_endpoint_url() && ! is_order_received_page() );
159 }
160 /**
161 * Single Page builder Detection
162 *
163 * @return boolean
164 */
165 public static function is_product() {
166 return self::is_page_builder( 'product', is_product() );
167 }
168 /**
169 * Builder page detector.
170 *
171 * @param string $type builder Page type.
172 * @param boolean $is_page page status.
173 * @return boolean
174 */
175 public static function is_page_builder( $type, $is_page ) {
176 $builder_id = self::builder_page_id_by_type( $type );
177 $builder_type = self::builder_type( $builder_id );
178 $type_status = $type === $builder_type; // Ticket issue.
179 if ( self::builder_type( get_the_ID() ) === $type || ( $type_status && $is_page ) ) {
180 return true;
181 }
182 return false;
183 }
184
185 /**
186 * Get builder content function
187 *
188 * @param [type] $template_id builder Template id.
189 * @param boolean $with_css with css.
190 * @return mixed
191 */
192 public static function get_builder_content( $template_id, $with_css = false ) {
193 return \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( $template_id, $with_css );
194 }
195
196 /**
197 * Page builder Page for.
198 *
199 * @return array
200 */
201 public static function default_layout() {
202 $demo_root_url = 'https://shopbuilderwp.com';
203 $page_layout = [
204 'default' => [
205 [
206 'text_label' => __( 'Blank', 'shopbuilder' ),
207 'image' => rtsb()->get_assets_uri( 'images/layout-preview/placeholder.png' ),
208 ],
209 ],
210 'product' => [
211 [
212 'text_label' => __( 'Product Layout 1', 'shopbuilder' ),
213 'image' => rtsb()->get_assets_uri( 'images/layout-preview/product-single-demo-1.jpg' ),
214 'live_preview' => $demo_root_url . '/rtsb-template/product-single-demo-1/',
215 'import_file' => '/sample-layout/products/product-single-demo-1.json',
216 ],
217 [
218 'text_label' => __( 'Product Layout 2', 'shopbuilder' ),
219 'image' => rtsb()->get_assets_uri( 'images/layout-preview/product-single-demo-2.jpg' ),
220 'live_preview' => $demo_root_url . '/rtsb-template/product-single-demo-2',
221 'import_file' => '/sample-layout/products/product-single-demo-2.json',
222 ],
223 [
224 'text_label' => __( 'Product Layout 3', 'shopbuilder' ),
225 'image' => rtsb()->get_assets_uri( 'images/layout-preview/product-single-demo-3.jpg' ),
226 'live_preview' => $demo_root_url . '/rtsb-template/product-single-demo-3/',
227 'import_file' => '/sample-layout/products/product-single-demo-3.json',
228 ],
229 [
230 'text_label' => __( 'Product Layout 4', 'shopbuilder' ),
231 'image' => rtsb()->get_assets_uri( 'images/layout-preview/product-single-demo-4.jpg' ),
232 'live_preview' => $demo_root_url . '/rtsb-template/product-single-demo-4/',
233 'import_file' => '/sample-layout/products/product-single-demo-4.json',
234 ],
235 [
236 'text_label' => __( 'Product Layout 5', 'shopbuilder' ),
237 'image' => rtsb()->get_assets_uri( 'images/layout-preview/product-single-demo-5.jpg' ),
238 'live_preview' => $demo_root_url . '/rtsb-template/product-single-demo-5/',
239 'import_file' => '/sample-layout/products/product-single-demo-5.json',
240 ],
241
242 ],
243 'shop' => [
244 [
245 'text_label' => __( 'Shop – Theme Default', 'shopbuilder' ),
246 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-theme-default.jpg' ),
247 'live_preview' => $demo_root_url . '/shop/',
248 'import_file' => '/sample-layout/shop/shop-theme-default.json',
249 ],
250 [
251 'text_label' => __( 'Shop – Left Sidebar', 'shopbuilder' ),
252 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-left-sidebar.jpg' ),
253 'live_preview' => $demo_root_url . '/rtsb-template/shop-left-sidebar-shop-builder-custom/',
254 'import_file' => '/sample-layout/shop/shop-left-sidebar.json',
255 ],
256 [
257 'text_label' => __( 'Shop - Custom Layout 1', 'shopbuilder' ),
258 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-custom-layout-1.jpg' ),
259 'live_preview' => $demo_root_url . '/rtsb-template/shop-builder-custom-layout-1/',
260 'import_file' => '/sample-layout/shop/shop-custom-layout-1.json',
261 ],
262 [
263 'text_label' => __( 'Shop - Custom Layout 2', 'shopbuilder' ),
264 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-custom-layout-2.jpg' ),
265 'live_preview' => $demo_root_url . '/rtsb-template/shop-builder-custom-layout-2/',
266 'import_file' => '/sample-layout/shop/shop–builder-custom-layout-2.json',
267 ],
268 [
269 'text_label' => __( 'Shop - List View 1', 'shopbuilder' ),
270 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-custom-layout-list-view-1.jpg' ),
271 'live_preview' => $demo_root_url . '/rtsb-template/shop-builder-custom-layout-list-view-1/',
272 'import_file' => '/sample-layout/shop/shop-custom-layout-list-view-1.json',
273 ],
274 [
275 'text_label' => __( 'Shop - List View 2', 'shopbuilder' ),
276 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-custom-layout-list-view-2.jpg' ),
277 'live_preview' => $demo_root_url . '/rtsb-template/shop-builder-custom-layout-list-view-2/',
278 'import_file' => '/sample-layout/shop/shop-custom-layout-list-view-2.json',
279 ],
280 ],
281 'archive' => [
282 [
283 'text_label' => __( 'Archive – Theme Default', 'shopbuilder' ),
284 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-theme-default.jpg' ),
285 'live_preview' => $demo_root_url . '/shop/',
286 'import_file' => '/sample-layout/shop/shop-theme-default.json',
287 ],
288 [
289 'text_label' => __( 'Archive – Left Sidebar', 'shopbuilder' ),
290 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-left-sidebar.jpg' ),
291 'live_preview' => $demo_root_url . '/rtsb-template/shop-left-sidebar-shop-builder-custom/',
292 'import_file' => '/sample-layout/shop/shop-left-sidebar.json',
293 ],
294 [
295 'text_label' => __( 'Archive - Custom Layout 1', 'shopbuilder' ),
296 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-custom-layout-1.jpg' ),
297 'live_preview' => $demo_root_url . '/rtsb-template/shop-builder-custom-layout-1/',
298 'import_file' => '/sample-layout/shop/shop-custom-layout-1.json',
299 ],
300 [
301 'text_label' => __( 'Archive - Custom Layout 2', 'shopbuilder' ),
302 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-custom-layout-2.jpg' ),
303 'live_preview' => $demo_root_url . '/rtsb-template/shop-builder-custom-layout-2/',
304 'import_file' => '/sample-layout/shop/shop–builder-custom-layout-2.json',
305 ],
306 [
307 'text_label' => __( 'Archive - List View 1', 'shopbuilder' ),
308 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-custom-layout-list-view-1.jpg' ),
309 'live_preview' => $demo_root_url . '/rtsb-template/shop-builder-custom-layout-list-view-1/',
310 'import_file' => '/sample-layout/shop/shop-custom-layout-list-view–1.json',
311 ],
312 [
313 'text_label' => __( 'Archive - List View 2', 'shopbuilder' ),
314 'image' => rtsb()->get_assets_uri( 'images/layout-preview/shop-custom-layout-list-view-2.jpg' ),
315 'live_preview' => $demo_root_url . '/rtsb-template/shop-builder-custom-layout-list-view-2/',
316 'import_file' => '/sample-layout/shop/shop-custom-layout-list-view-2.json',
317 ],
318
319 ],
320 'cart' => [
321 [
322 'text_label' => __( 'Cart - View 1', 'shopbuilder' ),
323 'image' => rtsb()->get_assets_uri( 'images/layout-preview/cart-view-1.jpg' ),
324 'live_preview' => $demo_root_url . '/rtsb-template/cart-page-demo-1/',
325 'import_file' => '/sample-layout/cart/cart-view-1.json',
326 ],
327 [
328 'text_label' => __( 'Cart - View 2', 'shopbuilder' ),
329 'image' => rtsb()->get_assets_uri( 'images/layout-preview/cart-view-2.jpg' ),
330 'live_preview' => $demo_root_url . '/rtsb-template/cart-page-demo-2/',
331 'import_file' => '/sample-layout/cart/cart-view-2.json',
332 ],
333 ],
334 'checkout' => [
335 [
336 'text_label' => __( 'Checkout - View 1', 'shopbuilder' ),
337 'image' => rtsb()->get_assets_uri( 'images/layout-preview/checkout-demo-1.jpg' ),
338 'live_preview' => $demo_root_url . '/rtsb-template/checkout-page-layout-1/',
339 'import_file' => '/sample-layout/checkout/checkout-view-1.json',
340 ],
341 [
342 'text_label' => __( 'Checkout - View 2', 'shopbuilder' ),
343 'image' => rtsb()->get_assets_uri( 'images/layout-preview/checkout-demo-2.jpg' ),
344 'live_preview' => $demo_root_url . '/rtsb-template/checkout-page-demo-2/',
345 'import_file' => '/sample-layout/checkout/checkout-view-2.json',
346 ],
347 [
348 'text_label' => __( 'Checkout - View 3', 'shopbuilder' ),
349 'image' => rtsb()->get_assets_uri( 'images/layout-preview/checkout-demo-3.jpg' ),
350 'live_preview' => $demo_root_url . '/rtsb-template/checkout-page-demo-3/',
351 'import_file' => '/sample-layout/checkout/checkout-view-3.json',
352 ],
353 [
354 'text_label' => __( 'Checkout - View 4', 'shopbuilder' ),
355 'image' => rtsb()->get_assets_uri( 'images/layout-preview/checkout-demo-4.jpg' ),
356 'live_preview' => $demo_root_url . '/rtsb-template/checkout-page-demo-4/',
357 'import_file' => '/sample-layout/checkout/checkout-view-4.json',
358 ],
359
360 ],
361 ];
362 $page_layout = apply_filters( 'rtsb/page/default/layout', $page_layout );
363 return $page_layout;
364 }
365
366 }
367