/** * Imports data from file into table * * @global object $wpdb Wordpress DB class * @global string $table_prefix Wordpress table prefix * @param string $path base path to folder where the install folder is located with trailing slash */ function import_data($path) { global $wpdb, $table_prefix; $path .= "install/data"; $files = gdDBInstallGDPT::scan_folder($path); $wpdb->show_errors = true; foreach ($files as $file) { if (substr($file, 0, 1) != '.') { $file_path = $path . "/" . $file; $handle = @fopen($file_path, "r"); if ($handle) { while (!feof($handle)) { $line = fgets($handle); $sql = sprintf($line, $table_prefix); $wpdb->query($sql); } fclose($handle); } } } }