Ask questions about WordPress courses

Plugin to move the admin bar to the bottom of WordPress

To begin with, I will say that there is a great plugin Stick Admin Bar To Bottom for these purposes. The plugin itself is written very simply., just two pieces of code.

Stick Admin Bar To Bottom plugin code:

/*
Plugin Name: Stick Admin Bar To Bottom
Description: Annoyed by the new Admin Bar that is covering the top 28 pixels of your website, but you don't want it completely gone? This plugin sticks the Admin Bar to the bottom of your screen!
Author: Coen Jacobs
Version: 1.2
Author URI: https://coenjacobs.me
*/
function stick_admin_bar_to_bottom_css() {
	$version = get_bloginfo( 'version' );

	if ( version_compare( $version, '3.3', '<' ) ) {
		$css_file = 'wordpress-3-1.css';
	} else {
		$css_file = 'wordpress-3-3.css';
	}
	wp_enqueue_style( 'stick-admin-bar-to-bottom', plugins_url( 'css/' . $css_file, __FILE__ ) );
}

add_action( 'admin_init', 'stick_admin_bar_to_bottom_css' );
add_action( 'wp_enqueue_scripts', 'stick_admin_bar_to_bottom_css' );

Style code wordpress-3-3.css:

* html body {
    margin-top: 0 !important; 
}

body.admin-bar {
	margin-top: -28px;
	padding-bottom: 28px;
}

body.wp-admin #footer {
	padding-bottom: 28px;
}

#wpadminbar {
	top: auto !important;
	bottom: 0;
}

#wpadminbar .quicklinks .ab-sub-wrapper {
	bottom: 28px;
}

#wpadminbar .quicklinks .ab-sub-wrapper ul .ab-sub-wrapper {
	bottom: -7px;
}

Style code wordpress-3-1.css:

* html body {
    margin-top: 0 !important; 
}

body.admin-bar {
	margin-top: -28px;
	padding-bottom: 28px;
}

body.wp-admin #footer {
	padding-bottom: 28px;
}

#wpadminbar {
	top: auto !important;
	bottom: 0;
}

#wpadminbar .quicklinks .menupop ul {
	bottom: 28px;
}

In the plugin itself, the code is placed in the main file called stick-admin-bar-to-bottom.php, folder next to it css and in it styles for admin bar file called wordpress-3-3.css and wordpress-3-1.css.

Laid out exclusively for myself and you as an example of the implementation of such code. You can safely use the plugin itself.


Купить хостинг WordPress
/* WordPress tutor
Online tutoring services. List of courses I teach
  • Basic web design course;
  • Site layout;
  • General course on CMS WordPress and continuation of the course on template development;
  • Website development in PHP.
Read more on the page WordPress tutor
*/

Nikolaenko Maxim

Director of web studies ProGrafika. I am developing, website design and promotion. Always glad to new blog readers and good clients.


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Templates for WordPress
The best hosting in Ukraine
Stable hosting for Drupal