Skip to content

Instantly share code, notes, and snippets.

@deckerweb
Created May 4, 2012 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deckerweb/2597157 to your computer and use it in GitHub Desktop.
Save deckerweb/2597157 to your computer and use it in GitHub Desktop.
Toolbar Buddy plugin v1.2+ -- hooks, filters and constants for customizing and branding
<?php
// since plugin version v1.2:
// Hooks:
add_action( 'tbb_custom_iresource_group_items', 'tbb_custom_additional_iresource_group_item' );
/**
* Toolbar Buddy: Custom iResource Group Items
*
* @global mixed $wp_admin_bar
*/
function tbb_custom_additional_iresource_group_item() {
global $wp_admin_bar;
$wp_admin_bar->add_menu( array(
'parent' => 'ddw-ibuddy-iresourcegroup',
'title' => __( 'Custom Menu Item Name', 'your-textdomain' ),
'href' => 'http://deckerweb.de/',
'meta' => array( 'title' => __( 'Custom Menu Item Name Tooltip', 'your-textdomain' ) )
) );
}
/**
* The same way you can use the other hooks for adding items:
* iThemes Builder items: 'tbb_custom_ithemes_group_items'
* DisplayBuddy items: 'tbb_custom_displaybuddy_group_items'
* LoopBuddy items: 'tbb_custom_loopbuddy_group_items'
* BackupBuddy items: 'tbb_custom_backupbuddy_group_items'
*/
// Filters:
/** Capability filters & helper functions */
add_filter( 'tbb_filter_capability_all', '__tbb_admin_only' );
add_filter( 'tbb_filter_capability_all', '__tbb_role_editor' );
add_filter( 'tbb_filter_capability_all', '__tbb_cap_edit_theme_options' );
add_filter( 'tbb_filter_capability_all', '__tbb_cap_manage_options' );
add_filter( 'tbb_filter_capability_all', '__tbb_cap_install_plugins' );
add_filter( 'tbb_filter_capability_all', 'custom_tbb_capability_all' );
/**
* Toolbar Buddy: Change Main Capability
*/
function custom_tbb_capability_all() {
return 'activate_plugins';
}
add_filter( 'tbb_filter_main_icon', 'custom_child_tbb_main_icon' );
/**
* Toolbar Buddy: Change Main Icon (Child Theme)
*/
function custom_child_tbb_main_icon() {
return get_stylesheet_directory_uri() . '/images/custom-icon.png';
}
/** 7 Alternate Icon filters & helper functions */
add_filter( 'tbb_filter_main_icon', '__tbb_icon_builder' );
add_filter( 'tbb_filter_main_icon', '__tbb_icon_buildertwo' );
add_filter( 'tbb_filter_main_icon', '__tbb_icon_pluginbuddy' );
add_filter( 'tbb_filter_main_icon', '__tbb_icon_pluginbuddytwo' );
add_filter( 'tbb_filter_main_icon', '__tbb_icon_displaybuddy' );
add_filter( 'tbb_filter_main_icon', '__tbb_icon_loopbuddy' );
add_filter( 'tbb_filter_main_icon', '__tbb_icon_backupbuddy' );
/**
* Custom Icon filter & helper function
* via child theme "images" folder (file: icon-tbb.png)
*/
add_filter( 'tbb_filter_main_icon', '__tbb_child_images_icon' );
add_filter( 'tbb_filter_main_icon_display', 'custom_tbb_main_icon_display_class' );
/**
* Toolbar Buddy: Change Main Icon CSS Class
*/
function custom_tbb_main_icon_display_class() {
return 'your-custom-icon-class';
}
/** Remove main icon completely */
add_filter( 'tbb_filter_main_icon_display', '__tbb_no_icon_display' );
add_filter( 'tbb_filter_main_item', 'custom_tbb_main_item' );
/**
* Toolbar Buddy: Change Main Item Name
*/
function custom_tbb_main_item() {
return __( 'Your custom main item', 'your-child-theme-textdomain' );
}
add_filter( 'tbb_filter_main_item_tooltip', 'custom_tbb_main_item_tooltip' );
/**
* Toolbar Buddy: Change Main Item Name's Tooltip
*/
function custom_tbb_main_item_tooltip() {
return __( 'Your custom main item tooltip', 'your-child-theme-textdomain' );
}
/**
* Filter: tbb_filter_ibuddy_hq_name
* For this one see the last two above - same principle/scheme
*/
// Constants:
/** Toolbar Buddy: Remove all Builder Items */
define( 'TBB_BUILDER_DISPLAY', FALSE );
/** Toolbar Buddy: Remove Builder's Manage Content Items */
define( 'TBB_BUILDER_MANAGE_CONTENT_DISPLAY', FALSE );
/** Toolbar Buddy: Remove DisplayBuddy Items */
define( 'TBB_DISPLAYBUDDY_DISPLAY', FALSE );
/** Toolbar Buddy: Remove LoopBuddy Items */
define( 'TBB_LOOPBUDDY_DISPLAY', FALSE );
/** Toolbar Buddy: Remove BackupBuddy Items */
define( 'TBB_BACKUPBUDDY_DISPLAY', FALSE );
/** Toolbar Buddy: Remove iResource Items */
define( 'TBB_RESOURCES_DISPLAY', FALSE );
/** Toolbar Buddy: Remove German Language Items */
define( 'TBB_DE_DISPLAY', FALSE );
/** Toolbar Buddy: Remove ALL items for "Editor" user role */
if ( current_user_can( 'editor' ) ) {
define( 'TBB_ALL_DISPLAY', FALSE );
}
/** Toolbar Buddy: Remove ALL items for user ID 2 */
if ( 2 == get_current_user_id() ) {
define( 'TBB_ALL_DISPLAY', FALSE );
}
/** Toolbar Buddy: Remove ALL items from frontend */
if ( ! is_admin() ) {
define( 'TBB_ALL_DISPLAY', FALSE );
}
/** Toolbar Buddy: Remove ALL items */
define( 'TBB_ALL_DISPLAY', FALSE );
// Other Stuff:
/** Toolbar Buddy: Remove Original Builder Toolbar Items */
define( 'TBB_REMOVE_BUILDER_ORIGINAL_TOOLBAR', TRUE );
@deckerweb
Copy link
Author

Note: The above codes work with plugin version 1.2 or higher!

Extended explanation can be found at the plugin's page "FAQ" section at the bottom:
http://wordpress.org/extend/plugins/toolbar-buddy/faq/

Download "Toolbar Buddy" plugin at wordpress.org:
http://wordpress.org/extend/plugins/toolbar-buddy/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment