<?php

/**
 * Fired during plugin activation
 *
 * @link       https://wpconfiguratorbuilder.com/
 * @since      1.0.0
 *
 * @package    wcb-configurator-builder
 * @subpackage wcb-configurator-builder/includes
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Fired during plugin activation.
 *
 * This class defines all code necessary to run during the plugin's activation.
 *
 * @since      1.0.0
 * @package    wcb-configurator-builder
 * @subpackage wcb-configurator-builder/includes
 * @author     WPCB <support@wpconfiguratorbuilder.com>
 */
class WPCB_Activator {

	/**
	 * Short Description. (use period)
	 *
	 * Long Description.
	 *
	 * @since    1.0.0
	 */
	public static function activate() {

		$upload_dir = wp_get_upload_dir();
		$base_dir   = $upload_dir['basedir'];
		
		$save_path  = $base_dir . WPCB_UPLOAD_DIR;
        if ( ! file_exists( $save_path ) ) {
           	mkdir( $save_path, 0777, true );
		}

		$temp_path  = $base_dir . WPCB_UPLOAD_TEMP_DIR;
        if ( ! file_exists( $temp_path ) ) {
            mkdir( $temp_path, 0777, true );
		}

		update_option( 'wpcb_new_install', 'true' );

		// Set defaults.
		if ( ! get_option( '_wpcb_configuration_visual_type' ) ) {
			update_option( '_wpcb_configuration_visual_type', 'image' );
		}

		if ( ! get_option( '_wpcb_panel_view_type' ) ) {
			update_option( '_wpcb_panel_view_type', 'panel' );
		}

		if ( ! get_option( '_wpcb_border_style' ) ) {
			update_option( '_wpcb_border_style', 'rounded' );
		}

		if ( ! get_option( '_wpcb_show_values_inline' ) ) {
			update_option( '_wpcb_show_values_inline', 'no' );
		}
	}
}
