public
Last active

WooCommerce Admin Bar Addition plugin version 2.2.0 or higher -- filters and constants for customizing and branding

  • Download Gist
wcaba-tweaks.php
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
<?php
/** Do NOT include the opening php tag */
 
 
// Hooks:
 
add_action( 'wcaba_custom_group_items', 'wcaba_custom_additional_group_item' );
/**
* BuddyPress Toolbar: Custom Resource Group Items
*
* @global mixed $wp_admin_bar
*/
function wcaba_custom_additional_group_item() {
 
global $wp_admin_bar;
 
$wp_admin_bar->add_menu( array(
'parent' => 'ddw-woocommerce-wcgroup',
'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: 'wcaba_custom_main_items'
* Extensions section: 'wcaba_custom_extend_items'
* Theme section: 'wcaba_custom_theme_items'
*/
 
// Filters:
 
/** Capability filters & helper functions */
add_filter( 'wcaba_filter_capability_all', '__wcaba_admin_only' );
add_filter( 'wcaba_filter_capability_all', '__wcaba_role_shop_manager' );
add_filter( 'wcaba_filter_capability_all', '__wcaba_role_editor' );
add_filter( 'wcaba_filter_capability_all', '__wcaba_cap_manage_options' );
add_filter( 'wcaba_filter_capability_all', '__wcaba_cap_install_plugins' );
 
add_filter( 'wcaba_filter_capability_all', 'custom_wcaba_capability_all' );
/**
* WooCommerce Admin Bar Addition: Change Main Capability
*/
function custom_wcaba_capability_all() {
return 'edit_theme_options';
}
 
/** Icon filters & helper functions */
add_filter( 'wcaba_filter_main_icon', '__wcaba_blue_icon' );
add_filter( 'wcaba_filter_main_icon', '__wcaba_grey_icon' );
add_filter( 'wcaba_filter_main_icon', '__wcaba_orange_icon' );
add_filter( 'wcaba_filter_main_icon', '__wcaba_pink_icon' );
add_filter( 'wcaba_filter_main_icon', '__wcaba_red_icon' );
add_filter( 'wcaba_filter_main_icon', '__wcaba_teal_icon' );
 
add_filter( 'wcaba_filter_main_icon', 'custom_wcaba_main_icon' );
/**
* WooCommerce Admin Bar Addition: Change Main Icon
*/
function custom_wcaba_main_icon() {
return get_stylesheet_directory_uri() . '/images/custom-icon.png';
}
 
/** Remove main icon completely */
add_filter( 'wcaba_filter_main_icon_display', '__wcaba_no_icon_display' );
 
add_filter( 'wcaba_filter_main_icon_display', 'custom_wcaba_main_icon_display_class' );
/**
* WooCommerce Admin Bar Addition: Change Main Icon CSS Class
*/
function custom_wcaba_main_icon_display_class() {
return 'your-custom-icon-class';
}
 
add_filter( 'wcaba_filter_main_item', 'custom_wcaba_main_item' );
/**
* WooCommerce Admin Bar Addition: Change Main Item Name
*/
function custom_wcaba_main_item() {
return __( 'Your custom main item', 'your-theme-textdomain' );
}
 
add_filter( 'wcaba_filter_main_item_tooltip', 'custom_wcaba_main_item_tooltip' );
/**
* WooCommerce Admin Bar Addition: Change Main Item Name's Tooltip
*/
function custom_wcaba_main_item_tooltip() {
return __( 'Your custom main item tooltip', 'your-theme-textdomain' );
}
 
/**
* Filter: 'wcaba_filter_woocommerce_name'
* Filter: 'wcaba_filter_woocommerce_name_tooltip'
* For these 2 see the last two above - same principle/scheme
*/
 
// Constants:
 
/** WooCommerce Admin Bar Addition: Remove ALL Items! */
define( 'WCABA_DISPLAY', FALSE );
 
/** WooCommerce Admin Bar Addition: Remove Extensions Items */
define( 'WCABA_EXTENSIONS_DISPLAY', FALSE );
 
/** WooCommerce Admin Bar Addition: Remove Themes Items */
define( 'WCABA_THEMES_DISPLAY', FALSE );
 
/** WooCommerce Admin Bar Addition: Remove Resource Items */
define( 'WCABA_RESOURCES_DISPLAY', FALSE );
 
/** WooCommerce Admin Bar Addition: Remove German Language Items */
define( 'WCABA_DE_DISPLAY', FALSE );
 
/** WooCommerce Admin Bar Addition: Remove Dutch Language Items */
define( 'WCABA_NL_DISPLAY', FALSE );
 
/** WooCommerce Admin Bar Addition: Remove WC Debug Link */
define( 'WCABA_DEBUG_DISPLAY', FALSE );
 
/** WooCommerce Admin Bar Addition: Remove Reports/Statistics */
define( 'WCABA_REPORTS_DISPLAY', FALSE );
 
/** WooCommerce Admin Bar Addition: Remove all items for "Editor" user role */
if ( current_user_can( 'editor' ) ) {
define( 'WCABA_DISPLAY', FALSE );
}
 
/** WooCommerce Admin Bar Addition: Remove all items for user ID 2 */
if ( 2 == get_current_user_id() ) {
define( 'WCABA_EXTENSIONS_DISPLAY', FALSE );
}

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

Extended explanation can be found at the plugin's page "Other Notes" section at the bottom:
http://wordpress.org/plugins/woocommerce-admin-bar-addition/other_notes/

Download "WooCommerce Toolbar / Admin Bar" plugin at wordpress.org:
http://wordpress.org/plugins/woocommerce-admin-bar-addition/

How about an update to this little gem? Can the orders listing screen be added to the dropdown?

@designerken The plugin was just updated to v2.6.0 http://wordpress.org/plugins/woocommerce-admin-bar-addition/ Enjoy! :)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.