-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin-page.php
59 lines (54 loc) · 1.58 KB
/
admin-page.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
<?php
function sm_scheduler_admin_menu() {
add_menu_page(
'Mars Share',
'Mars Share',
'manage_options',
'mars-share',
'sm_scheduler_admin_page',
'dashicons-share',
17
);
}
add_action('admin_menu', 'sm_scheduler_admin_menu');
function sm_scheduler_admin_page() {
?>
<div class="wrap">
<h2>Mars Share</h2>
<form method="post" action="options.php">
<?php
settings_fields('sm_scheduler_options_group');
do_settings_sections('mars-share');
submit_button();
?>
</form>
</div>
<?php
}
function sm_scheduler_settings_init() {
register_setting('sm_scheduler_options_group', 'sm_scheduler_options');
add_settings_section(
'sm_scheduler_section_developers',
__('Custom Settings', 'mars-share'),
'sm_scheduler_section_callback',
'mars-share'
);
add_settings_field(
'sm_scheduler_custom_message',
__('Custom Message', 'mars-share'),
'sm_scheduler_custom_message_render',
'mars-share',
'sm_scheduler_section_developers'
);
}
add_action('admin_init', 'sm_scheduler_settings_init');
function sm_scheduler_section_callback() {
echo '<p>Enter your custom message variations below. Separate them with a pipe "|" character.</p>';
}
function sm_scheduler_custom_message_render() {
$options = get_option('sm_scheduler_options');
?>
<input type='text' name='sm_scheduler_options[custom_message]'
value='<?php echo esc_attr($options['custom_message'] ?? ''); ?>' style="width: 100%;">
<?php
}