test.php source code
Contents of file
test.php
1
<?php
2 /*
3 * test.php
4 *
5 * Copyright 2015 mario spada <spadamar@spadamar.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 * MA 02110-1301, USA.
21 *
22 *
23 */
24
25
26 ?>
27 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
28 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
29 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
30
31 <head>
32 <title>senza nome</title>
33 <meta http-equiv="content-type" content="text/html;charset=utf-8" />
34 <meta name="generator" content="Geany 1.23.1" />
35 </head>
36
37 <body>
38
39 <?php
40 /***********************************************************************
41 * TEST
42 * *********************************************************************/
43
44 require_once("ImportPostWp.class.php");
45
46 $myData = array();
47
48 for ($i=1;$i<11;$i++) {
49 $myData[] = array('post_title'=>'Nuovo titolo n.'.$i,'post_content'=>'Nuova descrizione del post '.$i,'categories'=>'prova');
50 }
51
52 $obj = new ImportPostWp($myData,"../wp");
53 //$obj->get_field_list(true); //Mostra la lista dei nomi dei campi che verranno inseriti
54 //$obj->get_default_post_values(true); //Mostra i valori di default per alcuni campi
55 //$obj->get_data(true); //Mostra l'array dei dati da inserire
56 //$obj->debug = true; //Imposta il debug
57 //$res = $obj->delete_posts("prova"); //Elimina dal DB tutti i posts della categoria: prova
58 //echo "\n<br>Record eliminati: ".$res; //Mostra il numero di record eliminati
59 $res = $obj->insert_posts(); //Inserisce nel DB tutti i posts dell'array utilizzando funzioni native di WP
60 echo "\n<br>Record inseriti: ".$res;
61 echo "\n<br>Errori: ".implode(",",$obj->get_insert_errors());
62 echo "\n<br>Tempo trascorso".$obj->get_elapsed_time();
63 //$res = $obj->raw_insert_posts(); //Inserisce nel DB tutti i posts dell'array utilizzando query SQL
64 //echo "\n<br>Record inseriti: ".$res;
65 //echo "\n<br>Errori: ".implode(",",$obj->get_insert_errors());
66 //echo "\n<br>Tempo trascorso".$obj->get_elapsed_time();
67 ?>
68
69 </body>
70
71 </html>
72