Initial commit — migración Joomla→WordPress feadulta.org
Incluye: mu-plugins custom (fea-homepage, carta-semana), scripts de migración/traducción/deploy, documentación de auditoría, análisis de cartas y HTML de evangelios exportados desde Joomla. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
// Import libros subfolders: 100, 120, 200, 220, 400
|
||||
|
||||
$parent_id = 5; // libros (Libros)
|
||||
$base_path = '/var/www/html/wp-content/uploads/libros';
|
||||
|
||||
$subfolders = ['100', '120', '200', '220', '400'];
|
||||
|
||||
global $wpdb;
|
||||
$fbv = $wpdb->prefix . 'fbv';
|
||||
$fbv_att = $wpdb->prefix . 'fbv_attachment_folder';
|
||||
|
||||
foreach ($subfolders as $sub) {
|
||||
// Create or get subfolder
|
||||
$exists = $wpdb->get_var($wpdb->prepare("SELECT id FROM $fbv WHERE name = %s AND parent = %d", $sub, $parent_id));
|
||||
if (!$exists) {
|
||||
$wpdb->query($wpdb->prepare("INSERT INTO $fbv (name, parent, type) VALUES (%s, %d, 0)", $sub, $parent_id));
|
||||
$folder_id = $wpdb->insert_id;
|
||||
echo "Created: $sub (ID $folder_id)\n";
|
||||
} else {
|
||||
$folder_id = $exists;
|
||||
echo "Exists: $sub (ID $folder_id)\n";
|
||||
}
|
||||
|
||||
$dir = $base_path . '/' . $sub;
|
||||
if (!is_dir($dir)) continue;
|
||||
|
||||
$files = scandir($dir);
|
||||
$count = 0;
|
||||
foreach ($files as $f) {
|
||||
if ($f === '.' || $f === '..') continue;
|
||||
$filepath = $dir . '/' . $f;
|
||||
if (is_dir($filepath)) continue;
|
||||
|
||||
// Check if exists
|
||||
$guid_search = '%libros/' . $sub . '/' . $f;
|
||||
$att_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE guid LIKE %s AND post_type = 'attachment'", $guid_search));
|
||||
|
||||
if (!$att_id) {
|
||||
$cmd = "wp media import " . escapeshellarg($filepath) . " --porcelain --allow-root";
|
||||
$out = shell_exec($cmd);
|
||||
$att_id = trim($out);
|
||||
if (is_numeric($att_id)) {
|
||||
$wpdb->query("INSERT INTO $fbv_att (folder_id, attachment_id) VALUES ($folder_id, $att_id)");
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "Imported $count files to libros/$sub\n";
|
||||
}
|
||||
echo "DONE\n";
|
||||
Reference in New Issue
Block a user