joomlaworks Tabs & Slides Mambots" for Mambo/Joomla. Tabs and Slides (in content items) Plugin gives you the ability to easily add content tabs and/or content slides. The tabs emulate a multi-page structure, while the slides emulate an accordion-like structure, inside a single page! Version: 2.0.1 Author: Abdul Ibad Author URI: http://dulabs.com This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ // Show tags html on title, // REPLACE = < will be replace with < // STRIP = Strip html tags // NOFILTER = Don't filter (Not Recommend) define('WP_TABS_SLIDES_VERSION','2.0.1'); define('SHOW_TITLE_HTML','REPLACE'); class tabs_slides{ function init(){ $frontdisable = self::getOption("frontdisable"); if(empty($frontdisable)){ self::activation(); } add_action('wp_print_scripts', array($this,"wp_head_scripts")); add_action('wp_print_styles', array($this,"wp_head_styles")); //add_action('wp_head', array($this,"custom_head")); add_action('admin_menu', array($this,"admin_menu")); /* Use the save_post action to do something with the data entered */ add_action('save_post', array($this,'savepost')); add_filter('the_content', array($this,"formatting")); add_filter('the_excerpt', array($this,"formatting")); add_filter('widget_text', array($this,"formatting")); } function activation(){ $options['sliderspeed'] = 600; $options['optimized'] = "on"; $options['frontdisable'] = "off"; $options['postdisable'] = "off"; $options['style'] = "default.css"; add_option("wp_tabs_slides",$options); } function filter_title( $text ){ switch(SHOW_TITLE_HTML){ case 'REPLACE': $text = str_replace('<','<',$text); break; case 'STRIP': $text = strip_tags($text); break; case 'NOFILTER': $text = $text; break; } return $text; } function strip_punctuation( $text ){ $text = strip_tags($text); $text = preg_replace('/[^a-zA-Z0-9-\s]/', '', $text); return preg_replace("/[^A-Za-z0-9\s\s+\.\:\-\/%+\(\)\*\&\$\#\!\@\"\';\n\t\r\~]/","",$text); } function getSetting( $name ){ switch( strtoupper( $name ) ){ case "PLUGIN_URL": $dir = self::getSetting("PLUGIN_PATH"); $home = get_option('siteurl'); $start = strpos($dir,'/wp-content/'); $end = strlen($dir); $plugin_url = $home.substr($dir,$start,$end); return $plugin_url; break; case "PLUGIN_PATH": $dir = str_replace('\\','/',dirname(__FILE__)); return $dir; break; } } function getOption( $name ){ $options = get_option('wp_tabs_slides'); return $options[ $name ]; } function getStyles(){ $dir = self::getSetting("PLUGIN_PATH")."/style"; $opendir = opendir($dir); $styles = array(); while($file = readdir($opendir)){ if($file != "." && $file != ".."){ $ext = end(explode(".",$file)); if(strtoupper($ext) == "CSS"){ $styles[] = $file; } } } closedir($opendir); return $styles; } function custom_box($post=""){ global $post; echo ''; $enabletabs = get_post_meta($post->ID,'enabletabs',true); if($enabletabs=="on"){ $checked = ' checked="checked" '; }else{ $checked = ''; } ?>

/> 

' . "\n"; echo '
' . "\n"; echo '

' . __( 'Enable Tabs & Slides' ) . "

"; echo '
'; // output editing form self::custom_box(); // end wrapper echo "
\n"; } function savepost($post_ID){ $post_id = $post_ID; // verify this came from the our screen and with proper authorization, // because save_post can be triggered at other times if ( !wp_verify_nonce( $_POST['enabletabs_noncename'], plugin_basename(__FILE__) )) { return $post_id; } // verify if this is an auto save routine. If it is our form has not been submitted, so we dont want // to do anything if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id; // Check permissions if ( 'page' == $_POST['post_type'] ) { if ( !current_user_can( 'edit_page', $post_id ) ) return $post_id; } else { if ( !current_user_can( 'edit_post', $post_id ) ) return $post_id; } // OK, we're authenticated: we need to find and save the data $data = ($_POST['enabletabs'] == "on") ? "on" : "off"; update_post_meta($post_id, 'enabletabs', $data); return $post_id; } function wp_head_styles(){ if($this->disableThisPost()){ return; } $plugin_url = self::getSetting("PLUGIN_URL"); $style = self::getOption("style"); $customstyle = trim(self::getOption('custom_style')); $style = $plugin_url."/style/".strtolower($style); if(!empty($customstyle)){ $style = $customstyle; } $hacks = $plugin_url.'/hacks.css'; wp_enqueue_style('tabs-slides',$style,array(),WP_TABS_SLIDES_VERSION); wp_enqueue_style('tabs-slides-hacks',$hacks,array(),WP_TABS_SLIDES_VERSION); } function wp_head_scripts(){ if($this->disableThisPost()){ return; } wp_enqueue_script('jquery'); $plugin_url = self::getSetting("PLUGIN_URL"); $optimized = self::getOption("optimized"); $tabs_slides = $plugin_url.'/ts/tabs_slides.js'; wp_enqueue_script('tabs-slides',$tabs_slides,array(),WP_TABS_SLIDES_VERSION); $use_optimized_loader = ($optimized=="on") ? true:false; if($use_optimized_loader) { $loader = $plugin_url.'/ts/tabs_slides_opt_loader.js'; } else { $loader = $plugin_url.'/ts/tabs_slides_def_loader.js'; } wp_enqueue_script('tabs-slides-loader',$loader,array(),WP_TABS_SLIDES_VERSION); } function disableThisPost(){ $plugin_url = self::getSetting("PLUGIN_URL"); global $post; $disableFront = (self::getOption("frontdisable") == "on") ? true : false; $disableThisPost = (self::getOption("postdisable") == "on") ? true : false; $postID = $post->ID; $enableThisPost = get_post_meta($postID,'enabletabs',true); $enableThisPost = ($enableThisPost=="on") ? true : false; /* End get options */ if((is_front_page() || is_home()) && ($disableFront)){ return true; } if((is_page() || is_single()) && ($enableThisPost)){ return false; } if((is_page() || is_single()) && ($disableThisPost)){ return true; } return false; } function formatting( $content ){ global $post; // if post empty (check from the title) then return false if(empty($post->post_title)){ return $content; } $sliderspeed = intval(self::getOption("sliderspeed")); // if slider speed <= 0 than change speed to normal if($sliderspeed <= 0){ $sliderspeed = '"normal"'; } $b=1; if (preg_match_all("/{tab=.+?}{tab=.+?}|{tab=.+?}|{\/tabs}/", $content, $matches, PREG_PATTERN_ORDER) > 0) { foreach ($matches[0] as $match) { if($b==1 && $match!="{/tabs}") { $tabs[] = 1; $b=2; } elseif($match=="{/tabs}"){ $tabs[]=3; $b=1; } elseif(preg_match("/{tab=.+?}{tab=.+?}/", $match)){ $tabs[]=2; $tabs[]=1; $b=2; } else { $tabs[]=2; } } } @reset($tabs); $tabscount = 0; if (preg_match_all("/{tab=.+?}|{\/tabs}/", $content, $matches, PREG_PATTERN_ORDER) > 0) { foreach ($matches[0] as $match) { if($tabs[$tabscount]==1) { $match = str_replace("{tab=", "", $match); $match = str_replace("}", "", $match); $content = str_replace( "{tab=".$match."}", "

".$match."

", $content ); $tabid++; } elseif($tabs[$tabscount]==2) { $match = str_replace("{tab=", "", $match); $match = str_replace("}", "", $match); $content = str_replace( "{tab=".$match."}", "
 

".$match."

", $content ); } elseif($tabs[$tabscount]==3) { $content = str_replace( "{/tabs}", "
 
 
", $content ); } $tabscount++; } } $uniqueSlideID = 0; $uniqueToggleID = 0; // Make toggle id more unique with post id $pid = "p".$post->ID; if (preg_match_all("/{slide=.+?}/", $content, $matches, PREG_PATTERN_ORDER) > 0) { foreach ($matches[0] as $match) { $match = str_replace("{slide=", "", $match); $match = str_replace("}", "", $match); $title = self::filter_title($match); $link = self::strip_punctuation(str_replace(" ","-",strtolower($match))); $content = str_replace( "{slide=".$match."}", "
".$title."
", $content ); $content = str_replace( "{/slide}", "
", $content ); $uniqueSlideID++; $uniqueToggleID++; } } if (preg_match_all("/{accordion=.+?}/", $content, $matches, PREG_PATTERN_ORDER) > 0) { foreach ($matches[0] as $match) { $match = str_replace("{accordion=", "", $match); $match = str_replace("}", "", $match); $title = self::filter_title($match); $link = self::strip_punctuation(str_replace(" ","-",strtolower($match))); $content = str_replace( "{accordion=".$match."}", "
". $title."
", $content ); $content = str_replace( "{/accordion}", "
", $content ); $uniqueSlideID++; $uniqueToggleID++; } } return $content; } function optionsAction(){ $options = $newoptions = get_option('wp_tabs_slides'); if(isset($_POST['submit'])){ $newoptions['sliderspeed'] = intval($_POST['speed']); $newoptions['optimized'] = (isset($_POST['optimized']))?$_POST['optimized']:'off'; $newoptions['frontdisable'] = (isset($_POST['frontdisable']))?$_POST['frontdisable']:'off'; $newoptions['postdisable'] = (isset($_POST['postdisable']))?$_POST['postdisable']:'off'; $newoptions['style'] = $_POST['style']; $newoptions['custom_style'] = (isset($_POST['custom_style'])) ? $_POST['custom_style'] : ""; if($options != $newoptions){ update_option('wp_tabs_slides',$newoptions); echo '

'.__("Options Saved").'

'; } } } function optionsView(){ self::optionsAction(); $sliderpeed = self::getOption("sliderspeed"); $optimized = (self::getOption("optimized") =="on") ? " checked=\"checked\" ":" "; $frontdisable = (self::getOption("frontdisable") =="on") ? " checked=\"checked\" ":" "; $postdisable = (self::getOption("postdisable") =="on") ? " checked=\"checked\" ":" "; $defaultstyle = self::getOption("style"); $customstyle = self::getOption("custom_style"); $styles = self::getStyles(); ?>

Wordpress Tabs Slides


/>
/>
/>

" />


 |   |   |