get_charset_collate(); if($wpdb->get_var("show tables like '$table_name'") != $table_name) { $sql = "CREATE TABLE wp_moove_activity_log ( id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, post_id bigint(20) UNSIGNED NOT NULL, user_id int(11) DEFAULT NULL, status tinytext, user_ip tinytext, city tinytext, country varchar(255) NOT NULL, post_type tinytext, referer tinytext, campaign_id tinytext, month_year tinytext, display_name tinytext, visit_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY id (id) ) $charset_collate; CREATE TABLE wp_sql (id bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, post_id int(11) NOT NULL, `sql` varchar(4000) NOT NULL, `date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY id (id) ) $charset_collate;"; require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); dbDelta($sql); } } add_action( 'plugins_loaded', 'my_plugin_install' ); Related hooks register_activation_hook ($file, $function) to be run when the plugin is activated register_deactivation_hook ($file, […]">