<?php 

/**
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-3.0.txt
 */

if (!function_exists('citymag_before_content_function')) {

	function citymag_before_content_function( $type = "post" ) {
		
		if ( 
			$type == 'post' &&
			citymag_is_single() &&
			citymag_setting('citymag_enable_post_category', true ) == true
		) :

			$additional_css_class = ( citymag_setting('citymag_remove_background_post_meta_category') == true ) ? 'post-meta-category-remove-bg' : '';
			$separator = ( citymag_setting('citymag_remove_background_post_meta_category') == true ) ? ' &bull; ' : ' ';

			echo '<div class="post-meta">';

				echo '<span class="post-meta-category ' . esc_attr($additional_css_class) . '">'; 

					the_category($separator); 
				
				echo '</span>';

			echo '</div>';

		endif;
		
		if ( ! citymag_is_single() ) {

			do_action('citymag_get_title', 'blog' ); 

		} else {

			if ( !citymag_is_woocommerce_active('is_cart') ) :
	
				if ( citymag_is_single() && !is_page_template() ) :
							 
					do_action('citymag_get_title', 'single');
							
				else :
					
					do_action('citymag_get_title', 'blog'); 
							 
				endif;
	
			endif;

		}

		if ( 
			$type == 'post' &&
			(
				citymag_setting('citymag_enable_post_author', true) == true ||
				citymag_setting('citymag_enable_post_date', true) == true ||
				citymag_setting('citymag_enable_post_icon', true) == true

			)
		 ) :

			echo '<div class="post-meta">';

				if ( citymag_setting('citymag_enable_post_author', true) == true ) :
						
					echo '<span class="post-meta-author">';

						echo esc_html(citymag_setting('citymag_post_author_label', __( 'By', 'citymag' )));
						echo '&nbsp;';
						echo get_the_author_posts_link();

					echo '</span>';

				endif;

				if ( citymag_setting('citymag_enable_post_date', true) == true ) :
					
					echo '<span class="post-meta-date">';

						echo get_the_date();

					echo '</span>';

				endif;

				if ( citymag_setting('citymag_enable_post_icon', true ) == true ) :

					echo '<span class="post-meta-icon">'; 

						echo citymag_posticon();
					
					echo '</span>';
					
				endif;

			echo '</div>';

		endif;

	} 
	
	add_action( 'citymag_before_content', 'citymag_before_content_function' );

}

?>