get_charset_collate(); // Define table names with prefixes $rounds_predictions_table = $wpdb->prefix . ACPGC_PREFIX . 'rounds_predictions'; $rounds_user_score_table = $wpdb->prefix . ACPGC_PREFIX . 'rounds_user_scores'; $league_invites_table = $wpdb->prefix . ACPGC_PREFIX . 'league_invites'; // Check if the rounds_predictions table exists if ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $rounds_predictions_table)) != $rounds_predictions_table) { // SQL for creating the rounds_predictions table $sql = "CREATE TABLE `$rounds_predictions_table` ( `id` int(11) NOT NULL auto_increment, `user_id` int(11) NOT NULL, `rounds_prediction_round_id` int(11) NOT NULL, `rounds_prediction_question_id` int(11) NOT NULL, `rounds_prediction_choice_id` int(11) NOT NULL, `created_at` timestamp NOT NULL, `updated_at` timestamp NOT NULL, PRIMARY KEY (`id`) ) $charset_collate;"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql ); } // Check if the rounds_user_score table exists if ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $rounds_user_score_table)) != $rounds_user_score_table) { // SQL for creating the rounds_user_score table $sql = "CREATE TABLE `$rounds_user_score_table` ( `id` int(11) NOT NULL auto_increment, `user_id` int(11) NOT NULL, `rounds_user_score_round_id` int(11) NOT NULL, `rounds_user_score_value` int(11) NOT NULL, `created_at` timestamp NOT NULL, `updated_at` timestamp NOT NULL, PRIMARY KEY (`id`) ) $charset_collate;"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql ); } // Check if the league_invites table exists if ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $league_invites_table)) != $league_invites_table) { // SQL for creating the league_invites table $sql = "CREATE TABLE `$league_invites_table` ( `id` int(11) NOT NULL auto_increment, `league_id` int(11) NOT NULL, `invite_token` varchar(55) NOT NULL, `email` varchar(100) NOT NULL, `created_at` timestamp NOT NULL, `updated_at` timestamp NOT NULL, PRIMARY KEY (`id`) ) $charset_collate;"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); dbDelta( $sql ); } } /** * * Load the plugin * */ add_action( 'plugins_loaded', 'acpgc_load', 10, 0 ); function acpgc_load(){ new ACPGC_predictionGame(); }