有人可以帮我弄清楚为什么当我激活我的插件时 wordpress 没有创建“wp_locations”表。
global $wp_locations_version;
$wp_locations_version = "1.1";
define( 'LOCATIONURL', plugins_url().'/wp_locations' );
function locations_install() {
global $wpdb;
global $wp_locations_version;
$sql = "CREATE TABLE IF NOT EXISTS wp_locations (
ID BIGINT NOT NULL AUTO_INCREMENT,
location VARCHAR(100) NOT NULL,
address VARCHAR(255) NOT NULL,
lattitude INT,
longitude INT,
description MEDIUMTEXT NULL,
person VARCHAR(50) NOT NULL,
personimg VARCHAR(255) NOT NULL,
email VARCHAR(255) NULL,
phone INT,
sort INT
);";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
add_option("wp_locations_version", $wp_locations_version);
}
register_activation_hook( __FILE__ , 'locations_install' );