* @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(); ?>
post_type ) { $metadata = wp_get_attachment_metadata(); printf( '%1$s %4$s %5$s', ''.__('Published' , 'customizr').'', esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ), ( isset($metadata['width']) && isset($metadata['height']) ) ? __('at dimensions' , 'customizr').' '.$metadata['width'].' × '.$metadata['height'].'' : '', __('in' , 'customizr').' '.get_the_title( $post->post_parent ).'.' ); } else { $categories_list = $this -> tc_category_list(); $tag_list = $this -> tc_tag_list(); $date = apply_filters( 'tc_date_meta', sprintf( '' , esc_url( get_day_link( get_the_time( 'Y' ), get_the_time( 'm' ), get_the_time( 'd' ) ) ), esc_attr( get_the_time() ), esc_attr( get_the_date( 'c' ) ), esc_html( get_the_date() ) ) );//end filter $author = apply_filters( 'tc_author_meta', sprintf( '' , esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ), esc_attr( sprintf( __( 'View all posts by %s' , 'customizr' ), get_the_author() ) ), get_the_author() ) );//end filter // Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name. if ( $tag_list ) { $utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s by %4$s.' , 'customizr' ); } elseif ( $categories_list ) { $utility_text = __( 'This entry was posted in %1$s on %3$s by %4$s.' , 'customizr' ); } else { $utility_text = __( 'This entry was posted on %3$s by %4$s.' , 'customizr' ); } $utility_text = apply_filters( 'tc_meta_utility_text', $utility_text ); //echoes every metas components printf( $utility_text, $categories_list, $tag_list, $date, $author ); }//endif attachment ?>
_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(); }