mirror of
git://develop.git.wordpress.org/
synced 2025-02-28 02:22:25 +01:00
Return null if no term queried. fixes #11112
git-svn-id: https://develop.svn.wordpress.org/trunk@12200 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
56989f4f5c
commit
761aac294c
@ -301,6 +301,7 @@ function get_objects_in_term( $terms, $taxonomies, $args = array() ) {
|
|||||||
*/
|
*/
|
||||||
function &get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') {
|
function &get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
$null = null;
|
||||||
|
|
||||||
if ( empty($term) ) {
|
if ( empty($term) ) {
|
||||||
$error = new WP_Error('invalid_term', __('Empty Term'));
|
$error = new WP_Error('invalid_term', __('Empty Term'));
|
||||||
@ -321,6 +322,8 @@ function &get_term($term, $taxonomy, $output = OBJECT, $filter = 'raw') {
|
|||||||
$term = (int) $term;
|
$term = (int) $term;
|
||||||
if ( ! $_term = wp_cache_get($term, $taxonomy) ) {
|
if ( ! $_term = wp_cache_get($term, $taxonomy) ) {
|
||||||
$_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND t.term_id = %s LIMIT 1", $taxonomy, $term) );
|
$_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = %s AND t.term_id = %s LIMIT 1", $taxonomy, $term) );
|
||||||
|
if ( ! $_term )
|
||||||
|
return $null;
|
||||||
wp_cache_add($term, $_term, $taxonomy);
|
wp_cache_add($term, $_term, $taxonomy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user