| 1 |
<?php |
| 2 |
/** |
| 3 |
* UsersWP import export Settings |
| 4 |
* |
| 5 |
* @author AyeCode |
| 6 |
* @category Admin |
| 7 |
* @package userswp/Admin |
| 8 |
* @version 1.0.24 |
| 9 |
*/ |
| 10 |
|
| 11 |
if ( ! defined( 'ABSPATH' ) ) { |
| 12 |
exit; // Exit if accessed directly |
| 13 |
} |
| 14 |
|
| 15 |
if ( ! class_exists( 'UsersWP_Settings_Import_Export', false ) ) : |
| 16 |
|
| 17 |
/** |
| 18 |
* UsersWP_Settings_Email. |
| 19 |
*/ |
| 20 |
class UsersWP_Settings_Import_Export extends UsersWP_Settings_Page { |
| 21 |
|
| 22 |
public function __construct() { |
| 23 |
|
| 24 |
$this->id = 'import-export'; |
| 25 |
$this->label = __( 'Import/Export', 'userswp' ); |
| 26 |
|
| 27 |
add_filter( 'uwp_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); |
| 28 |
add_action( 'uwp_settings_' . $this->id, array( $this, 'output' ) ); |
| 29 |
add_action( 'uwp_sections_' . $this->id, array( $this, 'output_toggle_advanced' ) ); |
| 30 |
add_action( 'uwp_settings_save_' . $this->id, array( $this, 'save' ) ); |
| 31 |
add_action( 'uwp_sections_' . $this->id, array( $this, 'output_sections' ) ); |
| 32 |
|
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Output the settings. |
| 37 |
*/ |
| 38 |
public function output() { |
| 39 |
global $current_section; |
| 40 |
|
| 41 |
$settings = $this->get_settings( $current_section ); |
| 42 |
|
| 43 |
UsersWP_Admin_Settings::output_fields( $settings ); |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Save settings. |
| 48 |
*/ |
| 49 |
public function save() { |
| 50 |
global $current_section; |
| 51 |
|
| 52 |
$settings = $this->get_settings( $current_section ); |
| 53 |
UsersWP_Admin_Settings::save_fields( $settings ); |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Get sections. |
| 58 |
* |
| 59 |
* @return array |
| 60 |
*/ |
| 61 |
public function get_sections() { |
| 62 |
|
| 63 |
$sections = array( |
| 64 |
'' => __( 'Users', 'userswp' ), |
| 65 |
'settings' => __( 'Settings', 'userswp' ), |
| 66 |
); |
| 67 |
|
| 68 |
return apply_filters( 'uwp_get_sections_' . $this->id, $sections ); |
| 69 |
} |
| 70 |
|
| 71 |
public function get_settings( $current_section = '' ) { |
| 72 |
global $uwp_hide_save_button; |
| 73 |
|
| 74 |
if ( 'settings' == $current_section ) { |
| 75 |
|
| 76 |
/** |
| 77 |
* Filter import export settings array. |
| 78 |
* |
| 79 |
* @package userswp |
| 80 |
*/ |
| 81 |
$uwp_hide_save_button = true; |
| 82 |
$settings = apply_filters('uwp_settings_ie_main', array( |
| 83 |
|
| 84 |
array( |
| 85 |
'type' => 'import_export_settings', |
| 86 |
), |
| 87 |
|
| 88 |
array('type' => 'sectionend', 'id' => 'ie_users_options'), |
| 89 |
|
| 90 |
)); |
| 91 |
|
| 92 |
} else { |
| 93 |
|
| 94 |
/** |
| 95 |
* Filter import export users array. |
| 96 |
* |
| 97 |
* @package userswp |
| 98 |
*/ |
| 99 |
$uwp_hide_save_button = true; |
| 100 |
$settings = apply_filters('uwp_settings_ie_main', array( |
| 101 |
|
| 102 |
array( |
| 103 |
'type' => 'import_export_users', |
| 104 |
), |
| 105 |
|
| 106 |
array('type' => 'sectionend', 'id' => 'ie_settings_options'), |
| 107 |
|
| 108 |
)); |
| 109 |
|
| 110 |
} |
| 111 |
|
| 112 |
return apply_filters( 'uwp_get_settings_' . $this->id, $settings ); |
| 113 |
} |
| 114 |
|
| 115 |
} |
| 116 |
|
| 117 |
endif; |
| 118 |
|
| 119 |
|
| 120 |
return new UsersWP_Settings_Import_Export(); |