Check for valid post type/products when setting up data

This commit is contained in:
Mike Jolley 2013-11-27 16:03:54 +00:00
parent 2bd40b29b2
commit 417651d579
3 changed files with 5 additions and 2 deletions

View File

@ -491,6 +491,9 @@ class WC_Shortcodes {
$product = wc_setup_product_data( $product_data );
if ( ! $product )
return;
ob_start();
?>
<p class="product woocommerce" style="<?php echo $style; ?>">

View File

@ -464,7 +464,7 @@ class WC_Gateway_Paypal extends WC_Payment_Gateway {
' . implode( '', $paypal_args_array) . '
<!-- Button Fallback -->
<div class="payment_buttons">
<input type="submit" class="button alt" id="submit_paypal_payment_form" value="' . __( 'Pay via PayPal', 'woocommerce' ) . '" /> <a class="button cancel" href="'.esc_url( $order->get_cancel_order_url() ).'">'.__( 'Cancel order &amp; restore cart', 'woocommerce' ).'</a>
<input type="submit" class="button alt" id="submit_paypal_payment_form" value="' . __( 'Pay via PayPal', 'woocommerce' ) . '" /> <a class="button cancel" href="' . esc_url( $order->get_cancel_order_url() ) . '">'.__( 'Cancel order &amp; restore cart', 'woocommerce' ).'</a>
</div>
<script type="text/javascript">
jQuery(".payment_buttons").hide();

View File

@ -78,7 +78,7 @@ function wc_setup_product_data( $post ) {
if ( is_int( $post ) )
$post = get_post( $post );
if ( $post->post_type !== 'product' && $post->post_type !== 'product_variation' )
if ( empty( $post->post_type ) || ! in_array( $post->post_type, array( 'product', 'product_variation' ) ) )
return;
$GLOBALS['product'] = get_product( $post );