options-page.php
2.11 KB
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
<?php
// create custom custom_user_email_menu
add_action('admin_menu', 'custom_user_email_menu');
function custom_user_email_menu() {
//create new menu for plugin
add_menu_page('User email Settings', 'New User email', 'administrator', __FILE__, 'custom_user_email_settings_page' , plugins_url('/mail.png', __FILE__) );
//call register settings function
add_action( 'admin_init', 'custom_user_email_settings' );
}
function custom_user_email_settings() {
//register settings
register_setting( 'custom-user-email-settings-group', '_email_subject' );
register_setting( 'custom-user-email-settings-group', '_email_text' );
//register_setting( 'custom-user-email-settings-group', '_email_footer_text' );
}
function custom_user_email_settings_page() {
?>
<div class="wrap">
<h1><?php echo PLUGIN_NAME; ?></h1>
<div class="wp_new_user_panel">
<b><?php _e('Shortcodes', 'custom-user-email'); ?></b>
<p><?php _e('You can use these shortcodes to customize each message. (Ex Dear [[first_name]]).', 'custom-user-email'); ?></p>
<b>[[site_url]] [[password_url]] [[username]] [[first_name]] [[last_name]]</b>
</div>
<form method="post" action="options.php">
<?php settings_fields( 'custom-user-email-settings-group' ); ?>
<?php do_settings_sections( 'custom-user-email-settings-group' ); ?>
<table class="form-table">
<tr valign="top">
<th scope="row">
<?php _e('Welcome email Subject', 'custom-user-email'); ?>
</th>
<td>
<input type="text" name="_email_subject" class="regular-text" value="<?php echo esc_attr( get_option('_email_subject') ); ?>" />
<small><?php _e('Your welcome email subject for new user notification', 'custom-user-email'); ?></small>
</td>
</tr>
<tr valign="top">
<th scope="row">
<?php _e('Welcome email text', 'custom-user-email'); ?>
</th>
<td>
<?php
$content = get_option('_email_text');
$editor_id = '_email_text';
wp_editor( $content, $editor_id ); ?>
</td>
</tr>
<tr>
<th scope="row"></th>
<td><?php submit_button(); ?></td>
</tr>
</table>
</form>
</div>
<?php } ?>