From 26f3d4e6a0de0bbc03a0920606a3a9f7e4ea4eae Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Thu, 28 Jul 2016 09:37:57 -0400 Subject: [PATCH] Update the shop page to properly use the prepare method. When using the prepare method you need to have %d or %s at least once in the sql part and give a paramater for that replacement part. --- style.css | 2 +- woocommerce.php | 45 +++++++++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/style.css b/style.css index 0572052..4a4c99b 100644 --- a/style.css +++ b/style.css @@ -3,5 +3,5 @@ Theme Name: FranceJourneys Author: Gaslight Media Author URI: http://www.gaslightmedia.com Description: A theme for FranceJourneys -Version: 1.0.4 +Version: 1.0.5 */ diff --git a/woocommerce.php b/woocommerce.php index eecb4c0..5d66d88 100644 --- a/woocommerce.php +++ b/woocommerce.php @@ -6,7 +6,7 @@
- +
@@ -16,7 +16,7 @@
- + name; ?> - - - + + @@ -81,28 +81,33 @@ if ( $product_cats && ! is_wp_error ( $product_cats ) ){ $single_cat = array_shift( $product_cats ); - + // Set name to the default first picked category (however WC decides that) $primaryCatName = $single_cat->name; - + // Try to get the Primary Category based on how Yoast SEO has set it in the postmeta table global $wpdb; $sqlGetPrimary = "SELECT meta_value FROM $wpdb->postmeta WHERE - (meta_key = '_yoast_wpseo_primary_product_cat' AND post_id = '". get_the_id() ."'); + (meta_key = '_yoast_wpseo_primary_product_cat' AND post_id = %d); "; - $primaryCatID = $wpdb->get_var($wpdb->prepare($sqlGetPrimary)); + $primaryCatID = $wpdb->get_var( + $wpdb->prepare( + $sqlGetPrimary, + get_the_id() + ) + ); $term = get_term_by( 'id', $primaryCatID, 'product_cat' ); - + // Use the primary category instead if it's valid if( $term->name ) { $primaryCatName = $term->name; } ?> - - - + + + @@ -174,8 +179,8 @@
- \ No newline at end of file + -- 2.17.1