Improve error handling in `get_categories()`.
When passed an invalid `'taxonomy'`, `get_terms()` will return a `WP_Error` object. This object should not be blindly cast to an array. Instead, an empty array should be returned, to indicate that no matching terms have been found. Props virgodesign, sebastian.pisula. Fixes #36227. Built from https://develop.svn.wordpress.org/trunk@36988 git-svn-id: http://core.svn.wordpress.org/trunk@36955 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
138b2abcf5
commit
cac6d65780
|
@ -51,10 +51,16 @@ function get_categories( $args = '' ) {
|
|||
$taxonomy = $args['taxonomy'] = 'link_category';
|
||||
}
|
||||
|
||||
$categories = (array) get_terms( $taxonomy, $args );
|
||||
$categories = get_terms( $taxonomy, $args );
|
||||
|
||||
foreach ( array_keys( $categories ) as $k )
|
||||
_make_cat_compat( $categories[$k] );
|
||||
if ( is_wp_error( $categories ) ) {
|
||||
$categories = array();
|
||||
} else {
|
||||
$categories = (array) $categories;
|
||||
foreach ( array_keys( $categories ) as $k ) {
|
||||
_make_cat_compat( $categories[ $k ] );
|
||||
}
|
||||
}
|
||||
|
||||
return $categories;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.5-beta3-36987';
|
||||
$wp_version = '4.5-beta3-36988';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue