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"; } 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 = '