PluginProbe
Vision – Interactive Image Map with Hotspots Builder / 1.6.2
Vision – Interactive Image Map with Hotspots Builder v1.6.2
1.12.2 1.12.1 1.12.0 1.11.0 1.6.0 1.6.1 1.6.2 1.7.1 1.7.2 1.7.3 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.9.0 1.9.1 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 All 33 releases
vision / includes / activator.php

activator.php in Vision – Interactive Image Map with Hotspots Builder 1.6.2, at includes/activator.php

85 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined('ABSPATH') || exit;
3
4 if(!class_exists('Vision_Activator')) :
5
6 class Vision_Activator {
7 public function activate() {
8 require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
9
10 global $wpdb;
11
12 $table = $wpdb->prefix . VISION_PLUGIN_NAME;
13 $sql = "CREATE TABLE {$table} (
14 id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT,
15 title text DEFAULT NULL,
16 slug varchar(200) DEFAULT NULL,
17 active tinyint NOT NULL DEFAULT 1,
18 data longtext DEFAULT NULL,
19 config longtext DEFAULT NULL,
20 author bigint(20) UNSIGNED NOT NULL DEFAULT 0,
21 editor bigint(20) UNSIGNED NOT NULL DEFAULT 0,
22 created datetime NOT NULL,
23 modified datetime NOT NULL,
24 deleted tinyint NOT NULL DEFAULT 0,
25 UNIQUE KEY id (id)
26 )
27 CHARACTER SET utf8mb4,
28 COLLATE utf8mb4_unicode_ci;";
29 dbDelta($sql);
30
31 update_option('vision_db_version', VISION_DB_VERSION, false);
32
33 $this->update_data();
34 if(get_option('vision_activated') == false ) {
35 $this->install_data();
36 }
37 update_option('vision_activated', time(), false);
38 }
39
40 public function update_data() {
41 global $wpdb;
42 $table = $wpdb->prefix . VISION_PLUGIN_NAME;
43
44 $sql = $wpdb->prepare("UPDATE {$table} SET editor=author WHERE editor=%d", 0);
45 $wpdb->query($sql);
46
47 // modify field types
48 $wpdb->query("ALTER TABLE {$table} MODIFY data LONGTEXT");
49 $wpdb->query("ALTER TABLE {$table} MODIFY config LONGTEXT");
50
51 // Add support Emoji
52 $sql = "ALTER TABLE {$table} DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
53 $wpdb->query($sql);
54
55 $sql = "ALTER TABLE {$table} MODIFY title text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
56 $wpdb->query($sql);
57
58 $sql = "ALTER TABLE {$table} MODIFY data longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
59 $wpdb->query($sql);
60
61 $sql = "ALTER TABLE {$table} MODIFY config longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
62 $wpdb->query($sql);
63
64 $sql = "ALTER TABLE {$table} MODIFY slug varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci";
65 $wpdb->query($sql);
66
67 // Add the new column 'deleted"
68 $row = $wpdb->get_results($wpdb->prepare("SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name=%s AND column_name='deleted'", $table));
69 if(empty($row)){
70 $sql = "ALTER TABLE {$table} ADD deleted tinyint NOT NULL DEFAULT 0";
71 $wpdb->query($sql);
72 }
73 }
74
75 public function install_data() {
76 }
77
78 public function check_db() {
79 if(get_option('vision_db_version') != VISION_DB_VERSION ) {
80 $this->activate();
81 }
82 }
83 }
84
85 endif;