/
rpp-options.php
executable file
·235 lines (154 loc) · 11 KB
/
rpp-options.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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<div class="wrap">
<?php screen_icon(); ?>
<h2><?php _e('Restrict Page Parents', 'restrict-page-parents'); ?></h2>
<form method="post" action="options.php">
<?php settings_fields('rpp_plugin_options'); ?>
<?php $options = get_option('rpp_options'); ?>
<div id="poststuff">
<div id="post-body" class="metabox-holder columns-2">
<!-- main content -->
<div id="post-body-content">
<div class="meta-box">
<h2><?php _e('Role Permissions', 'restrict-page-parents'); ?></h2>
<table class="widefat">
<thead>
<tr>
<th class="row-title" width="40%"><?php _e('Role Name', 'restrict-page-parents'); ?></th>
<th><?php _e('Page Parent Restrictions', 'restrict-page-parents'); ?></th>
<th><?php _e('Force Page Parent', 'restrict-page-parents'); ?></th>
</tr>
</thead>
<tbody>
<?php
// get all available roles
global $wp_roles;
$roles = $wp_roles->roles;
$i = 0;
foreach ($roles as $role) :
if (isset($role['capabilities']['edit_pages']) && $role['capabilities']['edit_pages'] == 1) :
?>
<tr <?php if ($i%2) echo 'class="alt"'; ?>>
<td class="row-title"><?php echo $role['name']; ?></td>
<td>
<fieldset>
<select name="rpp_options[enable_restrictions-<?php echo strtolower($role['name']); ?>]" id="rpp_options[enable_restrictions-<?php echo strtolower($role['name']); ?>]">
<option value="0" <?php selected('0', $options['enable_restrictions-' . strtolower($role['name'])]); ?>><?php _e('Disable', 'restrict-page-parents'); ?></option>
<option value="1" <?php selected('1', $options['enable_restrictions-' . strtolower($role['name'])]); ?>><?php _e('Enable', 'restrict-page-parents'); ?></option>
</select>
</fieldset>
</td>
<td>
<fieldset>
<select name="rpp_options[force_parent-<?php echo strtolower($role['name']); ?>]" id="rpp_options[force_parent-<?php echo strtolower($role['name']); ?>]">
<option value="0" <?php selected('0', $options['force_parent-' . strtolower($role['name'])]); ?>><?php _e('Disable', 'restrict-page-parents'); ?></option>
<option value="1" <?php selected('1', $options['force_parent-' . strtolower($role['name'])]); ?>><?php _e('Enable', 'restrict-page-parents'); ?></option>
</select>
</fieldset>
</td>
</tr>
<?php $i++; endif; endforeach; ?>
</tbody>
</table>
<h2><?php _e('User Permissions', 'restrict-page-parents'); ?></h2>
<p><?php _e('Permissions set for an individual user will override any role permissions set.', 'restrict-page-parents'); ?></p>
<table class="widefat">
<thead>
<tr>
<th><?php _e('Override?', 'restrict-page-parents'); ?></th>
<th class="row-title" width="25%"><?php _e('Username', 'restrict-page-parents'); ?></th>
<th><?php _e('Page Parent Restrictions', 'restrict-page-parents'); ?></th>
<th><?php _e('Force Page Parent', 'restrict-page-parents'); ?></th>
</tr>
</thead>
<tbody>
<?php
// get all available users
$users = get_users();
$i = 0;
foreach ($users as $user) :
if (isset($user->allcaps['edit_pages']) && $user->allcaps['edit_pages'] == 1) :
?>
<tr <?php if ($i%2) echo 'class="alt"'; ?>>
<td>
<input name="rpp_options[override-<?php echo $user->user_login; ?>]"
type="checkbox"
value="1"
<?php if (isset($options['override-' . $user->user_login])) { checked('1', $options['override-' . $user->user_login]); } ?>
/>
</td>
<td class="row-title"><?php echo $user->user_login ?></td>
<td>
<fieldset>
<select name="rpp_options[enable_restrictions-<?php echo $user->user_login; ?>]" id="rpp_options[enable_restrictions-<?php echo $user->user_login; ?>]">
<option value="0" <?php selected('0', $options['enable_restrictions-' . $user->user_login]); ?>><?php _e('Disable', 'restrict-page-parents'); ?></option>
<option value="1" <?php selected('1', $options['enable_restrictions-' . $user->user_login]); ?>><?php _e('Enable', 'restrict-page-parents'); ?></option>
</select>
</fieldset>
</td>
<td>
<fieldset>
<select name="rpp_options[force_parent-<?php echo $user->user_login; ?>]" id="rpp_options[force_parent-<?php echo $user->user_login; ?>]">
<option value="0" <?php selected('0', $options['force_parent-' . $user->user_login]); ?>><?php _e('Disable', 'restrict-page-parents'); ?></option>
<option value="1" <?php selected('1', $options['force_parent-' . $user->user_login]); ?>><?php _e('Enable', 'restrict-page-parents'); ?></option>
</select>
</fieldset>
</td>
</tr>
<?php $i++; endif; endforeach; ?>
</tbody>
</table>
<h2><?php _e('Post Types', 'restrict-page-parents'); ?></h2>
<p><?php _e('Select the post types to enable restrictions for. If none are set, it will default to all.', 'restrict-page-parents'); ?></p>
<table class="widefat">
<thead>
<tr>
<th class="row-title"><?php _e('Post Type', 'restrict-page-parents'); ?></th>
<th class="row-title" width="25%"><?php _e('Enable?', 'restrict-page-parents'); ?></th>
</tr>
</thead>
<tbody>
<?php
// get all available users
$post_types=get_post_types();
$i = 0;
foreach ($post_types as $post_type) :
if (is_post_type_hierarchical($post_type)) :
?>
<tr <?php if ($i%2) echo 'class="alt"'; ?>>
<td class="row-title" width="30%">
<?php echo $post_type; ?>
</td>
<td width="70%">
<input name="rpp_options[type-<?php echo $post_type; ?>]"
type="checkbox"
value="1"
<?php if (isset($options['type-' . $post_type])) { checked('1', $options['type-' . $post_type]); } ?>
/>
</td>
</tr>
<?php $i++; endif; endforeach; ?>
</tbody>
</table>
</div><!-- .meta-box -->
</div><!-- post-body-content -->
<!-- sidebar -->
<div id="postbox-container-1" class="postbox-container">
<div class="meta-box" style="margin-top:66px">
<div class="postbox">
<h3><span>About Restrict Page Parents</span></h3>
<div class="inside">
<p>Restrict Page Parents prevents the set user roles or users from setting a page parent that isn't owned by them. It can also force these users to set a page parent.</p>
<p><em>NOTE: Only roles and users with the ability to edit pages will show here.</em></p>
<p>It's designed to enhance WordPress websites that have multiple editors, creating finer control over content management.</p>
<p>The plugin is built by <a href="http://www.tommaitland.net/" target="_blank">Tom Maitland</a>, the code lives on <a href="#">GitHub</a>.</p>
</div>
</div><!-- .postbox -->
</div><!-- .meta-box -->
</div><!-- #postbox-container-1 .postbox-container -->
</div><!-- #post-body .metabox-holder .columns-2 -->
<br class="clear">
</div><!-- #poststuff -->
<br />
<input class="button-primary" type="submit" name="Example" value="<?php _e( 'Save Changes', 'restrict-page-parents' ); ?>" />
</form>
</div> <!-- .wrap -->