Created
May 17, 2012 19:46
-
-
Save deckerweb/2721186 to your computer and use it in GitHub Desktop.
bbPress Admin Bar Addition v1.5+ -- 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.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 ); |
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.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/