trim($_POST['wp_host'] ?? ''),
'database' => trim($_POST['wp_database'] ?? ''),
'username' => trim($_POST['wp_username'] ?? ''),
'password' => $_POST['wp_password'] ?? ''
];
// Validate required fields
if (empty($wpConfig['host']) || empty($wpConfig['database']) || empty($wpConfig['username'])) {
throw new Exception("WordPress database configuration is required. Please provide host, database, and username.");
}
// Direct WordPress connection test (bypass WordPressImport class)
try {
// Set timeout options
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_TIMEOUT => 10,
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8mb4"
];
$dsn = "mysql:host={$wpConfig['host']};dbname={$wpConfig['database']};charset=utf8mb4";
$wpDb = new PDO($dsn, $wpConfig['username'], $wpConfig['password'], $options);
// Test connection
$wpDb->query("SELECT 1");
if (isset($_POST['test_connection'])) {
// Get stats with direct queries
$stats = [];
try {
$stats['posts'] = $wpDb->query("SELECT COUNT(*) FROM wp_posts WHERE post_type = 'post'")->fetchColumn();
} catch (Exception $e) {
$stats['posts'] = 0;
}
try {
$stats['categories'] = $wpDb->query("SELECT COUNT(*) FROM wp_term_taxonomy WHERE taxonomy = 'category'")->fetchColumn();
} catch (Exception $e) {
$stats['categories'] = 0;
}
try {
$stats['users'] = $wpDb->query("SELECT COUNT(*) FROM wp_users")->fetchColumn();
} catch (Exception $e) {
$stats['users'] = 0;
}
try {
$stats['comments'] = $wpDb->query("SELECT COUNT(*) FROM wp_comments")->fetchColumn();
} catch (Exception $e) {
$stats['comments'] = 0;
}
$message = "WordPress connection successful: " .
"Posts: " . $stats['posts'] . ", " .
"Categories: " . $stats['categories'] . ", " .
"Users: " . $stats['users'] . ", " .
"Comments: " . $stats['comments'];
}
} catch (Exception $e) {
throw new Exception("WordPress connection failed: " . $e->getMessage());
}
if (isset($_POST['start_import'])) {
// For now, just show a message that import is not implemented in this simplified version
throw new Exception("Import functionality is temporarily disabled. Please use the AJAX import tool for importing data.");
}
} catch (Exception $e) {
$message = $e->getMessage();
}
}
?>
WordPress Import -
Import Results
WordPress import completed successfully!
WordPress Import Information
What Gets Imported
- Posts (title, content, author, publication date)
- Categories (name and description)
- Users (username, email, display name)
- Comments (content, author, date, threading)
Requirements
- Database access to WordPress database
- WordPress database with standard structure
- Backup of your current data (recommended)
Important Notes
- Existing data with same identifiers will be skipped
- WordPress content is processed for compatibility
- WordPress users are mapped to your user system