| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package Adminimize |
| 4 |
* @subpackage Nav Menu 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 |
<div id="poststuff" class="ui-sortable meta-box-sortables"> |
| 13 |
<div class="postbox"> |
| 14 |
<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle', 'adminimize' ); ?>"><br /></div> |
| 15 |
<h3 class="hndle" id="nav_menu_options"><?php esc_attr_e( 'WP Nav Menu', 'adminimize' ); ?></h3> |
| 16 |
|
| 17 |
<div class="inside"> |
| 18 |
<br class="clear" /> |
| 19 |
|
| 20 |
<table summary="config_nav_menu" class="widefat"> |
| 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( 'Option', 'adminimize' ); ?></th> |
| 33 |
<?php |
| 34 |
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 |
</tr> |
| 39 |
<tr> |
| 40 |
<td><?php esc_attr_e( 'Select all', 'adminimize' ); ?></td> |
| 41 |
<?php |
| 42 |
foreach ( $user_roles as $role_slug ) { |
| 43 |
echo '<td class="num">'; |
| 44 |
echo '<input id="select_all" class="wp_nav_menu_options_' . $role_slug |
| 45 |
. '" type="checkbox" name="" value="" />'; |
| 46 |
echo '</td>' . "\n"; |
| 47 |
} ?> |
| 48 |
</tr> |
| 49 |
</thead> |
| 50 |
|
| 51 |
<tbody> |
| 52 |
<?php |
| 53 |
foreach ( $user_roles as $role ) { |
| 54 |
$disabled_nav_menu_option_[ $role ] = _mw_adminimize_get_option_value( |
| 55 |
'mw_adminimize_disabled_nav_menu_option_' . $role . '_items' |
| 56 |
); |
| 57 |
} |
| 58 |
|
| 59 |
$nav_menu_options = array( |
| 60 |
'#contextual-help-link-wrap', |
| 61 |
'#screen-options-link-wrap', |
| 62 |
'#nav-menu-theme-locations', |
| 63 |
'#add-custom-links', |
| 64 |
'.menu-add-new', |
| 65 |
); |
| 66 |
|
| 67 |
if ( wp_get_nav_menus() ) { |
| 68 |
array( $nav_menu_options, '#nav-menu-theme-locations' ); |
| 69 |
} |
| 70 |
|
| 71 |
$nav_menu_options_names = array( |
| 72 |
esc_attr__( 'Help', 'adminimize' ), |
| 73 |
esc_attr__( 'Screen Options' ), |
| 74 |
esc_attr__( 'Theme Locations', 'adminimize' ), |
| 75 |
esc_attr__( 'Custom Links', 'adminimize' ), |
| 76 |
'#(' . esc_attr__( 'Add menu', 'adminimize' ) . ')', |
| 77 |
); |
| 78 |
|
| 79 |
if ( wp_get_nav_menus() ) { |
| 80 |
array( $nav_menu_options_names, esc_attr__( 'Theme Locations' ) ); |
| 81 |
} |
| 82 |
|
| 83 |
// taxonomies |
| 84 |
$taxonomies = get_taxonomies( array( 'show_in_nav_menus' => TRUE ), 'object' ); |
| 85 |
if ( $taxonomies ) { |
| 86 |
foreach ( $taxonomies as $tax ) { |
| 87 |
if ( $tax ) { |
| 88 |
$nav_menu_options[] = '#add-' . $tax->name; |
| 89 |
$nav_menu_options_names[] = $tax->labels->name; |
| 90 |
} |
| 91 |
} |
| 92 |
} |
| 93 |
|
| 94 |
// post types |
| 95 |
$post_types = get_post_types( array( 'show_in_nav_menus' => TRUE ), 'object' ); |
| 96 |
if ( $post_types ) { |
| 97 |
foreach ( $post_types as $post_type ) { |
| 98 |
if ( $post_type ) { |
| 99 |
$nav_menu_options[] = '#add-' . $post_type->name; |
| 100 |
$nav_menu_options_names[] = $post_type->labels->name; |
| 101 |
} |
| 102 |
} |
| 103 |
} |
| 104 |
|
| 105 |
$_mw_adminimize_own_nav_menu_values = _mw_adminimize_get_option_value( |
| 106 |
'_mw_adminimize_own_nav_menu_values' |
| 107 |
); |
| 108 |
$_mw_adminimize_own_nav_menu_values = preg_split( "/\r\n/", $_mw_adminimize_own_nav_menu_values ); |
| 109 |
foreach ( (array) $_mw_adminimize_own_nav_menu_values as $key => $_mw_adminimize_own_nav_menu_value ) { |
| 110 |
$_mw_adminimize_own_nav_menu_value = trim( $_mw_adminimize_own_nav_menu_value ); |
| 111 |
$nav_menu_options[] = $_mw_adminimize_own_nav_menu_value; |
| 112 |
} |
| 113 |
|
| 114 |
$_mw_adminimize_own_nav_menu_options = _mw_adminimize_get_option_value( |
| 115 |
'_mw_adminimize_own_nav_menu_options' |
| 116 |
); |
| 117 |
$_mw_adminimize_own_nav_menu_options = preg_split( "/\r\n/", $_mw_adminimize_own_nav_menu_options ); |
| 118 |
foreach ( (array) $_mw_adminimize_own_nav_menu_options as $key => $_mw_adminimize_own_nav_menu_option ) { |
| 119 |
$_mw_adminimize_own_nav_menu_option = trim( $_mw_adminimize_own_nav_menu_option ); |
| 120 |
$nav_menu_options_names[] = $_mw_adminimize_own_nav_menu_option; |
| 121 |
} |
| 122 |
|
| 123 |
$x = 0; |
| 124 |
foreach ( $nav_menu_options as $index => $nav_menu_option ) { |
| 125 |
if ( $nav_menu_option != '' ) { |
| 126 |
$checked_user_role_ = array(); |
| 127 |
foreach ( $user_roles as $role ) { |
| 128 |
$checked_user_role_[ $role ] = ( isset( $disabled_nav_menu_option_[ $role ] ) |
| 129 |
&& in_array( |
| 130 |
$nav_menu_option, $disabled_nav_menu_option_[ $role ] |
| 131 |
) ) ? ' checked="checked"' : ''; |
| 132 |
} |
| 133 |
echo '<tr>' . "\n"; |
| 134 |
echo '<td>' . $nav_menu_options_names[ $index ] . ' <span>(' . $nav_menu_option . ')</span> </td>' . "\n"; |
| 135 |
foreach ( $user_roles as $role ) { |
| 136 |
echo '<td class="num">'; |
| 137 |
echo '<input id="check_post' . $role . $x . '" class="wp_nav_menu_options_' |
| 138 |
. preg_replace( '/[^a-z0-9_-]+/', '', $role ) . '" type="checkbox"' |
| 139 |
. $checked_user_role_[ $role ] . ' name="mw_adminimize_disabled_nav_menu_option_' |
| 140 |
. $role . '_items[]" value="' . $nav_menu_option . '" />'; |
| 141 |
echo '</td>' . "\n"; |
| 142 |
} |
| 143 |
echo '</tr>' . "\n"; |
| 144 |
$x ++; |
| 145 |
} |
| 146 |
} |
| 147 |
?> |
| 148 |
</tbody> |
| 149 |
</table> |
| 150 |
|
| 151 |
<?php |
| 152 |
//your own global options |
| 153 |
?> |
| 154 |
<br style="margin-top: 10px;" /> |
| 155 |
<table summary="config_edit_post" class="widefat"> |
| 156 |
<thead> |
| 157 |
<tr> |
| 158 |
<th><?php esc_attr_e( 'Your own Nav Menu options', 'adminimize' ); |
| 159 |
echo '<br />'; |
| 160 |
esc_attr_e( 'Option name', 'adminimize' ); ?></th> |
| 161 |
<th><?php echo '<br />'; |
| 162 |
esc_attr_e( 'Selector, ID or class', 'adminimize' ); ?></th> |
| 163 |
</tr> |
| 164 |
</thead> |
| 165 |
|
| 166 |
<tbody> |
| 167 |
<tr valign="top"> |
| 168 |
<td colspan="2"><?php esc_attr_e( |
| 169 |
'It is possible to add your own IDs or classes from elements and tags. You can find IDs and classes with the FireBug Add-on for Firefox. Assign a value and the associate name per line.', |
| 170 |
'adminimize' |
| 171 |
); ?></td> |
| 172 |
</tr> |
| 173 |
<tr valign="top"> |
| 174 |
<td> |
| 175 |
<textarea name="_mw_adminimize_own_nav_menu_options" cols="60" rows="3" id="_mw_adminimize_own_nav_menu_options" style="width: 95%;"><?php echo _mw_adminimize_get_option_value( |
| 176 |
'_mw_adminimize_own_nav_menu_options' |
| 177 |
); ?></textarea> |
| 178 |
<br /> |
| 179 |
<?php esc_attr_e( |
| 180 |
'Possible nomination for ID or class. Separate multiple nominations through a carriage return.', |
| 181 |
'adminimize' |
| 182 |
); ?> |
| 183 |
</td> |
| 184 |
<td> |
| 185 |
<textarea class="code" name="_mw_adminimize_own_nav_menu_values" cols="60" rows="3" id="_mw_adminimize_own_nav_menu_values" style="width: 95%;"><?php echo _mw_adminimize_get_option_value( |
| 186 |
'_mw_adminimize_own_nav_menu_values' |
| 187 |
); ?></textarea> |
| 188 |
<br /> |
| 189 |
<?php esc_attr_e( |
| 190 |
'Possible IDs or classes. Separate multiple values through a carriage return.', 'adminimize' |
| 191 |
); ?> |
| 192 |
</td> |
| 193 |
</tr> |
| 194 |
</tbody> |
| 195 |
</table> |
| 196 |
|
| 197 |
<p id="submitbutton"> |
| 198 |
<input type="hidden" name="_mw_adminimize_action" value="_mw_adminimize_insert" /> |
| 199 |
<input class="button button-primary" type="submit" name="_mw_adminimize_save" value="<?php esc_attr_e( |
| 200 |
'Update Options', 'adminimize' |
| 201 |
); ?> »" /><input type="hidden" name="page_options" value="'dofollow_timeout'" /> |
| 202 |
</p> |
| 203 |
|
| 204 |
<p> |
| 205 |
<a class="alignright button" href="javascript:void(0);" onclick="window.scrollTo(0,0);" style="margin:3px 0 0 30px;"><?php esc_attr_e( |
| 206 |
'scroll to top', 'adminimize' |
| 207 |
); ?></a><br class="clear" /></p> |
| 208 |
|
| 209 |
</div> |
| 210 |
</div> |
| 211 |
</div> |
| 212 |
|