PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.3
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / add-ons-free / labels-edit / inc / class-pble-export.php

class-pble-export.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 4.0.3, at add-ons-free/labels-edit/inc/class-pble-export.php

51 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // Exit if accessed directly
3 if ( ! defined( 'ABSPATH' ) ) exit;
4
5 class WPPB_LE_Export {
6
7 protected $args_to_export;
8
9 /**
10 * this will take labels that will be exported from database.
11 *
12 * @param array $args_to_export labels to export.
13 */
14 function __construct( $args_to_export ) {
15 $this->args_to_export = $args_to_export;
16 }
17
18 /* function to export from database */
19 private function export_array( $nonce ) {
20
21 if( !wp_verify_nonce( $nonce, 'wppb_export_labels' ) )
22 return;
23
24 /* export labels from database */
25 $all_for_export = array();
26 foreach( $this->args_to_export as $labels ) {
27 $all_for_export['pble'] = get_option( $labels );
28 }
29
30 return $all_for_export;
31 }
32
33 /* export to json file */
34 public function download_to_json_format( $prefix ) {
35
36 if( isset( $_POST['pble-export'] ) && isset( $_POST['wppb_nonce'] ) && wp_verify_nonce( sanitize_text_field( $_POST['wppb_nonce'] ), 'wppb_export_labels' ) ) {
37 $all_for_export = $this->export_array( sanitize_text_field( $_POST['wppb_nonce'] ) );
38 $json = json_encode( $all_for_export );
39 $filename = $prefix . date( 'Y-m-d_h.i.s', time() );
40 $filename .= '.json';
41 header( "Content-Disposition: attachment; filename=$filename" );
42 header( 'Content-type: application/json' );
43 header( 'Content-Length: ' . mb_strlen( $json ) );
44 header( 'Connection: close' );
45 echo $json; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
46 exit;
47 }
48
49 }
50 }
51