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 +93 -159 1.11.4 → 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,29 +75,37 @@
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;
84 +
85 + $users = array(
86 + 0 => 'Profile',
87 + 1 => 'edit_users',
88 + 2 => 'profile.php',
89 + 3 => '',
90 + 4 => 'menu-top',
91 + 5 => 'menu-users',
92 + 6 => 'div'
93 + );
94 +
110 95 foreach ( $wp_menu as $key => $item ) {
111 96
112 - $menu_slug = $item[ 2 ];
113 -
114 97 // non checked items
115 - $disabled_item_adm = '';
116 - if ( $menu_slug === 'options-general.php' ) {
98 + if ( $item[ 2 ] === 'options-general.php' ) {
117 99 $disabled_item_adm_hint = '<abbr title="' . esc_attr__(
118 - 'After activation of this checkbox you will loose the easy access to the settings area inside the menu.', 'adminimize'
100 + 'After activate the check box it heavy attitudes will change.', 'adminimize'
119 101 ) . '" style="cursor:pointer;"> ! </acronym>';
120 102 } else {
121 -
103 + $disabled_item_adm = '';
122 104 $disabled_item_adm_hint = '';
123 105 }
124 106
125 - if ( '' !== $menu_slug ) {
107 + if ( '' !== $item[ 2 ] ) {
126 108
127 109 if ( 'wp-menu-separator' === $item[ 4 ] ) {
128 110 $item[ 0 ] = 'Separator';
129 111 }
@@ -132,34 +114,30 @@
132 114
133 115 // checkbox checked
134 116 $checked_user_role_[ $role ] = '';
135 117 if ( isset( $disabled_menu_[ $role ] )
136 - && 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 ] )
137 121 ) {
138 122 $checked_user_role_[ $role ] = ' checked="checked"';
139 123 }
140 124 }
141 125
142 - if ( ! $item[ 0 ] ) {
143 - $item[ 0 ] = '<b><i>' . esc_attr__( 'No Title!', 'adminimize' ) . '</i></b>';
144 - }
145 -
146 - $typ = esc_attr__( 'Group', 'adminimize' );
147 - if ( 'custom' === $item[ 4 ] ) {
148 - $typ = esc_attr__( 'Custom', 'adminimize' );
149 - }
150 -
151 126 echo '<tr class="form-invalid">' . "\n";
152 127 echo "\t";
153 - echo '<td>';
154 - echo '<b>&bull; ' . strip_tags( $item[ 0 ] ) . '</b> <small>' . $typ . '</small>';
155 - echo '<span>('
156 - . preg_replace(
157 - '#[%2].*#',
158 - '...',
159 - htmlentities( $menu_slug )
160 - ) . ')</span>';
161 - 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>';
162 140
163 141 foreach ( $user_roles as $role ) {
164 142 if ( $role !== 'administrator' ) { // only admin disable items
165 143 $disabled_item_adm = '';
@@ -164,42 +142,50 @@
164 142 if ( $role !== 'administrator' ) { // only admin disable items
165 143 $disabled_item_adm = '';
166 144 $disabled_item_adm_hint = '';
167 145 }
168 - /**
169 - * Switch to key of each Menu item
170 - *
171 - * @since 2016-01-29
172 - * Use $key instead of htmlentities( $item[ 2 ] ) in the input field below, attribute value
173 - */
174 146 echo "\t" . '<td class="num">' . $disabled_item_adm_hint . '<input id="check_menu'
175 - . $role . $x . '" class="menu_options_'
176 - . preg_replace( '/[^a-z0-9_-]+/', '', $role ) . '" type="checkbox"'
177 - . $disabled_item_adm . $checked_user_role_[ $role ]
178 - . ' name="mw_adminimize_disabled_menu_' . $role . '_items[]" value="'
179 - . $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";
180 152 }
181 153 echo '</tr>';
182 154
155 + // Only for user smaller administrator, change user-Profile-File.
156 + if ( 'users.php' === $item[ 2 ] ) {
157 + $x ++;
158 + echo '<tr class="form-invalid">' . "\n";
159 + echo "\t" . '<th>' . esc_attr__( 'Profile' ) . ' <span>(profile.php)</span> </th>';
160 + foreach ( $user_roles as $role ) {
161 + echo "\t" . '<td class="num"><input disabled="disabled" id="check_menu'
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";
167 + }
168 + echo '</tr>';
169 + }
170 +
183 171 $x ++;
184 172
185 - if ( ! isset( $wp_submenu[ $menu_slug ] ) ) {
173 + if ( ! isset( $wp_submenu[ $item[ 2 ] ] ) ) {
186 174 continue;
187 175 }
188 176
189 - // Loop about Sub Menu items.
190 - foreach ( $wp_submenu[ $menu_slug ] as $subkey => $subitem ) {
191 - $submenu_slug = $subitem[ 2 ];
177 + // Loop about submenu items.
178 + foreach ( $wp_submenu[ $item[ 2 ] ] as $subkey => $subitem ) {
192 179
193 180 // Special solutions for the Adminimize link, that it not works on settings site.
194 - if ( strtolower( $submenu_slug ) === 'adminimize/adminimize.php' ) {
181 + if ( $subitem[ 2 ] === 'adminimize/adminimize.php' ) {
195 182 //$disabled_subitem_adm = ' disabled="disabled"';
196 183 $disabled_subitem_adm_hint = '<abbr title="'
197 - . esc_attr__(
198 - 'After activate the checkbox you will loose its easy access in the menu.',
199 - 'adminimize'
200 - )
201 - . '" 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>';
202 188 } else {
203 189 $disabled_subitem_adm = '';
204 190 $disabled_subitem_adm_hint = '';
205 191 }
@@ -208,24 +194,25 @@
208 194 foreach ( $user_roles as $role ) {
209 195 // checkbox checked
210 196 $checked_user_role_[ $role ] = '';
211 197 if ( isset( $disabled_submenu_[ $role ] )
212 - // @since 2015-11-11
213 - // Switch to custom key and url-slug of menu item.
214 - && _mw_adminimize_in_arrays(
215 - array( $menu_slug . '__' . $subkey, $submenu_slug ),
216 - $disabled_submenu_[ $role ]
217 - )
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 + )
218 204 ) {
219 205 $checked_user_role_[ $role ] = ' checked="checked"';
220 206 }
221 207 }
222 - echo '<td> &mdash; ' . strip_tags( $subitem[ 0 ] ) . ' <span>(Slug: '
223 - . preg_replace(
224 - '#[%2].*#',
225 - '...',
226 - htmlentities( $submenu_slug )
227 - ) . ')[__' . $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";
228 215
229 216 foreach ( $user_roles as $role ) {
230 217 if ( $role !== 'administrator' ) { // only admin disable items
231 218 $disabled_subitem_adm = '';
@@ -231,12 +218,13 @@
231 218 $disabled_subitem_adm = '';
232 219 $disabled_subitem_adm_hint = '';
233 220 }
234 221 echo '<td class="num">' . $disabled_subitem_adm_hint . '<input id="check_menu' . $role . $x
235 - . '" class="submenu_options_' . $role . '" type="checkbox"'
236 - . $disabled_subitem_adm . $checked_user_role_[ $role ]
237 - . ' name="mw_adminimize_disabled_submenu_' . $role . '_items[]" value="'
238 - . $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";
239 227 }
240 228 echo '</tr>' . "\n";
241 229 $x ++;
242 230 }
@@ -254,63 +242,8 @@
254 242 } ?>
255 243 </tbody>
256 244 </table>
257 245
258 - <?php
259 - //Your own dashboard options.
260 - ?>
261 - <br style="margin-top: 10px;" />
262 - <table summary="config_edit_post" class="widefat">
263 - <thead>
264 - <tr>
265 - <th><?php esc_attr_e( 'Your own options', 'adminimize' );
266 - echo '<br />';
267 - esc_attr_e( 'Slug', 'adminimize' ); ?></th>
268 - <th><?php echo '<br />';
269 - esc_attr_e( 'Custom Slug', 'adminimize' ); ?></th>
270 - </tr>
271 - </thead>
272 -
273 - <tbody>
274 - <tr valign="top">
275 - <td colspan="2"><?php esc_attr_e(
276 - 'It is possible to add your own slugs for menu items.',
277 - 'adminimize'
278 - ); ?></td>
279 - </tr>
280 - <tr valign="top">
281 - <td>
282 - <textarea name="_mw_adminimize_own_menu_slug" cols="60" rows="3"
283 - id="_mw_adminimize_own_menu_slug" style="width: 95%;"><?php
284 - echo _mw_adminimize_get_option_value(
285 - '_mw_adminimize_own_menu_slug'
286 - ); ?></textarea>
287 - <br />
288 - <label for="_mw_adminimize_own_menu_slug">
289 - <?php esc_attr_e(
290 - 'Possible nomination for the slug. Separate multiple nominations through a carriage return.',
291 - 'adminimize'
292 - ); ?>
293 - </label>
294 - </td>
295 - <td>
296 - <textarea class="code" name="_mw_adminimize_own_menu_custom_slug" cols="60" rows="3"
297 - id="_mw_adminimize_own_menu_custom_slug" style="width: 95%;"><?php
298 - echo _mw_adminimize_get_option_value(
299 - '_mw_adminimize_own_menu_custom_slug'
300 - ); ?></textarea>
301 - <br />
302 - <label for="_mw_adminimize_own_menu_custom_slug">
303 - <?php esc_attr_e(
304 - 'String of the custom slug.',
305 - 'adminimize'
306 - ); ?>
307 - </label>
308 - </td>
309 - </tr>
310 - </tbody>
311 - </table>
312 -
313 246 <p id="submitbutton">
314 247 <input class="button button-primary" type="submit" name="_mw_adminimize_save" value="<?php esc_attr_e(
315 248 'Update Options', 'adminimize'
316 249 ); ?> &raquo;" /><input type="hidden" name="page_options" value="'dofollow_timeout'" />
@@ -323,4 +256,5 @@
323 256
324 257 </div>
325 258 </div>
326 259 </div>
260 +