<?php // Creating tables in Single site installations function on_activate() { create_table(); } function create_table() { global $wpdb; $table_name = $wpdb->prefix . 'table_name'; if( $wpdb->get_var( "show tables like '{$table_name}'" ) != $table_name ) { $sql = "CREATE TABLE " . $table_name . " ( id mediumint(9) NOT NULL AUTO_INCREMENT, col VARCHAR(100) NOT NULL, PRIMARY KEY (id) );"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql ); add_option( EmailLog::DB_OPTION_NAME, EmailLog::DB_VERSION ); } } register_activation_hook( __FILE__, 'on_activate' ); ?>