-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwp-orphanage-extended-options.php
74 lines (63 loc) · 2.97 KB
/
wp-orphanage-extended-options.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
if ( ! current_user_can( 'manage_options' ) ) {
wp_die( __( 'You do not have sufficient permissions to access this page.', WPOEX_TD ) );
}
// Update options
if ( isset( $_POST['action'] ) && $_POST['action'] == 'update' ) {
// Check nonce
check_admin_referer( 'wporphanageex-settings' );
update_option( 'wporphanageex_role', $_POST['wporphanageex_role'] );
if ( isset( $_POST['wporphanageex_prefixes'] ) && is_array( $_POST['wporphanageex_prefixes'] ) ) {
$prefixes = array();
foreach ( $_POST['wporphanageex_prefixes'] as $prefix ) {
if ( ! empty( $prefix ) ) {
$prefixes[] = wp_kses_data( $prefix );
}
}
update_option( 'wporphanageex_prefixes', $prefixes );
}
echo '<div class="updated"><p><strong>' . __( 'Settings saved', WPOEX_TD ) . '</strong></p></div>';
}
$roles = wporphanageex_get_roles();
$wp_orphanageex_role = get_option( 'wporphanageex_role' );
$prefixes = get_option( 'wporphanageex_prefixes' );
?>
<div class="wrap">
<h1><?php _e( 'WP Orphanage Extended', WPOEX_TD ); ?></h1>
<form method="post" action="" id="wporphanageex-settings">
<input type="hidden" name="action" value="update" />
<?php wp_nonce_field( 'wporphanageex-settings' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="wporphanageex_role"><?php _e( 'Choose Default Role:', WPOEX_TD ); ?></label></th>
<td>
<select name="wporphanageex_role" id="wporphanageex_role">
<?php if ( $roles ) : ?>
<?php foreach ( $roles as $role => $value ) : ?>
<option value="<?php echo esc_attr( $role ); ?>" <?php selected( $wp_orphanageex_role, $role ); ?>><?php echo esc_html( ucfirst( $role ) ); ?></option>
<?php endforeach; ?>
<?php endif; ?>
</select><br />
<small><?php _e( 'Choose the default role orphan users should be promoted to (if no role to copy from other table was found).', WPOEX_TD ); ?></small>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="wporphanageex_prefixes"><?php _e( 'Add WP Prefixes:', WPOEX_TD ); ?></label></th>
<td>
<?php if ( $prefixes ) : ?>
<?php $i = 1; ?>
<?php foreach ( $prefixes as $prefix ) : ?>
<?php _e( 'Prefix', WPOEX_TD ); ?> <?php echo $i; ?>: <input name="wporphanageex_prefixes[]" id="wporphanageex_prefixes_<?php echo $i; ?>" class="regular-text" type="text" value="<?php echo esc_attr( $prefix ); ?>" /><br />
<?php $i++; ?>
<?php endforeach; ?>
<?php endif; ?>
<br /><?php _e( 'Add new:', WPOEX_TD ); ?> <input name="wporphanageex_prefixes[]" id="wporphanageex_prefixes" class="regular-text" type="text" value="" /><br />
<small><?php _e( 'Add prefixes of all WP installs where to search for user role. To remove field, leave it empty. Default WP prefix is <code>wp_</code> ', WPOEX_TD ); ?></small>
</td>
</tr>
</table>
<p class="submit">
<input type="submit" name="submit" value="<?php _e( 'Save Changes', WPOEX_TD ); ?>" class="button-primary" />
</p>
</form>
</div>