/
exporter-bbpress.php
83 lines (71 loc) · 1.87 KB
/
exporter-bbpress.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/*
Plugin Name: BBXF Export
Plugin URI: http://www.bbpress.org/
Description: Allows administrators to export forum data.
Author: Dan Larkin
Version: 0.1 alpha
Author URI: http://www.stealyourcarbon.net/
*/
/**
* Includes necessary files.
*/
function export_init ()
{
if (!class_exists ('BBXP'))
{
require_once ('exporter/bbxp.php');
require_once ('exporter/bbxp-bbpress.php');
}
}
/**
* Executes all necessary functions to make the exportation happen.
*/
function export_main ()
{
global $bbdb;
export_init ();
$bbxp = new BBXP_bbPress;
$bbxp->db = $bbdb;
$filename = 'bbpress' . date ('Y-m-d') . '.xml';
$bbxp->write_header ($filename);
$bbxp->write_users ();
$bbxp->write_forums ();
$bbxp->write_topics ();
$bbxp->write_footer ();
die ();
}
/**
* Displays the admin export page.
*
* Gives a simple explanation of how the export file works and gives
* users a nice shiny button to click.
*/
function export_page ()
{
?>
<h2><?php _e ('Export') ?></h2>
<p><?php _e ('When you click the button below, bbPress will generate a BBXF file for you to save to your computer.'); ?></p>
<p><?php _e ('This file will contain data about your users, forums, topics, and posts. You can use the Import function of another bbPress installation or another compatible web forums software to import this data.'); ?></p>
<form action="" method="post">
<p class="submit">
<input type="submit" name="submit" value="<?php _e ('Download Export File'); ?>" />
<input type="hidden" name="exporting" value="true" />
</p>
</form>
<?php
}
/**
* Adds export link to admin menu.
*/
function export_add_admin ()
{
global $bb_submenu;
$bb_submenu['content.php'][] = array (__('Export'), 'use_keys', 'export_page', 'exporter-bbpress.php');
}
if ('true' == $_POST['exporting'] )
{
add_action ('bb_init', 'export_main');
}
add_action ('bb_admin_menu_generator', 'export_add_admin');
?>