= 2.1 renamed functions-formatting.php to formatting.php.
if ( $wp_version < 2.1) {
require_once(ABSPATH . WPINC . '/functions-formatting.php');
} else {
require_once(ABSPATH . WPINC . '/formatting.php');
}
function dsq_get_temp_dir() {
if ( defined('WP_TEMP_DIR') ) {
if ( is_writable(WP_TEMP_DIR) ) {
return trailingslashit(WP_TEMP_DIR);
}
}
if ( function_exists('sys_get_temp_dir') ) {
$temp_dir = sys_get_temp_dir();
if ( is_writable($temp_dir) ) {
return trailingslashit($temp_dir);
}
}
$temp_dir = ABSPATH . 'wp-content/';
if ( is_dir($temp_dir) && is_writable($temp_dir) ) {
return $temp_dir;
}
// Try to get from environment variable
if ( !empty($_ENV['TMP']) ) {
if ( is_writable($_ENV['TMP']) ) {
return realpath(trailingslashit($_ENV['TMP']));
}
}
if ( !empty($_ENV['TMPDIR']) ) {
if ( is_writable($_ENV['TMPDIR']) ) {
return realpath(trailingslashit($_ENV['TMPDIR']));
}
}
if ( !empty($_ENV['TEMP']) ) {
if ( is_writable($_ENV['TEMP']) ) {
return realpath(trailingslashit($_ENV['TEMP']));
}
}
// Last ditch effort.
return '/tmp/';
}
function dsq_export_wp() {
global $wpdb, $posts, $post, $wp_version;
global $dsq_api;
$filename = dsq_get_temp_dir() . 'disqus-wordpress.' . date('Y-m-d') . '.xml';
$fp = fopen($filename, 'w');
ob_start();
$where = '';
if ( isset( $_GET['author'] ) && $_GET['author'] != 'all' ) {
$author_id = (int) $_GET['author'];
$where = " WHERE post_author = '$author_id' ";
}
$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt ASC");
function wxr_site_url() {
global $current_site;
// mu: the base url
if ( isset($current_site->domain) ) {
return 'http://'.$current_site->domain.$current_site->path;
}
// wp: the blog url
else {
return get_bloginfo_rss('url');
}
}
function wxr_cdata($str) {
if ( seems_utf8($str) == false )
$str = utf8_encode($str);
// $str = ent2ncr(wp_specialchars($str));
$str = "";
return $str;
}
function wxr_cat_name($c) {
if ( empty($c->cat_name) )
return;
echo '' . wxr_cdata($c->cat_name) . '';
}
function wxr_category_description($c) {
if ( empty($c->category_description) )
return;
echo '' . wxr_cdata($c->category_description) . '';
}
print '\n";
?>
http://wordpress.org/?v=
category_nicename; ?>category_parent ? $cats[$c->category_parent]->cat_name : ''; ?>posts_private ? '1' : '0'; ?>links_private ? '1' : '0'; ?>
-
post_content ?>]]>
ID; ?>
post_date; ?>
post_date_gmt; ?>
comment_status; ?>
ping_status; ?>
post_name; ?>
post_status; ?>
post_parent; ?>
menu_order; ?>
post_type; ?>
get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID");
if ( $postmeta ) {
?>
meta_key; ?>
meta_value; ?>
get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID AND comment_agent NOT LIKE 'Disqus/%'");
ob_start();
if ( $comments ) { foreach ( $comments as $c ) { ?>
comment_ID; ?>
comment_author; ?>
comment_author_email; ?>
comment_author_url; ?>
comment_author_IP; ?>
comment_date; ?>
comment_date_gmt; ?>
comment_content; ?>
comment_approved; ?>
comment_type; ?>
comment_parent; ?>
import_wordpress_comments($filename);
$import_id = $response;
unlink($filename);
if ( $response < 0 ) {
dsq_manage_dialog("There was an error exporting your comments. If your API key has changed, you may need to reinstall DISQUS (deactivate the plugin and then reactivate it). If you are still having issues, refer to the WordPress help page.", true);
} else {
update_option('disqus_last_import_id', $import_id);
dsq_manage_dialog('Your comments have been queued for importing to DISQUS. You may check the advanced options tab for a status update.');
}
}
?>