-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiceberg-crm-callback.php
62 lines (51 loc) · 2.22 KB
/
iceberg-crm-callback.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/*
Plugin Name: Iceberg CRM Callback
Description: Hey there! This is the ICEBERG crm reference!
Contributors: iceberg group
Author: Iceberg Group
Author URI: https://iceberg-crm.ru
Version: 0.1.0
*/
require_once plugin_dir_path( __FILE__ ) . 'themes/remote_params.php';
require_once plugin_dir_path( __FILE__ ) . 'admin/iceberg_crm_callback_admin_func.php';
require_once plugin_dir_path( __FILE__ ) . 'views/iceberg_crm_callback_views.php';
function iceberg_crm_callback_install() {
global $wpdb;
$table_name = $wpdb->prefix . 'iceberg_crm_callback_tokens';
$charset_collate = $wpdb->get_charset_collate();
if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
$sql = "CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT,
token text NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );
}
$table_name = $wpdb->prefix . 'iceberg_crm_callback_links';
$charset_collate = $wpdb->get_charset_collate();
if ($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
$sql = "CREATE TABLE $table_name (
id mediumint(9) NOT NULL AUTO_INCREMENT,
link text NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );
}
}
function iceberg_crm_callback_uninstall() {
global $wpdb;
$table_name = $wpdb->prefix . 'iceberg_crm_callback_tokens';
$wpdb->query("DROP TABLE IF EXISTS $table_name");
$table_name = $wpdb->prefix . 'iceberg_crm_callback_links';
$wpdb->query("DROP TABLE IF EXISTS $table_name");
}
add_action('admin_menu', 'add_iceberg_crm_callback_menu_page');
add_action('admin_init', 'iceberg_crm_callback_add_token_form_section_callback');
add_action('admin_init', 'iceberg_crm_callback_handle_token_authentication_callback');
add_action( 'wp_enqueue_scripts', 'iceberg_crm_callback_enqueue_scripts' );
add_action( 'wp_footer', 'iceberg_crm_callback_widget' );
register_activation_hook( __FILE__, 'iceberg_crm_callback_install' );
register_deactivation_hook( __FILE__, 'iceberg_crm_callback_uninstall' );