Skip to content

Instantly share code, notes, and snippets.

@nschaeferhoff
nschaeferhoff / customize WordPress toolbar 1
Last active November 17, 2017 10:55
Customize WordPress toolbar 1
#wpadminbar {
background: blue;
}
add_action('admin_bar_menu', 'add_toolbar_items', 11);
#wpadminbar {
display: none;
}
show_admin_bar(false);
#wpadminbar .quicklinks>ul>li {
position:relative;
}
#wpadminbar .ab-top-menu>.menupop>.ab-sub-wrapper {
bottom: 32px;
}
body.admin-bar {
margin-top: -32px;
padding-bottom: 32px;
}
#wpadminbar {
top: auto !important;
bottom: 0;
}
function conditionally_remove_admin_bar() {
if (!current_user_can('administrator') && !is_admin()) {
show_admin_bar(false);
}
}
add_action('after_setup_theme', 'conditionally_remove_admin_bar');
function style_tool_bar() {
echo '
<style type="text/css">
#wpadminbar {
background: blue;
}
</style>';
}
add_action( 'admin_head', 'style_tool_bar' );
add_action( 'wp_head', 'style_tool_bar' );
function delay_rss_feed($where) {
global $wpdb;
if ( is_feed() ) {
$now = gmdate('Y-m-d H:i:s');
$wait = '10';
$device = 'MINUTE';
$where.= " AND TIMESTAMPDIFF($device, $wpdb->posts.post_date_gmt, '$now') > $wait ";
}
function remove_toolbar_items($wp_adminbar) {
$wp_adminbar->remove_node('wpseo-menu');
}
add_action('admin_bar_menu', 'remove_toolbar_items', 999);