WordPress Import
Import WordPress data into your system.
Import posts, categories, users, and comments from a WordPress database to your publication system.
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(t('wordpress_import_config_required')); } // 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 = t('wordpress_connection_success') . ': ' . t('posts') . ': ' . $stats['posts'] . ', ' . t('categories') . ': ' . $stats['categories'] . ', ' . t('users') . ': ' . $stats['users'] . ', ' . t('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(); } } ?>