~canonical-sysadmins/wordpress/4.5.2

« back to all changes in this revision

Viewing changes to wp-includes/category.php

  • Committer: Nick Moffitt
  • Date: 2016-04-14 10:44:19 UTC
  • mfrom: (1.1.14 upstream)
  • Revision ID: nick.moffitt@canonical.com-20160414104419-w6lxcr3ru4enc2w5
Merge WP4.5 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 *
16
16
 * @since 2.1.0
17
17
 * @see get_terms() Type of arguments that can be changed.
18
 
 * @link https://codex.wordpress.org/Function_Reference/get_categories
19
 
 *
20
 
 * @param string|array $args Optional. Change the defaults retrieving categories.
 
18
 *
 
19
 * @param string|array $args {
 
20
 *     Optional. Arguments to retrieve categories. See {@see get_terms()} for additional options.
 
21
 *
 
22
 *     @type string $taxonomy Taxonomy to retrieve terms for. In this case, default 'category'.
 
23
 * }
21
24
 * @return array List of categories.
22
25
 */
23
26
function get_categories( $args = '' ) {
48
51
                $taxonomy = $args['taxonomy'] = 'link_category';
49
52
        }
50
53
 
51
 
        $categories = (array) get_terms( $taxonomy, $args );
 
54
        $categories = get_terms( $taxonomy, $args );
52
55
 
53
 
        foreach ( array_keys( $categories ) as $k )
54
 
                _make_cat_compat( $categories[$k] );
 
56
        if ( is_wp_error( $categories ) ) {
 
57
                $categories = array();
 
58
        } else {
 
59
                $categories = (array) $categories;
 
60
                foreach ( array_keys( $categories ) as $k ) {
 
61
                        _make_cat_compat( $categories[ $k ] );
 
62
                }
 
63
        }
55
64
 
56
65
        return $categories;
57
66
}