BuddyPress Toolbar plugin v1.2+ -- hooks, filters and constants for customizing and branding
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// since plugin version v1.2: | |
// Hooks: | |
add_action( 'bptb_custom_group_items', 'bptb_custom_additional_group_item' ); | |
/** | |
* BuddyPress Toolbar: Custom Resource Group Items | |
* | |
* @global mixed $wp_admin_bar | |
*/ | |
function bptb_custom_additional_group_item() { | |
global $wp_admin_bar; | |
$wp_admin_bar->add_menu( array( | |
'parent' => 'ddw-buddypress-bpgroup', | |
'id' => 'your-unique-item-id', | |
'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 new items: | |
* Main section: 'bptb_custom_main_items' | |
* Extensions section: 'bptb_custom_extension_items' | |
* Theme section: 'bptb_custom_theme_items' | |
*/ | |
// Filters: | |
/** Capability filters & helper functions */ | |
add_filter( 'bptb_filter_capability_all', '__bptb_role_editor' ); | |
add_filter( 'bptb_filter_capability_all', '__bptb_cap_edit_theme_options' ); | |
add_filter( 'bptb_filter_capability_all', '__bptb_cap_manage_options' ); | |
add_filter( 'bptb_filter_capability_all', '__bptb_cap_install_plugins' ); | |
add_filter( 'bptb_filter_capability_all', 'custom_bptb_capability_all' ); | |
/** | |
* BuddyPress Toolbar: Change Main Capability | |
*/ | |
function custom_bptb_capability_all() { | |
return 'activate_plugins'; | |
} | |
add_filter( 'bptb_filter_main_icon', 'custom_bptb_main_icon' ); | |
/** | |
* BuddyPress Toolbar: Change Main Icon | |
*/ | |
function custom_bptb_main_icon() { | |
return get_stylesheet_directory_uri() . '/images/custom-icon.png'; | |
} | |
/** 11 Colored Icon filters & helper functions */ | |
add_filter( 'bptb_filter_main_icon', '__bptb_blue_icon' ); | |
add_filter( 'bptb_filter_main_icon', '__bptb_brown_icon' ); | |
add_filter( 'bptb_filter_main_icon', '__bptb_gray_icon' ); | |
add_filter( 'bptb_filter_main_icon', '__bptb_green_icon' ); | |
add_filter( 'bptb_filter_main_icon', '__bptb_khaki_icon' ); | |
add_filter( 'bptb_filter_main_icon', '__bptb_orange_icon' ); | |
add_filter( 'bptb_filter_main_icon', '__bptb_pink_icon' ); | |
add_filter( 'bptb_filter_main_icon', '__bptb_red_icon' ); | |
add_filter( 'bptb_filter_main_icon', '__bptb_turquoise_icon' ); | |
add_filter( 'bptb_filter_main_icon', '__bptb_yellow_icon' ); | |
add_filter( 'bptb_filter_main_icon', '__bptb_yellowtwo_icon' ); | |
/** | |
* Custom Icon filter & helper function | |
* via theme/child theme "images" folder (file: icon-bptb.png) | |
*/ | |
add_filter( 'bptb_filter_main_icon', '__bptb_theme_images_icon' ); | |
add_filter( 'bptb_filter_main_icon_display', 'custom_bptb_main_icon_display_class' ); | |
/** | |
* BuddyPress Toolbar: Change Main Icon CSS Class | |
*/ | |
function custom_bptb_main_icon_display_class() { | |
return 'your-custom-icon-class'; | |
} | |
/** Remove main icon completely */ | |
add_filter( 'bptb_filter_main_icon_display', '__bptb_no_icon_display' ); | |
add_filter( 'bptb_filter_main_item_title', 'custom_bptb_main_item_title' ); | |
/** | |
* BuddyPress Toolbar: Change Main Item Name | |
*/ | |
function custom_bptb_main_item_title() { | |
return __( 'Your custom main item title', 'your-textdomain' ); | |
} | |
add_filter( 'bptb_filter_main_item_title_tooltip', 'custom_bptb_main_item_title_tooltip' ); | |
/** | |
* BuddyPress Toolbar: Change Main Item Name's Tooltip | |
*/ | |
function custom_bptb_main_item_title_tooltip() { | |
return __( 'Your custom main item title tooltip', 'your-textdomain' ); | |
} | |
/** | |
* Filter: 'bptb_filter_buddypress_name' | |
* Filter: 'bptb_filter_buddypress_name_tooltip' | |
* For these 2 see the last two above - same principle/scheme | |
*/ | |
// Constants: | |
/** BuddyPress Toolbar: Remove all items */ | |
define( 'BPTB_DISPLAY', FALSE ); | |
/** BuddyPress Toolbar: Remove Manage Content Items */ | |
define( 'BPTB_MANAGE_GROUPS_DISPLAY', FALSE ); | |
/** BuddyPress Toolbar: Remove Extensions Items */ | |
define( 'BPTB_EXTENSIONS_DISPLAY', FALSE ); | |
/** BuddyPress Toolbar: Remove Theme Items */ | |
define( 'BPTB_THEME_DISPLAY', FALSE ); | |
/** BuddyPress Toolbar: Remove Resource Items */ | |
define( 'BPTB_RESOURCES_DISPLAY', FALSE ); | |
/** BuddyPress Toolbar: Remove German Language Items */ | |
define( 'BPTB_DE_DISPLAY', FALSE ); | |
/** BuddyPress Toolbar: Remove Translations Items */ | |
define( 'BPTB_TRANSLATIONS_DISPLAY', FALSE ); | |
/** BuddyPress Toolbar: Remove all items for "Editor" user role */ | |
if ( current_user_can( 'editor' ) ) { | |
define( 'BPTB_DISPLAY', FALSE ); | |
} | |
/** BuddyPress Toolbar: Remove all items for user ID 2 */ | |
if ( 2 == get_current_user_id() ) { | |
define( 'BPTB_DISPLAY', FALSE ); | |
} | |
/** BuddyPress Toolbar: Remove all items from frontend */ | |
if ( ! is_admin() ) { | |
define( 'BPTB_DISPLAY', FALSE ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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/buddypress-toolbar/faq/
Download "BuddyPress Toolbar" plugin at wordpress.org:
http://wordpress.org/extend/plugins/buddypress-toolbar/