PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.4.0
ShopBuilder – WooCommerce Builder For Elementor v2.4.0
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 / Modules / Compare / CompareInstaller.php

CompareInstaller.php in ShopBuilder – WooCommerce Builder For Elementor 2.4.0, at app/Modules/Compare/CompareInstaller.php

68 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace RadiusTheme\SB\Modules\Compare;
4
5 use RadiusTheme\SB\Helpers\Fns;
6
7 // Do not allow directly accessing this file.
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit( 'This script cannot be accessed directly.' );
10 }
11
12
13 class CompareInstaller {
14
15 /**
16 * Run the installer
17 *
18 * @return void
19 */
20 public function run() {
21 $this->create_page();
22 }
23
24 /**
25 * [create_page] Create page
26 *
27 * @return void [void]
28 */
29 private function create_page() {
30
31 $page_id = Fns::get_option( 'modules', 'compare', 'page', 0, 'number' );
32 if ( $page_id > 0 ) {
33 $page_object = get_post( $page_id );
34
35 if ( $page_object && 'page' === $page_object->post_type && ! in_array(
36 $page_object->post_status,
37 [
38 'pending',
39 'trash',
40 'future',
41 'auto-draft',
42 ],
43 true
44 ) ) {
45 // Valid page is already in place.
46 return;
47 }
48 }
49 if ( function_exists( 'WC' ) ) {
50 if ( ! function_exists( 'wc_create_page' ) ) {
51 require_once WC_ABSPATH . '/includes/admin/wc-admin-functions.php';
52 }
53 $create_page_id = wc_create_page(
54 sanitize_title_with_dashes( _x( 'compare', 'page_slug', 'shopbuilder' ) ),
55 '',
56 esc_html__( 'Compare', 'shopbuilder' ),
57 '<!-- wp:shortcode -->[rtsb_compare_list]<!-- /wp:shortcode -->'
58 );
59 if ( $create_page_id ) {
60 $section_items = [];
61 $section_items['page'] = strval( $create_page_id );
62 Fns::set_options( 'modules', 'compare', $section_items );
63
64 }
65 }
66 }
67 }
68