From 415f1b2a62bd896b48cd351511e4fd47622074e4 Mon Sep 17 00:00:00 2001 From: Travis Smith Date: Tue, 20 Feb 2018 18:03:50 -0500 Subject: [PATCH] Fix ->prepare & implode --- cpt-onomy.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpt-onomy.php b/cpt-onomy.php index dee6ad2..083bf17 100644 --- a/cpt-onomy.php +++ b/cpt-onomy.php @@ -270,7 +270,7 @@ public function get_term_by( $field, $value, $taxonomy, $output = OBJECT, $filte $eligible_post_types = ( $tax = get_taxonomy( $taxonomy ) ) && isset( $tax->object_type ) ? $tax->object_type : array(); // Find term and term count. - $query = $wpdb->prepare( "SELECT (SELECT COUNT(*) FROM {$wpdb->postmeta} wpcountmeta INNER JOIN {$wpdb->posts} wpcountposts ON wpcountposts.ID = wpcountmeta.post_id AND wpcountposts.post_status = 'publish' AND wpcountposts.post_type IN (%s) WHERE wpcountmeta.meta_key = %s AND wpcountmeta.meta_value = wpposts.ID) AS count, wpposts.* FROM {$wpdb->posts} wpposts WHERE wpposts.post_type = %s AND wpposts.post_name = %s and wpposts.post_status = 'publish'", implode( "','", $eligible_post_types, CPT_ONOMIES_POSTMETA_KEY, $taxonomy, $value ) ); + $query = $wpdb->prepare( "SELECT (SELECT COUNT(*) FROM {$wpdb->postmeta} wpcountmeta INNER JOIN {$wpdb->posts} wpcountposts ON wpcountposts.ID = wpcountmeta.post_id AND wpcountposts.post_status = 'publish' AND wpcountposts.post_type IN (%s) WHERE wpcountmeta.meta_key = %s AND wpcountmeta.meta_value = wpposts.ID) AS count, wpposts.* FROM {$wpdb->posts} wpposts WHERE wpposts.post_type = %s AND wpposts.post_name = %s and wpposts.post_status = 'publish'", implode( "','", $eligible_post_types ), CPT_ONOMIES_POSTMETA_KEY, $taxonomy, $value ); } elseif ( 'name' == $field ) { @@ -281,7 +281,7 @@ public function get_term_by( $field, $value, $taxonomy, $output = OBJECT, $filte $eligible_post_types = ( $tax = get_taxonomy( $taxonomy ) ) && isset( $tax->object_type ) ? $tax->object_type : array(); // Find term and term count. - $query = $wpdb->prepare( "SELECT (SELECT COUNT(*) FROM {$wpdb->postmeta} wpcountmeta INNER JOIN {$wpdb->posts} wpcountposts ON wpcountposts.ID = wpcountmeta.post_id AND wpcountposts.post_status = 'publish' AND wpcountposts.post_type IN (%s) WHERE wpcountmeta.meta_key = %s AND wpcountmeta.meta_value = wpposts.ID) AS count, wpposts.* FROM {$wpdb->posts} wpposts WHERE wpposts.post_type = %s AND wpposts.post_title = %s and wpposts.post_status = 'publish'", implode( "','", $eligible_post_types, CPT_ONOMIES_POSTMETA_KEY, $taxonomy, $value ) ); + $query = $wpdb->prepare( "SELECT (SELECT COUNT(*) FROM {$wpdb->postmeta} wpcountmeta INNER JOIN {$wpdb->posts} wpcountposts ON wpcountposts.ID = wpcountmeta.post_id AND wpcountposts.post_status = 'publish' AND wpcountposts.post_type IN (%s) WHERE wpcountmeta.meta_key = %s AND wpcountmeta.meta_value = wpposts.ID) AS count, wpposts.* FROM {$wpdb->posts} wpposts WHERE wpposts.post_type = %s AND wpposts.post_title = %s and wpposts.post_status = 'publish'", implode( "','", $eligible_post_types ), CPT_ONOMIES_POSTMETA_KEY, $taxonomy, $value ); } else {