X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/03f2fa83c13c1b532284205fa7efcab9b8b2c41f..784f914b1e4b1c62d6657e86397c2e83bcee4295:/wp-includes/category.php diff --git a/wp-includes/category.php b/wp-includes/category.php index 9f1064e2..a89b4106 100644 --- a/wp-includes/category.php +++ b/wp-includes/category.php @@ -15,9 +15,12 @@ * * @since 2.1.0 * @see get_terms() Type of arguments that can be changed. - * @link https://codex.wordpress.org/Function_Reference/get_categories * - * @param string|array $args Optional. Change the defaults retrieving categories. + * @param string|array $args { + * Optional. Arguments to retrieve categories. See {@see get_terms()} for additional options. + * + * @type string $taxonomy Taxonomy to retrieve terms for. In this case, default 'category'. + * } * @return array List of categories. */ function get_categories( $args = '' ) { @@ -48,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; }