<?php
/**
 * @package 	WordPress
 * @subpackage 	Welfare
 * @version		1.1.1
 * 
 * Single Campaign Template
 * Created by CMSMasters
 * 
 */


get_header();


$cmsms_option = cmsms_get_global_options();


list($cmsms_layout) = cmsms_theme_page_layout_scheme();


$campaign_tags = get_the_terms(get_the_ID(), 'cp-tags');


$cmsms_campaign_sharing_box = get_post_meta(get_the_ID(), 'cmsms_campaign_sharing_box', true);

$cmsms_campaign_author_box = get_post_meta(get_the_ID(), 'cmsms_campaign_author_box', true);

$cmsms_campaign_more_posts = get_post_meta(get_the_ID(), 'cmsms_campaign_more_posts', true);

$cmsms_campaign_title = get_post_meta(get_the_ID(), 'cmsms_campaign_title', true);


echo '<!--_________________________ Start Content _________________________ -->' . "\n";


if ($cmsms_layout == 'r_sidebar') {
	echo '<div class="content entry" role="main">' . "\n\t";
} elseif ($cmsms_layout == 'l_sidebar') {
	echo '<div class="content entry fr" role="main">' . "\n\t";
} else {
	echo '<div class="middle_content entry" role="main">' . "\n\t";
}


if (have_posts()) : the_post();
	echo '<div class="campaigns opened-article">' . "\n";


?>
<!--_________________________ Start Standard Campaign _________________________ -->

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
	<div class="cmsms_campaign_cont">
	<?php
		if (!post_password_required() && has_post_thumbnail()) {
			cmsms_thumb(get_the_ID(), 'post-thumbnail', false, false, true, true, true, true, false);
		}
		
		
		echo '<div class="campaign_meta_wrap">';
		
			cmsms_campaign_target(get_the_ID(), true);
			
			cmsms_campaign_donations_count(get_the_ID(), true);
			
			cmsms_campaign_donated(get_the_ID(), 'post');
			
			cmsms_campaign_donate_button(get_the_ID(), true);
			
		echo '</div>';
		
		
		if ($cmsms_campaign_title == 'true') {
			cmsms_campaign_heading(get_the_ID(), 'h2', false);
		}
		
		
		if ( 
			$cmsms_option[CMSMS_SHORTNAME . '_donations_campaign_date'] || 
			$cmsms_option[CMSMS_SHORTNAME . '_donations_campaign_author'] || 
			$cmsms_option[CMSMS_SHORTNAME . '_donations_campaign_cat'] || 
			$cmsms_option[CMSMS_SHORTNAME . '_donations_campaign_tag'] || 
			$cmsms_option[CMSMS_SHORTNAME . '_donations_campaign_like'] || 
			$cmsms_option[CMSMS_SHORTNAME . '_donations_campaign_comment'] 
		) {
			echo '<div class="cmsms_campaign_cont_info entry-meta' . ((get_the_content() == '') ? ' no_bdb' : '') . '">';
				
				if ( 
					$cmsms_option[CMSMS_SHORTNAME . '_donations_campaign_like'] || 
					$cmsms_option[CMSMS_SHORTNAME . '_donations_campaign_comment'] 
				) {
					echo '<div class="cmsms_campaign_meta_info">';
						
						cmsms_campaign_comments('post');
						
						cmsms_campaign_like('post');
						
					echo '</div>';
				}
				
				
				cmsms_campaign_date('post');
				
				cmsms_campaign_author('post');
				
				cmsms_campaign_category(get_the_ID(), 'cp-categs', 'post');
				
				cmsms_campaign_tags(get_the_ID(), 'cp-tags', 'post');
				
			echo '</div>';
		}
		
		
		if (get_the_content() != '') {
			echo '<div class="cmsms_campaign_content entry-content">';
				
				the_content();
				
				
				wp_link_pages(array( 
					'before' => '<div class="subpage_nav" role="navigation">' . '<strong>' . esc_html__('Pages', 'welfare') . ':</strong>', 
					'after' => '</div>', 
					'link_before' => ' [ ', 
					'link_after' => ' ] ' 
				));
				
			echo '<div class="cl"></div>' . 
			'</div>';
		}
	?>
	</div>
</article>
<!--_________________________ Finish Standard Campaign _________________________ -->
<?php
	
	
	if ($cmsms_option[CMSMS_SHORTNAME . '_donations_campaign_nav_box']) {
		cmsms_prev_next_posts();
	}
	
	
	if ($cmsms_campaign_sharing_box == 'true') {
		cmsms_sharing_box(esc_html__('Share this campaign?', 'welfare'), 'h3');
	}
	
	
	if ($cmsms_campaign_author_box == 'true') {
		cmsms_author_box(esc_html__('About author', 'welfare'), 'h3');
	}
	
	
	if ($campaign_tags) {
		$tgsarray = array();
		
		foreach ($campaign_tags as $tagone) {
			$tgsarray[] = $tagone->term_id;
		}  
	} else {
		$tgsarray = '';
	}
	
	
	if (is_array($cmsms_campaign_more_posts)) {
		cmsms_related( 
			'h3', 
			in_array('related', $cmsms_campaign_more_posts), 
			$tgsarray, 
			in_array('popular', $cmsms_campaign_more_posts), 
			in_array('recent', $cmsms_campaign_more_posts), 
			$cmsms_option[CMSMS_SHORTNAME . '_donations_campaign_r_p_l_number'], 
			'campaign', 
			'cp-tags' 
		);
	}
	
	
	comments_template(); 
	
	
	echo '</div>';
endif;


echo '</div>' . "\n" . 
'<!-- _________________________ Finish Content _________________________ -->' . "\n\n";


if ($cmsms_layout == 'r_sidebar') {
	echo "\n" . '<!-- _________________________ Start Sidebar _________________________ -->' . "\n" . 
	'<div class="sidebar" role="complementary">' . "\n";
	
	
	get_sidebar();
	
	
	echo "\n" . '</div>' . "\n" . 
	'<!-- _________________________ Finish Sidebar _________________________ -->' . "\n";
} elseif ($cmsms_layout == 'l_sidebar') {
	echo "\n" . '<!-- _________________________ Start Sidebar _________________________ -->' . "\n" . 
	'<div class="sidebar fl" role="complementary">' . "\n";
	
	
	get_sidebar();
	
	
	echo "\n" . '</div>' . "\n" . 
	'<!-- _________________________ Finish Sidebar _________________________ -->' . "\n";
}


get_footer();

