fetch('title'), "'\" "); $date = $post->fetch('date'); $date = date('Y-m-d H:i:s', strtotime($date)); $body = $post->fetch('content'); $tags = explode(',', str_replace(array("'", '[', ']'), '', $post->fetch('tags'))); // Slug is filename - remove date from beginning, and extensions from end $slug = substr($fn, 11); $slug = preg_replace('/-+/', '-', substr($slug, 0, strpos($slug, '.'))); // Build full permalink $permalink = $site_domain . '/blog/' . $slug . "\n"; // Replace 'READMORE' with WordPress equivalent $body = str_replace('READMORE', '', $body); $title = mysql_escape_string($title); $body_md = mysql_escape_string($body); $body_html = mysql_escape_string(str_replace(array("\r\n", "\r", "\n"), " ", $parsedown->text($body))); echo 'Imported: ' . $permalink . " (tags: " . implode($tags, ',') . ")
\n"; $sql = "INSERT INTO wp_posts (post_author, post_date, post_date_gmt, post_content, post_content_filtered, post_title, post_status, comment_status, ping_status, post_name, post_modified, post_modified_gmt, post_parent, post_type) VALUES "; $sql .= "(1, '$date', '$date', '$body_html', '$body_md', '$title', 'publish', 'closed', 'open', '$slug', '$date', '$date', 0, 'post')"; mysql_query($sql, $db); $id = mysql_insert_id($db); wp_set_post_tags($id, $tags, false); mysql_query("UPDATE wp_posts SET guid = '$site_domain/?p=$id' WHERE ID = $id", $db); mysql_query("INSERT INTO wp_postmeta (post_id, meta_key, meta_value) VALUES ($id, '_sd_is_markdown', '1')", $db); }