From b5bc8e336e107a9a49df45f5cb511e489a1de287 Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Fri, 12 Feb 2016 14:25:05 +0000 Subject: [PATCH] Bail from `get_term()` if a filter returns an object that is not a `WP_Term`. This prevents fatal errors in certain cases. Props tmuikku. Fixes #35808. git-svn-id: https://develop.svn.wordpress.org/trunk@36516 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/taxonomy.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php index ce01f1771a..4d672564ef 100644 --- a/src/wp-includes/taxonomy.php +++ b/src/wp-includes/taxonomy.php @@ -857,6 +857,11 @@ function get_term( $term, $taxonomy = '', $output = OBJECT, $filter = 'raw' ) { */ $_term = apply_filters( "get_$taxonomy", $_term, $taxonomy ); + // Bail if a filter callback has changed the type of the `$_term` object. + if ( ! ( $_term instanceof WP_Term ) ) { + return $_term; + } + // Sanitize term, according to the specified filter. $_term->filter( $filter );