-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.php
More file actions
75 lines (62 loc) · 1.75 KB
/
settings.php
File metadata and controls
75 lines (62 loc) · 1.75 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
67
68
69
70
71
72
73
74
75
<?php
class Runscope_Settings {
public function __construct() {
if ( is_admin() ) {
add_action( 'admin_menu', array( $this, 'add_plugin_page' ) );
add_action( 'admin_init', array( $this, 'page_init' ) );
}
}
public function add_plugin_page(){
// This page will be under "Settings"
add_options_page( 'Runscope Settings', 'Runscope Settings', 'manage_options', 'runscope-settings-admin', array( $this, 'create_admin_page' ) );
}
public function create_admin_page() {
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2>Settings</h2>
<form method="post" action="options.php">
<?php
settings_fields( 'runscope_option_group' );
do_settings_sections( 'runscope-settings-admin' );
submit_button();
?>
</form>
</div>
<?php
}
public function page_init() {
register_setting( 'runscope_option_group', 'array_key', array( $this, 'check_ID' ) );
add_settings_section(
'setting_section_id',
'Bucket Settings',
array( $this, 'print_section_info' ),
'runscope-settings-admin'
);
add_settings_field(
'runscope_bucket_id',
'Bucket ID',
array( $this, 'create_an_id_field' ),
'runscope-settings-admin',
'setting_section_id'
);
}
public function check_ID( $input ) {
$mid = $input['runscope_bucket_id'];
if ( get_option( 'runscope_bucket_id' ) === FALSE ) {
add_option( 'runscope_bucket_id', $mid );
} else {
update_option( 'runscope_bucket_id', $mid );
}
return $mid;
}
public function print_section_info(){
print 'Enter your bucket ID below:';
}
public function create_an_id_field(){
?>
<input type="text" id="bucket" name="array_key[runscope_bucket_id]" value="<?php echo get_option( 'runscope_bucket_id' ); ?>" />
<?php
}
}
$runscope_settings = new Runscope_Settings();