Created
September 24, 2024 07:45
-
-
Save AchalJ/ecf2069cd2f1790ba3bfc2cea955fda3 to your computer and use it in GitHub Desktop.
Add custom tabs to PowerPack Advanced Tabs module using PHP
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 // <-- ignore this. | |
| /** Copy the code below. */ | |
| add_filter('pp_tabs_items', 'custom_tab_items', 10, 2); | |
| function custom_tab_items( $items, $settings ) { | |
| // Add custom tabs. | |
| $new_items = array( | |
| array( | |
| 'label' => 'My custom tab 1', // Tab label (required) | |
| 'description' => '', // Tab description (optional) | |
| 'content_type' => 'content', // Tab content type (required) | |
| 'content' => 'My custom tab content 1' // Tab content (required) | |
| ), | |
| array( | |
| 'label' => 'My custom tab 2', | |
| 'description' => '', | |
| 'content_type' => 'content', | |
| 'content' => 'My custom tab content 2' | |
| ), | |
| ); | |
| $count_items = count( $items ); | |
| foreach ( $new_items as $item ) { | |
| $item['html_id'] = ( '' !== $settings->tab_id_prefix ) ? $settings->tab_id_prefix . '-' . ( $count_items + 1 ) : 'pp-tab-custom-' . ( $count_items + 1 ); | |
| $items[ $count_items + 1 ] = (object) $item; | |
| $count_items++; | |
| } | |
| return $items; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment