prefix . 'mb_plgn_ads_txt_backups'; $charset_collate = $wpdb->get_charset_collate(); $sql = "CREATE TABLE IF NOT EXISTS `$table_name` ( `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, `content` LONGTEXT NOT NULL, `user_id` BIGINT(20) UNSIGNED NOT NULL, `file_type` VARCHAR(10) DEFAULT 'web', `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`id`) ) $charset_collate;"; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; dbDelta($sql); global $wpdb; }); add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'mb_plgn_ads_txt_plugin_action_links'); function mb_plgn_ads_txt_plugin_action_links($links) { $settings_link = 'Settings'; array_unshift($links, $settings_link); return $links; } define('MB_PLGN_ADS_TXT_TABLE_BACKUPS', $wpdb->prefix . 'mb_plgn_ads_txt_backups' ); // UPDATE COLUMN add_action('plugins_loaded', 'mb_plgn_ads_txt_check_db_version'); function mb_plgn_ads_txt_check_db_version() { global $wpdb; $installed_ver = get_option('mb_plgn_ads_txt_db_version'); if ($installed_ver !== MB_PLGN_ADS_TXT_DB_VERSION) { // Check if 'file_type' column exists // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.PreparedSQL.NotPrepared -- $table is derived from $wpdb->prefix and escaped. DDL queries cannot be prepared or cached.; $column = $wpdb->get_var("SHOW COLUMNS FROM `".MB_PLGN_ADS_TXT_TABLE_BACKUPS."` LIKE 'file_type'"); if (empty($column) || $column === null) { // Add column if missing (schema change during plugin upgrade) // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.DirectDatabaseQuery.SchemaChange,WordPress.DB.PreparedSQL.InterpolatedNotPrepared,WordPress.DB.PreparedSQL.NotPrepared -- $table is derived from $wpdb->prefix and escaped; $wpdb->query("ALTER TABLE `".MB_PLGN_ADS_TXT_TABLE_BACKUPS."` ADD COLUMN `file_type` VARCHAR(10) DEFAULT 'web'"); } update_option('mb_plgn_ads_txt_db_version', MB_PLGN_ADS_TXT_DB_VERSION); } } require_once MB_PLGN_ADS_TXT_PATH . 'functions/functions.php'; require_once MB_PLGN_ADS_TXT_PATH . 'views/review-notice.php';