چطور میتونم چند table هنگام شروع پلاگین بسازم توی mysql ?
function start_plugin()
{
global $wpdb;
$charset_collate = $wpdb->get_charset_collate();
$sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->base_prefix}demo_table` (
id bigint(50) NOT NULL AUTO_INCREMENT,
post_id bigint(20) NOT NULL,
user_id bigint(20),
city varchar(100),
country varchar(100),
PRIMARY KEY (id),
FOREIGN KEY (post_id) REFERENCES wp_posts(ID)
) $charset_collate;";
require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta( $sql );
$is_error = empty( $wpdb->last_error );
return $is_error;
}
register_activation_hook(__FILE__, 'start_plugin');
این کد نوشتم ولی کار نمیکنه