Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Custom Tabs for Downloads Display using Shortcode
- *
- * Outputs an extra tab to the default set of info tabs on the single product page.
- */
- function custom_tab_options_tab_down() {
- ?>
- <li class="custom_tab2"><a href="#custom_tab_data2"><?php _e('Custom Tab 2', 'woothemes'); ?></a></li>
- <?php
- }
- add_action('woocommerce_product_write_panel_tabs', 'custom_tab_options_tab_down');
- /**
- * Custom Tab Options
- *
- * Provides the input fields and add/remove buttons for custom tabs on the single product page.
- */
- function custom_tab_options_down() {
- global $post;
- $custom_tab_options_down = array(
- 'titleb' => get_post_meta($post->ID, 'custom_tab_title_down', true),
- 'contentb' => get_post_meta($post->ID, 'custom_tab_content_down', true),
- );
- ?>
- <div id="custom_tab_data2" class="panel woocommerce_options_panel">
- <div class="options_group">
- <p class="form-field">
- <?php woocommerce_wp_checkbox( array( 'id' => 'custom_tab_enabled_down', 'label' => __('Enable Custom Tab?', 'woothemes'), 'description' => __('Enable this option to enable the custom tab on the frontend.', 'woothemes') ) ); ?>
- </p>
- </div>
- <div class="options_group custom_tab_options">
- <p class="form-field">
- <label><?php _e('Custom Tab Title:', 'woothemes'); ?></label>
- <input type="text" size="5" name="custom_tab_title_down" value="<?php echo @$custom_tab_options_down['titleb']; ?>" placeholder="<?php _e('Enter your custom tab title', 'woothemes'); ?>" />
- </p>
- <p class="form-field">
- <?php _e('Custom Tab Content:', 'woothemes'); ?>
- </p>
- <table class="form-table">
- <tr>
- <td>
- <textarea class="theEditor" rows="10" cols="40" name="custom_tab_content_down" placeholder="<?php _e('Enter your custom tab content', 'woothemes'); ?>"><?php echo @$custom_tab_options_down['contentb']; ?></textarea>
- </td>
- </tr>
- </table>
- </div>
- </div>
- <?php
- }
- add_action('woocommerce_product_write_panels', 'custom_tab_options_down');
- /**
- * Process meta
- *
- * Processes the custom tab options when a post is saved
- */
- function process_product_meta_custom_tab_down( $post_id ) {
- update_post_meta( $post_id, 'custom_tab_enabled_down', ( isset($_POST['custom_tab_enabled_down']) && $_POST['custom_tab_enabled_down'] ) ? 'yes' : 'no' );
- update_post_meta( $post_id, 'custom_tab_title_down', $_POST['custom_tab_title_down']);
- update_post_meta( $post_id, 'custom_tab_content_down', $_POST['custom_tab_content_down']);
- }
- add_action('woocommerce_process_product_meta', 'process_product_meta_custom_tab_down');
- /** Add extra tabs to front end product page **/
- if (!function_exists('woocommerce_product_custom_tab_down')) {
- function woocommerce_product_custom_tab_down() {
- global $post;
- $custom_tab_options_down = array(
- 'enabled' => get_post_meta($post->ID, 'custom_tab_enabled_down', true),
- 'titleb' => get_post_meta($post->ID, 'custom_tab_title_down', true),
- );
- if ( $custom_tab_options_down['enabled'] != 'yes' )
- return false;
- ?>
- <li><a href="#tab-downloads"><?php echo $custom_tab_options_down['titleb']; ?></a></li>
- <?php
- }
- }
- add_action( 'woocommerce_product_tabs', 'woocommerce_product_custom_tab_down', 24 );
- if (!function_exists('woocommerce_product_custom_panel_down')) {
- function woocommerce_product_custom_panel_down() {
- global $post;
- $custom_tab_options_down = array(
- 'titleb' => get_post_meta($post->ID, 'custom_tab_title_down', true),
- );
- $downloads = get_post_meta($post->ID, 'custom_tab_content_down', true);
- $nsoutput = do_shortcode( $downloads ) ;
- ?>
- <div class="panel" id="tab-downloads">
- <?php print $nsoutput; ?>
- </div>
- <?php
- }
- }
- add_action( 'woocommerce_product_tab_panels', 'woocommerce_product_custom_panel_down', 24 );
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement