PluginProbe ʕ •ᴥ•ʔ
CommerceBird – AI Command Center, ERP Integrations & B2B for WooCommerce (Zoho, Exact Online). / 2.3.10
CommerceBird – AI Command Center, ERP Integrations & B2B for WooCommerce (Zoho, Exact Online). v2.3.10
3.0.3 3.0.2 3.0.1 trunk 2.2.14 2.2.15 2.2.16 2.2.17 2.2.18 2.2.19 2.3.0 2.3.1 2.3.10 2.3.11 2.3.12 2.3.13 2.3.14 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5.0 2.5.1 2.5.2 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.6.5 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.7.91 2.7.92 2.7.93 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.9.0 2.9.1 2.9.2 2.9.3 3.0.0
commercebird / includes / classes / class-plugin.php
commercebird / includes / classes Last commit date
apis 1 year ago purchase-orders 1 year ago zoho-crm 1 year ago zoho-inventory 1 year ago class-api-handler-zoho.php 1 year ago class-auth-zoho.php 1 year ago class-common.php 1 year ago class-plugin.php 1 year ago class-wc-api.php 1 year ago index.php 1 year ago
class-plugin.php
183 lines
1 <?php
2
3 namespace CommerceBird;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 require_once ABSPATH . 'wp-admin/includes/upgrade.php';
10
11 use CommerceBird\Admin\Actions\Ajax\ExactOnlineAjax;
12 use CommerceBird\Admin\Actions\Ajax\ZohoInventoryAjax;
13 use CommerceBird\Admin\Actions\Ajax\ZohoCRMAjax;
14 use CommerceBird\Admin\Actions\Ajax\AcfAjax;
15 use CommerceBird\Admin\Template;
16 use CommerceBird\Admin\Cmbird_Acf;
17 use CommerceBird\Cmbird_WC_API;
18 use CMBIRD_Purchase_Orders_Automation;
19
20 class Plugin {
21
22
23 public function __construct() {
24 add_action( 'admin_init', array( $this, 'init' ) );
25 }
26
27 public static function activate() {
28 // create log table
29 // global $wpdb;
30 // $charset_collate = $wpdb->get_charset_collate();
31 // $zi_product_log_table = "{$wpdb->prefix}cmbird_zi_product_error";
32 // $zi_create_sql = "CREATE TABLE $zi_product_log_table ( ID bigint(20) PRIMARY KEY auto_increment, product_id bigint(20) NOT NULL, error_message TEXT NOT NULL, sync_timestamp VARCHAR(20) NOT NULL, status int(10) NOT NULL )$charset_collate;";
33 // dbDelta( $zi_create_sql );
34 }
35
36 public static function deactivate() {
37 wp_clear_scheduled_hook( 'zi_execute_import_sync' );
38 wp_clear_scheduled_hook( 'cmbird_eo_get_payment_statuses' );
39 wp_clear_scheduled_hook( 'cmbird_exact_online_sync_orders' );
40 wp_clear_scheduled_hook( 'cmbird_zoho_sync_category_cron' );
41 wp_clear_scheduled_hook( 'cmbird_zoho_contact_sync' );
42 }
43
44 public static function uninstall() {
45 $post_meta_keys = array(
46 'zi_item_id',
47 'zi_purchase_account_id',
48 'zi_account_id',
49 'zi_account_name',
50 'zi_inventory_account_id',
51 'zi_salesorder_id',
52 'zi_category_id',
53 '_cost_price',
54 'eo_item_id',
55 );
56 $user_meta_keys = array(
57 'zi_contact_id',
58 'zi_primary_contact_id',
59 'zi_created_time',
60 'zi_last_modified_time',
61 'zi_billing_address_id',
62 'zi_shipping_address_id',
63 'zi_contact_persons_id',
64 'zi_currency_id',
65 'zi_currency_code',
66 'eo_contact_id',
67 'eo_account_id',
68 'eo_gl_account',
69 );
70 $zi_option_keys = array(
71 'cmbird_zi_webhook_password',
72 'cmbird_zoho_inventory_cron_class',
73 'cmbird_zoho_sync_status',
74 'cmbird_zoho_item_category',
75 'cmbird_zoho_stock_sync_status',
76 'cmbird_zoho_item_name_sync_status',
77 'cmbird_zoho_enable_auto_no_status',
78 'cmbird_zoho_product_sync_status',
79 'cmbird_zoho_disable_image_sync_status',
80 'cmbird_zoho_disable_price_sync_status',
81 'cmbird_zoho_disable_name_sync_status',
82 'cmbird_zoho_disable_description_sync_status',
83 'cmbird_zoho_enable_accounting_stock_status',
84 'cmbird_zoho_enable_order_status',
85 'cmbird_wootozoho_custom_fields',
86 'cmbird_zoho_pricelist_id',
87 'cmbird_zoho_location_id_status',
88 'cmbird_zoho_inventory_auth_code',
89 'cmbird_zoho_inventory_access_token',
90 'cmbird_zoho_inventory_refresh_token',
91 'cmbird_zoho_inventory_timestamp',
92 'cmbird_zoho_inventory_oid',
93 'cmbird_zoho_inventory_url',
94 'cmbird_zoho_inventory_cid',
95 'cmbird_zoho_inventory_cs',
96 'cmbird_zoho_inventory_domain',
97 'cmbird_authorization_redirect_uri',
98 'cmbird_zoho_crm_auth_code',
99 'cmbird_zoho_crm_access_token',
100 'cmbird_zoho_crm_refresh_token',
101 'cmbird_zoho_crm_timestamp',
102 'cmbird_location_data',
103 );
104
105 foreach ( $zi_option_keys as $zi_option ) {
106 delete_option( $zi_option );
107 }
108
109 foreach ( $post_meta_keys as $post_key ) {
110 delete_post_meta_by_key( $post_key );
111 }
112
113 $users = get_users(
114 array(
115 'fields' => array( 'ID' ),
116 )
117 );
118 foreach ( $users as $user_id ) {
119 foreach ( $user_meta_keys as $user_key ) {
120 delete_user_meta( $user_id, $user_key );
121 }
122 }
123 // deleting mapped categories
124 global $wpdb;
125 $table_name = $wpdb->prefix . 'options';
126 $sql = $wpdb->get_results( $wpdb->prepare( 'SELECT * FROM %s WHERE option_name LIKE %s', $table_name, '%zoho_id_for_term_id_%' ) );
127 foreach ( $sql as $key => $row ) {
128 $option_name = $row->option_name;
129 $wpdb->delete( $table_name, array( 'option_name' => $option_name ), array( '%s' ) );
130 }
131 // clear scheduled zcrm_refresh_token
132 wp_clear_scheduled_hook( 'zcrm_refresh_token' );
133 }
134
135 public static function init() {
136 if ( is_admin() ) {
137 $php_min_version = '8.2';
138 $php_current_version = phpversion();
139
140 if ( version_compare( $php_min_version, $php_current_version, '>' ) ) {
141 $error_message = sprintf( 'Your server is running PHP version %s but the commercebird plugin requires at least PHP %s. Please update your PHP version.', $php_current_version, $php_min_version, );
142 wp_die(
143 esc_html( $error_message ),
144 'Plugin Activation Error',
145 array(
146 'response' => 200,
147 'back_link' => true,
148 )
149 );
150 }
151 $zoho_inventory_access_token = get_option( 'cmbird_zoho_inventory_access_token' );
152 // remove option zoho_inventory_access_token if it contains only one character
153 if ( $zoho_inventory_access_token && strlen( $zoho_inventory_access_token ) === 1 ) {
154 delete_option( 'cmbird_zoho_inventory_access_token' );
155 } else {
156 // schedule cronjob for import sync
157 $interval = get_option( 'zi_cron_interval' );
158 if ( 'none' !== $interval && ! empty( $zoho_inventory_access_token ) ) {
159 if ( ! wp_next_scheduled( 'zi_execute_import_sync' ) ) {
160 wp_schedule_event( time(), $interval, 'zi_execute_import_sync' );
161 }
162 } else {
163 wp_clear_scheduled_hook( 'zi_execute_import_sync' );
164 }
165 }
166 // create webhook password if does not exists.
167 if ( ! get_option( 'cmbird_zi_webhook_password', false ) ) {
168 add_option( 'cmbird_zi_webhook_password', password_hash( 'commercebird-zi-webhook-token', PASSWORD_BCRYPT ) );
169 }
170 Template::instance();
171 ZohoInventoryAjax::instance();
172 ZohoCRMAjax::instance();
173 AcfAjax::instance();
174 }
175 ExactOnlineAjax::instance();
176 if ( class_exists( 'ACF' ) ) {
177 Cmbird_Acf::instance();
178 }
179 new Cmbird_WC_API();
180 new CMBIRD_Purchase_Orders_Automation();
181 }
182 }
183