]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/category.php
WordPress 4.5
[autoinstalls/wordpress.git] / wp-includes / category.php
index 9f1064e282a125e6d1cd0a5ef0085dc4f594a12b..a89b41065f6c4ab64606dcb8af5a9bfadede6dd1 100644 (file)
  *
  * @since 2.1.0
  * @see get_terms() Type of arguments that can be changed.
  *
  * @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 = '' ) {
  * @return array List of categories.
  */
 function get_categories( $args = '' ) {
@@ -48,10 +51,16 @@ function get_categories( $args = '' ) {
                $taxonomy = $args['taxonomy'] = 'link_category';
        }
 
                $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;
 }
 
        return $categories;
 }