masterbar.php
6 years ago
overrides.css
6 years ago
rtl-admin-bar.php
7 years ago
tracks-events.js
6 years ago
rtl-admin-bar.php
56 lines
| 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 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 | /** |
| 15 | * Display the admin bar. |
| 16 | */ |
| 17 | public function render() { |
| 18 | global $is_IE; |
| 19 | $root = $this->_bind(); |
| 20 | |
| 21 | // Add browser and RTL classes. |
| 22 | // We have to do this here since admin bar shows on the front end. |
| 23 | $class = 'nojq nojs rtl'; |
| 24 | if ( $is_IE ) { |
| 25 | if ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 7' ) ) { |
| 26 | $class .= ' ie7'; |
| 27 | } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 8' ) ) { |
| 28 | $class .= ' ie8'; |
| 29 | } elseif ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE 9' ) ) { |
| 30 | $class .= ' ie9'; |
| 31 | } |
| 32 | } elseif ( wp_is_mobile() ) { |
| 33 | $class .= ' mobile'; |
| 34 | } |
| 35 | |
| 36 | ?> |
| 37 | <div id="wpadminbar" class="<?php echo esc_attr( $class ); ?>"> |
| 38 | <?php if ( ! is_admin() ) : ?> |
| 39 | <a class="screen-reader-shortcut" href="#wp-toolbar" tabindex="1"><?php esc_html_e( 'Skip to toolbar', 'jetpack' ); ?></a> |
| 40 | <?php endif; ?> |
| 41 | <div class="quicklinks" id="wp-toolbar" role="navigation" aria-label="<?php esc_attr_e( 'Toolbar', 'jetpack' ); ?>" tabindex="0"> |
| 42 | <?php |
| 43 | foreach ( $root->children as $group ) : |
| 44 | $this->_render_group( $group ); |
| 45 | endforeach; |
| 46 | ?> |
| 47 | </div> |
| 48 | <?php if ( is_user_logged_in() ) : ?> |
| 49 | <a class="screen-reader-shortcut" href="<?php echo esc_url( wp_logout_url() ); ?>"><?php esc_html_e( 'Log Out', 'jetpack' ); ?></a> |
| 50 | <?php endif; ?> |
| 51 | </div> |
| 52 | |
| 53 | <?php |
| 54 | } |
| 55 | } |
| 56 |