8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC', 'exclude' => '', 'include' => '', 'link' => 'view', 'taxonomy' => OCI_DEFAULT_TAG_TAXONOMY, 'url' => OCI_DEFAULT_URL, 'hide_empty' => false ); $args = wp_parse_args( $args, $defaults ); // woah. $args['taxonomy'] can be an array of tax's. hmmm $tags = get_terms( $args['taxonomy'], array_merge( $args, array( 'orderby' => 'count', 'order' => 'DESC' ) ) ); // Always query top tags if ( empty( $tags ) ) return; foreach ( $tags as $key => $tag ) { if ( 'edit' == $args['link'] ) $link = oci_get_edit_tag_link( $tag->term_id, $args['taxonomy'] ); else $link = oci_get_term_link( intval($tag->term_id), $args['taxonomy'], $args['url'] ); if ( is_wp_error( $link ) ) return false; $tags[ $key ]->link = $link; $tags[ $key ]->id = $tag->term_id; } $return = wp_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args $return = apply_filters( 'oci_tag_cloud', $return, $args ); return $return; } /** * Retrieve edit tag link. * * @since 2.7.0 * * @param int $tag_id Tag ID * @return string */ function oci_get_edit_tag_link( $tag_id, $taxonomy ) { $tag = get_term($tag_id, $taxonomy); if ( !current_user_can('manage_categories') ) return; $location = admin_url('edit-tags.php?action=edit&tag_ID=') . $tag->term_id; return apply_filters( 'get_edit_tag_link', $location ); } ?>