| 1 |
<?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?> |
| 2 |
<?php |
| 3 |
|
| 4 |
global $wpdb; |
| 5 |
$charset_collate = $wpdb->get_charset_collate(); |
| 6 |
require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); // Require to use dbDelta |
| 7 |
include('settings.php'); // Load the files to get the databse info |
| 8 |
|
| 9 |
// ============================================================== |
| 10 |
// install the plugin for the first time |
| 11 |
// ============================================================== |
| 12 |
|
| 13 |
// Making sure the table we want to create don't exists |
| 14 |
if( $wpdb->get_var("SHOW TABLES LIKE '{$table_name}' ") != $table_name ) { |
| 15 |
|
| 16 |
$sql = "CREATE TABLE " . $table_name . "( |
| 17 |
id INTEGER(11) UNSIGNED AUTO_INCREMENT, |
| 18 |
page_post_id INTEGER(11), |
| 19 |
notes TEXT, |
| 20 |
PRIMARY KEY (id) |
| 21 |
) $charset_collate;"; |
| 22 |
|
| 23 |
dbDelta($sql); |
| 24 |
|
| 25 |
} // if( $wpdb->get_var("SHOW TABLES LIKE '{$table_name}' ") != $table_name ) { |
| 26 |
|