コード例 #1
0
ファイル: import-wordpress.php プロジェクト: xb11/Website
                $category_statement->execute(array(':post_id' => $wp->post_id, ':taxonomy_id' => $this->categories[(string) $category['nicename']]));
            } elseif ($category['domain'] == 'post_tag') {
                $tag_statement->execute(array(':post_id' => $wp->post_id, ':taxonomy_id' => $this->tags[(string) $category['nicename']]));
            } else {
                echo 'Unknown category type: ', $category['domain'], "\n";
            }
        }
    }
    protected function process_comments_for(SimpleXMLElement $post, SimpleXMLElement $wp, PDOStatement $comment_statement)
    {
        foreach ($wp->comment as $comment) {
            // Ignore pingbacks and trackbacks for now
            if ($comment->comment_type == 'pingback' || $comment->comment_type == 'trackback') {
                continue;
            }
            $comment_statement->execute(array(':id' => $comment->comment_id, ':post_id' => $wp->post_id, ':author' => $comment->comment_author, ':email' => $comment->comment_author_email, ':url' => (string) $comment->comment_author_url, ':ip' => $comment->comment_author_IP, ':date' => strtotime($comment->comment_date), ':content' => (string) $comment->comment_content, ':parent_comment_id' => $comment->comment_parent == 0 ? null : $comment->comment_parent, ':status' => $comment->comment_approved == 1 ? 'visible' : 'pending'));
        }
    }
    protected function finalise()
    {
        $this->db->query('UPDATE blog_comments SET email = "*****@*****.**", url = "http://dan.cx/" WHERE author = "Daniel15"');
    }
}
//header('Content-Type: text/plain');
echo '<pre>';
$importer = new WordpressImporter();
$importer->connectToDB('daniel15_new', 'root', 'password');
$importer->load('c:/Users/Daniel/Downloads/daniel15039sblog.wordpress.2011-05-03.xml');
$importer->process();
?>
All done!