Line | |
---|
1 | <?php
|
---|
2 | // Find wp-load.php so we can access the database from within our non-standard, external file here
|
---|
3 | $d = 0; // search depth;
|
---|
4 | while (!file_exists(str_repeat('../', $d) . 'wp-load.php')) if (++$d > 99) exit;
|
---|
5 | $wp_load = str_repeat('../', $d) . 'wp-load.php';
|
---|
6 | require_once($wp_load);
|
---|
7 |
|
---|
8 | global $wpdb;
|
---|
9 |
|
---|
10 | // get all option names and options values from the WP Options table where the option name starts with "bfa_ata_"
|
---|
11 | $atahualpa_options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE option_name REGEXP '^bfa_ata_'");
|
---|
12 |
|
---|
13 | // output the header
|
---|
14 | $filename = 'atahualpa.options.' . str_replace("http://","",get_option('siteurl')) . "." . date('Y-m-d') . '.xml';
|
---|
15 | header('Content-Description: File Transfer');
|
---|
16 | header("Content-Disposition: attachment; filename=$filename");
|
---|
17 | header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true);
|
---|
18 |
|
---|
19 | // output the file
|
---|
20 | echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n";
|
---|
21 |
|
---|
22 | echo "<atahualpa_options>\n";
|
---|
23 | // Loop through the database query that we got earlier
|
---|
24 | foreach ($atahualpa_options as $atahualpa_option) {
|
---|
25 | echo "<" . $atahualpa_option->option_name . ">\n";
|
---|
26 | echo htmlspecialchars($atahualpa_option->option_value);
|
---|
27 | echo "\n</" . $atahualpa_option->option_name . ">\n";
|
---|
28 | }
|
---|
29 | echo"</atahualpa_options>\n";
|
---|
30 | ?> |
---|
Note:
See
TracBrowser
for help on using the repository browser.