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

ShopBuilder – WooCommerce Builder For Elementor, version 1.1.4. 73 lines.

- Page: https://pluginprobe.com/plugins/shopbuilder/1.1.4/code/app/Helpers/Installation.php
- Raw: https://pluginprobe.com/plugins/shopbuilder/1.1.4/raw/app/Helpers/Installation.php
- Modified: 2023-07-11T10:48:20+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/1.1.4/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, '<' ) ) {
            self::activate();
        }
    }

	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 );

        if ( ! get_option( 'rtsb_version' ) ) {
            self::set_default_options();
        }

        self::update_rtsb_version();

        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( ! empty( $blocks['active'] ) ){
                        $rawOptions['active'] = $blocks['active'];
                    }
                    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 );
                }
            }
        }
    }


}
```
