public
Last active

Easy Digital Downloads Toolbar plugin v1.0+ -- 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
<?php
 
// Action hooks:
 
add_action( 'eddtb_custom_main_items', 'eddtb_add_custom_main_items' );
/**
* Easy Digital Downloads Toolbar: Add Custom Main Items
*/
function eddtb_add_custom_main_items() {
// Your custom stuff here, you might only use the WP Toolbar / Admin Bar API here!
}
 
add_action( 'eddtb_custom_group_items', 'eddtb_add_custom_group_items' );
/**
* Easy Digital Downloads Toolbar: Add Custom Resource Group Items
*/
function eddtb_add_custom_group_items() {
// Your custom resources stuff here, you might only use the WP Toolbar / Admin Bar API here!
}
 
// Filters:
 
/** Capability filters & helper functions */
add_filter( 'eddtb_filter_capability_all', '__eddtb_admin_only' );
add_filter( 'eddtb_filter_capability_all', '__eddtb_role_editor' );
add_filter( 'eddtb_filter_capability_all', '__eddtb_cap_manage_options' );
add_filter( 'eddtb_filter_capability_all', '__eddtb_cap_edit_theme_options' );
add_filter( 'eddtb_filter_capability_all', '__eddtb_cap_install_plugins' );
 
add_filter( 'eddtb_filter_capability_all', 'custom_eddtb_capability_all' );
/**
* Easy Digital Downloads Toolbar: Change Main Capability
*/
function custom_eddtb_capability_all() {
return 'activate_plugins';
}
 
add_filter( 'eddtb_filter_main_icon', 'custom_eddtb_main_icon' );
/**
* Easy Digital Downloads Toolbar: Change Main Icon
*/
function custom_eddtb_main_icon() {
return get_stylesheet_directory_uri() . '/images/custom-icon.png';
}
 
/** 10 Colored Icon filters & helper functions */
add_filter( 'eddtb_filter_main_icon', '__eddtb_blue_icon' );
add_filter( 'eddtb_filter_main_icon', '__eddtb_brown_icon' );
add_filter( 'eddtb_filter_main_icon', '__eddtb_gray_icon' );
add_filter( 'eddtb_filter_main_icon', '__eddtb_green_icon' );
add_filter( 'eddtb_filter_main_icon', '__eddtb_khaki_icon' );
add_filter( 'eddtb_filter_main_icon', '__eddtb_orange_icon' );
add_filter( 'eddtb_filter_main_icon', '__eddtb_pink_icon' );
add_filter( 'eddtb_filter_main_icon', '__eddtb_red_icon' );
add_filter( 'eddtb_filter_main_icon', '__eddtb_turquoise_icon' );
add_filter( 'eddtb_filter_main_icon', '__eddtb_yellow_icon' );
 
/** Alternate Icon filter & helper function */
add_filter( 'eddtb_filter_main_icon', '__eddtb_alternate_icon' );
 
/**
* Custom Icon filter & helper function
* via theme/child theme "images" folder (file: icon-eddtb.png)
*/
add_filter( 'eddtb_filter_main_icon', '__eddtb_theme_images_icon' );
 
add_filter( 'eddtb_filter_main_icon_display', 'custom_eddtb_main_icon_display_class' );
/**
* Easy Digital Downloads Toolbar: Change Main Icon CSS Class
*/
function custom_eddtb_main_icon_display_class() {
return 'your-custom-icon-class';
}
 
/** Remove main icon completely */
add_filter( 'eddtb_filter_main_icon_display', '__eddtb_no_icon_display' );
 
add_filter( 'eddtb_filter_main_item', 'custom_eddtb_main_item' );
/**
* Easy Digital Downloads Toolbar: Change Main Item Name
*/
function custom_eddtb_main_item() {
return __( 'Your custom main item', 'your-theme-textdomain' );
}
 
add_filter( 'eddtb_filter_main_item_tooltip', 'custom_eddtb_main_item_tooltip' );
/**
* Easy Digital Downloads Toolbar: Change Main Item Name's Tooltip
*/
function custom_eddtb_main_item_tooltip() {
return __( 'Your custom main item tooltip', 'your-theme-textdomain' );
}
 
/**
* Filter: 'eddtb_filter_edd_name'
* Filter: 'eddtb_filter_edd_name_tooltip'
* For these 2 see the last two above - same principle/scheme
*/
 
// Constants:
 
/** Easy Digital Downloads Toolbar: Remove all items */
define( 'EDDTB_DISPLAY', FALSE );
 
/** Easy Digital Downloads Toolbar: Remove Add-On(s) Item(s) */
define( 'EDDTB_ADDONS_DISPLAY', FALSE );
 
/** Easy Digital Downloads Toolbar: Remove Resource Items */
define( 'EDDTB_RESOURCES_DISPLAY', FALSE );
 
/** Easy Digital Downloads Toolbar: Remove German Language Items */
define( 'EDDTB_DE_DISPLAY', FALSE );
 
/** Easy Digital Downloads Toolbar: Remove Translations Items */
define( 'EDDTB_TRANSLATIONS_DISPLAY', FALSE );
 
// Support for EDD's own constant:
 
/** Easy Digital Downloads: Downloads Slug, i.e. yoursite.com/my-own-downloads-slug/ */
define( 'EDD_SLUG', 'my-own-downloads-slug' );

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

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

Download "Easy Digital Downloads Toolbar" plugin at wordpress.org:
http://wordpress.org/extend/plugins/edd-toolbar/

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.