Skip to content

Commit

Permalink
Merge pull request #44 from westonruter/add/use-admin-bar-inline-style
Browse files Browse the repository at this point in the history
Use inline style system to add admin bar styles to page
  • Loading branch information
danielbachhuber authored Sep 9, 2019
2 parents 12b6c38 + fd1e9bf commit f08e5b2
Showing 1 changed file with 51 additions and 46 deletions.
97 changes: 51 additions & 46 deletions inc/class-toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public static function get_instance() {

private function setup_actions() {
add_action( 'admin_bar_menu', array( $this, 'action_admin_bar_menu' ), 100 );
add_action( 'wp_head', array( $this, 'action_wp_head' ) );
add_action( 'admin_head', array( $this, 'action_wp_head' ) );
add_action( 'wp_enqueue_scripts', array( $this, 'add_admin_bar_inline_styles' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'add_admin_bar_inline_styles' ) );
}

public function action_admin_bar_menu( $wp_admin_bar ) {
Expand Down Expand Up @@ -113,50 +113,55 @@ public function action_admin_bar_menu( $wp_admin_bar ) {

}

public function action_wp_head() {
?>
<style>
#wpadminbar li#wp-admin-bar-pantheon-hud > .ab-item img {
height:32px;
width:32px;
vertical-align:middle;
margin-top:-4px;
}
#wpadminbar li#wp-admin-bar-pantheon-hud em {
font-size: 11px;
line-height: 13px;
font-style: italic;
}
#wpadminbar li#wp-admin-bar-pantheon-hud br {
line-height: 0;
}
#wpadminbar #wp-admin-bar-pantheon-hud-wp-admin-links a {
display: inline;
padding:0;
height: auto;
}
#wpadminbar ul li#wp-admin-bar-pantheon-hud-wp-admin-links .ab-item,
#wpadminbar ul li#wp-admin-bar-pantheon-hud-environment-details .ab-item,
#wpadminbar ul li#wp-admin-bar-pantheon-hud-wp-cli-stub .ab-item {
height: auto;
}
#wpadminbar ul li#wp-admin-bar-pantheon-hud-wp-cli-stub input {
width: 100%;
line-height: 15px;
background-color: rgba( 255, 255, 255, 0.9 );
border-width: 1px;
}
#wpadminbar ul li#wp-admin-bar-pantheon-hud-dashboard-link {
padding-left: 3px;
padding-right: 3px;
}
#wpadminbar ul li#wp-admin-bar-pantheon-hud-dashboard-link a {
border-top: 1px solid rgba(240,245,250,.4);
padding-top: 3px;
margin-top: 10px;
}
</style>
<?php
/**
* Add admin bar inline styles.
*/
public function add_admin_bar_inline_styles() {
ob_start();
?>
<style>
#wpadminbar li#wp-admin-bar-pantheon-hud > .ab-item img {
height:32px;
width:32px;
vertical-align:middle;
margin-top:-4px;
}
#wpadminbar li#wp-admin-bar-pantheon-hud em {
font-size: 11px;
line-height: 13px;
font-style: italic;
}
#wpadminbar li#wp-admin-bar-pantheon-hud br {
line-height: 0;
}
#wpadminbar #wp-admin-bar-pantheon-hud-wp-admin-links a {
display: inline;
padding:0;
height: auto;
}
#wpadminbar ul li#wp-admin-bar-pantheon-hud-wp-admin-links .ab-item,
#wpadminbar ul li#wp-admin-bar-pantheon-hud-environment-details .ab-item,
#wpadminbar ul li#wp-admin-bar-pantheon-hud-wp-cli-stub .ab-item {
height: auto;
}
#wpadminbar ul li#wp-admin-bar-pantheon-hud-wp-cli-stub input {
width: 100%;
line-height: 15px;
background-color: rgba( 255, 255, 255, 0.9 );
border-width: 1px;
}
#wpadminbar ul li#wp-admin-bar-pantheon-hud-dashboard-link {
padding-left: 3px;
padding-right: 3px;
}
#wpadminbar ul li#wp-admin-bar-pantheon-hud-dashboard-link a {
border-top: 1px solid rgba(240,245,250,.4);
padding-top: 3px;
margin-top: 10px;
}
</style>
<?php
wp_add_inline_style( 'admin-bar', str_replace( array( '<style>', '</style>' ), '', ob_get_clean() ) );
}

private function get_environment() {
Expand Down

0 comments on commit f08e5b2

Please sign in to comment.