[ Index ]

PHP Cross Reference of WordPress 3.0 beta 1

[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

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

   1  <?php
   2  /**
   3   * WordPress Export Administration Panel
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   */
   8  
   9  /** Load WordPress Bootstrap */
  10  require_once  ('admin.php');
  11  
  12  if ( !current_user_can('edit_files') )
  13      wp_die(__('You do not have sufficient permissions to export the content of this blog.'));
  14  
  15  /** Load WordPress export API */
  16  require_once ('includes/export.php');
  17  $title = __('Export');
  18  
  19  if ( isset( $_GET['download'] ) ) {
  20          $author = isset($_GET['author']) ? $_GET['author'] : 'all';
  21          $category = isset($_GET['category']) ? $_GET['category'] : 'all';
  22          $post_type = isset($_GET['post_type']) ? stripslashes_deep($_GET['post_type']) : 'all';
  23          $status = isset($_GET['status']) ? stripslashes_deep($_GET['status']) : 'all';
  24          $mm_start = isset($_GET['mm_start']) ? $_GET['mm_start'] : 'all';
  25          $mm_end = isset($_GET['mm_end']) ? $_GET['mm_end'] : 'all';
  26          $aa_start = isset($_GET['aa_start']) ? intval($_GET['aa_start']) : 0;
  27          $aa_end = isset($_GET['aa_end']) ? intval($_GET['aa_end']) : 0;
  28          if($mm_start != 'all' && $aa_start > 0) {
  29              $start_date = sprintf( "%04d-%02d-%02d", $aa_start, $mm_start, 1 );
  30          } else {
  31              $start_date = 'all';
  32          }
  33          if($mm_end != 'all' && $aa_end > 0) {
  34              if($mm_end == 12) {
  35                  $mm_end = 1;
  36                  $aa_end++;
  37              } else {
  38                  $mm_end++;
  39              }
  40              $end_date = sprintf( "%04d-%02d-%02d", $aa_end, $mm_end, 1 );
  41          } else {
  42              $end_date = 'all';
  43          }
  44      export_wp( $author, $category, $post_type, $status, $start_date, $end_date );
  45      die();
  46  }
  47  
  48  require_once  ('admin-header.php');
  49  
  50  $months = "";
  51  for ( $i = 1; $i < 13; $i++ ) {
  52      $months .= "\t\t\t<option value=\"" . zeroise($i, 2) . '">' .
  53          $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) . "</option>\n";
  54  } ?>
  55  
  56  <div class="wrap">
  57  <?php screen_icon(); ?>
  58  <h2><?php echo esc_html( $title ); ?></h2>
  59  
  60  <p><?php _e('When you click the button below WordPress will create an XML file for you to save to your computer.'); ?></p>
  61  <p><?php _e('This format, which we call WordPress eXtended RSS or WXR, will contain your posts, pages, comments, custom fields, categories, and tags.'); ?></p>
  62  <p><?php _e('Once you&#8217;ve saved the download file, you can use the Import function on another WordPress blog to import this blog.'); ?></p>
  63  <form action="" method="get">
  64  <h3><?php _e('Options'); ?></h3>
  65  
  66  <table class="form-table">
  67  <tr>
  68  <th><label for="mm_start"><?php _e('Restrict Date'); ?></label></th>
  69  <td><strong><?php _e('Start:'); ?></strong> <?php _e('Month'); ?>&nbsp;
  70  <select name="mm_start" id="mm_start">
  71  <option value="all" selected="selected"><?php _e('All Dates'); ?></option>
  72  <?php echo $months; ?>
  73  </select>&nbsp;<?php _e('Year'); ?>&nbsp;
  74  <input type="text" id="aa_start" name="aa_start" value="" size="4" maxlength="5" />
  75  </td>
  76  <td><strong><?php _e('End:'); ?></strong> <?php _e('Month'); ?>&nbsp;
  77  <select name="mm_end" id="mm_end">
  78  <option value="all" selected="selected"><?php _e('All Dates'); ?></option>
  79  <?php echo $months; ?>
  80  </select>&nbsp;<?php _e('Year'); ?>&nbsp;
  81  <input type="text" id="aa_end" name="aa_end" value="" size="4" maxlength="5" />
  82  </td>
  83  </tr>
  84  <tr>
  85  <th><label for="author"><?php _e('Restrict Author'); ?></label></th>
  86  <td>
  87  <select name="author" id="author">
  88  <option value="all" selected="selected"><?php _e('All Authors'); ?></option>
  89  <?php
  90  $authors = $wpdb->get_col( "SELECT post_author FROM $wpdb->posts GROUP BY post_author" );
  91  foreach ( $authors as $id ) {
  92      $o = get_userdata( $id );
  93      echo "<option value='{$o->ID}'>{$o->display_name}</option>\n";
  94  }
  95  ?>
  96  </select>
  97  </td>
  98  </tr>
  99  <tr>
 100  <th><label for="category"><?php _e('Restrict Category'); ?></label></th>
 101  <td>
 102  <select name="category" id="category">
 103  <option value="all" selected="selected"><?php _e('All Categories'); ?></option>
 104  <?php
 105  $categories = (array) get_categories('get=all');
 106  if($categories) {
 107      foreach ( $categories as $cat ) {
 108          echo "<option value='{$cat->term_taxonomy_id}'>{$cat->name}</option>\n";
 109      }
 110  }
 111  ?>
 112  </select>
 113  </td>
 114  </tr>
 115  <tr>
 116  <th><label for="post_type"><?php _e('Restrict Content'); ?></label></th>
 117  <td>
 118  <select name="post_type" id="post_type">
 119  <option value="all" selected="selected"><?php _e('All Content'); ?></option>
 120  <option value="page"><?php _e('Pages'); ?></option>
 121  <option value="post"><?php _e('Posts'); ?></option>
 122  </select>
 123  </td>
 124  </tr>
 125  <tr>
 126  <th><label for="status"><?php _e('Restrict Status'); ?></label></th>
 127  <td>
 128  <select name="status" id="status">
 129  <option value="all" selected="selected"><?php _e('All Statuses'); ?></option>
 130  <option value="draft"><?php _e('Draft'); ?></option>
 131  <option value="private"><?php _e('Privately published'); ?></option>
 132  <option value="publish"><?php _e('Published'); ?></option>
 133  <option value="future"><?php _e('Scheduled'); ?></option>
 134  </select>
 135  </td>
 136  </tr>
 137  </table>
 138  <p class="submit"><input type="submit" name="submit" class="button" value="<?php esc_attr_e('Download Export File'); ?>" />
 139  <input type="hidden" name="download" value="true" />
 140  </p>
 141  </form>
 142  </div>
 143  
 144  <?php
 145  
 146  
 147  include  ('admin-footer.php');
 148  ?>


Generated: Mon Apr 5 14:26:09 2010 Cross-referenced by PHPXref 0.7