PluginProbe
Adminimize / 1.11.2
Adminimize v1.11.2
1.11.14 1.11.13 1.11.1 1.11.10 1.11.11 1.11.12 1.11.2 1.11.3 1.11.4 1.11.5 1.11.6 1.11.7 1.11.8 1.11.9 1.3 1.4.7 1.6 1.7.12 1.7.13 1.7.14 1.7.15 1.7.16 1.7.17 1.7.18 1.7.19 All 53 releases
adminimize / inc-options / menu_options.php

menu_options.php in Adminimize 1.11.2, at inc-options/menu_options.php

352 lines 11.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Adminimize
4 * @subpackage Menu, Submenu Options
5 * @author Frank Bültge
6 */
7 if ( ! function_exists( 'add_action' ) ) {
8 echo "Hi there! I'm just a part of plugin, not much I can do when called directly.";
9 exit;
10 }
11 ?>
12
13 <div id="poststuff" class="ui-sortable meta-box-sortables">
14 <div class="postbox">
15 <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'adminimize' ); ?>"><br /></div>
16 <h3 class="hndle" id="config_menu"><?php esc_attr_e( 'Menu Options', 'adminimize' ); ?></h3>
17
18 <div class="inside">
19 <br class="clear" />
20
21 <table summary="config_menu" class="widefat config_menu">
22 <colgroup>
23 <?php
24 $col = 0;
25 foreach ( $user_roles_names as $role_name ) {
26 echo '<col class="col' . $col . '">' . "\n";
27 $col ++;
28 }
29 ?>
30 </colgroup>
31 <thead>
32 <tr>
33 <th><?php esc_attr_e( 'Menu options - Menu, Submenu', 'adminimize' ); ?></th>
34
35 <?php foreach ( $user_roles_names as $role_name ) { ?>
36 <th><?php esc_attr_e( 'Deactivate for', 'adminimize' );
37 echo '<br/>' . $role_name; ?></th>
38 <?php } ?>
39
40 </tr>
41 <tr>
42 <td><?php esc_attr_e( 'Select all', 'adminimize' ); ?></td>
43 <?php
44 foreach ( $user_roles as $role_slug ) {
45 echo '<td class="num">';
46 echo '<span class="form-invalid">';
47 echo '<input id="select_all" class="menu_options_' . $role_slug
48 . '" type="checkbox" name="" value="" />';
49 echo '</span>';
50 echo '<input id="select_all" class="submenu_options_' . $role_slug
51 . '" type="checkbox" name="" value="" />';
52 echo '</td>' . "\n";
53 } ?>
54 </tr>
55 </thead>
56 <tbody>
57 <?php
58 $wp_menu = (array) _mw_adminimize_get_option_value( 'mw_adminimize_default_menu' );
59 $wp_submenu = (array) _mw_adminimize_get_option_value( 'mw_adminimize_default_submenu' );
60
61 // Object to array
62 if ( is_object( $wp_submenu ) ) {
63 $wp_submenu = get_object_vars( $wp_submenu );
64 }
65
66 if ( ! isset( $wp_menu ) || empty( $wp_menu ) ) {
67 global $menu;
68
69 $wp_menu = (array) $menu;
70 }
71 if ( ! isset( $wp_submenu ) || empty( $wp_submenu ) ) {
72 global $submenu;
73
74 $wp_submenu = $submenu;
75 }
76
77 // Enhance Menu with custom slugs.
78 $own_menu_slug = _mw_adminimize_get_option_value(
79 '_mw_adminimize_own_menu_slug'
80 );
81 $own_menu_custom_slug = _mw_adminimize_get_option_value(
82 '_mw_adminimize_own_menu_custom_slug'
83 );
84 $own_menu_slug = preg_split( "/\r\n/", $own_menu_slug );
85 $own_menu_custom_slug = preg_split( "/\r\n/", $own_menu_custom_slug );
86 foreach ( (array) $own_menu_slug as $key => $slug ) {
87 $wp_menu[] = array(
88 0 => trim( $slug ),
89 1 => '',
90 2 => $own_menu_custom_slug[ $key ],
91 3 => '',
92 4 => 'custom',
93 );
94 }
95
96 foreach ( $user_roles as $role ) {
97 $disabled_metaboxes_post_[ $role ] = _mw_adminimize_get_option_value(
98 'mw_adminimize_disabled_metaboxes_post_' . $role . '_items'
99 );
100 $disabled_metaboxes_page_[ $role ] = _mw_adminimize_get_option_value(
101 'mw_adminimize_disabled_metaboxes_page_' . $role . '_items'
102 );
103 }
104
105 // print menu, sub-menu
106 if ( isset( $wp_menu ) && '' !== $wp_menu ) {
107
108 $i = 0;
109 $x = 0;
110
111 $users = array(
112 0 => 'Profile',
113 1 => 'edit_users',
114 2 => 'profile.php',
115 3 => '',
116 4 => 'menu-top',
117 5 => 'menu-users',
118 6 => 'div',
119 );
120
121 foreach ( $wp_menu as $key => $item ) {
122
123 $menu_slug = $item[ 2 ];
124
125 // non checked items
126 if ( $menu_slug === 'options-general.php' ) {
127 $disabled_item_adm_hint = '<abbr title="' . esc_attr__(
128 'After activate the checkbox you will loose its easy access in the menu.', 'adminimize'
129 ) . '" style="cursor:pointer;"> ! </acronym>';
130 } else {
131 $disabled_item_adm = '';
132 $disabled_item_adm_hint = '';
133 }
134
135 if ( '' !== $menu_slug ) {
136
137 if ( 'wp-menu-separator' === $item[ 4 ] ) {
138 $item[ 0 ] = 'Separator';
139 }
140
141 foreach ( $user_roles as $role ) {
142
143 // checkbox checked
144 $checked_user_role_[ $role ] = '';
145 if ( isset( $disabled_menu_[ $role ] )
146 && in_array( $menu_slug, $disabled_menu_[ $role ], FALSE )
147 ) {
148 $checked_user_role_[ $role ] = ' checked="checked"';
149 }
150 }
151
152 if ( ! $item[ 0 ] ) {
153 $item[ 0 ] = '<b><i>' . esc_attr__( 'No Title!', 'adminimize' ) . '</i></b>';
154 }
155
156 $typ = esc_attr__( 'Group', 'adminimize' );
157 if ( 'custom' === $item[ 4 ] ) {
158 $typ = esc_attr__( 'Custom', 'adminimize' );
159 }
160
161 echo '<tr class="form-invalid">' . "\n";
162 echo "\t";
163 echo '<td>';
164 echo '<b>&bull; ' . strip_tags( $item[ 0 ] ) . '</b> <small>' . $typ . '</small>';
165 echo '<span>('
166 . preg_replace(
167 '#[%2].*#',
168 '...',
169 htmlentities( $menu_slug )
170 ) . ')</span>';
171 echo '</td>';
172
173 foreach ( $user_roles as $role ) {
174 if ( $role !== 'administrator' ) { // only admin disable items
175 $disabled_item_adm = '';
176 $disabled_item_adm_hint = '';
177 }
178 /**
179 * Switch to key of each Menu item
180 *
181 * @since 2016-01-29
182 * Use $key instead of htmlentities( $item[ 2 ] ) in the input field below, attribute value
183 */
184 echo "\t" . '<td class="num">' . $disabled_item_adm_hint . '<input id="check_menu'
185 . $role . $x . '" class="menu_options_'
186 . preg_replace( '/[^a-z0-9_-]+/', '', $role ) . '" type="checkbox"'
187 . $disabled_item_adm . $checked_user_role_[ $role ]
188 . ' name="mw_adminimize_disabled_menu_' . $role . '_items[]" value="'
189 . $menu_slug . '" />' . $disabled_item_adm_hint . '</td>' . "\n";
190 }
191 echo '</tr>';
192
193 // Only for user smaller administrator, change user-Profile-File.
194 if ( 'users.php' === $menu_slug ) {
195 $x ++;
196 echo '<tr>' . "\n";
197 echo "\t" . '<th>' . esc_attr__( 'Profile' ) . ' <span>(profile.php)</span> </th>';
198 foreach ( $user_roles as $role ) {
199 echo "\t" . '<td class="num"><input disabled="disabled" id="check_menu'
200 . $role . $x . '" class="menu_options_'
201 . preg_replace( '/[^a-z0-9_-]+/', '', $role )
202 . '" type="checkbox"' . $checked_user_role_[ $role ]
203 . ' name="mw_adminimize_disabled_menu_' . $role
204 . '_items[]" value="profile.php" /></td>' . "\n";
205 }
206 echo '</tr>';
207 }
208
209 $x ++;
210
211 if ( ! isset( $wp_submenu[ $menu_slug ] ) ) {
212 continue;
213 }
214
215 // Loop about Sub Menu items.
216 foreach ( $wp_submenu[ $menu_slug ] as $subkey => $subitem ) {
217 $submenu_slug = $subitem[ 2 ];
218
219 // Special solutions for the Adminimize link, that it not works on settings site.
220 if ( strtolower( $submenu_slug ) === 'adminimize/adminimize.php' ) {
221 //$disabled_subitem_adm = ' disabled="disabled"';
222 $disabled_subitem_adm_hint = '<abbr title="'
223 . esc_attr__(
224 'After activate the checkbox you will loose its easy access in the menu.',
225 'adminimize'
226 )
227 . '" style="cursor:pointer;"> ! </acronym>';
228 } else {
229 $disabled_subitem_adm = '';
230 $disabled_subitem_adm_hint = '';
231 }
232
233 echo '<tr>' . "\n";
234 foreach ( $user_roles as $role ) {
235 // checkbox checked
236 $checked_user_role_[ $role ] = '';
237 if ( isset( $disabled_submenu_[ $role ] )
238 // @since 2015-11-11
239 // Switch to custom key and url-slug of menu item.
240 && _mw_adminimize_in_arrays(
241 array( $menu_slug . '__' . $subkey, $submenu_slug ),
242 $disabled_submenu_[ $role ]
243 )
244 ) {
245 $checked_user_role_[ $role ] = ' checked="checked"';
246 }
247 }
248 echo '<td> &mdash; ' . strip_tags( $subitem[ 0 ] ) . ' <span>(Slug: '
249 . preg_replace(
250 '#[%2].*#',
251 '...',
252 htmlentities( $submenu_slug )
253 ) . ')[__' . $subkey . ']</span> </td>' . "\n";
254
255 foreach ( $user_roles as $role ) {
256 if ( $role !== 'administrator' ) { // only admin disable items
257 $disabled_subitem_adm = '';
258 $disabled_subitem_adm_hint = '';
259 }
260 echo '<td class="num">' . $disabled_subitem_adm_hint . '<input id="check_menu' . $role . $x
261 . '" class="submenu_options_' . $role . '" type="checkbox"'
262 . $disabled_subitem_adm . $checked_user_role_[ $role ]
263 . ' name="mw_adminimize_disabled_submenu_' . $role . '_items[]" value="'
264 . $menu_slug . '__' . $subkey . '" />' . $disabled_subitem_adm_hint . '</td>' . "\n";
265 }
266 echo '</tr>' . "\n";
267 $x ++;
268 }
269 $i ++;
270 $x ++;
271 }
272 }
273
274 } else {
275 $myErrors = new _mw_adminimize_message_class();
276 $myErrors = '<tr><td style="color: red;">' . $myErrors->get_error(
277 '_mw_adminimize_get_option'
278 ) . '</td></tr>';
279 echo $myErrors;
280 } ?>
281 </tbody>
282 </table>
283
284 <?php
285 //Your own dashboard options.
286 ?>
287 <br style="margin-top: 10px;" />
288 <table summary="config_edit_post" class="widefat">
289 <thead>
290 <tr>
291 <th><?php esc_attr_e( 'Your own options', 'adminimize' );
292 echo '<br />';
293 esc_attr_e( 'Slug', 'adminimize' ); ?></th>
294 <th><?php echo '<br />';
295 esc_attr_e( 'Custom Slug', 'adminimize' ); ?></th>
296 </tr>
297 </thead>
298
299 <tbody>
300 <tr valign="top">
301 <td colspan="2"><?php esc_attr_e(
302 'It is possible to add your own slugs for menu items.',
303 'adminimize'
304 ); ?></td>
305 </tr>
306 <tr valign="top">
307 <td>
308 <textarea name="_mw_adminimize_own_menu_slug" cols="60" rows="3"
309 id="_mw_adminimize_own_menu_slug" style="width: 95%;"><?php
310 echo _mw_adminimize_get_option_value(
311 '_mw_adminimize_own_menu_slug'
312 ); ?></textarea>
313 <br />
314 <label for="_mw_adminimize_own_menu_slug">
315 <?php esc_attr_e(
316 'Possible nomination for the slug. Separate multiple nominations through a carriage return.',
317 'adminimize'
318 ); ?>
319 </label>
320 </td>
321 <td>
322 <textarea class="code" name="_mw_adminimize_own_menu_custom_slug" cols="60" rows="3"
323 id="_mw_adminimize_own_menu_custom_slug" style="width: 95%;"><?php
324 echo _mw_adminimize_get_option_value(
325 '_mw_adminimize_own_menu_custom_slug'
326 ); ?></textarea>
327 <br />
328 <label for="_mw_adminimize_own_menu_custom_slug">
329 <?php esc_attr_e(
330 'String of the custom slug.',
331 'adminimize'
332 ); ?>
333 </label>
334 </td>
335 </tr>
336 </tbody>
337 </table>
338
339 <p id="submitbutton">
340 <input class="button button-primary" type="submit" name="_mw_adminimize_save" value="<?php esc_attr_e(
341 'Update Options', 'adminimize'
342 ); ?> &raquo;" /><input type="hidden" name="page_options" value="'dofollow_timeout'" />
343 </p>
344
345 <p>
346 <a class="alignright button" href="javascript:void(0);" onclick="window.scrollTo(0,0);" style="margin:3px 0 0 30px;"><?php esc_attr_e(
347 'scroll to top', 'adminimize'
348 ); ?></a><br class="clear" /></p>
349
350 </div>
351 </div>
352 </div>