PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.4.0
ShopBuilder – WooCommerce Builder For Elementor v3.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
← All changes | app/Helpers/Installation.php +69 -19 2.1.13.4.0 View file →
@@ -1,24 +1,42 @@
1 1 <?php
2 +/**
3 + * Activation Helpers class
4 + *
5 + * @package RadiusTheme\SB
6 + */
2 7
3 8 namespace RadiusTheme\SB\Helpers;
4 9
5 -// Do not allow directly accessing this file.
10 +use WC_Product_Simple;
11 +use RadiusTheme\SB\Models\Settings;
6 12 use RadiusTheme\SB\Models\ExtraSettings;
7 -use RadiusTheme\SB\Models\Settings;
8 13
14 +// Do not allow directly accessing this file.
9 15 if ( ! defined( 'ABSPATH' ) ) {
10 16 exit( 'This script cannot be accessed directly.' );
11 17 }
12 18
19 +/**
20 + * Activation Helpers class
21 + */
13 22 class Installation {
14 -
23 + /**
24 + * Init.
25 + *
26 + * @return void
27 + */
15 28 public static function init() {
16 29 add_action( 'init', [ __CLASS__, 'check_version' ], 5 );
17 30 }
18 31
32 + /**
33 + * Check version.
34 + *
35 + * @return int|void
36 + */
19 37 public static function check_version() {
20 - $version = ExtraSettings::instance()->get_option( 'rtsb_version' ) ?? get_option( 'rtsb_version' );
38 + $version = ExtraSettings::instance()->get_option( 'rtsb_version', '' ) ?? get_option( 'rtsb_version' );
21 39 if ( version_compare( $version, RTSB_VERSION, '<' ) ) {
22 40 if ( ! $version ) {
23 41 self::set_default_options();
24 42 if ( ! Fns::get_product() ) {
@@ -28,13 +46,18 @@
28 46 self::update_rtsb_version();
29 47 }
30 48 }
31 49
50 + /**
51 + * Activation.
52 + *
53 + * @return void
54 + */
32 55 public static function activate() {
33 56 if ( ! is_blog_installed() ) {
34 57 return;
35 58 }
36 - // flush_rewrite_rules();
59 +
37 60 if ( ExtraSettings::instance()->get_option( 'first_instilled_version', false ) ) {
38 61 ExtraSettings::instance()->set_option( 'first_instilled_version', RTSB_VERSION );
39 62 }
40 63
@@ -51,30 +74,61 @@
51 74 set_transient( 'rtsb_installing', 'yes', MINUTE_IN_SECONDS * 10 );
52 75 delete_transient( 'rtsb_installing' );
53 76 }
54 77
78 + /**
79 + * Update version.
80 + *
81 + * @return void
82 + */
55 83 private static function update_rtsb_version() {
56 - // update_option( 'rtsb_version', RTSB_VERSION );
57 84 ExtraSettings::instance()->set_option( 'rtsb_version', RTSB_VERSION );
58 85 }
59 86
87 + /**
88 + * Deactivation.
89 + *
90 + * @return void
91 + */
60 92 public static function deactivation() {
61 93 delete_option( 'shopbuilder_permalinks_flushed' );
94 + self::clear_scheduled_events();
62 95 }
63 -
96 + /**
97 + * Clear Scheduled Events
98 + *
99 + * @return void
100 + */
101 + public static function clear_scheduled_events() {
102 + $schedule = get_option( 'rtsb_cron_schedule_free', [] );
103 + if ( empty( $schedule ) ) {
104 + return;
105 + }
106 + foreach ( $schedule as $v ) {
107 + wp_clear_scheduled_hook( $v );
108 + }
109 + }
110 + /**
111 + * Set default options.
112 + *
113 + * @return void
114 + */
64 115 public static function set_default_options() {
65 116 $sections = Settings::instance()->get_sections();
66 117 foreach ( $sections as $sections_id => $section ) {
67 - $rawOptions = [];
68 118 if ( ! empty( $section['list'] ) ) {
69 119 foreach ( $section['list'] as $blocks_id => $blocks ) {
120 + $rawOptions = [];
70 121 if ( ! rtsb()->has_pro() && 'free' !== ( $blocks['package'] ?? '' ) ) {
71 122 continue;
72 123 }
73 124 $rawOptions['active'] = $blocks['active'] ?? null;
74 - foreach ( $blocks['fields'] as $field_id => $field ) {
75 - $type = 'array' === gettype( $field['value'] ) ? [] : '';
76 - $rawOptions[ $field_id ] = ! empty( $field['value'] ) ? $field['value'] : $type;
125 +
126 + if ( ! empty( $blocks['fields'] ) ) {
127 + foreach ( $blocks['fields'] as $field_id => $field ) {
128 + $type = 'array' === gettype( $field['value'] ) ? [] : '';
129 + $rawOptions[ $field_id ] = ! empty( $field['value'] ) ? $field['value'] : $type;
130 + }
77 131 }
78 132 Fns::set_options( $sections_id, $blocks_id, $rawOptions );
79 133 }
80 134 }
@@ -81,14 +135,14 @@
81 135 }
82 136 }
83 137
84 138 /**
139 + * Create product.
140 + *
85 141 * @return int
86 - * @throws \WC_Data_Exception
87 142 */
88 143 public static function create_wc_product() {
89 -
90 - $product = new \WC_Product_Simple();
144 + $product = new WC_Product_Simple();
91 145 $product->set_name( 'Confirm at least one product is created before deleting' );
92 146 $product->set_description( 'This is a ShopBuilder demo preview product' );
93 147 $product->set_short_description( 'This is a ShopBuilder product' );
94 148 $product->set_status( 'draft' );
@@ -96,12 +150,8 @@
96 150 $product->set_regular_price( 50 );
97 151 $product->set_sale_price( 49 );
98 152 $product->set_price( 49 );
99 153
100 - $product->set_sku( 'SAMPLE-001' );
101 -
102 - $product->set_manage_stock( false );
103 - $product->set_stock_status( 'instock' );
104 -
154 + $product->set_sku( '' );
105 155 return $product->save();
106 156 }
107 157 }