PluginProbe
Adminimize / 1.11.4
Adminimize v1.11.4
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.4, at inc-options/menu_options.php

327 lines 10.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 foreach ( $wp_menu as $key => $item ) {
111
112 $menu_slug = $item[ 2 ];
113
114 // non checked items
115 $disabled_item_adm = '';
116 if ( $menu_slug === 'options-general.php' ) {
117 $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'
119 ) . '" style="cursor:pointer;"> ! </acronym>';
120 } else {
121
122 $disabled_item_adm_hint = '';
123 }
124
125 if ( '' !== $menu_slug ) {
126
127 if ( 'wp-menu-separator' === $item[ 4 ] ) {
128 $item[ 0 ] = 'Separator';
129 }
130
131 foreach ( $user_roles as $role ) {
132
133 // checkbox checked
134 $checked_user_role_[ $role ] = '';
135 if ( isset( $disabled_menu_[ $role ] )
136 && in_array( $menu_slug, $disabled_menu_[ $role ], FALSE )
137 ) {
138 $checked_user_role_[ $role ] = ' checked="checked"';
139 }
140 }
141
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 echo '<tr class="form-invalid">' . "\n";
152 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>';
162
163 foreach ( $user_roles as $role ) {
164 if ( $role !== 'administrator' ) { // only admin disable items
165 $disabled_item_adm = '';
166 $disabled_item_adm_hint = '';
167 }
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 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";
180 }
181 echo '</tr>';
182
183 $x ++;
184
185 if ( ! isset( $wp_submenu[ $menu_slug ] ) ) {
186 continue;
187 }
188
189 // Loop about Sub Menu items.
190 foreach ( $wp_submenu[ $menu_slug ] as $subkey => $subitem ) {
191 $submenu_slug = $subitem[ 2 ];
192
193 // Special solutions for the Adminimize link, that it not works on settings site.
194 if ( strtolower( $submenu_slug ) === 'adminimize/adminimize.php' ) {
195 //$disabled_subitem_adm = ' disabled="disabled"';
196 $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>';
202 } else {
203 $disabled_subitem_adm = '';
204 $disabled_subitem_adm_hint = '';
205 }
206
207 echo '<tr>' . "\n";
208 foreach ( $user_roles as $role ) {
209 // checkbox checked
210 $checked_user_role_[ $role ] = '';
211 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 )
218 ) {
219 $checked_user_role_[ $role ] = ' checked="checked"';
220 }
221 }
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";
228
229 foreach ( $user_roles as $role ) {
230 if ( $role !== 'administrator' ) { // only admin disable items
231 $disabled_subitem_adm = '';
232 $disabled_subitem_adm_hint = '';
233 }
234 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";
239 }
240 echo '</tr>' . "\n";
241 $x ++;
242 }
243 $i ++;
244 $x ++;
245 }
246 }
247
248 } else {
249 $myErrors = new _mw_adminimize_message_class();
250 $myErrors = '<tr><td style="color: red;">' . $myErrors->get_error(
251 '_mw_adminimize_get_option'
252 ) . '</td></tr>';
253 echo $myErrors;
254 } ?>
255 </tbody>
256 </table>
257
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 <p id="submitbutton">
314 <input class="button button-primary" type="submit" name="_mw_adminimize_save" value="<?php esc_attr_e(
315 'Update Options', 'adminimize'
316 ); ?> &raquo;" /><input type="hidden" name="page_options" value="'dofollow_timeout'" />
317 </p>
318
319 <p>
320 <a class="alignright button" href="javascript:void(0);" onclick="window.scrollTo(0,0);" style="margin:3px 0 0 30px;"><?php esc_attr_e(
321 'scroll to top', 'adminimize'
322 ); ?></a><br class="clear" /></p>
323
324 </div>
325 </div>
326 </div>
327