Hey all,
I’m using Jquery UI tabs with the WordPress Post Tabs plugin and it works like a charm. However, I’d like to auto disable or hide tabs that do not have any data. I’ve worked with Jquery quite a bit but I’m lost in this mess. Any help would be appreciated. Thanks!
Jquery Tabs Information from the official site
Initialize a tabs with the disabled option specified.
$( ".selector" ).tabs({ disabled: true });
Get or set the disabled option, after init.
var disabled = $( ".selector" ).tabs( "option", "disabled" );
//setter
$( ".selector" ).tabs( "option", "disabled", true );
Found in wordpress-post-tabs.php line 105
<script type="text/javascript">
jQuery(function() {
<?php
if($wpts_count and $wpts_count!=0){
for($i=0;$i<$wpts_count;$i++) { ?>
jQuery("#tabs_<?php echo $i;?>").tabs({ cookie: { expires: 30 } });
//getter
var cookie = jQuery("#tabs_<?php echo $i;?>").tabs( "option", "cookie" );
//setter
jQuery("#tabs_<?php echo $i;?>").tabs( "option", "cookie", { expires: 30 } );
<?php if(isset($wpts['fade']) and $wpts['fade']=='1'){ ?>
//fx for animation
jQuery("#tabs_<?php echo $i;?>").tabs({ fx: { opacity: 'toggle' } });
//getter
var fx = jQuery("#tabs_<?php echo $i;?>").tabs( "option", "fx" );
//setter
jQuery("#tabs_<?php echo $i;?>").tabs( "option", "fx", { opacity: 'toggle' } );
<?php }}} ?>
});
<?php if($wpts['reload']=='1') { ?>
function wptReload(ar)
{
location.href=location.href.split(/?|#/)[0] + '#' + ar;
location.reload(true);
return false;
}
<?php } ?>
</script>
****See edit history for previous comments***
I decided i’m going to write a plugin to do this, the plugin discussed i’m sure was written with the best intentions, but the code in my personal opinion needs a total rewrite, which is essentially what i’ll be doing.
The aim will basically be to emulate the functionality of the WordPress Post Tabs plugin.
NOTE:
This plugin includes jQuery cookie, which is dual licensed under the MIT and GPL licenses, just a heads up for those of you that need to know such things.
Features
The plugin will feature the following.
Smart CSS and Script loading
– Only loads CSS and JS when there’s a post in the loop with the shortcode
Skin selection
– Choose from a list of jQuery UI styles
Disable skin loading
– Optionally turn off stylesheet loading, and just define your own
Disabled tabs
– Disable clicking on tabs that do not have any content yet
jQuery cookie
– Enable the jQuery cookie script to track selected tabs
Tab navigation
– Display clickable links to navigate between tabs
Loading on archive pages
– Choose whether to display the tabs on archive pages
Translation ready
– Supports other languages
Live style preview
– See a live preview of tab styles in the plugin settings page
Filter hooks for navigation links
– So you can change the navigation icons
Utilises the settings API
Screenshots
Front side
Admin side
Have a few more bits to test, but it’s almost ready, watch this space!.. 🙂
Update:
Just need to get some things worked out regarding using the plugin repository first, then we should be good to go..Post UI Tabs (or PUT for short)
http://wordpress.org/extend/plugins/put/