Completed
Push — kraftbj-patch-2 ( 82c983...ae9d16 )
by
unknown
513:58 queued 503:20
created

RTL_Admin_Bar::render()   D

Complexity

Conditions 9
Paths 48

Size

Total Lines 38
Code Lines 30

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 9
eloc 30
nc 48
nop 0
dl 0
loc 38
rs 4.909
c 0
b 0
f 0
1
<?php
2
3
if ( ! class_exists( 'WP_Admin_Bar' ) ) {
4
	require_once ABSPATH . '/wp-includes/class-wp-admin-bar.php';
5
}
6
7
/**
8
 * We are using this class to replace core WP_Admin_Bar in cases when
9
 * we need to override the default styles with rtl ones. This is
10
 * achieved by adding 'rtl' class to #wpadminbar div. Apart from that
11
 * the output of render method should be the same as the one of base class.
12
 */
13
class RTL_Admin_Bar extends WP_Admin_Bar {
14
	function render() {
15
		global $is_IE;
16
		$root = $this->_bind();
17
18
		// Add browser and RTL classes.
19
		// We have to do this here since admin bar shows on the front end.
20
		$class = 'nojq nojs rtl';
21
		if ( $is_IE ) {
22
			if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 7' ) ) {
23
				$class .= ' ie7';
24
			} elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 8' ) ) {
25
				$class .= ' ie8';
26
			} elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 9' ) ) {
27
				$class .= ' ie9';
28
			}
29
		} elseif ( wp_is_mobile() ) {
30
			$class .= ' mobile';
31
		}
32
33
		?>
34
		<div id="wpadminbar" class="<?php echo $class; ?>">
35
			<?php if ( ! is_admin() ) : ?>
36
				<a class="screen-reader-shortcut" href="#wp-toolbar" tabindex="1"><?php _e( 'Skip to toolbar', 'jetpack' ); ?></a>
37
			<?php endif; ?>
38
			<div class="quicklinks" id="wp-toolbar" role="navigation" aria-label="<?php esc_attr_e( 'Toolbar', 'jetpack' ); ?>" tabindex="0">
39
				<?php
40
				foreach ( $root->children as $group ) :
41
					$this->_render_group( $group );
42
				endforeach;
43
				?>
44
			</div>
45
			<?php if ( is_user_logged_in() ) : ?>
46
				<a class="screen-reader-shortcut" href="<?php echo esc_url( wp_logout_url() ); ?>"><?php _e( 'Log Out', 'jetpack' ); ?></a>
47
			<?php endif; ?>
48
		</div>
49
50
		<?php
51
	}
52
}
53