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 +259 -157 1.7.19 → 1.9.1 View file →
@@ -1,158 +1,260 @@
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 _e('Click to toggle'); ?>"><br/></div>
16 - <h3 class="hndle" id="config_menu"><?php _e('Menu Options', FB_ADMINIMIZE_TEXTDOMAIN ); ?></h3>
17 - <div class="inside">
18 - <br class="clear" />
19 -
20 - <table summary="config_menu" class="widefat">
21 - <thead>
22 - <tr>
23 - <th><?php _e('Menu options - Menu, <span style=\"font-weight: 400;\">Submenu</span>', FB_ADMINIMIZE_TEXTDOMAIN ); ?></th>
24 -
25 - <?php foreach ($user_roles_names as $role_name) { ?>
26 - <th><?php _e('Deactivate for', FB_ADMINIMIZE_TEXTDOMAIN ); echo '<br/>' . $role_name; ?></th>
27 - <?php } ?>
28 -
29 - </tr>
30 - </thead>
31 - <tbody>
32 - <?php
33 - $wp_menu = _mw_adminimize_get_option_value('mw_adminimize_default_menu');
34 - $wp_submenu = _mw_adminimize_get_option_value('mw_adminimize_default_submenu');
35 -
36 - if ( empty($wp_menu) ) {
37 - global $menu;
38 -
39 - $wp_menu = $menu;
40 - }
41 - if ( !isset($wp_submenu) ) {
42 - global $submenu;
43 -
44 - $wp_submenu = $submenu;
45 - }
46 -
47 - foreach ($user_roles as $role) {
48 - $disabled_metaboxes_post_[$role] = _mw_adminimize_get_option_value('mw_adminimize_disabled_metaboxes_post_'. $role .'_items');
49 - $disabled_metaboxes_page_[$role] = _mw_adminimize_get_option_value('mw_adminimize_disabled_metaboxes_page_'. $role .'_items');
50 - }
51 -
52 - // print menu, submenu
53 - if ( isset($wp_menu) && '' != $wp_menu ) {
54 -
55 - $i = 0;
56 - $x = 0;
57 - $class = '';
58 -
59 - $users = array( 0 => 'Profile', 1 => 'edit_users', 2 => 'profile.php', 3 => '', 4 => 'menu-top', 5 => 'menu-users', 6 => 'div' );
60 - //array_push( $menu, $users );
61 -
62 - foreach ($wp_menu as $item) {
63 -
64 - // non checked items
65 - if ( $item[2] === 'options-general.php' ) {
66 - //$disabled_item_adm = ' disabled="disabled"';
67 - $disabled_item_adm_hint = '<abbr title="' . __( 'After activate the check box it heavy attitudes will change.', FB_ADMINIMIZE_TEXTDOMAIN ) . '" style="cursor:pointer;"> ! </acronym>';
68 - } else {
69 - $disabled_item_adm = '';
70 - $disabled_item_adm_hint = '';
71 - }
72 -
73 - if ( $item[0] != '' ) {
74 - foreach($user_roles as $role) {
75 - // checkbox checked
76 - if ( isset( $disabled_menu_[$role]) && in_array($item[2], $disabled_menu_[$role]) ) {
77 - $checked_user_role_[$role] = ' checked="checked"';
78 - } else {
79 - $checked_user_role_[$role] = '';
80 - }
81 - }
82 -
83 - echo '<tr class="form-invalid">' . "\n";
84 - echo "\t" . '<th>' . $item[0] . ' <span style="color:#ccc; font-weight: 400;">(' . $item[2] . ')</span> </th>';
85 - foreach ($user_roles as $role) {
86 - if ( $role != 'administrator' ) { // only admin disable items
87 - $disabled_item_adm = '';
88 - $disabled_item_adm_hint = '';
89 - }
90 - echo "\t" . '<td class="num">' . $disabled_item_adm_hint . '<input id="check_menu'. $role . $x .'" type="checkbox"' . $disabled_item_adm . $checked_user_role_[$role] . ' name="mw_adminimize_disabled_menu_'. $role .'_items[]" value="' . $item[2] . '" />' . $disabled_item_adm_hint . '</td>' . "\n";
91 - }
92 - echo '</tr>';
93 -
94 - // only for user smaller administrator, change user-Profile-File
95 - if ( 'users.php' === $item[2] ) {
96 - $x++;
97 - echo '<tr class="form-invalid">' . "\n";
98 - echo "\t" . '<th>' . __('Profile') . ' <span style="color:#ccc; font-weight: 400;">(profile.php)</span> </th>';
99 - foreach ($user_roles as $role) {
100 - echo "\t" . '<td class="num"><input disabled="disabled" id="check_menu'. $role . $x .'" type="checkbox"' . $checked_user_role_[$role] . ' name="mw_adminimize_disabled_menu_'. $role .'_items[]" value="profile.php" /></td>' . "\n";
101 - }
102 - echo '</tr>';
103 - }
104 -
105 - $x++;
106 -
107 - if ( !isset($wp_submenu[$item[2]]) )
108 - continue;
109 -
110 - // submenu items
111 - foreach ( $wp_submenu[ $item[2] ] as $subitem ) {
112 - $class = ( ' class="alternate"' == $class ) ? '' : ' class="alternate"';
113 - if ( $subitem[2] === 'adminimize/adminimize.php' ) {
114 - //$disabled_subitem_adm = ' disabled="disabled"';
115 - $disabled_subitem_adm_hint = '<abbr title="' . __( 'After activate the check box it heavy attitudes will change.', FB_ADMINIMIZE_TEXTDOMAIN ) . '" style="cursor:pointer;"> ! </acronym>';
116 - } else {
117 - $disabled_subitem_adm = '';
118 - $disabled_subitem_adm_hint = '';
119 - }
120 -
121 - echo '<tr' . $class . '>' . "\n";
122 - foreach ($user_roles as $role) {
123 - if ( isset($disabled_submenu_[$role]) )
124 - $checked_user_role_[$role] = ( in_array($subitem[2], $disabled_submenu_[$role] ) ) ? ' checked="checked"' : '';
125 - }
126 - echo '<td> &mdash; ' . $subitem[0] . ' <span style="color:#ccc; font-weight: 400;">(' . $subitem[2] . ')</span> </td>' . "\n";
127 - foreach ($user_roles as $role) {
128 - if ( $role != 'administrator' ) { // only admin disable items
129 - $disabled_subitem_adm = '';
130 - $disabled_subitem_adm_hint = '';
131 - }
132 - echo '<td class="num">' . $disabled_subitem_adm_hint . '<input id="check_menu'. $role.$x .'" type="checkbox"' . $disabled_subitem_adm . $checked_user_role_[$role] . ' name="mw_adminimize_disabled_submenu_'. $role .'_items[]" value="' . $subitem[2] . '" />' . $disabled_subitem_adm_hint . '</td>' . "\n";
133 - }
134 - echo '</tr>' . "\n";
135 - $x++;
136 - }
137 - $i++;
138 - $x++;
139 - }
140 - }
141 -
142 - } else {
143 - $myErrors = new _mw_adminimize_message_class();
144 - $myErrors = '<tr><td style="color: red;">' . $myErrors->get_error('_mw_adminimize_get_option') . '</td></tr>';
145 - echo $myErrors;
146 - } ?>
147 - </tbody>
148 - </table>
149 -
150 - <p id="submitbutton">
151 - <input class="button button-primary" type="submit" name="_mw_adminimize_save" value="<?php _e('Update Options', FB_ADMINIMIZE_TEXTDOMAIN ); ?> &raquo;" /><input type="hidden" name="page_options" value="'dofollow_timeout'" />
152 - </p>
153 - <p><a class="alignright button" href="javascript:void(0);" onclick="window.scrollTo(0,0);" style="margin:3px 0 0 30px;"><?php _e('scroll to top', FB_ADMINIMIZE_TEXTDOMAIN); ?></a><br class="clear" /></p>
154 -
155 - </div>
156 - </div>
157 - </div>
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' ); ?>"><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">
22 + <thead>
23 + <tr>
24 + <th><?php esc_attr_e( 'Menu options - Menu, Submenu', 'adminimize' ); ?></th>
25 +
26 + <?php foreach ( $user_roles_names as $role_name ) { ?>
27 + <th><?php esc_attr_e( 'Deactivate for', 'adminimize' );
28 + echo '<br/>' . $role_name; ?></th>
29 + <?php } ?>
30 +
31 + </tr>
32 + <tr>
33 + <td><?php esc_attr_e( 'Select all', 'adminimize' ); ?></td>
34 + <?php
35 + foreach ( $user_roles_names as $role_name ) {
36 + $role_name = strtolower( $role_name );
37 + $role_name = preg_replace( '/[^a-z0-9]+/', '', $role_name );
38 + echo '<td class="num">';
39 + echo '<span class="form-invalid">';
40 + echo '<input id="select_all" class="menu_options_' . $role_name
41 + . '" type="checkbox" name="" value="" />';
42 + echo '</span>';
43 + echo '<input id="select_all" class="submenu_options_' . $role_name
44 + . '" type="checkbox" name="" value="" />';
45 + echo '</td>' . "\n";
46 + } ?>
47 + </tr>
48 + </thead>
49 + <tbody>
50 + <?php
51 + $wp_menu = _mw_adminimize_get_option_value( 'mw_adminimize_default_menu' );
52 + $wp_submenu = _mw_adminimize_get_option_value( 'mw_adminimize_default_submenu' );
53 +
54 + // Object to array
55 + if ( is_object( $wp_submenu ) ) {
56 + $wp_submenu = get_object_vars( $wp_submenu );
57 + }
58 +
59 + if ( ! isset( $wp_menu ) || empty( $wp_menu ) ) {
60 + global $menu;
61 +
62 + $wp_menu = $menu;
63 + }
64 + if ( ! isset( $wp_submenu ) || empty( $wp_submenu ) ) {
65 + global $submenu;
66 +
67 + $wp_submenu = $submenu;
68 + }
69 +
70 + foreach ( $user_roles as $role ) {
71 + $disabled_metaboxes_post_[ $role ] = _mw_adminimize_get_option_value(
72 + 'mw_adminimize_disabled_metaboxes_post_' . $role . '_items'
73 + );
74 + $disabled_metaboxes_page_[ $role ] = _mw_adminimize_get_option_value(
75 + 'mw_adminimize_disabled_metaboxes_page_' . $role . '_items'
76 + );
77 + }
78 +
79 + // print menu, submenu
80 + if ( isset( $wp_menu ) && '' !== $wp_menu ) {
81 +
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 +
95 + foreach ( $wp_menu as $key => $item ) {
96 +
97 + // non checked items
98 + if ( $item[ 2 ] === 'options-general.php' ) {
99 + $disabled_item_adm_hint = '<abbr title="' . esc_attr__(
100 + 'After activate the check box it heavy attitudes will change.', 'adminimize'
101 + ) . '" style="cursor:pointer;"> ! </acronym>';
102 + } else {
103 + $disabled_item_adm = '';
104 + $disabled_item_adm_hint = '';
105 + }
106 +
107 + if ( '' !== $item[ 2 ] ) {
108 +
109 + if ( 'wp-menu-separator' === $item[ 4 ] ) {
110 + $item[ 0 ] = 'Separator';
111 + }
112 +
113 + foreach ( $user_roles as $role ) {
114 +
115 + // checkbox checked
116 + $checked_user_role_[ $role ] = '';
117 + if ( isset( $disabled_menu_[ $role ] )
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 ] )
121 + ) {
122 + $checked_user_role_[ $role ] = ' checked="checked"';
123 + }
124 + }
125 +
126 + echo '<tr class="form-invalid">' . "\n";
127 + echo "\t";
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>';
140 +
141 + foreach ( $user_roles as $role ) {
142 + if ( $role !== 'administrator' ) { // only admin disable items
143 + $disabled_item_adm = '';
144 + $disabled_item_adm_hint = '';
145 + }
146 + echo "\t" . '<td class="num">' . $disabled_item_adm_hint . '<input id="check_menu'
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";
152 + }
153 + echo '</tr>';
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 +
171 + $x ++;
172 +
173 + if ( ! isset( $wp_submenu[ $item[ 2 ] ] ) ) {
174 + continue;
175 + }
176 +
177 + // Loop about submenu items.
178 + foreach ( $wp_submenu[ $item[ 2 ] ] as $subkey => $subitem ) {
179 +
180 + // Special solutions for the Adminimize link, that it not works on settings site.
181 + if ( $subitem[ 2 ] === 'adminimize/adminimize.php' ) {
182 + //$disabled_subitem_adm = ' disabled="disabled"';
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>';
188 + } else {
189 + $disabled_subitem_adm = '';
190 + $disabled_subitem_adm_hint = '';
191 + }
192 +
193 + echo '<tr>' . "\n";
194 + foreach ( $user_roles as $role ) {
195 + // checkbox checked
196 + $checked_user_role_[ $role ] = '';
197 + if ( isset( $disabled_submenu_[ $role ] )
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 + )
204 + ) {
205 + $checked_user_role_[ $role ] = ' checked="checked"';
206 + }
207 + }
208 + echo '<td> &mdash; ' . $subitem[ 0 ] . ' <span>['
209 + . $subkey . ']('
210 + . preg_replace(
211 + "#[%2].*#",
212 + '...',
213 + htmlentities( $subitem[ 2 ] )
214 + ) . ')</span> </td>' . "\n";
215 +
216 + foreach ( $user_roles as $role ) {
217 + if ( $role !== 'administrator' ) { // only admin disable items
218 + $disabled_subitem_adm = '';
219 + $disabled_subitem_adm_hint = '';
220 + }
221 + echo '<td class="num">' . $disabled_subitem_adm_hint . '<input id="check_menu' . $role . $x
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";
227 + }
228 + echo '</tr>' . "\n";
229 + $x ++;
230 + }
231 + $i ++;
232 + $x ++;
233 + }
234 + }
235 +
236 + } else {
237 + $myErrors = new _mw_adminimize_message_class();
238 + $myErrors = '<tr><td style="color: red;">' . $myErrors->get_error(
239 + '_mw_adminimize_get_option'
240 + ) . '</td></tr>';
241 + echo $myErrors;
242 + } ?>
243 + </tbody>
244 + </table>
245 +
246 + <p id="submitbutton">
247 + <input class="button button-primary" type="submit" name="_mw_adminimize_save" value="<?php esc_attr_e(
248 + 'Update Options', 'adminimize'
249 + ); ?> &raquo;" /><input type="hidden" name="page_options" value="'dofollow_timeout'" />
250 + </p>
251 +
252 + <p>
253 + <a class="alignright button" href="javascript:void(0);" onclick="window.scrollTo(0,0);" style="margin:3px 0 0 30px;"><?php esc_attr_e(
254 + 'scroll to top', 'adminimize'
255 + ); ?></a><br class="clear" /></p>
256 +
257 + </div>
258 + </div>
259 +</div>
158 260