Skip to content
This repository has been archived by the owner on Dec 27, 2018. It is now read-only.

Fix ->prepare & implode #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cpt-onomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {

Expand All @@ -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 {

Expand Down