# shopbuilder/2.0.1/app/Helpers/Installation.php

ShopBuilder – WooCommerce Builder For Elementor, version 2.0.1. 70 lines.

- Page: https://pluginprobe.com/plugins/shopbuilder/2.0.1/code/app/Helpers/Installation.php
- Raw: https://pluginprobe.com/plugins/shopbuilder/2.0.1/raw/app/Helpers/Installation.php
- Modified: 2023-11-13T05:30:08+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/shopbuilder/2.0.1/code/app/Helpers/Installation.php#L10-L20`.

```php
<?php

namespace RadiusTheme\SB\Helpers;

// Do not allow directly accessing this file.
use RadiusTheme\SB\Models\DataModel;
use RadiusTheme\SB\Models\Settings;

if ( ! defined( 'ABSPATH' ) ) {
	exit( 'This script cannot be accessed directly.' );
}

class Installation {

    public static function init(){
        add_action( 'init', [ __CLASS__, 'check_version' ], 5 );
    }

    public static function check_version() {
        if ( version_compare( get_option( 'rtsb_version' ), RTSB_VERSION, '<' ) ) {
	        if ( ! get_option( 'rtsb_version' ) ) {
		        self::set_default_options();
	        }
	        self::update_rtsb_version();
        }
    }

	public static function activate() {
        if ( ! is_blog_installed() ) {
            return;
        }

        // Check if we are not already running this routine.
        if ( 'yes' === get_transient( 'rtsb_installing' ) ) {
            return;
        }

        // If we made it till here nothing is running yet, lets set the transient now.
        set_transient( 'rtsb_installing', 'yes', MINUTE_IN_SECONDS * 10 );
		delete_transient( 'rtsb_installing' );
	}

    private static function update_rtsb_version() {
         update_option( 'rtsb_version', RTSB_VERSION );
    }

	public static function deactivation() { }

    public static function set_default_options(){
        $sections = Settings::instance()->get_sections();
        foreach ( $sections as $sections_id  => $section ) {
            $rawOptions = [];
            if ( ! empty( $section['list'] ) ) {
                foreach ( $section['list'] as $blocks_id  => $blocks) {
					if( ! rtsb()->has_pro() && 'free' !== ( $blocks['package'] ?? '' ) ){
						continue;
					}
					$rawOptions['active'] = $blocks['active'] ?? null;
	                foreach ( $blocks['fields'] as $field_id  => $field ) {
                        $type = 'array' === gettype( $field['value'] ) ? [] : '' ;
                        $rawOptions[$field_id] = ! empty( $field['value'] ) ? $field['value'] : $type;
                    }
                    Fns::set_options( $sections_id, $blocks_id, $rawOptions );
                }
            }
        }
    }


}
```
