Hide tabs if we have none

This commit is contained in:
Mike Jolley 2012-04-03 10:34:02 +01:00
parent c21b70e483
commit 4182a35ed5
8 changed files with 79 additions and 30 deletions

View File

@ -23,6 +23,7 @@ include_once('writepanel-order_downloads.php');
add_action( 'add_meta_boxes', 'woocommerce_meta_boxes' );
function woocommerce_meta_boxes() {
global $post;
// Products
add_meta_box( 'woocommerce-product-type', __('Product Type', 'woocommerce'), 'woocommerce_product_type_box', 'product', 'normal', 'high' );
@ -31,7 +32,16 @@ function woocommerce_meta_boxes() {
// Excerpt
if ( function_exists('wp_editor') ) {
remove_meta_box( 'postexcerpt', 'product', 'normal' );
add_meta_box( 'postexcerpt', __('Short Description', 'woocommerce'), 'woocommerce_product_short_description_meta_box', 'product', 'normal' );
add_meta_box( 'postexcerpt', __('Product Short Description', 'woocommerce'), 'woocommerce_product_short_description_meta_box', 'product', 'normal' );
}
// Comments/Reviews
remove_meta_box( 'commentstatusdiv', 'product', 'normal' );
add_meta_box( 'commentstatusdiv', __('Product Reviews', 'woocommerce'), 'woocommerce_product_review_status_meta_box', 'product', 'normal' );
if ( ('publish' == $post->post_status || 'private' == $post->post_status) ) {
remove_meta_box( 'commentsdiv', 'product', 'normal' );
add_meta_box( 'commentsdiv', __('Reviews', 'woocommerce'), 'post_comment_meta_box', 'product', 'normal' );
}
// Orders
@ -103,6 +113,23 @@ function woocommerce_product_short_description_meta_box( $post ) {
wp_editor( htmlspecialchars_decode( $post->post_excerpt ), 'excerpt', $settings );
}
/**
* Display comments status form fields.
*
* @param object $post
*/
function woocommerce_product_review_status_meta_box( $post ) {
?>
<input name="advanced_view" type="hidden" value="1" />
<p class="meta-options">
<label for="comment_status" class="selectit"><input name="comment_status" type="checkbox" id="comment_status" value="open" <?php checked($post->comment_status, 'open'); ?> /> <?php _e( 'Allow reviews.', 'woocommerce' ) ?></label><br />
<label for="ping_status" class="selectit"><input name="ping_status" type="checkbox" id="ping_status" value="open" <?php checked($post->ping_status, 'open'); ?> /> <?php printf( __( 'Allow <a href="%s" target="_blank">trackbacks and pingbacks</a> on this page.' ), __( 'http://codex.wordpress.org/Introduction_to_Blogging#Managing_Comments' ) ); ?></label>
<?php do_action('post_comment_status_meta_box-options', $post); ?>
</p>
<?php
}
/**
* Product data
*

View File

@ -145,7 +145,10 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
= 1.5.4 =
* Feature - Allow external products to be a part of a grouped product. Button titles will be respected when displayed.
* Tweaked - For the short description, removed the_content filter and used woocommerce_short_description
* Tweak - Don't send password in new account email (some customers complained/privacy concerns)
* Tweak - Don't show unused tabs on the frontend (description and reviews)
* Tweak - Rename comments meta box to reviews
* Localization - Canada post code locale
* Localization - RMB paypal
* Localization - Bundled translation updates

View File

@ -2,10 +2,19 @@
/**
* Single Product Tabs
*/
?>
<div class="woocommerce_tabs">
// Get tabs
ob_start();
do_action('woocommerce_product_tabs');
$tabs = trim( ob_get_clean() );
if ( ! empty( $tabs ) ) : ?>
<div class="woocommerce_tabs">
<ul class="tabs">
<?php do_action('woocommerce_product_tabs'); ?>
<?php echo $tabs; ?>
</ul>
<?php do_action('woocommerce_product_tab_panels'); ?>
</div>
</div>
<?php endif; ?>

View File

@ -4,8 +4,9 @@
*/
global $woocommerce, $post, $product;
?>
<div class="panel" id="tab-attributes">
if ($product->has_attributes() || $product->has_dimensions() || $product->has_weight()) : ?>
<div class="panel" id="tab-attributes">
<?php $heading = apply_filters('woocommerce_product_additional_information_heading', __('Additional Information', 'woocommerce')); ?>
@ -13,4 +14,5 @@ global $woocommerce, $post, $product;
<?php $product->list_attributes(); ?>
</div>
</div>
<?php endif; ?>

View File

@ -4,8 +4,9 @@
*/
global $woocommerce, $post;
?>
<div class="panel" id="tab-description">
if ( $post->post_content ) : ?>
<div class="panel" id="tab-description">
<?php $heading = apply_filters('woocommerce_product_description_heading', __('Product Description', 'woocommerce')); ?>
@ -13,4 +14,5 @@ global $woocommerce, $post;
<?php the_content(); ?>
</div>
</div>
<?php endif; ?>

View File

@ -4,9 +4,11 @@
*/
global $woocommerce, $post;
?>
<div class="panel" id="tab-reviews">
if ( comments_open() ) : ?>
<div class="panel" id="tab-reviews">
<?php comments_template(); ?>
</div>
</div>
<?php endif; ?>

View File

@ -1,5 +1,5 @@
<?php global $product; ?>
<?php global $product;
<?php if ($product->has_attributes() || $product->has_dimensions() || $product->has_weight()) : ?>
if ($product->has_attributes() || $product->has_dimensions() || $product->has_weight()) : ?>
<li><a href="#tab-attributes"><?php _e('Additional Information', 'woocommerce'); ?></a></li>
<?php endif; ?>

View File

@ -1 +1,5 @@
<li><a href="#tab-description"><?php _e('Description', 'woocommerce'); ?></a></li>
<?php global $post;
if ( $post->post_content ) : ?>
<li><a href="#tab-description"><?php _e('Description', 'woocommerce'); ?></a></li>
<?php endif; ?>