-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.php
56 lines (49 loc) · 2.21 KB
/
settings.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
// Add the menu item to the network admin menu
function tmu_wpmu_custom_menu() {
add_menu_page(
'TMU WPMU Settings', // Page title
'TMU WPMU', // Menu title
'manage_network', // Capability required to access this menu
'tmu-wpmu-menu', // Menu slug
'tmu_wpmu_menu_page', // Function to display the menu page content
'dashicons-admin-generic' // Icon URL (optional)
);
}
add_action('network_admin_menu', 'tmu_wpmu_custom_menu');
// Display the menu page content
function tmu_wpmu_menu_page() {
// Check if the user is allowed to update options
if (!current_user_can('manage_network')) {
wp_die(__('You do not have sufficient permissions to access this page.'));
}
// Handle form submission
if (isset($_POST['tmu_wpmu_menu_submit'])) {
check_admin_referer('tmu_wpmu_menu_nonce');
// Get the submitted value and sanitize it
$tmu_wpmu_forgot_password_redirect = sanitize_text_field($_POST['tmu_wpmu_forgot_password_redirect']);
// Save the value to the network settings
update_site_option('tmu_wpmu_forgot_password_redirect', $tmu_wpmu_forgot_password_redirect);
// Display success message
echo '<div class="notice notice-success is-dismissible"><p>Settings saved successfully!</p></div>';
}
// Retrieve the current setting value
$current_value = get_site_option('tmu_wpmu_forgot_password_redirect', '');
// Display the settings form
?>
<div class="wrap">
<h1>TMU WPMU Settings</h1>
<form method="post" action="">
<?php wp_nonce_field('tmu_wpmu_menu_nonce'); ?>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="tmu_wpmu_forgot_password_redirect">Forgot Password Redirect</label></th>
<td><input type="text" id="tmu_wpmu_forgot_password_redirect" name="tmu_wpmu_forgot_password_redirect" value="<?php echo esc_attr($current_value); ?>" class="regular-text" /></td>
</tr>
</table>
<?php submit_button('Save Changes', 'primary', 'tmu_wpmu_menu_submit'); ?>
</form>
</div>
<?php
}
?>