Created
January 22, 2015 08:24
-
-
Save atwellpub/4500d9002b479c1d8d37 to your computer and use it in GitHub Desktop.
Code example on how to add a tab content section to a lead profile
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 | |
| /** | |
| * Adds events section to a Lead's Activity tab | |
| */ | |
| class Extension_Practice_Add_Lead_Tab { | |
| static $click_events; | |
| static $unsubscribe_events; | |
| /** | |
| * Initiate class | |
| */ | |
| function __construct() { | |
| self::load_hooks(); | |
| } | |
| /** | |
| * Loads hooks and filters | |
| */ | |
| private function load_hooks() { | |
| /* add nav tabs */ | |
| add_filter('wpl_lead_tabs', array( __CLASS__ , 'create_nav_tabs' ) , 10, 1); | |
| /* add inline css & js rules - maybe should consider enqueuing your css and js instead of printing inline */ | |
| add_action('wp_footer', array( __CLASS__ , 'add_js_css' ) , 10); | |
| /* add nav tab content */ | |
| add_action( 'wpl_print_lead_tab_sections' , array( __CLASS__ , 'add_content_container' ) ); | |
| } | |
| /** | |
| * Create New Nav Tabs in WordPress Leads - Lead UI | |
| */ | |
| public static function create_nav_tabs( $nav_items ) { | |
| global $post; | |
| /* Add attachments tab */ | |
| $nav_items[] = array( | |
| 'id'=> 'wpleads_lead_tab_attachments', | |
| 'label'=> __( 'Attachments' , 'inbound-pro' ) | |
| ); | |
| return $nav_items; | |
| } | |
| /** | |
| * Prints container content | |
| */ | |
| public static function add_content_container() { | |
| ?> | |
| <div class="lead-profile-section" id="wpleads_lead_tab_attachments" > | |
| test | |
| </div> | |
| <?php | |
| } | |
| /** | |
| * Prints inline css and js | |
| */ | |
| public static function add_js_css() { | |
| global $post; | |
| /* bail if not wp-lead screen */ | |
| if ( isset($post) && $post->post_type != 'wp-lead' ) { | |
| return; | |
| } | |
| /* add supporting js and css here */ | |
| } | |
| } | |
| /* Load Post Type Pre Init */ | |
| $GLOBALS['Extension_Practice_Add_Lead_Tab'] = new Extension_Practice_Add_Lead_Tab(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment