File: /var/www/html/corepla/mappe.php
<?php
require_once( '/var/www/html/corepla/wp-load.php' );
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
$infografiche = array();
$infografiche[] = "";
$infografiche[] = "CSS";
$infografiche[] = "CDR";
$infografiche[] = "Riciclo Imprese (PEPS; PIA; PIFU)";
$infografiche[] = "ECP";
$infografiche[] = "Clienti";
$infografiche[] = "Comuni convenzionati";
$infografiche[] = "CC";
$infografiche[] = "CSS con distinzione visita";
$infografiche[] = "RIC";
$entity_id = array();
$infografica = array();
$rows = $wpdb->get_results( "select entity_id, field_tipo_mappa_value from field_revision_field_tipo_mappa;" , ARRAY_A);
foreach($rows as $row){
$entity_id[] = $row['entity_id'];
$infografica[] = $row['field_tipo_mappa_value'];
}
$i = 0;
while ($i < count($entity_id)) {
$post_id = -1;
$rows = $wpdb->get_results( "select post_id from wp_postmeta where meta_value = " . $entity_id[$i] . " and meta_key = '_fgd2wp_old_node_id ';" , ARRAY_A);
foreach($rows as $row){
$post_id = $row['post_id'];
if ($post_id > -1) {
add_row(
'contenuto_flessibile', [
'acf_fc_layout' => 'mappa',
'mappa_id' => $infografiche[$infografica[$i]]
], $post_id);
echo $post_id . " " . $infografiche[$infografica[$i]] . "\n";
}
}
$i++;
}
echo "done";
?>