-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDeclutterWP.SettingsPage.php
More file actions
153 lines (136 loc) · 3.71 KB
/
DeclutterWP.SettingsPage.php
File metadata and controls
153 lines (136 loc) · 3.71 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php
/*
* SettingsPage
*/
class DeclutterWP_SettingsPage {
public function __construct() {
add_action('admin_menu', array($this, 'addPage'));
add_action('admin_init', array( $this, 'initPage'));
}
public function addPage() {
add_options_page(
DECLUTTER_WP_NAME,
DECLUTTER_WP_NAME,
'manage_options',
'declutter-wp',
array($this, 'createPage')
);
}
public function createPage() {
$this->options = get_option('declutter_wp_options');
?>
<div class="wrap">
<h1><?php echo DECLUTTER_WP_NAME; ?></h1>
<p>
<b><?php echo DECLUTTER_WP_DESCRIPTION; ?></b><br>
Find information, report issues and make contributions on <a href="<?php echo DECLUTTER_WP_URL; ?>" title="<?php echo DECLUTTER_WP_NAME; ?>" target="_blank">GitHub</a>.
</p>
<form method="post" action="options.php">
<?php
settings_fields('declutter_wp');
do_settings_sections( 'declutter-wp' );
submit_button();
?>
</form>
</div>
<?php
}
public function initPage() {
register_setting(
'declutter_wp',
'declutter_wp_options'
);
add_settings_section(
'general-settings',
'General Settings',
array(
$this,
'printGeneralInfo'
),
'declutter-wp'
);
add_settings_field(
'remove-header-junk',
'Remove header junk',
array(
$this,
'printCheckbox'
),
'declutter-wp',
'general-settings',
array(
$this,
'field' => 'remove-header-junk',
'description' => 'Remove unnecessarily injected links from the header'
)
);
add_settings_field(
'disable-json-rest-api',
'Disable JSON REST API',
array(
$this,
'printCheckbox'
),
'declutter-wp',
'general-settings',
array(
$this,
'field' => 'disable-json-rest-api',
'description' => 'Disable the JSON REST API'
)
);
add_settings_field(
'disable-oembed',
'Disable OEmbed',
array(
$this,
'printCheckbox'
),
'declutter-wp',
'general-settings',
array(
$this,
'field' => 'disable-oembed',
'description' => 'Disable auto embed functionality'
)
);
add_settings_field(
'disable-xml-rpc',
'Disable XML-RPC',
array(
$this,
'printCheckbox'
),
'declutter-wp',
'general-settings',
array(
$this,
'field' => 'disable-xml-rpc',
'description' => 'Disable the XML-RPC API'
)
);
add_settings_field(
'remove-emoji-support',
'Remove emoji support',
array(
$this,
'printCheckbox'
),
'declutter-wp',
'general-settings',
array(
$this,
'field' => 'remove-emoji-support',
'description' => 'Disable support for Emojis'
)
);
}
public function printGeneralInfo() {
// print '';
}
public function printCheckbox($args) {
$field = $args['field'];
$checked = isset($this->options[$field]) ? ' checked' : '';
echo '<input type="checkbox" id="' . $field . '" name="declutter_wp_options[' . $field . ']"' . $checked . '><label for="' . $field . '">' . $args['description'] . '</label>';
}
}