Created
April 18, 2018 13:37
-
-
Save woodyhayday/c3f895e525927be8a1c03160bffe653a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/* | |
Plugin Name: Zero BS CRM [Example Code] | |
Plugin URI: https://zerobscrm.com | |
Description: This code example adds a custom tab to your Zero BS CRM Contact View | |
Version: 1.0 | |
Author: <a href="https://zerobscrm.com">Zero BS CRM</a> | |
Text Domain: zerobscrm | |
*/ | |
/* | |
Info | |
-------- | |
This is a code example from ZeroBSCRM.com, | |
it shows you how to add your own custom tabs | |
to the Zero BS CRM Contact View Vitals area | |
-------- | |
We advise you to rename the plugin and function names to fit your project. | |
-------- | |
Guide: | |
https://zerobscrm.com/kb/knowledge-base/adding-custom-tabs-to-contact-view-or-company-view/ | |
-------- | |
For extra info on WordPress Hooks & Actions: | |
https://developer.wordpress.org/reference/functions/add_filter/ | |
*/ | |
/* | |
This function tells our plugin to add the tags, on the action admin_init | |
*/ | |
function zbsCustom_admin_init(){ | |
// Here we add the filter which will call our function lower down in this file | |
// ... when a contact's vital tabs are loaded | |
add_filter( 'zbs-contact-vital-tabs', 'zbsCustom_modifyTabs', 10, 2); | |
} add_action('admin_init','zbsCustom_admin_init'); | |
/* | |
This function lets you modify the tabs displayed, | |
here we add our own new custom tab. | |
... the contact ID is passed via $id | |
... using this you could generate any HTML you need to. | |
*/ | |
function zbsCustom_modifyTabs( $arr, $id ) { | |
// this is just a check :) | |
if (!is_array($arr)) $arr = array(); | |
// Here we add the new tab | |
// 'id' = Represents HTML id attribute, must be unique & html-attribute format (e.g. a-b-c) | |
// 'name' = Title string | |
// 'content' = the HTML you want to display in your tab (you could use another function to produce this) | |
$arr[] = array( | |
'id' => 'example-tab', | |
'name' => 'Example Tab', | |
'content' => '<h2>The contact ID is: '.$id.'</h2>' | |
); | |
return $arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sdafsdf