admin_bar.php 4.65 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
<?php
/**
 * @package    Adminimize
 * @subpackage Admin Bar Options, settings page
 * @author     Frank Bültge
 * @since      1.8.1  01/10/2013
 */
if ( ! function_exists( 'add_action' ) ) {
	die( "Hi there!  I'm just a part of plugin, not much I can do when called directly." );
}

/** @var $wp_admin_bar WP_Admin_Bar */
if ( ! isset( $wp_admin_bar ) ) {
	$wp_admin_bar = '';
}

if ( ! isset( $user_roles ) ) {
	$user_roles = _mw_adminimize_get_all_user_roles();
}

if ( ! isset( $user_roles_names ) ) {
	$user_roles_names = _mw_adminimize_get_all_user_roles_names();
}
?>
<div id="poststuff" class="ui-sortable meta-box-sortables">
	<div class="postbox">
		<div class="handlediv" title="<?php esc_attr_e( 'Click to toggle' ); ?>"><br /></div>
		<h3 class="hndle" id="admin_bar_options" title="<?php esc_attr_e( 'Click to toggle' ); ?>"><?php
			esc_attr_e( 'Admin Bar Back end options', 'adminimize' ); ?></h3>

		<div class="inside">
			<br class="clear" />

			<table summary="config_widget" class="widefat">
				<colgroup>
					<?php
					$col = 0;
					foreach ( $user_roles_names as $role_name ) {
						echo '<col class="col' . $col . '">' . "\n";
						$col ++;
					}
					?>
				</colgroup>
				<thead>
				<tr>
					<th><?php esc_attr_e( 'Option', 'adminimize' ); ?></th>
					<?php
					foreach ( $user_roles_names as $role_name ) { ?>
						<th><?php esc_attr_e( 'Deactivate for', 'adminimize' );
							echo '<br/>' . $role_name; ?></th>
					<?php } ?>
				</tr>
				<tr>
					<td><?php esc_attr_e( 'Select all', 'adminimize' ); ?></td>
					<?php
					foreach ( $user_roles as $role_slug ) {
						echo '<td class="num">';
						echo '<input id="select_all" class="admin_bar_' . $role_slug
								. '" type="checkbox" name="" value="" />';
						echo '</td>' . "\n";
					} ?>
				</tr>
				</thead>

				<tbody>
				<?php
				foreach ( $user_roles as $role ) {
					$disabled_admin_bar_option_[ $role ] = _mw_adminimize_get_option_value(
						'mw_adminimize_disabled_admin_bar_' . $role . '_items'
					);
				}

				$x = 0;
				// add items to array for select
				// Use the hook to enhance for custom items, there are not in the list
				$admin_bar_items = apply_filters(
					'adminimize_admin_bar_items', _mw_adminimize_get_option_value( 'mw_adminimize_admin_bar_nodes' )
				);

				$message = '';
				if ( ! empty( $admin_bar_items ) && is_array( $admin_bar_items ) ) {
					foreach ( $admin_bar_items as $key => $value ) {

						$is_parent = ! empty( $value->parent );
						$has_link  = ! empty( $value->href );

						// No title on the item.
						if ( ! $value->title ) {
							$value->title = '<b><i>' . esc_attr__( 'No Title!', 'adminimize' ) . '</i></b>';
						}

						$item_string  = '&bull; ';
						$before_title = '<b>';
						$after_title  = '</b> <small>' . esc_attr__( 'Group', 'adminimize' ) . '</small>';
						if ( $is_parent ) {
							$item_string = '&mdash; ';
							$before_title = '';
							$after_title  = '';
						}

						$checked_user_role_ = array();
						foreach ( $user_roles as $role ) {
							$checked_user_role_[ $role ] = ( isset( $disabled_admin_bar_option_[ $role ] )
								&& in_array(
									$key, $disabled_admin_bar_option_[ $role ], FALSE
								)
							) ? ' checked="checked"' : '';
						}

						echo '<tr>' . "\n";
						echo '<td>'. $before_title . $item_string . strip_tags( $value->title, '<strong><b><em><i>' )
								. $after_title . ' <span>(' . $key . ')</span> </td>' . "\n";
						foreach ( $user_roles as $role ) {
							echo '<td class="num"><input id="check_post' . $role . $x . '" class="admin_bar_'
									. $role . '" type="checkbox"'
								. $checked_user_role_[ $role ] . ' name="mw_adminimize_disabled_admin_bar_'
								. $role . '_items[]" value="' . $key . '" /></td>' . "\n";
						}
						echo '</tr>' . "\n";
						$x ++;
					}
				}
				$message = '<span style="font-size: 35px;">&#x261D;</span>'
					. 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' );
				?>
				</tbody>
			</table>

			<p><?php echo $message; ?></p>
			<p id="submitbutton">
				<input type="hidden" name="_mw_adminimize_action" value="_mw_adminimize_insert" />
				<input class="button button-primary" type="submit" name="_mw_adminimize_save" value="<?php esc_attr_e(
					'Update Options', 'adminimize'
				); ?> &raquo;" /><input type="hidden" name="page_options" value="'dofollow_timeout'" />
			</p>

			<p>
				<a class="alignright button" href="javascript:void(0);" onclick="window.scrollTo(0,0);"
						style="margin:3px 0 0 30px;"><?php esc_attr_e(
						'scroll to top', 'adminimize'
					); ?></a>
				<br class="clear" />
			</p>

		</div>
	</div>
</div>