PluginProbe
Adminimize / 1.9.1
Adminimize v1.9.1
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
← All changes | inc-options/menu_options.php +74 -166 1.11.1 → 1.9.1 View file →
@@ -11,24 +11,15 @@
11 11 ?>
12 12
13 13 <div id="poststuff" class="ui-sortable meta-box-sortables">
14 14 <div class="postbox">
15 - <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'adminimize' ); ?>"><br /></div>
15 + <div class="handlediv" title="<?php esc_attr_e( 'Click to toggle' ); ?>"><br /></div>
16 16 <h3 class="hndle" id="config_menu"><?php esc_attr_e( 'Menu Options', 'adminimize' ); ?></h3>
17 17
18 18 <div class="inside">
19 19 <br class="clear" />
20 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>
21 + <table summary="config_menu" class="widefat">
31 22 <thead>
32 23 <tr>
33 24 <th><?php esc_attr_e( 'Menu options - Menu, Submenu', 'adminimize' ); ?></th>
34 25
@@ -40,16 +31,18 @@
40 31 </tr>
41 32 <tr>
42 33 <td><?php esc_attr_e( 'Select all', 'adminimize' ); ?></td>
43 34 <?php
44 - foreach ( $user_roles as $role_slug ) {
35 + foreach ( $user_roles_names as $role_name ) {
36 + $role_name = strtolower( $role_name );
37 + $role_name = preg_replace( '/[^a-z0-9]+/', '', $role_name );
45 38 echo '<td class="num">';
46 39 echo '<span class="form-invalid">';
47 - echo '<input id="select_all" class="menu_options_' . $role_slug
48 - . '" type="checkbox" name="" value="" />';
40 + echo '<input id="select_all" class="menu_options_' . $role_name
41 + . '" type="checkbox" name="" value="" />';
49 42 echo '</span>';
50 - echo '<input id="select_all" class="submenu_options_' . $role_slug
51 - . '" type="checkbox" name="" value="" />';
43 + echo '<input id="select_all" class="submenu_options_' . $role_name
44 + . '" type="checkbox" name="" value="" />';
52 45 echo '</td>' . "\n";
53 46 } ?>
54 47 </tr>
55 48 </thead>
@@ -54,10 +47,10 @@
54 47 </tr>
55 48 </thead>
56 49 <tbody>
57 50 <?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' );
51 + $wp_menu = _mw_adminimize_get_option_value( 'mw_adminimize_default_menu' );
52 + $wp_submenu = _mw_adminimize_get_option_value( 'mw_adminimize_default_submenu' );
60 53
61 54 // Object to array
62 55 if ( is_object( $wp_submenu ) ) {
63 56 $wp_submenu = get_object_vars( $wp_submenu );
@@ -65,9 +58,9 @@
65 58
66 59 if ( ! isset( $wp_menu ) || empty( $wp_menu ) ) {
67 60 global $menu;
68 61
69 - $wp_menu = (array) $menu;
62 + $wp_menu = $menu;
70 63 }
71 64 if ( ! isset( $wp_submenu ) || empty( $wp_submenu ) ) {
72 65 global $submenu;
73 66
@@ -73,27 +66,8 @@
73 66
74 67 $wp_submenu = $submenu;
75 68 }
76 69
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 70 foreach ( $user_roles as $role ) {
97 71 $disabled_metaboxes_post_[ $role ] = _mw_adminimize_get_option_value(
98 72 'mw_adminimize_disabled_metaboxes_post_' . $role . '_items'
99 73 );
@@ -101,13 +75,13 @@
101 75 'mw_adminimize_disabled_metaboxes_page_' . $role . '_items'
102 76 );
103 77 }
104 78
105 - // print menu, sub-menu
79 + // print menu, submenu
106 80 if ( isset( $wp_menu ) && '' !== $wp_menu ) {
107 81
108 - $i = 0;
109 - $x = 0;
82 + $i = 0;
83 + $x = 0;
110 84
111 85 $users = array(
112 86 0 => 'Profile',
113 87 1 => 'edit_users',
@@ -114,19 +88,17 @@
114 88 2 => 'profile.php',
115 89 3 => '',
116 90 4 => 'menu-top',
117 91 5 => 'menu-users',
118 - 6 => 'div',
92 + 6 => 'div'
119 93 );
120 94
121 95 foreach ( $wp_menu as $key => $item ) {
122 96
123 - $menu_slug = $item[ 2 ];
124 -
125 97 // non checked items
126 - if ( $menu_slug === 'options-general.php' ) {
98 + if ( $item[ 2 ] === 'options-general.php' ) {
127 99 $disabled_item_adm_hint = '<abbr title="' . esc_attr__(
128 - 'After activate the checkbox you will loose its easy access in the menu.', 'adminimize'
100 + 'After activate the check box it heavy attitudes will change.', 'adminimize'
129 101 ) . '" style="cursor:pointer;"> ! </acronym>';
130 102 } else {
131 103 $disabled_item_adm = '';
132 104 $disabled_item_adm_hint = '';
@@ -131,9 +103,9 @@
131 103 $disabled_item_adm = '';
132 104 $disabled_item_adm_hint = '';
133 105 }
134 106
135 - if ( '' !== $menu_slug ) {
107 + if ( '' !== $item[ 2 ] ) {
136 108
137 109 if ( 'wp-menu-separator' === $item[ 4 ] ) {
138 110 $item[ 0 ] = 'Separator';
139 111 }
@@ -142,34 +114,30 @@
142 114
143 115 // checkbox checked
144 116 $checked_user_role_[ $role ] = '';
145 117 if ( isset( $disabled_menu_[ $role ] )
146 - && in_array( $menu_slug, $disabled_menu_[ $role ], FALSE )
118 + // @since 2015-11-11
119 + // Switch to the key and url of menu item.
120 + && _mw_adminimize_in_arrays( array( $key, $item[ 2 ] ), $disabled_menu_[ $role ] )
147 121 ) {
148 122 $checked_user_role_[ $role ] = ' checked="checked"';
149 123 }
150 124 }
151 125
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 126 echo '<tr class="form-invalid">' . "\n";
162 127 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>';
128 + echo '<th>';
129 + echo '<b>&bull; ' . $item[ 0 ] . '</b> <small>' . esc_attr__(
130 + 'Group', 'adminimize'
131 + ) . '</small>';
132 + echo '<span>'
133 + . $key . '('
134 + . preg_replace(
135 + "#[%2].*#",
136 + '...',
137 + htmlentities( $item[ 2 ] )
138 + ) . ')</span>';
139 + echo '</th>';
172 140
173 141 foreach ( $user_roles as $role ) {
174 142 if ( $role !== 'administrator' ) { // only admin disable items
175 143 $disabled_item_adm = '';
@@ -174,35 +142,29 @@
174 142 if ( $role !== 'administrator' ) { // only admin disable items
175 143 $disabled_item_adm = '';
176 144 $disabled_item_adm_hint = '';
177 145 }
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 146 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";
147 + . $role . $x . '" class="menu_options_'
148 + . preg_replace( '/[^a-z0-9]+/', '', $role ) . '" type="checkbox"'
149 + . $disabled_item_adm . $checked_user_role_[ $role ]
150 + . ' name="mw_adminimize_disabled_menu_' . $role . '_items[]" value="'
151 + . htmlentities( $item[ 2 ] ) . '" />' . $disabled_item_adm_hint . '</td>' . "\n";
190 152 }
191 153 echo '</tr>';
192 154
193 155 // Only for user smaller administrator, change user-Profile-File.
194 - if ( 'users.php' === $menu_slug ) {
156 + if ( 'users.php' === $item[ 2 ] ) {
195 157 $x ++;
196 - echo '<tr>' . "\n";
158 + echo '<tr class="form-invalid">' . "\n";
197 159 echo "\t" . '<th>' . esc_attr__( 'Profile' ) . ' <span>(profile.php)</span> </th>';
198 160 foreach ( $user_roles as $role ) {
199 161 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";
162 + . $role . $x . '" class="menu_options_'
163 + . preg_replace( '/[^a-z0-9]+/', '', $role )
164 + . '" type="checkbox"' . $checked_user_role_[ $role ]
165 + . ' name="mw_adminimize_disabled_menu_' . $role
166 + . '_items[]" value="profile.php" /></td>' . "\n";
205 167 }
206 168 echo '</tr>';
207 169 }
208 170
@@ -207,25 +169,23 @@
207 169 }
208 170
209 171 $x ++;
210 172
211 - if ( ! isset( $wp_submenu[ $menu_slug ] ) ) {
173 + if ( ! isset( $wp_submenu[ $item[ 2 ] ] ) ) {
212 174 continue;
213 175 }
214 176
215 - // Loop about Sub Menu items.
216 - foreach ( $wp_submenu[ $menu_slug ] as $subkey => $subitem ) {
217 - $submenu_slug = $subitem[ 2 ];
177 + // Loop about submenu items.
178 + foreach ( $wp_submenu[ $item[ 2 ] ] as $subkey => $subitem ) {
218 179
219 180 // Special solutions for the Adminimize link, that it not works on settings site.
220 - if ( strtolower( $submenu_slug ) === 'adminimize/adminimize.php' ) {
181 + if ( $subitem[ 2 ] === 'adminimize/adminimize.php' ) {
221 182 //$disabled_subitem_adm = ' disabled="disabled"';
222 183 $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>';
184 + . esc_attr__(
185 + 'After activate the check box it heavy attitudes will change.', 'adminimize'
186 + )
187 + . '" style="cursor:pointer;"> ! </acronym>';
228 188 } else {
229 189 $disabled_subitem_adm = '';
230 190 $disabled_subitem_adm_hint = '';
231 191 }
@@ -234,24 +194,25 @@
234 194 foreach ( $user_roles as $role ) {
235 195 // checkbox checked
236 196 $checked_user_role_[ $role ] = '';
237 197 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 - )
198 + // @since 2015-11-11
199 + // Switch to custom key and url of menu item.
200 + && _mw_adminimize_in_arrays(
201 + array( $item[ 2 ] . '__' . $subkey, $subitem[ 2 ] ),
202 + $disabled_submenu_[ $role ]
203 + )
244 204 ) {
245 205 $checked_user_role_[ $role ] = ' checked="checked"';
246 206 }
247 207 }
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";
208 + echo '<td> &mdash; ' . $subitem[ 0 ] . ' <span>['
209 + . $subkey . ']('
210 + . preg_replace(
211 + "#[%2].*#",
212 + '...',
213 + htmlentities( $subitem[ 2 ] )
214 + ) . ')</span> </td>' . "\n";
254 215
255 216 foreach ( $user_roles as $role ) {
256 217 if ( $role !== 'administrator' ) { // only admin disable items
257 218 $disabled_subitem_adm = '';
@@ -257,12 +218,13 @@
257 218 $disabled_subitem_adm = '';
258 219 $disabled_subitem_adm_hint = '';
259 220 }
260 221 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";
222 + . '" class="submenu_options_'
223 + . preg_replace( '/[^a-z0-9]+/', '', $role ) . '" type="checkbox"'
224 + . $disabled_subitem_adm . $checked_user_role_[ $role ]
225 + . ' name="mw_adminimize_disabled_submenu_' . $role . '_items[]" value="'
226 + . $item[ 2 ] . '__' . $subkey . '" />' . $disabled_subitem_adm_hint . '</td>' . "\n";
265 227 }
266 228 echo '</tr>' . "\n";
267 229 $x ++;
268 230 }
@@ -280,63 +242,8 @@
280 242 } ?>
281 243 </tbody>
282 244 </table>
283 245
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 246 <p id="submitbutton">
340 247 <input class="button button-primary" type="submit" name="_mw_adminimize_save" value="<?php esc_attr_e(
341 248 'Update Options', 'adminimize'
342 249 ); ?> &raquo;" /><input type="hidden" name="page_options" value="'dofollow_timeout'" />
@@ -348,5 +255,6 @@
348 255 ); ?></a><br class="clear" /></p>
349 256
350 257 </div>
351 258 </div>
352 -</div>
259 +</div>
260 +