header(); check_admin_referer( 'wpv-import' ); $file = $_GET['file']; set_time_limit(0); $this->import( $file ); $this->footer(); } /** * The main controller for the actual import stage. * * @param string $file Path to the WXR file for importing */ function import( $file ) { add_filter( 'import_post_meta_key', array( $this, 'is_valid_meta_key' ) ); add_filter( 'http_request_timeout', array( &$this, 'bump_request_timeout' ) ); $this->import_start( $file ); wp_suspend_cache_invalidation( true ); $this->import_widgets($file); wp_suspend_cache_invalidation( false ); $this->import_end(); } function import_widgets($file) { $data = unserialize(base64_decode(file_get_contents($file))); $data['positions']['wp_inactive_widgets'] = array(); wp_set_sidebars_widgets($data['positions']); foreach($data['widgets'] as $class=>$widget) { update_option($class, $widget); } } /** * Parses the WXR file and prepares us for the task of processing parsed data * * @param string $file Path to the WXR file for importing */ function import_start( $file ) { if ( ! is_file($file) ) { echo '
' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '
';
echo __( 'The file does not exist, please try again.', 'wordpress-importer' ) . '
' . __( 'All done.', 'wordpress-importer' ) . ' ' . __( 'Have fun!', 'wordpress-importer' ) . '' . '
'; $quick_setup = admin_url('admin.php?page=wpv_quick_setup'); echo <<