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