PluginProbe
Adminimize / 1.11.6
Adminimize v1.11.6
1.11.14 1.11.13 1.11.1 1.11.10 1.11.11 1.11.12 1.11.2 1.11.3 1.11.4 1.11.5 1.11.6 1.11.7 1.11.8 1.11.9 1.3 1.4.7 1.6 1.7.12 1.7.13 1.7.14 1.7.15 1.7.16 1.7.17 1.7.18 1.7.19 All 53 releases
adminimize / inc-setup / export.php

export.php in Adminimize 1.11.6, at inc-setup/export.php

60 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Export settings as json file.
4 *
5 * @package Adminimize
6 * @subpackage export
7 * @author Frank Bültge
8 * @version 2017-04-13
9 */
10
11 if ( ! function_exists( 'add_action' ) ) {
12 echo "Hi there! I'm just a part of plugin, not much I can do when called directly.";
13 exit;
14 }
15
16 add_action( 'admin_init', '_mw_adminimize_export_json' );
17 /**
18 * Process a settings export that generates a .json file of the shop settings.
19 */
20 function _mw_adminimize_export_json() {
21
22 if ( ! is_admin() ) {
23 return;
24 }
25
26 if ( ! current_user_can( 'manage_options' ) ) {
27 return;
28 }
29
30 // If is AJAX Call.
31 if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
32 return;
33 }
34
35 if ( empty( $_POST[ '_mw_adminimize_export' ] ) || 'true' !== $_POST[ '_mw_adminimize_export' ] ) {
36 return;
37 }
38
39 require_once ABSPATH . 'wp-includes/pluggable.php';
40 if ( ! wp_verify_nonce( $_POST[ 'mw_adminimize_export_nonce' ], 'mw_adminimize_export_nonce' ) ) {
41 return;
42 }
43
44 $settings = _mw_adminimize_get_option_value();
45 $filepath = 'mw_adminimize-settings-export-' . date( 'm-d-Y' ) . '.json';
46
47 ignore_user_abort( TRUE );
48
49 nocache_headers();
50 header( 'Cache-Control: public' );
51 header( 'Content-Type: application/json; charset=utf-8' );
52 header( 'Content-Transfer-Encoding: binary' );
53 header( 'Content-Disposition: attachment; filename=' . $filepath );
54 //header( 'Content-Length: ' . filesize( $filepath ) );
55 header( 'Expires: 0' );
56
57 echo wp_json_encode( $settings );
58 exit();
59 }
60