* @copyright Copyright (c) 2013, Nicolas GUILLAUME * @link http://themesandco.com/customizr * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html */ if ( ! class_exists( 'TC_post_metas' ) ) : class TC_post_metas { static $instance; function __construct () { self::$instance =& $this; add_action ( '__after_content_title' , array( $this , 'tc_post_metas' )); } /** * The template part for displaying entry metas * * @package Customizr * @since Customizr 1.0 */ function tc_post_metas() { global $post; //when do we display the metas ? //1) we don't show metas on home page, 404, search page by default //2) +filter conditions $post_metas_bool = ( tc__f('__is_home') || is_404() || 'page' == $post -> post_type ) ? false : true ; $post_metas_bool = apply_filters('tc_show_post_metas', $post_metas_bool ); if (!$post_metas_bool) return; ob_start(); ?>
_get_terms_of_tax_type( $hierarchical = true ) ); $html = false; if ( false != $post_terms) { foreach( $post_terms as $term_id => $term ) { $html .= sprintf(' %4$s ', apply_filters( 'tc_category_list_class', 'btn btn-mini' ), get_term_link( $term_id , $term -> taxonomy ), esc_attr( sprintf( __( "View all posts in %s", 'customizr' ), $term -> name ) ), $term -> name ); }//end foreach }//end if $postcats return apply_filters( 'tc_category_list', $html ); } /** * Displays all the non-hierarchical taxonomy terms (including the tag list for posts) * Handles tag like terms * Alternative * * @package Customizr * @since Customizr 3.0 * */ function tc_tag_list() { $post_terms = apply_filters( 'tc_tag_meta_list', $this -> _get_terms_of_tax_type( $hierarchical = false ) ); $html = false; if ( false != $post_terms) { foreach( $post_terms as $term_id => $term ) { $html .= sprintf(' %4$s ', apply_filters( 'tc_tag_list_class', 'btn btn-mini btn-tag' ), get_term_link( $term_id , $term -> taxonomy ), esc_attr( sprintf( __( "View all posts in %s", 'customizr' ), $term -> name ) ), $term -> name ); }//end foreach }//end if return apply_filters( 'tc_tag_list', $html ); } /** * Helper to return the current post terms of specified taxonomy type : hierarchical or not * * @return boolean (false) or array * @param boolean : hierarchical or not * @package Customizr * @since Customizr 3.1.20 * */ private function _get_terms_of_tax_type ( $hierarchical = true ) { //var declaration $post_type = get_post_type( tc__f('__ID') ); $tax_list = get_object_taxonomies( $post_type, 'object' ); $_tax_type_list = array(); $_tax_type_terms_list = array(); if ( empty($tax_list) ) return false; //filter the post taxonomies while ( $el = current($tax_list) ) { //skip the post format taxinomy if ( in_array( key($tax_list) , apply_filters( 'tc_exclude_taxonomies_from_metas' , array('post_format') , $post_type , tc__f('__ID') ) ) ) { next($tax_list); continue; } if ( (bool) $hierarchical === (bool) $el -> hierarchical ) $_tax_type_list[key($tax_list)] = $el; next($tax_list); } if ( empty($_tax_type_list) ) return false; //fill the post terms array foreach ($_tax_type_list as $tax_name => $data ) { $_current_tax_terms = get_the_terms( tc__f('__ID') , $tax_name ); //If current post support this tax but no terms has been assigned yet = continue if ( ! $_current_tax_terms ) continue; while( $term = current($_current_tax_terms) ) { $_tax_type_terms_list[$term -> term_id] = $term; next($_current_tax_terms); } } return empty($_tax_type_terms_list) ? false : $_tax_type_terms_list; } }//end of class endif; //this only purpose of this function is to use the_tags() wp function. function tc_get_the_tags() { return the_tags(); }