668d973889
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>
38 lines
1.2 KiB
PHP
38 lines
1.2 KiB
PHP
<?php
|
|
// Import small folders into Carpetas_varias (ID 26)
|
|
|
|
$folders = ['home', 'jornada', 'pdf', 'presentaciones', 'publi', 'sobipro', 'titulos'];
|
|
$folder_id = 26;
|
|
|
|
global $wpdb;
|
|
$fbv_att = $wpdb->prefix . 'fbv_attachment_folder';
|
|
|
|
foreach ($folders as $name) {
|
|
$base_dir = '/var/www/html/wp-content/uploads/' . $name;
|
|
if (!is_dir($base_dir)) continue;
|
|
|
|
$files = scandir($base_dir);
|
|
$count = 0;
|
|
|
|
foreach ($files as $f) {
|
|
if ($f === '.' || $f === '..') continue;
|
|
$filepath = $base_dir . '/' . $f;
|
|
if (is_dir($filepath)) continue;
|
|
|
|
$guid_search = '%' . $name . '/' . $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 "$name: $count files\n";
|
|
}
|
|
echo "DONE\n";
|