File: /var/www/html/corepla/cf.txt
<?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);
$posts_id = array();
$rows = $wpdb->get_results( "select ID, post_type from wp_posts where post_type in ('articoli','comunicato_stampa','page','pagina_scuola','post');" , ARRAY_A);
foreach($rows as $row){
$posts_id[] = $row['ID'];
}
//$post_id = 593;
foreach($posts_id as $post_id){
echo $post_id . "<br>";
//echo '<pre>';
// echo '</pre>';
$c = 0;
$descrizione = array();
$titolo = array();
$lista_documenti = array();
$link_vimeo = array();
$embed_id = array();
$rows = $wpdb->get_results( "select meta_key, meta_value from wp_postmeta where post_id = " . $post_id , ARRAY_A);
foreach($rows as $row){
$key = $row['meta_key'];
$val = $row['meta_value'];
$value = $row['meta_value'];
//$val = str_replace(" ","",implode(" ",$value));
$print = 1;
if (str_replace(" ","",$value) == "") {
$print = 0;
}
if (strpos($val, "field_") > -1) {
$print = 0;
}
if ($print == 1) {
if ($value != "") {
//add_row('drupal_text_repeater_' . $c . '_drupal_text_descrizione', $val, $post_id);
if (strpos($key, "lista_documenti") > -1) {
$lista_documenti[] = $value;
}
if (strpos($key, "descrizione") > -1) {
$descrizione[] = $value;
}
if (strpos($key, "titolo") > -1) {
$titolo[] = $value;
}
if (strpos($key, "link_vimeo") > -1) {
$link_vimeo[] = $value;
}
if (strpos($key, "embed_id") > -1) {
$embed_id[] = $value;
}
}
}
}
echo count($descrizione);
foreach ($descrizione as $val) {
$row = array(
'descrizione' => $val
);
add_row('drupal_descrizione_group', $row, $post_id);
}
foreach ($titolo as $val) {
$row = array(
'titolo' => $val
);
add_row('drupal_titolo_group', $row, $post_id);
}
foreach ($lista_documenti as $val) {
echo "*****" . $val . "<br>";
$row = array(
'listadocumenti' => $val
);
add_row('drupal_listadocumenti_group', $row, $post_id);
}
foreach ($link_vimeo as $val) {
$row = array(
'linkvimeo' => $val
);
add_row('drupal_linkvimeo_group', $row, $post_id);
}
foreach ($embed_id as $val) {
$row = array(
'embedid' => $val
);
add_row('drupal_embedid_group', $row, $post_id);
}
}
echo "done";
?>