PluginProbe
Adminimize / 1.11.3
Adminimize v1.11.3
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.3, at inc-options/menu_options.php

360 lines 11.5 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 /**
112 * @ToDo Remove it after feedback from users.
113 *
114 $users = array(
115 0 => 'Profile',
116 1 => 'edit_users',
117 2 => 'profile.php',
118 3 => '',
119 4 => 'menu-top',
120 5 => 'menu-users',
121 6 => 'div',
122 );
123 */
124
125 foreach ( $wp_menu as $key => $item ) {
126
127 $menu_slug = $item[ 2 ];
128
129 // non checked items
130 if ( $menu_slug === 'options-general.php' ) {
131 $disabled_item_adm_hint = '<abbr title="' . esc_attr__(
132 'After activate the checkbox you will loose its easy access in the menu.', 'adminimize'
133 ) . '" style="cursor:pointer;"> ! </acronym>';
134 } else {
135 $disabled_item_adm = '';
136 $disabled_item_adm_hint = '';
137 }
138
139 if ( '' !== $menu_slug ) {
140
141 if ( 'wp-menu-separator' === $item[ 4 ] ) {
142 $item[ 0 ] = 'Separator';
143 }
144
145 foreach ( $user_roles as $role ) {
146
147 // checkbox checked
148 $checked_user_role_[ $role ] = '';
149 if ( isset( $disabled_menu_[ $role ] )
150 && in_array( $menu_slug, $disabled_menu_[ $role ], FALSE )
151 ) {
152 $checked_user_role_[ $role ] = ' checked="checked"';
153 }
154 }
155
156 if ( ! $item[ 0 ] ) {
157 $item[ 0 ] = '<b><i>' . esc_attr__( 'No Title!', 'adminimize' ) . '</i></b>';
158 }
159
160 $typ = esc_attr__( 'Group', 'adminimize' );
161 if ( 'custom' === $item[ 4 ] ) {
162 $typ = esc_attr__( 'Custom', 'adminimize' );
163 }
164
165 echo '<tr class="form-invalid">' . "\n";
166 echo "\t";
167 echo '<td>';
168 echo '<b>&bull; ' . strip_tags( $item[ 0 ] ) . '</b> <small>' . $typ . '</small>';
169 echo '<span>('
170 . preg_replace(
171 '#[%2].*#',
172 '...',
173 htmlentities( $menu_slug )
174 ) . ')</span>';
175 echo '</td>';
176
177 foreach ( $user_roles as $role ) {
178 if ( $role !== 'administrator' ) { // only admin disable items
179 $disabled_item_adm = '';
180 $disabled_item_adm_hint = '';
181 }
182 /**
183 * Switch to key of each Menu item
184 *
185 * @since 2016-01-29
186 * Use $key instead of htmlentities( $item[ 2 ] ) in the input field below, attribute value
187 */
188 echo "\t" . '<td class="num">' . $disabled_item_adm_hint . '<input id="check_menu'
189 . $role . $x . '" class="menu_options_'
190 . preg_replace( '/[^a-z0-9_-]+/', '', $role ) . '" type="checkbox"'
191 . $disabled_item_adm . $checked_user_role_[ $role ]
192 . ' name="mw_adminimize_disabled_menu_' . $role . '_items[]" value="'
193 . $menu_slug . '" />' . $disabled_item_adm_hint . '</td>' . "\n";
194 }
195 echo '</tr>';
196
197 /**
198 * @ToDo Remove it after feedback from users.
199 *
200 // Only for user smaller administrator, change user-Profile-File.
201 if ( 'users.php' === $menu_slug ) {
202 $x ++;
203 echo '<tr>' . "\n";
204 echo "\t" . '<th>' . esc_attr__( 'Profile' ) . ' <span>(profile.php)</span> </th>';
205 foreach ( $user_roles as $role ) {
206 echo "\t" . '<td class="num"><input disabled="disabled" id="check_menu'
207 . $role . $x . '" class="menu_options_'
208 . preg_replace( '/[^a-z0-9_-]+/', '', $role )
209 . '" type="checkbox"' . $checked_user_role_[ $role ]
210 . ' name="mw_adminimize_disabled_menu_' . $role
211 . '_items[]" value="profile.php" /></td>' . "\n";
212 }
213 echo '</tr>';
214 }
215 */
216
217 $x ++;
218
219 if ( ! isset( $wp_submenu[ $menu_slug ] ) ) {
220 continue;
221 }
222
223 // Loop about Sub Menu items.
224 foreach ( $wp_submenu[ $menu_slug ] as $subkey => $subitem ) {
225 $submenu_slug = $subitem[ 2 ];
226
227 // Special solutions for the Adminimize link, that it not works on settings site.
228 if ( strtolower( $submenu_slug ) === 'adminimize/adminimize.php' ) {
229 //$disabled_subitem_adm = ' disabled="disabled"';
230 $disabled_subitem_adm_hint = '<abbr title="'
231 . esc_attr__(
232 'After activate the checkbox you will loose its easy access in the menu.',
233 'adminimize'
234 )
235 . '" style="cursor:pointer;"> ! </acronym>';
236 } else {
237 $disabled_subitem_adm = '';
238 $disabled_subitem_adm_hint = '';
239 }
240
241 echo '<tr>' . "\n";
242 foreach ( $user_roles as $role ) {
243 // checkbox checked
244 $checked_user_role_[ $role ] = '';
245 if ( isset( $disabled_submenu_[ $role ] )
246 // @since 2015-11-11
247 // Switch to custom key and url-slug of menu item.
248 && _mw_adminimize_in_arrays(
249 array( $menu_slug . '__' . $subkey, $submenu_slug ),
250 $disabled_submenu_[ $role ]
251 )
252 ) {
253 $checked_user_role_[ $role ] = ' checked="checked"';
254 }
255 }
256 echo '<td> &mdash; ' . strip_tags( $subitem[ 0 ] ) . ' <span>(Slug: '
257 . preg_replace(
258 '#[%2].*#',
259 '...',
260 htmlentities( $submenu_slug )
261 ) . ')[__' . $subkey . ']</span> </td>' . "\n";
262
263 foreach ( $user_roles as $role ) {
264 if ( $role !== 'administrator' ) { // only admin disable items
265 $disabled_subitem_adm = '';
266 $disabled_subitem_adm_hint = '';
267 }
268 echo '<td class="num">' . $disabled_subitem_adm_hint . '<input id="check_menu' . $role . $x
269 . '" class="submenu_options_' . $role . '" type="checkbox"'
270 . $disabled_subitem_adm . $checked_user_role_[ $role ]
271 . ' name="mw_adminimize_disabled_submenu_' . $role . '_items[]" value="'
272 . $menu_slug . '__' . $subkey . '" />' . $disabled_subitem_adm_hint . '</td>' . "\n";
273 }
274 echo '</tr>' . "\n";
275 $x ++;
276 }
277 $i ++;
278 $x ++;
279 }
280 }
281
282 } else {
283 $myErrors = new _mw_adminimize_message_class();
284 $myErrors = '<tr><td style="color: red;">' . $myErrors->get_error(
285 '_mw_adminimize_get_option'
286 ) . '</td></tr>';
287 echo $myErrors;
288 } ?>
289 </tbody>
290 </table>
291
292 <?php
293 //Your own dashboard options.
294 ?>
295 <br style="margin-top: 10px;" />
296 <table summary="config_edit_post" class="widefat">
297 <thead>
298 <tr>
299 <th><?php esc_attr_e( 'Your own options', 'adminimize' );
300 echo '<br />';
301 esc_attr_e( 'Slug', 'adminimize' ); ?></th>
302 <th><?php echo '<br />';
303 esc_attr_e( 'Custom Slug', 'adminimize' ); ?></th>
304 </tr>
305 </thead>
306
307 <tbody>
308 <tr valign="top">
309 <td colspan="2"><?php esc_attr_e(
310 'It is possible to add your own slugs for menu items.',
311 'adminimize'
312 ); ?></td>
313 </tr>
314 <tr valign="top">
315 <td>
316 <textarea name="_mw_adminimize_own_menu_slug" cols="60" rows="3"
317 id="_mw_adminimize_own_menu_slug" style="width: 95%;"><?php
318 echo _mw_adminimize_get_option_value(
319 '_mw_adminimize_own_menu_slug'
320 ); ?></textarea>
321 <br />
322 <label for="_mw_adminimize_own_menu_slug">
323 <?php esc_attr_e(
324 'Possible nomination for the slug. Separate multiple nominations through a carriage return.',
325 'adminimize'
326 ); ?>
327 </label>
328 </td>
329 <td>
330 <textarea class="code" name="_mw_adminimize_own_menu_custom_slug" cols="60" rows="3"
331 id="_mw_adminimize_own_menu_custom_slug" style="width: 95%;"><?php
332 echo _mw_adminimize_get_option_value(
333 '_mw_adminimize_own_menu_custom_slug'
334 ); ?></textarea>
335 <br />
336 <label for="_mw_adminimize_own_menu_custom_slug">
337 <?php esc_attr_e(
338 'String of the custom slug.',
339 'adminimize'
340 ); ?>
341 </label>
342 </td>
343 </tr>
344 </tbody>
345 </table>
346
347 <p id="submitbutton">
348 <input class="button button-primary" type="submit" name="_mw_adminimize_save" value="<?php esc_attr_e(
349 'Update Options', 'adminimize'
350 ); ?> &raquo;" /><input type="hidden" name="page_options" value="'dofollow_timeout'" />
351 </p>
352
353 <p>
354 <a class="alignright button" href="javascript:void(0);" onclick="window.scrollTo(0,0);" style="margin:3px 0 0 30px;"><?php esc_attr_e(
355 'scroll to top', 'adminimize'
356 ); ?></a><br class="clear" /></p>
357
358 </div>
359 </div>
360 </div>