czr_fn_get_meta( 'categories', $limit, $sep ) : ''; } public function czr_fn_get_tag_list( $limit = false, $sep = '' ) { return 0 != esc_attr( czr_fn_opt( 'tc_show_post_metas_tags' ) ) ? $this -> czr_fn_get_meta( 'tags', $limit, $sep ) : ''; } public function czr_fn_get_author( $before = null ) { return 0 != esc_attr( czr_fn_opt( 'tc_show_post_metas_author' ) ) ? $this -> czr_fn_get_meta( 'author', array( $before ) ) : ''; } public function czr_fn_get_author_with_avatar( $before = null ) { return 0 != esc_attr( czr_fn_opt( 'tc_show_post_metas_author' ) ) ? $this -> czr_fn_get_meta( 'author_with_avatar', array( $before ) ) : ''; } public function czr_fn_get_publication_date( $permalink = false, $before = null, $only_text = false ) { return 0 != esc_attr( czr_fn_opt( 'tc_show_post_metas_publication_date' ) ) ? $this -> czr_fn_get_meta( 'pub_date', array( '', $permalink, $before, $only_text ) ) : ''; } public function czr_fn_get_update_date( $permalink = false, $before = null, $only_text = false ) { return 0 != esc_attr( czr_fn_opt( 'tc_show_post_metas_update_date' ) ) && false !== czr_fn_post_has_update() ? $this -> czr_fn_get_meta( 'up_date', array( '', $permalink, $before, $only_text ) ) : ''; } public function czr_fn_get_attachment_image_info( $permalink = false, $before = null ) { return $this -> czr_fn_get_meta( 'attachment_image_info' ); } /* END PUBLIC GETTERS */ /* HELPERS */ protected function czr_fn_get_meta( $meta, $params = array(), $separator = '' ) { //we don't don't display metas in pages, e.g. in search results if ( 'page' == czr_fn_get_post_type() ) return ''; $params = is_array( $params ) ? $params : array( $params ); return czr_fn_stringify_array( call_user_func_array( array( $this, "czr_fn_meta_generate_{$meta}" ), $params ), $separator ); } private function czr_fn_meta_generate_categories( $limit = false ) { return $this -> czr_fn_meta_generate_tax_list( $hierarchical = true, $limit ); } private function czr_fn_meta_generate_tags( $limit = false ) { return $this -> czr_fn_meta_generate_tax_list( $hierarchical = false, $limit ); } private function czr_fn_meta_generate_author( $before ) { $author = $this -> czr_fn_get_meta_author(); $before = is_null($before) ? __( 'by', 'customizr' ) : $before; return sprintf( '', $before, $author ); } private function czr_fn_meta_generate_author_with_avatar( $before ) { $author = $this -> czr_fn_get_meta_author( $get_avatar = true ); $before = is_null($before) ? __( 'by', 'customizr' ) : $before; return sprintf( '', $before, $author ); } private function czr_fn_meta_generate_pub_date( $format = '', $permalink = false, $before = null, $only_text = false ) { $date = $this -> czr_fn_get_meta_date( 'publication', $format, $permalink, $only_text ); $before = is_null($before) ? __( 'Published', 'customizr' ) : $before; return sprintf( '%1$s %2$s', $before , $date ); } private function czr_fn_meta_generate_up_date( $format = '', $permalink = false, $before = null, $only_text = false ) { $date = $this -> czr_fn_get_meta_date( 'update', $format, $permalink, $only_text ); $before = is_null($before) ? __( 'Updated', 'customizr' ) : $before; return sprintf( '%1$s %2$s', $before , $date ); } public function czr_fn_meta_generate_attachment_image_info() { $metadata = wp_get_attachment_metadata(); global $post; $_html_parts = array( ( isset($metadata['width']) && isset($metadata['height']) ) ? '' : '', //when post parent id is 0 means that the media is not attached to any post ( 0 != $post->post_parent ) ? '' : '' ); return apply_filters( 'tc_attachment_image_sizes_meta', join( ' ', $_html_parts ) ); } protected function czr_fn_get_term_css_class( $_is_hierarchical ) { $_classes = array(); if ( $_is_hierarchical ) array_push( $_classes , 'tax__link' ); else array_push( $_classes , 'tag__link btn btn-skin-dark-oh inverted' ); return $_classes; } /* Helpers */ /** * Helper * Return the date post metas * * @package Customizr * @since Customizr 3.2.6 */ protected function czr_fn_get_meta_date( $pub_or_update = 'publication', $_format = '', $permalink = false, $only_text ) { if ( 'short' == $_format ) { $_format = 'j M, Y'; } $_format = apply_filters( 'czr_meta_date_format' , $_format ); $_use_post_mod_date = apply_filters( 'czr_use_the_post_modified_date' , 'publication' != $pub_or_update ); //time $date_meta = sprintf( '', 'publication' == $pub_or_update ? 'published updated' : 'updated', $_use_post_mod_date ? esc_attr( get_the_modified_date('c') ) : esc_attr( get_the_date( 'c' ) ), $_use_post_mod_date ? esc_html( get_the_modified_date( $_format ) ) : esc_html( get_the_date( $_format ) ) ); if ( ! $only_text ) { $date_meta = sprintf( '%3$s', $permalink ? esc_url( get_the_permalink() ) : esc_url( get_day_link( get_the_time( 'Y' ), get_the_time( 'm' ), get_the_time( 'd' ) ) ), $permalink ? esc_attr( the_title_attribute( array( 'before' => __('Permalink to: ', 'customizr'), 'echo' => false ) ) ) : esc_attr( get_the_time() ), $date_meta ); } return apply_filters( 'tc_date_meta', $date_meta );//end filter } /** * Helper * Return the post author metas * * @package Customizr * @since Customizr 3.2.6 */ private function czr_fn_get_meta_author( $get_avatar = false ) { $author_id = get_the_author_meta( 'ID' ); if ( is_single() ) { if ( ! in_the_loop() ) { global $post; $author_id = $post->post_author; } } $author_id_array = apply_filters( 'tc_post_author_id', array( $author_id ) ); $author_id_array = is_array( $author_id_array ) ? $author_id_array : array( $author_id ); $_html = ''; $_i = 1; foreach ( $author_id_array as $author_id ) { $author_name = get_the_author_meta( 'display_name', $author_id ); if ( 1 != $_i && count( $author_id_array ) > $_i - 1 ) { $_html .= ', '; } $_html .= ''; $_i +=1; } return apply_filters('tc_author_meta', $_html ); } /** * Helper * @return string of all the taxonomy terms (including the category list for posts) * @param hierarchical tax boolean => true = categories like, false = tags like * * @package Customizr * @since Customizr 3.0 */ private function czr_fn_meta_generate_tax_list( $hierarchical, $limit = false ) { $post_terms = $this -> czr_fn_get_term_of_tax_type( $hierarchical, $limit ); if ( ! $post_terms ) return; $_terms_html_array = array_map( array( $this , 'czr_fn_meta_term_view' ), $post_terms ); return $_terms_html_array; } /** * Helper * @return string of the single term view * @param $term object * * @package Customizr * @since Customizr 3.3.2 */ private function czr_fn_meta_term_view( $term ) { $_is_hierarchical = is_taxonomy_hierarchical( $term -> taxonomy ); $_classes = czr_fn_stringify_array( apply_filters( 'czr_meta_tax_class', $this -> czr_fn_get_term_css_class( $_is_hierarchical ), $_is_hierarchical, $term ) ); // (Rocco's PR Comment) : following to this https://wordpress.org/support/topic/empty-articles-when-upgrading-to-customizr-version-332 // I found that at least wp 3.6.1 get_term_link($term->term_id, $term->taxonomy) returns a WP_Error // Looking at the codex, looks like we can just use get_term_link($term), when $term is a term object. // Just this change avoids the issue with 3.6.1, but I thought should be better make a check anyway on the return type of that function. $_term_link = is_wp_error( get_term_link( $term ) ) ? '' : get_term_link( $term ); $_to_return = $_term_link ? ' %4$s ' : ' %4$s '; $_to_return = $_is_hierarchical ? $_to_return : '