Plugin Page. Version: 1.2 Author: Internet Techies Author URI: http://www.clickonf5.org/about/tejaswini WordPress version supported: 2.8 and above */ /* Copyright 2010 Internet Techies (email : tedeshpa@gmail.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 St, Fifth Floor, Boston, MA 02110-1301 USA */ if ( ! defined( 'WPTS_PLUGIN_BASENAME' ) ) define( 'WPTS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); function wpts_url( $path = '' ) { global $wp_version; if ( version_compare( $wp_version, '2.8', '<' ) ) { // Using WordPress 2.7 $folder = dirname( plugin_basename( __FILE__ ) ); if ( '.' != $folder ) $path = path_join( ltrim( $folder, '/' ), $path ); return plugins_url( $path ); } return plugins_url( $path, __FILE__ ); } //on activation, your WordPress Post Tabs options will be populated. Here a single option is used which is actually an array of multiple options function activate_wpts() { $wpts_opts1 = get_option('wpts_options'); $wpts_opts2 =array('speed' => '1', 'transition' => '', 'pages' => '1', 'posts' => '1', 'stylesheet' => 'default', 'reload' => '0', 'tab_code' => 'tab', 'tab_end_code' => 'end_tabset', 'support' => '1', 'fade' => '0', 'jquerynoload' => '0'); if ($wpts_opts1) { $wpts = $wpts_opts1 + $wpts_opts2; update_option('wpts_options',$wpts); } else { $wpts_opts1 = array(); $wpts = $wpts_opts1 + $wpts_opts2; add_option('wpts_options',$wpts); } } register_activation_hook( __FILE__, 'activate_wpts' ); global $wpts; $wpts = get_option('wpts_options'); define("WPTS_VER","1.2",false); define('WPTS_URLPATH', trailingslashit( WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) ) ); function wpts_wp_init() { if(is_singular()) { global $post,$wpts; $enablewpts = get_post_meta($post->ID, 'enablewpts', true); if( (is_page() and ((!empty($enablewpts) and $enablewpts=='1') or $wpts['pages'] != '0' ) ) or (is_single() and ((!empty($enablewpts) and $enablewpts=='1') or $wpts['posts'] != '0' ) ) ) { $css="css/styles/".$wpts['stylesheet'].'/style.css'; wp_enqueue_style( 'wpts_ui_css', wpts_url( $css ),false, WPTS_VER, 'all'); if(isset($wpts['jquerynoload']) and $wpts['jquerynoload']=='1') { wp_deregister_script( 'jquery' ); wp_enqueue_script('wpts_ui_cookie', wpts_url( 'js/jquery.cookie.js'), array('jquery-ui-core','jquery-ui-tabs'), WPTS_VER, true ); } else{ wp_enqueue_script('wpts_ui_cookie', wpts_url( 'js/jquery.cookie.js'), array('jquery','jquery-ui-core','jquery-ui-tabs'), WPTS_VER, true ); } global $wpts_count,$wpts_tab_count,$wpts_content; $wpts_count=0; $wpts_tab_count=0; $wpts_content=array(); } } } add_action( 'wp', 'wpts_wp_init' ); function wpts_wp_footer_js(){ global $wpts,$wpts_count,$wpts_tab_count,$wpts_content; if(is_singular()) { global $post,$wpts; $enablewpts = get_post_meta($post->ID, 'enablewpts', true); if( (is_page() and ((!empty($enablewpts) and $enablewpts=='1') or $wpts['pages'] != '0' ) ) or (is_single() and ((!empty($enablewpts) and $enablewpts=='1') or $wpts['posts'] != '0' ) ) ) { ?> '; ?> ID,'enablewpts',true); if($enablewpts=="1"){ $checked = ' checked="checked" '; }else{ $checked = ''; } ?>

/> 

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

' . __( 'Post/Page Tabs', 'wordpress-post-tabs' ) . "

"; echo '
'; // output editing form wpts_edit_custom_box(); // end wrapper echo "
\n"; } function wpts_add_custom_box() { if( function_exists( 'add_meta_box' ) ) { add_meta_box( 'wpts_box1', __( 'Post Tabs' ), 'wpts_edit_custom_box', 'post', 'side','high' ); //add_meta_box( $id, $title, $callback, $page, $context, $priority ); add_meta_box( 'wpts_box2', __( 'Page Tabs' ), 'wpts_edit_custom_box', 'page', 'advanced' ); } else { add_action('dbx_post_advanced', 'myplugin_old_custom_box' ); add_action('dbx_page_advanced', 'myplugin_old_custom_box' ); } } /* Use the admin_menu action to define the custom boxes */ add_action('admin_menu', 'wpts_add_custom_box'); function wpts_savepost(){ global $post; $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['enablewpts_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['enablewpts'] == "1") ? "1" : "0"; update_post_meta($post_id, 'enablewpts', $data); return $data; } add_action('save_post', 'wpts_savepost'); function wpts_tab_shortcode($atts,$content) { extract(shortcode_atts(array( 'name' => 'Tab Name', ), $atts)); global $wpts; global $wpts_content,$wpts_tab_count,$wpts_count; $wpts_content[$wpts_tab_count]['name'] = $name; $wpts_content[$wpts_tab_count]['content'] = do_shortcode($content); $wpts_tab_count = $wpts_tab_count+1; return null; } add_shortcode($wpts['tab_code'], 'wpts_tab_shortcode'); function wpts_end_shortcode($atts) { if(is_singular()) { global $wpts; global $wpts_content,$wpts_tab_count,$wpts_count,$post; if($wpts_tab_count!=0 and isset($wpts_tab_count)) { $tab_content = ''; for($i=0;$i<$wpts_tab_count;$i++) { $tab_content = $tab_content.'
'.$wpts_content[$i]['content'].'
'; } } $tab_content = '
'.$tab_content.'
'; $wpts_count = $wpts_count+1; $wpts_tab_count = 0; $support_link='
WP Post Tabs
'; if($wpts['support']=='1'){ return $tab_content.$support_link; } else { return $tab_content; } } else { return null; } } add_shortcode($wpts['tab_end_code'], 'wpts_end_shortcode'); //Code to add settings page link to the main plugins page on admin function wpts_admin_url( $query = array() ) { global $plugin_page; if ( ! isset( $query['page'] ) ) $query['page'] = $plugin_page; $path = 'admin.php'; if ( $query = build_query( $query ) ) $path .= '?' . $query; $url = admin_url( $path ); return esc_url_raw( $url ); } add_filter( 'plugin_action_links', 'wpts_plugin_action_links', 10, 2 ); function wpts_plugin_action_links( $links, $file ) { if ( $file != WPTS_PLUGIN_BASENAME ) return $links; $url = wpts_admin_url( array( 'page' => 'wpts_settings_page' ) ); $settings_link = '' . esc_html( __( 'Settings') ) . ''; array_unshift( $links, $settings_link ); return $links; } // function for adding settings page to wp-admin function wpts_settings() { // Add a new submenu under Options: add_options_page('Post/Page Tabs', 'Post/Page Tabs', 9, basename(__FILE__), 'wpts_settings_page'); } function wpts_admin_head() {?>

WordPress Post Tabs

Tabs Style

/> This may increase your pageviews.
/>
/> (In case jQuery.js is added by hardcoding in active theme or plugin. This will avoid js conflict)

Disable Plugin Resources

This will help you avoid the loading of the plugin files (js,css) on all pages. You would get an option (custom checkbox) on edit post/page panel if disable the below options. If the below checkboxes are not ticked, then the plugin files will load on every page/post of your wordpress site.
/> You would get a custom box on your edit post panel to enable tabs on that particular post.
/> You would get a custom box on your edit page panel to enable tabs on that particular page.

Custom Shortcodes

The default shortcodes are [tab] for adding a tab and [end_tabset] to end particular set/group of tabs. Please do not use spaces in the custom shortcodes. To check how to insert the tabs in your post/page, please refer the plugin help page.

IMPORTANT: While changing these values to new values, you would need to check if you have used old shortcode values in any of the posts.

[]     (For example, you can enter: mytabs)
[]     (For example, you can enter: end_mytabs)
/>

Our Facebook Fan Page

Support & Donations