PluginProbe
Adminimize / 1.11.7
Adminimize v1.11.7
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.7, at inc-options/menu_options.php

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