Created
September 9, 2014 07:52
-
-
Save janbiasi/fd6a3ce26097488a6180 to your computer and use it in GitHub Desktop.
A simple Wordpress post exporter written in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Security checking | |
define('ABSPATH') or die ("Script kiddies!"); | |
// Defining path and filename | |
$outPath = 'postbackup/'; | |
$fileName = 'wp_posts_' . date('m-d-Y-His A e') . '.xml'; | |
// Indlude the wordpress stuff | |
require(dirname(dirname(__FILE__)) . '/wp-load.php'); | |
require(ABSPATH . 'wp-admin/includes/admin.php'); | |
require('includes/export.php'); | |
// Handle data | |
ob_start(); | |
export_wp(); | |
$xml = ob_get_clean(); | |
// Write to the file in path configured above | |
file_put_contents($outPath . $fileName, $xml); | |
// Redirect to the root page | |
header('Location: http://' . $_SERVER['HTTP_HOST']); | |
exit; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment