PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.1.13
ShopBuilder – WooCommerce Builder For Elementor v2.1.13
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 +54 -12 2.1.12.1.13 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,31 +74,49 @@
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' );
62 94 }
63 95
96 + /**
97 + * Set default options.
98 + *
99 + * @return void
100 + */
64 101 public static function set_default_options() {
65 102 $sections = Settings::instance()->get_sections();
66 103 foreach ( $sections as $sections_id => $section ) {
67 - $rawOptions = [];
68 104 if ( ! empty( $section['list'] ) ) {
69 105 foreach ( $section['list'] as $blocks_id => $blocks ) {
106 + $rawOptions = [];
70 107 if ( ! rtsb()->has_pro() && 'free' !== ( $blocks['package'] ?? '' ) ) {
71 108 continue;
72 109 }
73 110 $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;
111 +
112 + if ( ! empty( $blocks['fields'] ) ) {
113 + foreach ( $blocks['fields'] as $field_id => $field ) {
114 + $type = 'array' === gettype( $field['value'] ) ? [] : '';
115 + $rawOptions[ $field_id ] = ! empty( $field['value'] ) ? $field['value'] : $type;
116 + }
77 117 }
118 +
78 119 Fns::set_options( $sections_id, $blocks_id, $rawOptions );
79 120 }
80 121 }
81 122 }
@@ -81,14 +122,15 @@
81 122 }
82 123 }
83 124
84 125 /**
126 + * Create product.
127 + *
85 128 * @return int
86 - * @throws \WC_Data_Exception
87 129 */
88 130 public static function create_wc_product() {
89 131
90 - $product = new \WC_Product_Simple();
132 + $product = new WC_Product_Simple();
91 133 $product->set_name( 'Confirm at least one product is created before deleting' );
92 134 $product->set_description( 'This is a ShopBuilder demo preview product' );
93 135 $product->set_short_description( 'This is a ShopBuilder product' );
94 136 $product->set_status( 'draft' );