
WordPress Bootstrap Tab code revise
4599
$25
- Posted:
- Proposals: 1
- Remote
- #359909
- Archived
Description
Experience Level: Entry
Estimated project duration: 1 day or less
I'm using Bootstraps Tabs in a WordPress theme. When using multiple instances of the short-code within the WordPress post the tabs will duplicate after the [end_bootstrap_tab] short-code. I think I need to add a new global to the code to keep track of the tabs counter that I tried to code in. I'm stuck. Should be relatively simple and very short project.
You can view the page at: http://andrewjrobertson.com/tecusa/variety-entertainment/
Heres the PHP end of the code(original without $tabs_counter):
// Add Tabs functionality for bootstrap
function bootstraptabs_wp_init() {
global $bootstraptabs_count,$bootstraptabs_tab_count,$bootstraptabs_content;
$bootstraptabs_count=0;
$bootstraptabs_tab_count=0;
$bootstraptabs_content=array();
}
add_action( 'wp', 'bootstraptabs_wp_init' );
function bootstraptabs_tab_shortcode($atts,$content) {
extract(shortcode_atts(array(
'name' => 'Tab Name',
'link' => '',
'active' => '',
), $atts));
global $bootstraptabs_content,$bootstraptabs_tab_count,$bootstraptabs_count;
$bootstraptabs_content[$bootstraptabs_tab_count]['name'] = $name;
$bootstraptabs_content[$bootstraptabs_tab_count]['link'] = $link;
$bootstraptabs_content[$bootstraptabs_tab_count]['active'] = $active;
$bootstraptabs_content[$bootstraptabs_tab_count]['content'] = do_shortcode($content);
$bootstraptabs_tab_count = $bootstraptabs_tab_count+1;
}
add_shortcode('bootstrap_tab', 'bootstraptabs_tab_shortcode');
function bootstraptabs_end_shortcode($atts) {
global $bootstraptabs_content,$bootstraptabs_tab_count,$bootstraptabs_count;
if($bootstraptabs_tab_count!=0 and isset($bootstraptabs_tab_count)) {
$tab_content = '';
for($i=0;$i<$bootstraptabs_tab_count;$i++) {
$tab_content = $tab_content.''.$bootstraptabs_content[$i]['name'].'';
}
$tab_content = $tab_content.'';
$tab_html='';
for($i=0;$i<$bootstraptabs_tab_count;$i++) {
$link_html = $bootstraptabs_content[$i]['link'];
$tab_html.=''.$bootstraptabs_content[$i]['content'].'';
}
$tab_content = $tab_content.$tab_html;
}
$tab_content = $tab_content;
return $tab_content;
}
add_shortcode('end_bootstrap_tab', 'bootstraptabs_end_shortcode');
You can view the page at: http://andrewjrobertson.com/tecusa/variety-entertainment/
Heres the PHP end of the code(original without $tabs_counter):
// Add Tabs functionality for bootstrap
function bootstraptabs_wp_init() {
global $bootstraptabs_count,$bootstraptabs_tab_count,$bootstraptabs_content;
$bootstraptabs_count=0;
$bootstraptabs_tab_count=0;
$bootstraptabs_content=array();
}
add_action( 'wp', 'bootstraptabs_wp_init' );
function bootstraptabs_tab_shortcode($atts,$content) {
extract(shortcode_atts(array(
'name' => 'Tab Name',
'link' => '',
'active' => '',
), $atts));
global $bootstraptabs_content,$bootstraptabs_tab_count,$bootstraptabs_count;
$bootstraptabs_content[$bootstraptabs_tab_count]['name'] = $name;
$bootstraptabs_content[$bootstraptabs_tab_count]['link'] = $link;
$bootstraptabs_content[$bootstraptabs_tab_count]['active'] = $active;
$bootstraptabs_content[$bootstraptabs_tab_count]['content'] = do_shortcode($content);
$bootstraptabs_tab_count = $bootstraptabs_tab_count+1;
}
add_shortcode('bootstrap_tab', 'bootstraptabs_tab_shortcode');
function bootstraptabs_end_shortcode($atts) {
global $bootstraptabs_content,$bootstraptabs_tab_count,$bootstraptabs_count;
if($bootstraptabs_tab_count!=0 and isset($bootstraptabs_tab_count)) {
$tab_content = '';
for($i=0;$i<$bootstraptabs_tab_count;$i++) {
$tab_content = $tab_content.''.$bootstraptabs_content[$i]['name'].'';
}
$tab_content = $tab_content.'';
$tab_html='';
for($i=0;$i<$bootstraptabs_tab_count;$i++) {
$link_html = $bootstraptabs_content[$i]['link'];
$tab_html.=''.$bootstraptabs_content[$i]['content'].'';
}
$tab_content = $tab_content.$tab_html;
}
$tab_content = $tab_content;
return $tab_content;
}
add_shortcode('end_bootstrap_tab', 'bootstraptabs_end_shortcode');
Andrew R.
100% (15)Projects Completed
10
Freelancers worked with
11
Projects awarded
65%
Last project
24 Oct 2017
United States
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies