Last active
February 3, 2021 17:39
-
-
Save wpmu-authors/9a1d4757d023f2442093a9a158cdb6b4 to your computer and use it in GitHub Desktop.
create-tables.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global $jal_db_version; | |
$jal_db_version = '1.0'; | |
function jal_install() { | |
global $wpdb; | |
global $jal_db_version; | |
$table_name = $wpdb->prefix . 'liveshoutbox'; | |
$charset_collate = $wpdb->get_charset_collate(); | |
$sql = "CREATE TABLE $table_name ( | |
id mediumint(9) NOT NULL AUTO_INCREMENT, | |
time datetime DEFAULT '0000-00-00 00:00:00' NOT NULL, | |
name tinytext NOT NULL, | |
text text NOT NULL, | |
url varchar(55) DEFAULT '' NOT NULL, | |
UNIQUE KEY id (id) | |
) $charset_collate;"; | |
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); | |
dbDelta( $sql ); | |
add_option( 'jal_db_version', $jal_db_version ); | |
} | |
function jal_install_data() { | |
global $wpdb; | |
$welcome_name = 'Mr. WordPres'; | |
$welcome_text = 'Congratulations, you just completed the installation!'; | |
$table_name = $wpdb->prefix . 'liveshoutbox'; | |
$wpdb->insert( | |
$table_name, | |
array( | |
'time' => current_time( 'mysql' ), | |
'name' => $welcome_name, | |
'text' => $welcome_text, | |
) | |
); | |
} | |
register_activation_hook( __FILE__, 'jal_install' ); | |
register_activation_hook( __FILE__, 'jal_install_data' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment