Last active
October 5, 2015 01:28
-
-
Save deckerweb/2732242 to your computer and use it in GitHub Desktop.
Gravity Forms Toolbar v1.4.0 or higher -- 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 | |
/** --> Do NOT include the opening php tag! <-- */ | |
// since plugin version v1.4.0: | |
// Hooks: | |
add_action( 'gftb_custom_group_items', 'gftb_custom_additional_group_item' ); | |
/** | |
* Gravity Forms Toolbar: Custom Resource Group Items | |
* | |
* @global mixed $wp_admin_bar | |
*/ | |
function gftb_custom_additional_group_item() { | |
global $wp_admin_bar; | |
$wp_admin_bar->add_menu( array( | |
'parent' => 'ddw-gravityforms-gfgroup', | |
'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: 'gftb_custom_main_items' | |
* Extensions section: 'gftb_custom_extension_items' | |
*/ | |
// Filters: | |
/** Capability filters & helper functions */ | |
add_filter( 'gftb_filter_capability_all', '__gftb_admin_only' ); | |
add_filter( 'gftb_filter_capability_all', '__gftb_role_editor' ); | |
add_filter( 'gftb_filter_capability_all', '__gftb_cap_manage_options' ); | |
add_filter( 'gftb_filter_capability_all', '__gftb_cap_install_plugins' ); | |
add_filter( 'gftb_filter_capability_all', '__gftb_cap_activate_plugins' ); | |
add_filter( 'gftb_filter_capability_all', '__gftb_cap_edit_theme_options' ); | |
add_filter( 'gftb_filter_capability_all', 'custom_gftb_capability_all' ); | |
/** | |
* Gravity Forms Toolbar: Change Main Capability | |
*/ | |
function custom_gftb_capability_all() { | |
return 'switch_themes'; | |
} | |
add_filter( 'gftb_filter_main_icon', 'custom_gftb_main_icon' ); | |
/** | |
* Gravity Forms Toolbar: Change Main Icon | |
*/ | |
function custom_gftb_main_icon() { | |
return get_stylesheet_directory_uri() . '/images/custom-icon.png'; | |
} | |
/** 8 Colored Icon filters & helper functions */ | |
add_filter( 'gftb_filter_main_icon', '__gftb_blue_icon' ); | |
add_filter( 'gftb_filter_main_icon', '__gftb_lightgreen_icon' ); | |
add_filter( 'gftb_filter_main_icon', '__gftb_lightgrey_icon' ); | |
add_filter( 'gftb_filter_main_icon', '__gftb_orange_icon' ); | |
add_filter( 'gftb_filter_main_icon', '__gftb_pink_icon' ); | |
add_filter( 'gftb_filter_main_icon', '__gftb_red_icon' ); | |
add_filter( 'gftb_filter_main_icon', '__gftb_turquoise_icon' ); | |
add_filter( 'gftb_filter_main_icon', '__gftb_yellow_icon' ); | |
/** | |
* Custom Icon filter & helper function | |
* via theme/child theme "images" folder (file: icon-gftb.png) | |
*/ | |
add_filter( 'gftb_filter_main_icon', '__gftb_theme_images_icon' ); | |
add_filter( 'gftb_filter_main_icon_display', 'custom_gftb_main_icon_display_class' ); | |
/** | |
* Gravity Forms Toolbar: Change Main Icon CSS Class | |
*/ | |
function custom_gftb_main_icon_display_class() { | |
return 'your-custom-icon-class'; | |
} | |
/** Remove main icon completely */ | |
add_filter( 'gftb_filter_main_icon_display', '__gftb_no_icon_display' ); | |
add_filter( 'gftb_filter_main_item', 'custom_gftb_main_item' ); | |
/** | |
* Gravity Forms Toolbar: Change Main Item Name | |
*/ | |
function custom_gftb_main_item() { | |
return __( 'Your custom main item title', 'your-textdomain' ); | |
} | |
add_filter( 'gftb_filter_main_item_tooltip', 'custom_gftb_main_item_tooltip' ); | |
/** | |
* Gravity Forms Toolbar: Change Main Item Name's Tooltip | |
*/ | |
function custom_gftb_main_item_tooltip() { | |
return __( 'Your custom main item title tooltip', 'your-textdomain' ); | |
} | |
// Constants: | |
/** Gravity Forms Toolbar: Remove Add-On Items */ | |
define( 'GFTB_ADDONS_DISPLAY', FALSE ); | |
/** Gravity Forms Toolbar: Remove Extensions Items */ | |
define( 'GFTB_EXTENSIONS_DISPLAY', FALSE ); | |
/** Gravity Forms Toolbar: Remove Resource Items */ | |
define( 'GFTB_RESOURCES_DISPLAY', FALSE ); | |
/** Gravity Forms Toolbar: Remove German Language Items */ | |
define( 'GFTB_DE_DISPLAY', FALSE ); | |
/** Gravity Forms Toolbar: Remove Dutch Language Items */ | |
define( 'GFTB_NL_DISPLAY', FALSE ); | |
/** Gravity Forms Toolbar: Remove Spanish Language Items */ | |
define( 'GFTB_ES_DISPLAY', FALSE ); | |
/** Gravity Forms Toolbar: Remove all items for "Editor" user role */ | |
if ( current_user_can( 'editor' ) ) { | |
define( 'GFTB_DISPLAY', FALSE ); | |
} | |
/** Gravity Forms Toolbar: Remove all items for user ID 2 */ | |
if ( 2 == get_current_user_id() ) { | |
define( 'GFTB_DISPLAY', FALSE ); | |
} | |
/** Gravity Forms Toolbar: Remove all items from frontend */ | |
if ( ! is_admin() ) { | |
define( 'GFTB_DISPLAY', FALSE ); | |
} | |
/** Gravity Forms Toolbar: Remove all items */ | |
define( 'GFTB_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.4.0 or higher!
Extended explanation can be found at the plugin's page "FAQ" section at the bottom:
http://wordpress.org/plugins/gravity-forms-toolbar/faq/
Download "Gravity Forms Toolbar" plugin at wordpress.org:
http://wordpress.org/plugins/gravity-forms-toolbar/