| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package Adminimize |
| 4 |
* @subpackage Admin Bar Options, settings page |
| 5 |
* @author Frank Bültge |
| 6 |
* @since 1.8.1 01/10/2013 |
| 7 |
*/ |
| 8 |
if ( ! function_exists( 'add_action' ) ) { |
| 9 |
die( "Hi there! I'm just a part of plugin, not much I can do when called directly." ); |
| 10 |
} |
| 11 |
|
| 12 |
/** @var $wp_admin_bar WP_Admin_Bar */ |
| 13 |
if ( ! isset( $wp_admin_bar ) ) { |
| 14 |
$wp_admin_bar = ''; |
| 15 |
} |
| 16 |
|
| 17 |
if ( ! isset( $user_roles ) ) { |
| 18 |
$user_roles = _mw_adminimize_get_all_user_roles(); |
| 19 |
} |
| 20 |
|
| 21 |
if ( ! isset( $user_roles_names ) ) { |
| 22 |
$user_roles_names = _mw_adminimize_get_all_user_roles_names(); |
| 23 |
} |
| 24 |
?> |
| 25 |
<div id="poststuff" class="ui-sortable meta-box-sortables"> |
| 26 |
<div class="postbox"> |
| 27 |
<h3 class="hndle ui-sortable-handle" id="admin_bar_options" title="<?php esc_attr_e( 'Click to toggle', 'adminimize' ); ?>"><?php |
| 28 |
esc_attr_e( 'Admin Bar Back end Options', 'adminimize' ); ?></h3> |
| 29 |
|
| 30 |
<div class="inside"> |
| 31 |
<br class="clear" /> |
| 32 |
|
| 33 |
<table summary="config_widget" class="widefat"> |
| 34 |
<colgroup> |
| 35 |
<?php |
| 36 |
$col = 0; |
| 37 |
foreach ( $user_roles_names as $role_name ) { |
| 38 |
echo '<col class="col' . $col . '">' . "\n"; |
| 39 |
$col ++; |
| 40 |
} |
| 41 |
?> |
| 42 |
</colgroup> |
| 43 |
<thead> |
| 44 |
<tr> |
| 45 |
<th><?php esc_attr_e( 'Option', 'adminimize' ); ?></th> |
| 46 |
<?php |
| 47 |
foreach ( $user_roles_names as $role_name ) { ?> |
| 48 |
<th><?php esc_attr_e( 'Deactivate for', 'adminimize' ); |
| 49 |
echo '<br/>' . $role_name; ?></th> |
| 50 |
<?php } ?> |
| 51 |
</tr> |
| 52 |
<tr> |
| 53 |
<td><?php esc_attr_e( 'Select all', 'adminimize' ); ?></td> |
| 54 |
<?php |
| 55 |
foreach ( $user_roles as $role_slug ) { |
| 56 |
echo '<td class="num">'; |
| 57 |
echo '<input id="select_all" class="admin_bar_' . $role_slug |
| 58 |
. '" type="checkbox" name="" value="" />'; |
| 59 |
echo '</td>' . "\n"; |
| 60 |
} ?> |
| 61 |
</tr> |
| 62 |
</thead> |
| 63 |
|
| 64 |
<tbody> |
| 65 |
<?php |
| 66 |
foreach ( $user_roles as $role ) { |
| 67 |
$disabled_admin_bar_option_[ $role ] = _mw_adminimize_get_option_value( |
| 68 |
'mw_adminimize_disabled_admin_bar_' . $role . '_items' |
| 69 |
); |
| 70 |
} |
| 71 |
|
| 72 |
$x = 0; |
| 73 |
// add items to array for select |
| 74 |
// Use the hook to enhance for custom items, there are not in the list |
| 75 |
$admin_bar_items = apply_filters( |
| 76 |
'adminimize_admin_bar_items', _mw_adminimize_get_option_value( 'mw_adminimize_admin_bar_nodes' ) |
| 77 |
); |
| 78 |
|
| 79 |
$message = ''; |
| 80 |
if ( ! empty( $admin_bar_items ) && is_array( $admin_bar_items ) ) { |
| 81 |
foreach ( $admin_bar_items as $key => $value ) { |
| 82 |
|
| 83 |
$is_parent = ! empty( $value->parent ); |
| 84 |
$has_link = ! empty( $value->href ); |
| 85 |
|
| 86 |
// No title on the item. |
| 87 |
if ( ! $value->title ) { |
| 88 |
$value->title = '<b><i>' . esc_attr__( 'No Title!', 'adminimize' ) . '</i></b>'; |
| 89 |
} |
| 90 |
|
| 91 |
$item_string = '• '; |
| 92 |
$before_title = '<b>'; |
| 93 |
$after_title = '</b> <small>' . esc_attr__( 'Group', 'adminimize' ) . '</small>'; |
| 94 |
if ( $is_parent ) { |
| 95 |
$item_string = '— '; |
| 96 |
$before_title = ''; |
| 97 |
$after_title = ''; |
| 98 |
} |
| 99 |
|
| 100 |
$checked_user_role_ = array(); |
| 101 |
foreach ( $user_roles as $role ) { |
| 102 |
$checked_user_role_[ $role ] = ( isset( $disabled_admin_bar_option_[ $role ] ) |
| 103 |
&& in_array( |
| 104 |
$key, $disabled_admin_bar_option_[ $role ], FALSE |
| 105 |
) |
| 106 |
) ? ' checked="checked"' : ''; |
| 107 |
} |
| 108 |
|
| 109 |
echo '<tr>' . "\n"; |
| 110 |
echo '<td>'. $before_title . $item_string . strip_tags( $value->title, '<strong><b><em><i>' ) |
| 111 |
. $after_title . ' <span>(' . $key . ')</span> </td>' . "\n"; |
| 112 |
foreach ( $user_roles as $role ) { |
| 113 |
echo '<td class="num"><input id="check_post' . $role . $x . '" class="admin_bar_' |
| 114 |
. $role . '" type="checkbox"' |
| 115 |
. $checked_user_role_[ $role ] . ' name="mw_adminimize_disabled_admin_bar_' |
| 116 |
. $role . '_items[]" value="' . $key . '" /></td>' . "\n"; |
| 117 |
} |
| 118 |
echo '</tr>' . "\n"; |
| 119 |
$x ++; |
| 120 |
} |
| 121 |
} |
| 122 |
$message = '<span style="font-size: 35px;">☝</span>' |
| 123 |
. esc_attr__( 'Switch to another back-end page and come back to update the options to get all items of the admin bar in the back end area.', 'adminimize' ); |
| 124 |
?> |
| 125 |
</tbody> |
| 126 |
</table> |
| 127 |
|
| 128 |
<p><?php echo $message; ?></p> |
| 129 |
<p id="submitbutton"> |
| 130 |
<input type="hidden" name="_mw_adminimize_action" value="_mw_adminimize_insert" /> |
| 131 |
<input class="button button-primary" type="submit" name="_mw_adminimize_save" value="<?php esc_attr_e( |
| 132 |
'Update Options', 'adminimize' |
| 133 |
); ?> »" /><input type="hidden" name="page_options" value="'dofollow_timeout'" /> |
| 134 |
</p> |
| 135 |
|
| 136 |
<p> |
| 137 |
<a class="alignright button adminimize-scroltop" href="#" |
| 138 |
style="margin:3px 0 0 30px;"><?php esc_attr_e( |
| 139 |
'scroll to top', 'adminimize' |
| 140 |
); ?></a> |
| 141 |
<br class="clear" /> |
| 142 |
</p> |
| 143 |
|
| 144 |
</div> |
| 145 |
</div> |
| 146 |
</div> |
| 147 |
|