hesabixWCPlugin/includes/class-hesabix-activator.php

57 lines
2.2 KiB
PHP
Raw Normal View History

2025-08-05 17:24:52 +03:30
<?php
/**
* Hesabix Activator Class
*
* @package Hesabix
* @author Mohammad Rezai
* @author URI https://pirouz.xyz
* @since 1.0.0
*/
class Hesabix_Activator {
public static $hesabix_db_version = '1.1';
public static function activate() {
add_option('hesabix_webhook_password', bin2hex(openssl_random_pseudo_bytes(16)));
add_option('hesabix_last_log_check_id', 0);
add_option('hesabix_live_mode', 0);
add_option('hesabix_debug_mode', 0);
add_option('hesabix_contact_address_status', 1);
add_option('hesabix_contact_node_family', __('Online Store Customers', 'hesabix'));
add_option('hesabix_contact_automaatic_save_node_family', 'yes');
add_option('hesabix_contact_automatically_save_in_hesabix', 'yes');
add_option('hesabix_activation_date', date("Y-m-d"));
add_option('hesabix_use_export_product_opening_quantity', false);
add_option('hesabix_business_expired', 0);
add_option('hesabix_do_not_submit_product_automatically', "no");
add_option('hesabix_do_not_update_product_price_in_hesabix', "no");
add_option('hesabix_contact_add_additional_checkout_fields_hesabix', 1);
add_option('hesabix_show_product_code_in_products_page', "yes");
add_option('hesabix_show_hesabix_code_in_excel_export', "yes");
self::hesabix_create_database_table();
}
public static function hesabix_create_database_table()
{
global $wpdb;
$table_name = $wpdb->prefix . "hesabix";
$charset_collate = $wpdb->get_charset_collate();
$sql = "
CREATE TABLE $table_name (
id int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
obj_type varchar(32) NOT NULL,
id_hesabix int(11) UNSIGNED NOT NULL,
id_ps int(11) UNSIGNED NOT NULL,
id_ps_attribute int(11) UNSIGNED NOT NULL DEFAULT 0,
uid_hesabix int(11) UNSIGNED NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
update_option('hesabix_db_version', self::$hesabix_db_version);
}
}