PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.0.0
ShopBuilder – WooCommerce Builder For Elementor v2.0.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 / WishList / WishlistInstaller.php

WishlistInstaller.php in ShopBuilder – WooCommerce Builder For Elementor 2.0.0, at app/Modules/WishList/WishlistInstaller.php

62 lines 1.5 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\WishList;
4
5 use RadiusTheme\SB\Helpers\Fns;
6 use RadiusTheme\SB\Models\DataModel;
7
8 // Do not allow directly accessing this file.
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit( 'This script cannot be accessed directly.' );
11 }
12
13 class WishlistInstaller {
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', 'wishlist', '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( $page_object->post_status, [
36 'pending',
37 'trash',
38 'future',
39 'auto-draft'
40 ], true ) ) {
41 // Valid page is already in place.
42 return;
43 }
44 }
45 if ( function_exists( 'WC' ) ) {
46 if ( ! function_exists( 'wc_create_page' ) ) {
47 require_once WC_ABSPATH . '/includes/admin/wc-admin-functions.php';
48 }
49 $create_page_id = wc_create_page(
50 sanitize_title_with_dashes( _x( 'wishlist', 'page_slug', 'shopbuilder' ) ),
51 '',
52 esc_html__( 'Wishlist', 'shopbuilder' ),
53 '<!-- wp:shortcode -->[rtsb_wishlist]<!-- /wp:shortcode -->'
54 );
55 if ( $create_page_id ) {
56 $section_items = DataModel::source()->get_option( 'modules', [] );
57 $section_items['wishlist']['page'] = strval( $create_page_id );
58 DataModel::source()->set_option( 'modules', $section_items );
59 }
60 }
61 }
62 }