File: /var/www/html/corepla/import_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);
$mappe = array();
$mappe[] = "";
$mappe[] = "CSS";
$mappe[] = "CDR";
$mappe[] = "Riciclo Imprese";
$mappe[] = "ECP";
$mappe[] = "Clienti";
$mappe[] = "Comuni";
$mappe[] = "CC";
$mappe[] = "CSS";
$mappe[] = "RIC";
$entity_id = array();
$infografica = array();
$rows = $wpdb->get_results( "select * from corepla_mappe" , ARRAY_A);
foreach($rows as $row){
$new_post = array(
'post_title' => $row['titolo'],
'post_content' => $row['note'],
'post_status' => 'publish',
'post_date' => date('Y-m-d H:i:s'),
'post_author' => 1,
'post_type' => 'punto-su-mappa'
);
$post_id = wp_insert_post($new_post);
add_post_meta($post_id, 'tipo_mappa', $mappe[$row['tipo_mappa']]);
add_post_meta($post_id, 'indirizzo', $row['indirizzo']);
add_post_meta($post_id, 'latitudine', $row['latitudine']);
add_post_meta($post_id, 'longitudine', $row['longitudine']);
add_post_meta($post_id, 'modifica_manuale', 1);
add_post_meta($post_id, 'note', $row['note']);
add_post_meta($post_id, 'chiave_mappa', $row['tipo_mappa']);
if ($mappe[$row['tipo_mappa']] == "CSS") {
add_post_meta($post_id, 'tipo_punto_css', 'Normale');
}
$tipo_punto = "";
if ($row['tipo_punto'] == "1") {
}
$tipo_punto = "";
if ($row['tipo_punto'] == "1") {
$tipo_punto = "PEPS";
}
if ($row['tipo_punto'] == "2") {
$tipo_punto = "PIA";
}
if ($row['tipo_punto'] == "3") {
$tipo_punto = "PIFU";
}
add_post_meta($post_id, 'tipo_punto_riciclo_imprese', $tipo_punto);
}
echo "done";
?>