function create_custom_tables(){

global $table_prefix, $wpdb;

$charset_collate = $wpdb->get_charset_collate();
$tblname = 'wp_dictionary_category';
$wp_dictionary_category_table = $table_prefix . "$tblname ";

#Check to see if the table exists already, if not, then create it
if($wpdb->get_var( "show tables like '$wp_track_table'" ) != $wp_dictionary_category_table)
{
$sql = "CREATE TABLE $wp_dictionary_category_table (
id mediumint(9) NOT NULL AUTO_INCREMENT,
category_name CHAR(255),
category_slug CHAR(255),
UNIQUE KEY id (id)
) $charset_collate;";
require_once(ABSPATH . '/wp-admin/upgrade-functions.php');
dbDelta($sql);
}
}
register_activation_hook( __FILE__, 'create_custom_tables' );

Advertisements