forked from statamic/wordpress-to-statamic-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport-to-statamic.php
57 lines (44 loc) · 1.43 KB
/
export-to-statamic.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
* Plugin Name: Export to Statamic
* Description: Export all the Wordpress data to be imported into Statamic.
* Version: 1.0.2
* Author: Statamic
* Author URI: https://statamic.com
*/
add_action( 'admin_menu', 'statamic_export_register_menu' );
function statamic_request_input($key, $default = null)
{
if (! isset($_POST[$key])) {
return $default;
}
return $_POST[$key];
}
function statamic_export_register_menu() {
add_submenu_page( 'tools.php', 'Export to Statamic', 'Export to Statamic', 'manage_options', 'export-to-statamic', 'statamic_export_view' );
}
function statamic_export_view() {
// Query all the custom post types.
$postTypes = get_post_types([
'_builtin' => false,
], 'object');
// Query all the authors of the said posts.
require_once __DIR__ . '/form.php';
}
add_action(
'admin_post_statamic_export_run',
'statamic_export_run_admin_action'
);
function statamic_export_run_admin_action() {
if ( ! current_user_can('export') ) {
wp_die( 'You do not have sufficient permissions to export the content of this site.' );
}
require_once __DIR__ . '/Exporter.php';
(new Statamic\Exporter)
->content(statamic_request_input('content', array()))
->customPostTypes(statamic_request_input('post_types', array()))
->export()
->download();
exit;
}
?>