PluginProbe
Adminimize / 1.11.12
Adminimize v1.11.12
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.12, at inc-options/menu_options.php

333 lines 10.7 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 <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>
16
17 <div class="inside">
18 <br class="clear" />
19
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>
33 <thead>
34 <tr>
35 <th><?php esc_attr_e( 'Menu options - Menu, Submenu', 'adminimize' ); ?></th>
36
37 <?php foreach ( $user_roles_names as $role_name ) { ?>
38 <th><?php esc_attr_e( 'Deactivate for', 'adminimize' );
39 echo '<br/>' . $role_name; ?></th>
40 <?php } ?>
41
42 </tr>
43 <tr>
44 <td><?php esc_attr_e( 'Select all', 'adminimize' ); ?></td>
45 <?php
46 if ( ! isset( $user_roles ) ) {
47 $user_roles = _mw_adminimize_get_all_user_roles();
48 }
49 foreach ( $user_roles as $role_slug ) {
50 echo '<td class="num">';
51 echo '<span class="form-invalid">';
52 echo '<input id="select_all" class="menu_options_' . $role_slug
53 . '" type="checkbox" name="" value="" />';
54 echo '</span>';
55 echo '<input id="select_all" class="submenu_options_' . $role_slug
56 . '" type="checkbox" name="" value="" />';
57 echo '</td>' . "\n";
58 } ?>
59 </tr>
60 </thead>
61 <tbody>
62 <?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' );
66
67 // Object to array.
68 if ( is_object( $wp_submenu ) ) {
69 $wp_submenu = get_object_vars( $wp_submenu );
70 }
71
72 if ( ! isset( $wp_menu ) || empty( $wp_menu ) ) {
73 $wp_menu = $menu;
74 }
75 if ( ! isset( $wp_submenu ) || empty( $wp_submenu ) ) {
76 $wp_submenu = $submenu;
77 }
78
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 foreach ( $user_roles as $role ) {
99 $disabled_metaboxes_post_[ $role ] = _mw_adminimize_get_option_value(
100 'mw_adminimize_disabled_metaboxes_post_' . $role . '_items'
101 );
102 $disabled_metaboxes_page_[ $role ] = _mw_adminimize_get_option_value(
103 'mw_adminimize_disabled_metaboxes_page_' . $role . '_items'
104 );
105 }
106
107 // print menu, sub-menu
108 if ( isset( $wp_menu ) && '' !== $wp_menu ) {
109
110 $i = 0;
111 $x = 0;
112 foreach ( $wp_menu as $key => $item ) {
113
114 $menu_slug = $item[ 2 ];
115
116 // non checked items
117 $disabled_item_adm = '';
118 if ( $menu_slug === 'options-general.php' ) {
119 $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'
121 ) . '" style="cursor:pointer;"> ! </acronym>';
122 } else {
123
124 $disabled_item_adm_hint = '';
125 }
126
127 if ( '' !== $menu_slug ) {
128
129 if ( 'wp-menu-separator' === $item[ 4 ] ) {
130 $item[ 0 ] = 'Separator';
131 }
132
133 foreach ( $user_roles as $role ) {
134
135 // checkbox checked
136 $checked_user_role_[ $role ] = '';
137 if ( isset( $disabled_menu_[ $role ] )
138 && in_array( $menu_slug, $disabled_menu_[ $role ], FALSE )
139 ) {
140 $checked_user_role_[ $role ] = ' checked="checked"';
141 }
142 }
143
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 echo '<tr class="form-invalid">' . "\n";
154 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>';
164
165 foreach ( $user_roles as $role ) {
166 if ( $role !== 'administrator' ) { // only admin disable items
167 $disabled_item_adm = '';
168 $disabled_item_adm_hint = '';
169 }
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 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";
182 }
183 echo '</tr>';
184
185 $x ++;
186
187 if ( ! isset( $wp_submenu[ $menu_slug ] ) ) {
188 continue;
189 }
190
191 // Loop about Sub Menu items.
192 foreach ( $wp_submenu[ $menu_slug ] as $subkey => $subitem ) {
193
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 // Special solutions for the Adminimize link, that it not works on settings site.
202 if ( strtolower( $submenu_slug ) === 'adminimize/adminimize.php' ) {
203 //$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>';
208 } else {
209 $disabled_subitem_adm = '';
210 $disabled_subitem_adm_hint = '';
211 }
212
213 echo '<tr>' . "\n";
214 foreach ( $user_roles as $role ) {
215 // checkbox checked
216 $checked_user_role_[ $role ] = '';
217 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 )
224 ) {
225 $checked_user_role_[ $role ] = ' checked="checked"';
226 }
227 }
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";
234
235 foreach ( $user_roles as $role ) {
236 if ( $role !== 'administrator' ) { // only admin disable items
237 $disabled_subitem_adm = '';
238 $disabled_subitem_adm_hint = '';
239 }
240 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";
245 }
246 echo '</tr>' . "\n";
247 $x ++;
248 }
249 $i ++;
250 $x ++;
251 }
252 }
253
254 } else {
255 $myErrors = new _mw_adminimize_message_class();
256 $myErrors = '<tr><td style="color: red;">' . $myErrors->get_error(
257 '_mw_adminimize_get_option'
258 ) . '</td></tr>';
259 echo $myErrors;
260 } ?>
261 </tbody>
262 </table>
263
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 <p id="submitbutton">
320 <input class="button button-primary" type="submit" name="_mw_adminimize_save" value="<?php esc_attr_e(
321 'Update Options', 'adminimize'
322 ); ?> &raquo;" /><input type="hidden" name="page_options" value="'dofollow_timeout'" />
323 </p>
324
325 <p>
326 <a class="alignright button adminimize-scroltop" href="#" style="margin:3px 0 0 30px;"><?php esc_attr_e(
327 'scroll to top', 'adminimize'
328 ); ?></a><br class="clear" /></p>
329
330 </div>
331 </div>
332 </div>
333