public
Created

bbPress Admin Bar Addition v1.5+ -- hooks, filters and constants for customizing and branding

  • Download Gist
gistfile1.aw
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
<?php
 
// since plugin version v1.5:
 
// Hooks:
 
add_action( 'bbpaba_custom_group_items', 'bbpaba_custom_additional_group_item' );
/**
* bbPress Admin Bar Addition: Custom Resource Group Items
*
* @global mixed $wp_admin_bar
*/
function bbpaba_custom_additional_group_item() {
 
global $wp_admin_bar;
 
$wp_admin_bar->add_menu( array(
'parent' => 'ddw-bbpress-bbpgroup',
'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: 'bbpaba_custom_main_items'
* Forums section (frontend): 'bbpaba_custom_forum_items'
* Extensions section: 'bbpaba_custom_extension_items'
* Theme section: 'bbpaba_custom_theme_items'
*/
 
// Filters:
 
/** Capability filters & helper functions */
add_filter( 'bbpaba_filter_capability_all', '__bbpaba_admin_only' );
add_filter( 'bbpaba_filter_capability_all', '__bbpaba_role_editor' );
add_filter( 'bbpaba_filter_capability_all', '__bbpaba_role_bbp_moderator' );
add_filter( 'bbpaba_filter_capability_all', '__bbpaba_cap_moderate' );
add_filter( 'bbpaba_filter_capability_all', '__bbpaba_cap_manage_options' );
add_filter( 'bbpaba_filter_capability_all', '__bbpaba_cap_install_plugins' );
add_filter( 'bbpaba_filter_capability_all', '__bbpaba_cap_edit_theme_options' );
 
add_filter( 'bbpaba_filter_capability_all', 'custom_bbpaba_capability_all' );
/**
* bbPress Admin Bar Addition: Change Main Capability
*/
function custom_bbpaba_capability_all() {
return 'activate_plugins';
}
 
add_filter( 'bbpaba_filter_main_icon', 'custom_bbpaba_main_icon' );
/**
* bbPress Admin Bar Addition: Change Main Icon
*/
function custom_bbpaba_main_icon() {
return get_stylesheet_directory_uri() . '/images/custom-icon.png';
}
 
/** 9 Colored Icon filters & helper functions */
add_filter( 'bbpaba_filter_main_icon', '__bbpaba_blue_icon' );
add_filter( 'bbpaba_filter_main_icon', '__bbpaba_brown_icon' );
add_filter( 'bbpaba_filter_main_icon', '__bbpaba_gray_icon' );
add_filter( 'bbpaba_filter_main_icon', '__bbpaba_green_icon' );
add_filter( 'bbpaba_filter_main_icon', '__bbpaba_khaki_icon' );
add_filter( 'bbpaba_filter_main_icon', '__bbpaba_orange_icon' );
add_filter( 'bbpaba_filter_main_icon', '__bbpaba_pink_icon' );
add_filter( 'bbpaba_filter_main_icon', '__bbpaba_red_icon' );
add_filter( 'bbpaba_filter_main_icon', '__bbpaba_turquoise_icon' );
add_filter( 'bbpaba_filter_main_icon', '__bbpaba_alternate_icon' );
add_filter( 'bbpaba_filter_main_icon', '__bbpaba_theme_images_icon' );
 
/**
* Custom Icon filter & helper function
* via theme/child theme "images" folder (file: icon-bbpaba.png)
*/
add_filter( 'bbpaba_filter_main_icon', '__bbpaba_theme_images_icon' );
 
add_filter( 'bbpaba_filter_main_icon_display', 'custom_bbpaba_main_icon_display_class' );
/**
* bbPress Admin Bar Addition: Change Main Icon CSS Class
*/
function custom_bbpaba_main_icon_display_class() {
return 'your-custom-icon-class';
}
 
/** Remove main icon completely */
add_filter( 'bbpaba_filter_main_icon_display', '__bbpaba_no_icon_display' );
 
add_filter( 'bbpaba_filter_main_item_title', 'custom_bbpaba_main_item_title' );
/**
* bbPress Admin Bar Addition: Change Main Item Name
*/
function custom_bbpaba_main_item_title() {
return __( 'Your custom main item title', 'your-textdomain' );
}
 
add_filter( 'bbpaba_filter_main_item_title_tooltip', 'custom_bbpaba_main_item_title_tooltip' );
/**
* bbPress Admin Bar Addition: Change Main Item Name's Tooltip
*/
function custom_bbpaba_main_item_title_tooltip() {
return __( 'Your custom main item title tooltip', 'your-textdomain' );
}
 
/**
* Filter: 'bbpaba_filter_bbpress_name'
* Filter: 'bbpaba_filter_bbpress_name_tooltip'
* For these 2 see the last two above - same principle/scheme
*/
 
// Constants:
 
/** bbPress Admin Bar Addition: Remove Extensions Items */
define( 'BBPABA_EXTENSIONS_DISPLAY', FALSE );
 
/** bbPress Admin Bar Addition: Remove Theme Items */
define( 'BBPABA_THEME_DISPLAY', FALSE );
 
/** bbPress Admin Bar Addition: Remove Resource Items */
define( 'BBPABA_RESOURCES_DISPLAY', FALSE );
 
/** bbPress Admin Bar Addition: Remove German Language Items */
define( 'BBPABA_DE_DISPLAY', FALSE );
 
/** bbPress Admin Bar Addition: Remove all items for "Editor" user role */
if ( current_user_can( 'editor' ) ) {
define( 'BBPABA_DISPLAY', FALSE );
}
 
/** bbPress Admin Bar Addition: Remove all items for user ID 2 */
if ( 2 == get_current_user_id() ) {
define( 'BBPABA_DISPLAY', FALSE );
}
 
/** bbPress Admin Bar Addition: Remove all items from frontend */
if ( ! is_admin() ) {
define( 'BBPABA_DISPLAY', FALSE );
}
 
/** bbPress Admin Bar Addition: Remove all items */
define( 'BBPABA_DISPLAY', FALSE );
 
// Other Stuff:
 
/** bbPress Admin Bar Addition: Remove original GD bbPress Tools items */
define( 'BBPABA_REMOVE_GDBBPRESSTOOLS_TOOLBAR', true );

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

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

Download "bbPress Toolbar / Admin Bar" plugin at wordpress.org:
http://wordpress.org/extend/plugins/bbpress-admin-bar-addition/

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.