[ Index ]

WordPress Source Cross Reference

title

Body

[close]

/wp-admin/ -> export.php (source)

   1  <?php
   2  require_once  ('admin.php');
   3  $title = __('Export');
   4  $parent_file = 'edit.php';
   5  
   6  if ( isset( $_GET['download'] ) )
   7      export_wp();
   8  
   9  require_once  ('admin-header.php');
  10  ?>
  11  
  12  <div class="wrap">
  13  <h2><?php _e('Export'); ?></h2>
  14  <p><?php _e('This will allow you to download an export of your WordPress posts and comments in a XML format.'); ?></p>
  15  <p>We need some more text here. Maybe talking about the export file or how to save it.</p>
  16  <form action="" method="get">
  17  <p class="submit"><input type="submit" name="submit" value="<?php _e('Download Export File'); ?> &raquo;" />
  18  <input type="hidden" name="download" value="true" />
  19  </p>
  20  </form>
  21  </div>
  22  
  23  <?php
  24  
  25  function export_wp() {
  26      global $wpdb, $posts, $post;
  27      $filename = 'wordpress.' . date('Y-m-d') . '.xml';
  28  header('Content-Description: File Transfer');
  29  header('Content-Type: application/octet-stream');
  30  header("Content-Disposition: attachment; filename=$filename");
  31  header('Content-type: text/xml; charset=' . get_settings('blog_charset'), true);
  32  //$posts = query_posts('');

  33  $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts ORDER BY post_date_gmt ASC");
  34  ?>
  35  <!-- generator="wordpress/<?php bloginfo_rss('version') ?>" created="<?php echo date('Y-m-d H:m'); ?>"-->
  36  <rss version="2.0" 
  37      xmlns:content="http://purl.org/rss/1.0/modules/content/"
  38      xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  39      xmlns:dc="http://purl.org/dc/elements/1.1/"
  40      xmlns:wp="http://wordpress.org/export/1.0/"
  41  >
  42  
  43  <channel>
  44      <title><?php bloginfo_rss('name'); ?></title>
  45      <link><?php bloginfo_rss('url') ?></link>
  46      <description><?php bloginfo_rss("description") ?></description>
  47      <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></pubDate>
  48      <generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
  49      <language><?php echo get_option('rss_language'); ?></language>
  50      <?php do_action('rss2_head'); ?>
  51      <?php if ($posts) { foreach ($posts as $post) { start_wp(); ?>
  52  <item>
  53  <title><?php the_title_rss() ?></title>
  54  <link><?php permalink_single_rss() ?></link>
  55  <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_post_time('Y-m-d H:i:s', true), false); ?></pubDate>
  56  <dc:creator><?php the_author() ?></dc:creator>
  57  <?php the_category_rss() ?>
  58  
  59  <guid isPermaLink="false"><?php the_guid(); ?></guid>
  60  <description></description>
  61  <content:encoded><![CDATA[<?php echo $post->post_content ?>]]></content:encoded>
  62  <wp:post_date><?php echo $post->post_date; ?></wp:post_date>
  63  <wp:post_date_gmt><?php echo $post->post_date_gmt; ?></wp:post_date_gmt>
  64  <wp:comment_status><?php echo $post->comment_status; ?></wp:comment_status>
  65  <wp:ping_status><?php echo $post->ping_status; ?></wp:ping_status>
  66  <wp:post_name><?php echo $post->post_name; ?></wp:post_name>
  67  <wp:status><?php echo $post->post_status; ?></wp:status>
  68  <wp:post_parent><?php echo $post->post_parent; ?></wp:post_parent>
  69  <wp:post_type><?php echo $post->post_type; ?></wp:post_type>
  70  <?php
  71  $postmeta = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID"); 
  72  if ( $postmeta ) {
  73  ?>
  74  <?php foreach( $postmeta as $meta ) { ?>
  75  <wp:postmeta>
  76  <wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
  77  <wp:meta_value><?Php echo $meta->meta_value; ?></wp:meta_value>
  78  </wp:postmeta>
  79  <?php } ?>
  80  <?php } ?>
  81  <?php
  82  $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_post_ID = $post->ID"); 
  83  if ( $comments ) { foreach ( $comments as $c ) { ?>
  84  <wp:comment>
  85  <wp:comment_author><?php echo $c->comment_author; ?></wp:comment_author>
  86  <wp:comment_author_email><?php echo $c->comment_author_email; ?></wp:comment_author_email>
  87  <wp:comment_author_url><?php echo $c->comment_author_url; ?></wp:comment_author_url>
  88  <wp:comment_author_IP><?php echo $c->comment_author_IP; ?></wp:comment_author_IP>
  89  <wp:comment_date><?php echo $c->comment_date; ?></wp:comment_date>
  90  <wp:comment_date_gmt><?php echo $c->comment_date_gmt; ?></wp:comment_date_gmt>
  91  <wp:comment_content><?php echo $c->comment_content; ?></wp:comment_content>
  92  <wp:comment_approved><?php echo $c->comment_approved; ?></wp:comment_approved>
  93  <wp:comment_type><?php echo $c->comment_type; ?></wp:comment_type>
  94  <wp:comment_parent><?php echo $c->comment_parent; ?></wp:comment_parent>
  95  </wp:comment>
  96  <?php } } ?>
  97      </item>
  98  <?php } } ?>
  99  </channel>
 100  </rss>
 101  <?php
 102      die();
 103  }
 104  
 105  include  ('admin-footer.php');
 106  ?>

Your comment here...

Name: Location:
Comments:


List: Classes | Functions | Variables | Constants | Tables

Generated: Sat Jul 15 11:57:04 2006 Courtesy of Taragana