-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.class.php
More file actions
56 lines (46 loc) · 1.16 KB
/
settings.class.php
File metadata and controls
56 lines (46 loc) · 1.16 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
<?php
/**
* The Broadly Settings class
*
* Handling the Account ID database handling
*
* @author nofearinc
*
*/
class Broadly_Settings {
/**
* Register the Setting, and the required section and settings field.
*/
public function __construct() {
register_setting( 'broadly_options', 'broadly_options' );
add_settings_section(
'broadly_admin_section',
null,
null,
'broadly'
);
add_settings_field(
'broadly_account_id',
__( 'Business ID', 'broadly' ),
array( $this, 'broadly_account_id_cb' ),
'broadly',
'broadly_admin_section'
);
}
/**
* Broadly Account ID field management
*/
public function broadly_account_id_cb() {
$broadly_options = get_option( 'broadly_options', array() );
$account_id = '';
if ( is_array( $broadly_options ) && ! empty( $broadly_options['broadly_account_id'] ) ) {
// Make sure it's properly escaped
$account_id = esc_html( $broadly_options['broadly_account_id'] );
}
echo "<input type=\"text\" name=\"broadly_options[broadly_account_id]\" value='$account_id'>";
}
}
/**
* Initialize the Settings class
*/
$broadly_settings = new Broadly_Settings();