| 1 |
<?php |
| 2 |
/** |
| 3 |
* UsersWP Uninstall 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_Uninstall', false ) ) { |
| 16 |
|
| 17 |
/** |
| 18 |
* UsersWP_Settings_Uninstall. |
| 19 |
*/ |
| 20 |
class UsersWP_Settings_Uninstall extends UsersWP_Settings_Page { |
| 21 |
|
| 22 |
/** |
| 23 |
* Constructor. |
| 24 |
*/ |
| 25 |
public function __construct() { |
| 26 |
|
| 27 |
$this->id = 'uninstall'; |
| 28 |
$this->label = __( 'Uninstall', 'userswp' ); |
| 29 |
|
| 30 |
add_filter( 'uwp_settings_tabs_array', array( $this, 'add_settings_page' ), 99 ); |
| 31 |
add_action( 'uwp_settings_' . $this->id, array( $this, 'output' ) ); |
| 32 |
add_action( 'uwp_sections_' . $this->id, array( $this, 'output_toggle_advanced' ) ); |
| 33 |
add_action( 'uwp_settings_save_' . $this->id, array( $this, 'save' ) ); |
| 34 |
add_action( 'uwp_sections_' . $this->id, array( $this, 'output_sections' ) ); |
| 35 |
|
| 36 |
} |
| 37 |
|
| 38 |
/** |
| 39 |
* Output the settings. |
| 40 |
*/ |
| 41 |
public function output() { |
| 42 |
global $current_section; |
| 43 |
|
| 44 |
$settings = $this->get_settings( $current_section ); |
| 45 |
|
| 46 |
UsersWP_Admin_Settings::output_fields( $settings ); |
| 47 |
} |
| 48 |
|
| 49 |
/** |
| 50 |
* Save settings. |
| 51 |
*/ |
| 52 |
public function save() { |
| 53 |
global $current_section; |
| 54 |
|
| 55 |
$settings = $this->get_settings( $current_section ); |
| 56 |
UsersWP_Admin_Settings::save_fields( $settings ); |
| 57 |
} |
| 58 |
|
| 59 |
/** |
| 60 |
* Get sections. |
| 61 |
* |
| 62 |
* @return array |
| 63 |
*/ |
| 64 |
public function get_sections() { |
| 65 |
|
| 66 |
$sections = array( |
| 67 |
'' => __( 'Uninstall Settings', 'userswp' ), |
| 68 |
); |
| 69 |
|
| 70 |
return apply_filters( 'uwp_get_sections_' . $this->id, $sections ); |
| 71 |
} |
| 72 |
|
| 73 |
public function get_settings( $current_section = '' ) { |
| 74 |
|
| 75 |
/** |
| 76 |
* Filter uninstall settings array. |
| 77 |
* |
| 78 |
* @package userswp |
| 79 |
*/ |
| 80 |
$settings = apply_filters( 'uwp_uninstall_options', array( |
| 81 |
array( |
| 82 |
'title' => __( 'Uninstall Settings', 'userswp' ), |
| 83 |
'type' => 'title', |
| 84 |
'desc' => '<b style="color:#f00 ">' . __( 'NOTE: Add-ons should be deleted before core to ensure complete uninstall.', 'userswp' ) . '</b>', |
| 85 |
'id' => 'uninstall_options', |
| 86 |
), |
| 87 |
|
| 88 |
array( |
| 89 |
'name' => __( 'Remove Data on Uninstall?', 'userswp' ), |
| 90 |
'desc' => __( 'Check this box if you would like UsersWP to completely remove all of its data when the plugin is deleted.', 'userswp' ), |
| 91 |
'id' => 'uninstall_erase_data', |
| 92 |
'type' => 'checkbox', |
| 93 |
), |
| 94 |
|
| 95 |
) ); |
| 96 |
|
| 97 |
$settings = apply_filters( 'uwp_get_settings_' . $this->id, $settings ); |
| 98 |
|
| 99 |
$settings[] = array( 'type' => 'sectionend', 'id' => 'uninstall_options' ); |
| 100 |
|
| 101 |
return $settings; |
| 102 |
} |
| 103 |
|
| 104 |
} |
| 105 |
|
| 106 |
} |
| 107 |
|
| 108 |
return new UsersWP_Settings_Uninstall(); |
| 109 |
|