define('DISALLOW_FILE_EDIT', true);{"id":568,"date":"2011-02-07T19:37:01","date_gmt":"2011-02-08T00:37:01","guid":{"rendered":"http:\/\/www.unfocus.com\/?p=568"},"modified":"2011-12-02T12:06:20","modified_gmt":"2011-12-02T17:06:20","slug":"wordpress-admin-bar-theme-support","status":"publish","type":"post","link":"http:\/\/www.unfocus.com\/2011\/02\/07\/wordpress-admin-bar-theme-support\/","title":{"rendered":"WordPress Admin Bar Theme Support"},"content":{"rendered":"

Here’s a quickie for WordPress Theme designers:<\/p>\n

If your theme is getting unwanted scroll-bars because of the new Admin Bar is WordPress 3.1, the core team included a way to handle it. Add Theme Support for it! <\/p>\n

With a full height layout, you’ll want to avoid adding a margin or padding to a height that is already at 100% because you’ll get useless scrollbars, and no one wants that. Instead, find the first non-full height element (usually #header or some-such), and apply the margin there (either the 28px for the height of the admin bar, or add 28 to the existing margin if the element already has one). In the code snippet below I assumed you’d create an element or assign the class ‘admin-bar-fix’ to an existing element.<\/p>\n

In your theme’s function file, add the following and modify as you see fit: (best to leave out the closing php tag though)
\n[cc lang=”php”]
\n< ?php\nadd_action( 'after_setup_theme', 'custom_theme_setup' );\nfunction custom_theme_setup() {\nadd_theme_support( 'admin-bar', array( 'callback' => ‘admin_bar_bump_callback’) );
\n}
\nfunction admin_bar_bump_callback() { ?><\/p>\n