Skip to content

Commit

Permalink
Move post_type_icon into inc/term-icons.php
Browse files Browse the repository at this point in the history
  • Loading branch information
benlk committed Jul 8, 2016
1 parent a30deda commit 8400768
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 36 deletions.
36 changes: 0 additions & 36 deletions inc/post-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,39 +464,3 @@ function largo_comment( $comment, $args, $depth ) {
endswitch;
}
}


/**
* Post format icon
* @since 0.4
*/
if ( ! function_exists( 'post_type_icon' ) ) {
function post_type_icon( $options = array() ) {

if ( ! taxonomy_exists('post-type') ) return false;

$defaults = array(
'echo' => TRUE,
'id' => get_the_ID()
);
$args = wp_parse_args( $options, $defaults );
$terms = wp_get_post_terms( $args['id'], 'post-type' );
if ( ! count($terms) ) return false;
//try to get a child term if there is one
$the_term = 0;
foreach ( $terms as $term ) {
if ( $term->parent ) {
$the_term = $term;
break;
}
}
//just grab the first one otherwise
if ( ! $the_term ) $the_term = $terms[0];

//get the icon value
if ( ! $args['echo'] ) ob_start();
$icons = new Largo_Term_Icons();
$icons->the_icon( $the_term );
if ( ! $args['echo'] ) return ob_get_clean();
}
}
35 changes: 35 additions & 0 deletions inc/term-icons.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,38 @@ function the_icon( $taxonomy_or_term, $term_id='i', $tag='i' ) {
}

$largo['term-icons'] = new Largo_Term_Icons();

/**
* Post format icon
* @since 0.4
*/
if ( ! function_exists( 'post_type_icon' ) ) {
function post_type_icon( $options = array() ) {

if ( ! taxonomy_exists('post-type') ) return false;

$defaults = array(
'echo' => TRUE,
'id' => get_the_ID()
);
$args = wp_parse_args( $options, $defaults );
$terms = wp_get_post_terms( $args['id'], 'post-type' );
if ( ! count($terms) ) return false;
//try to get a child term if there is one
$the_term = 0;
foreach ( $terms as $term ) {
if ( $term->parent ) {
$the_term = $term;
break;
}
}
//just grab the first one otherwise
if ( ! $the_term ) $the_term = $terms[0];

//get the icon value
if ( ! $args['echo'] ) ob_start();
$icons = new Largo_Term_Icons();
$icons->the_icon( $the_term );
if ( ! $args['echo'] ) return ob_get_clean();
}
}

0 comments on commit 8400768

Please sign in to comment.