<?php
if ( ! defined( 'ABSPATH' ) ) exit;



function sp_breadcrum() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

<?php switch ($opt_themes['themes_styles']) { case 'liteapks': ?>
<div class="py-2">
<div class="container">
<?php break; } ?>

<ul style="margin: 10px 0;" id="breadcrumb" class="
	<?php 
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>
	pt-1 pb-3 breadcrumb
	<?php
	break; 	
	case 'modyolo':
	?>
	pt-1 pb-3 breadcrumb
	<?php
	break; 	
	case 'reborn':
	?>
	pt-1 pb-3 breadcrumb
	<?php
	break; 	
	case 'liteapks':
	?>
	breadcrumb
	<?php	
	break; 
	default:
	?>
	pt-1 pb-3 breadcrumb
	<?php
	break; 
	}
	?>" itemscope='itemscope' itemtype='https://schema.org/BreadcrumbList' <?php
if ($opt_themes['ex_themes_breadcrumbs_activate_']) { ?>style="display:none"<?php } ?>>
		<li class="breadcrumb-item home" itemprop="itemListElement" itemscope="itemscope" itemtype="http://schema.org/ListItem">
		<a href="<?php echo get_bloginfo("home"); ?>" title="<?php _e($opt_themes['text_homes'], TEXT_DOMAIN); ?>"><?php _e($opt_themes['text_homes'], TEXT_DOMAIN); ?>
		<meta itemprop='item' content='<?php echo get_bloginfo("home"); ?>' />
		<meta itemprop='name' content='<?php _e($opt_themes['text_homes'], TEXT_DOMAIN); ?>' />
		<meta itemprop='position' content='1' />
		</a> 
		</li> 
 
		<?php 
		global $post; 
		$home_url       = home_url('/');
		$link           = '<li class="breadcrumb-item home" itemprop="itemListElement" itemscope="itemscope" itemtype="http://schema.org/ListItem"><a href="%1$s" >%2$s';
		$link          .= '<meta itemprop="item" content="%1$s"><meta itemprop="name" content="%2$s"><meta itemprop="position" content="%3$s" />'; 
		$link          .= '</a></li>'; 
		$cat			= get_the_category(); $catID = $cat[0]->cat_ID;
		$parents		= get_ancestors( $catID, 'category' );
		$parents		= array_reverse( $parents );
		$parents[] 		= $catID;
		$position		= 2;
		foreach ( $parents as $cat ) { 
		echo sprintf( $link, get_category_link( $cat ), get_cat_name( $cat ), $position );
		$position++;}
		?>
		
		<li class="breadcrumb-item active">
		<?php if($opt_themes['single_appname']) { if(get_post_meta( $post->ID, 'wp_title_GP', true )){echo get_post_meta( $post->ID, 'wp_title_GP', true );} else {if (the_title()) {the_title(); }}} else { the_title(); }?>  
		</li> 
</ul>
<?php switch ($opt_themes['themes_styles']) { case 'liteapks': ?>
</div>
</div>
<?php break; } ?>
<?php
}

function sp_single_row() { 
global $wpdb, $post, $opt_themes, $wp_query; 

switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>
	<div class="row ml-1">
	<?php
	break; 
	
	case 'modyolo':
	?>
	
	<?php
	break; 
	
	case 'reborn':
	?>
	
	<?php
	break; 
	
	case 'liteapks':
	?>
	<?php
	break; 
	
	default:
	?>
	<div class="row ml-1">
	<?php
	break;
} 
}

function sp_close_single_row() { 
global $wpdb, $post, $opt_themes, $wp_query; 

switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>
	</div>
	<?php
	break; 
	
	case 'modyolo':
	?>
	
	<?php
	break; 
	
	case 'reborn':
	?>
	
	<?php
	break; 
	
	default:
	?>
	</div>
	<?php
	break;
} 
}

function sp_main() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

<main id="primary" class="
<?php 
switch($opt_themes['themes_styles']){
	case 'moddroid':
		echo 'content-area col-12 col-lg-8';
	break; 
	
	case 'modyolo':
		echo 'content-area';
	break; 
	
	case 'reborn':
		echo 'content-area mx-auto';
	break; 

	
	default:
		echo 'content-area col-12 col-lg-8';
	break;
} ?> " <?php switch($opt_themes['themes_styles']){ case 'reborn': ?>style="max-width:  880px" <?php break; } ?>>
 
 
<?php
}

function sp_close_main() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  
</main>
<?php
}

function sp_article() { 
global $wpdb, $post, $opt_themes, $wp_query; 
 
switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>
	
	<?php
	break; 
	
	case 'modyolo':
	?>
	<article class="bg-white border rounded shadow-sm px-2 px-md-3 mx-auto mb-3" style="max-width: 880px;">
	<?php
	break; 
	
	case 'reborn':
	?>
	
	<?php
	break; 
	
	case 'liteapks':
	?>
	<article class="bg-white border rounded shadow-sm p-3 mb-4">
	<?php
	break; 
	
	default:
	?>
	
	<?php
	break;
}
 
}

function sp_close_article() { 
global $wpdb, $post, $opt_themes, $wp_query; 

switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>
	
	<?php
	break; 
	
	case 'modyolo':
	?>
	</article>		
	<?php
	break; 
	
	case 'reborn':
	?>
					
	<?php
	break; 
	
	default:
	?>
					
	<?php
	break;
} 
}

function sp_close_section() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  
</section>
<?php
}

function sp_class() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  
<?php 
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>
	 mt-1
	<?php
	break; 	
	case 'modyolo':
	?>
	 mt-1
	<?php
	break; 	
	case 'reborn':
	?>
	 mt-1
	<?php
	break; 	
	case 'liteapks':
	?>
	
	<?php	
	break; 
	default:
	?>
	 mt-1
	<?php
	break; 
	}
	?>
<?php
}

function sp_opening() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

	<?php 
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>
	<div class="container" >  
	<?php 
	sp_single_row();
	sp_main();
	sp_article();
	sp_breadcrum();
	
	break; 	
	case 'modyolo':
	?>
	<div class="container" >  
	<?php 
	sp_single_row();
	sp_main();
	sp_article();	
	sp_breadcrum();
	
	break; 	
	case 'reborn':
	?>
	<div class="container" >  
	<?php
	sp_single_row();
	sp_main(); 
	sp_breadcrum();
	sp_article();	
	
	break; 	
	case 'liteapks':
	?> 
	<div class="container">
	<div class="row">
	<main id="primary" class="col-12 col-lg-8 col-xl-9 content-area">
	<?php 	
	sp_breadcrum();
	?>
	<article class="bg-white border rounded shadow-sm p-3 mb-4">
	<?php
	break; 	
	default:
	?>
	<div class="container" >  
	<?php 
	sp_breadcrum();
	sp_single_row();
	sp_main();
	sp_article();
	
	break; 
	}
	sp_info_apk();
	?>
	<?php switch ($opt_themes['themes_styles']) { case 'liteapks': ?>
	</article>	 
	<a class="btn btn-primary btn-block mb-4" href="<?php the_permalink() ?>download/" rel="nofollow">
	<svg class="svg-5 mr-1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><path d="M528 288h-92.1l46.1-46.1c30.1-30.1 8.8-81.9-33.9-81.9h-64V48c0-26.5-21.5-48-48-48h-96c-26.5 0-48 21.5-48 48v112h-64c-42.6 0-64.2 51.7-33.9 81.9l46.1 46.1H48c-26.5 0-48 21.5-48 48v128c0 26.5 21.5 48 48 48h480c26.5 0 48-21.5 48-48V336c0-26.5-21.5-48-48-48zm-400-80h112V48h96v160h112L288 368 128 208zm400 256H48V336h140.1l65.9 65.9c18.8 18.8 49.1 18.7 67.9 0l65.9-65.9H528v128zm-88-64c0-13.3 10.7-24 24-24s24 10.7 24 24-10.7 24-24 24-24-10.7-24-24z"></path></svg>
	<span class="align-middle"><?php echo $opt_themes['exthemes_Download']; ?> <?php if(get_post_meta( get_the_ID(), 'wp_sizes', true )){ ?> (<?php echo get_post_meta( $post->ID, 'wp_sizes', true ); ?>)<?php } ?></span>
	</a>
	<?php break; } ?>
	
<?php
}

function sp_info_apk() { 
global $wpdb, $post, $opt_themes, $wp_query; 
 
switch($opt_themes['themes_styles']){
	case 'moddroid':
	get_template_part('include/single/info_apk_mdr');  
	break; 
					
	case 'modyolo':
	get_template_part('include/single/background'); 
	get_template_part('include/single/info_apk_mdy');  
	break; 
					
	case 'reborn':
	get_template_part('include/single/background'); 
	get_template_part('include/single/info_apk_reborn');  
	break; 	
	
	case 'liteapks':
	get_template_part('include/single/background.liteapks'); 
	get_template_part('include/single/info_apk_liteapks');  
	break; 
					
	default:
	get_template_part('include/single/info_apk_mdr');  
	break;
} 

}

function sp_mods() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

	<?php 
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>
	<?php get_template_part('include/single/info_mod'); 
	if ($opt_themes['enable_gallery_top']) { ?>	
	<div class="mb-3">
	<?php gallery_image_top_(); ?>
	</div>
	<?php } ?> 
	<?php
	break; 	
	case 'modyolo':
	?>
	<?php get_template_part('include/single/info_mod'); 
	if ($opt_themes['enable_gallery_top']) { ?>	
	<div class="mb-3">
	<?php gallery_image_top_(); ?>
	</div>
	<?php } ?> 
	<?php
	break; 	
	case 'reborn':
	?>
	<?php get_template_part('include/single/info_mod'); 
	if ($opt_themes['enable_gallery_top']) { ?>	
	<div class="mb-3">
	<?php gallery_image_top_(); ?>
	</div>
	<?php } ?> 
	<?php
	break; 	
	case 'liteapks':
	?>
	<div class="bg-white border rounded shadow-sm p-3 mb-4">
	<?php if ($opt_themes['enable_gallery_top']) { ?>	
	<div class="overflow-auto mb-3">
	<div class="row row-small flex-nowrap align-items-end">
	<?php gallery_image_top_(); ?>
	</div>
	</div>
	<?php } get_template_part('include/single/info_mod'); ?>
	
	<?php	
	break; 
	default:
	?>
	<?php get_template_part('include/single/info_mod'); 
	if ($opt_themes['enable_gallery_top']) { ?>	
	<div class="mb-3">
	<?php gallery_image_top_(); ?>
	</div>
	<?php } ?> 
	<?php
	break; 
	}
	?>
 
<?php
}

function sp_what_news() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

	<?php 	 	
	if (get_post_meta( $post->ID, 'wp_whatnews_GP', true )) {
	?> 
	<div id="accordion-whats-news" class="border rounded-lg overflow-hidden mb-3 accordion accordion-more-info">
	<div>
	<a class="bg-col-button d-flex py-2 px-3 toggler" data-toggle="collapse" href="#whats-news" aria-expanded="false"><?php _e($opt_themes['exthemes_Whats_NewAPK'], TEXT_DOMAIN); ?></a>
	<div id="whats-news" class="collapse show" data-parent="#accordion-whats-news">
	<div class="pt-3 px-3 mb-3"> 
	<?php echo apply_filters('the_content', get_post_meta( $post->ID, 'wp_whatnews_GP', true )); ?>
	</div>
	</div>
	</div>
	</div>
	<?php } ?>	
<?php
}

function sp_slider_rating() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

	<?php 
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>
	<div class="mb-3">
	<?php ex_themes_poster_img_sliders_(); ?>
	</div>
	<?php
	get_template_part('include/single/info_rating');
	?>
	<br>
	<?php
	break; 	
	case 'modyolo':
	?>
	<div class="mb-3">
	<?php ex_themes_poster_img_sliders_(); ?>
	</div>
	<?php
	get_template_part('include/single/info_rating');
	?>
	<br>
	<?php
	break; 	
	case 'reborn':
	?>
	<div class="mb-3">
	<?php ex_themes_poster_img_sliders_(); ?>
	</div>
	<?php
	get_template_part('include/single/info_rating');
	?>
	<br>
	<?php
	break; 	
	case 'liteapks':
	?>
	<div class="mb-3">
	<?php ex_themes_poster_img_sliders_(); ?>
	</div>
	<?php
	get_template_part('include/single/info_rating');
	?>
	<br> 
	<?php	
	break; 
	default:
	?>
	<div class="mb-3">
	<?php ex_themes_poster_img_sliders_(); ?>
	</div>
	<?php
	get_template_part('include/single/info_rating');
	?>
	<br>
	<?php
	break; 
	}
	?>
<?php
}

function sp_middle() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

	<?php if(get_post_meta( $post->ID, 'wp_GP_ID', true )){ 
	get_template_part('include/single/info_download'); 
	} 
	if($opt_themes['activate_download_notices']){ ?>
	<div class="small mb-3 notice_download">
	<p><?php if($opt_themes['exthemes_download_times_notice_6']){ echo $opt_themes['exthemes_download_times_notice_6']; } ?> <strong><em><?php echo get_post_meta( $post->ID, 'wp_title_GP', true ); ?></em></strong> <?php if($opt_themes['exthemes_download_times_notice_7']){ echo $opt_themes['exthemes_download_times_notice_7']; } ?></p>
	<?php echo $opt_themes['notice_download_pages']; ?>
	</div>
	<?php }
	get_template_part('include/telegram'); 
	if(function_exists('kk_star_ratings')) { ?>
	<div class="text-center d-flex align-items-center justify-content-center py-3 mb-3">
	<?php echo kk_star_ratings(); ?>
	</div>
	<?php } ?>
<?php
}

function sp_() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

<?php
}

function sp_closing() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

	<?php 
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>
	
	<?php if (shortcode_exists( 'rns_reactions' )) {
	if($opt_themes['enable_emoji_bottom']) {
	echo do_shortcode( '[rns_reactions]' );
	}} if ($opt_themes['enable_social_share']) {
	?>
	<div class="text-center border-top border-bottom d-flex align-items-center justify-content-center py-3 mb-3">
	<?php ex_themes_blog_shares_2(); ?>
	</div>	
	<?php
	} 
	if ($opt_themes['enable_tags']) { 
	$post_tags = get_the_tags();
	if ( ! empty( $post_tags ) ) {
	echo '<span class="tags-links "> ';
	foreach( $post_tags as $post_tag ) { 
	echo '<a href="'.get_tag_link( $post_tag ).'" title="'.$post_tag->name.' tag" rel="tag"># '.$post_tag->name.'</a>'; 
	}
	echo '</span>';
	} }
	?>
	<?php
	break; 	
	case 'modyolo':
	?>
	
	<?php if (shortcode_exists( 'rns_reactions' )) {
	if($opt_themes['enable_emoji_bottom']) {
	echo do_shortcode( '[rns_reactions]' );
	}} if ($opt_themes['enable_social_share']) {
	?>
	<div class="text-center border-top border-bottom d-flex align-items-center justify-content-center py-3 mb-3">
	<?php ex_themes_blog_shares_2(); ?>
	</div>	
	<?php
	} 
	if ($opt_themes['enable_tags']) { 
	$post_tags = get_the_tags();
	if ( ! empty( $post_tags ) ) {
	echo '<span class="tags-links "> ';
	foreach( $post_tags as $post_tag ) { 
	echo '<a href="'.get_tag_link( $post_tag ).'" title="'.$post_tag->name.' tag" rel="tag"># '.$post_tag->name.'</a>'; 
	}
	echo '</span>';
	} }
	?>
	<?php
	break; 	
	case 'reborn':
	?>
	
	<?php if (shortcode_exists( 'rns_reactions' )) {
	if($opt_themes['enable_emoji_bottom']) {
	echo do_shortcode( '[rns_reactions]' );
	}} if ($opt_themes['enable_social_share']) {
	?>
	<div class="text-center border-top border-bottom d-flex align-items-center justify-content-center py-3 mb-3">
	<?php ex_themes_blog_shares_2(); ?>
	</div>	
	<?php
	} 
	if ($opt_themes['enable_tags']) { 
	$post_tags = get_the_tags();
	if ( ! empty( $post_tags ) ) {
	echo '<span class="tags-links "> ';
	foreach( $post_tags as $post_tag ) { 
	echo '<a href="'.get_tag_link( $post_tag ).'" title="'.$post_tag->name.' tag" rel="tag"># '.$post_tag->name.'</a>'; 
	}
	echo '</span>';
	} }
	?>
	<?php
	break; 	
	case 'liteapks':
	?>
	
	<?php	
	break; 
	default:
	?>
	
	<?php if (shortcode_exists( 'rns_reactions' )) {
	if($opt_themes['enable_emoji_bottom']) {
	echo do_shortcode( '[rns_reactions]' );
	}} if ($opt_themes['enable_social_share']) {
	?>
	<div class="text-center border-top border-bottom d-flex align-items-center justify-content-center py-3 mb-3">
	<?php ex_themes_blog_shares_2(); ?>
	</div>	
	<?php
	} 
	if ($opt_themes['enable_tags']) { 
	$post_tags = get_the_tags();
	if ( ! empty( $post_tags ) ) {
	echo '<span class="tags-links "> ';
	foreach( $post_tags as $post_tag ) { 
	echo '<a href="'.get_tag_link( $post_tag ).'" title="'.$post_tag->name.' tag" rel="tag"># '.$post_tag->name.'</a>'; 
	}
	echo '</span>';
	} }
	?>
	<?php
	break; 
	}
	?>
	
	<?php switch ($opt_themes['themes_styles']) { case 'liteapks': ?>
	</div>
	<?php 
	sp_devs();
	sp_related();
	sp_related_pcat();
	//ex_themes_related_posts_();	
	do_action('komentar_post');
	?>
	</main>
	<?php 
	do_action('single_sidebar');
	?>
	</div>
	<?php break; } ?>
	
	
	<?php 
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>
	
	<?php sp_close_article(); ?>
	<?php 
	ex_themes_versions();
	sp_devs();
	sp_related();
	sp_related_pcat();
	//ex_themes_related_posts_(); 	
	do_action('komentar_post');
	/* get_template_part('include/info_slider_new'); */ 
	get_template_part('include/single/popup-post');
	?>
	<?php
	sp_close_section();
	sp_close_main();
	?> 
	<!--sidebar-->	
	<?php do_action('single_sidebar'); ?> 
	<!--sidebar--> 
	<?php sp_close_single_row(); ?> 
	<?php
	break; 	
	case 'modyolo':
	?>
	
	<?php sp_close_article(); ?>
	<?php 
	ex_themes_versions();
	sp_devs();
	sp_related();
	sp_related_pcat();
	//ex_themes_related_posts_(); 	
	do_action('komentar_post');
	/* get_template_part('include/info_slider_new'); */ 
	get_template_part('include/single/popup-post');
	?>
	<?php
	sp_close_section();
	sp_close_main();
	?> 
	<!--sidebar-->	
	<?php do_action('single_sidebar'); ?> 
	<!--sidebar--> 
	<?php sp_close_single_row(); ?> 
	<?php
	break; 	
	case 'reborn':
	?>
	
	<?php sp_close_article(); ?>
	<?php 
	ex_themes_versions();
	sp_devs();
	sp_related();
	sp_related_pcat();
	//ex_themes_related_posts_(); 	
	do_action('komentar_post');
	/* get_template_part('include/info_slider_new'); */ 
	get_template_part('include/single/popup-post');
	?>
	<?php
	sp_close_section();
	sp_close_main();
	?> 
	<!--sidebar-->	
	<?php do_action('single_sidebar'); ?> 
	<!--sidebar--> 
	<?php sp_close_single_row(); ?> 
	<?php
	break; 	
	case 'liteapks':
	?>
	
	<?php	
	break; 
	default:
	?>
	
	<?php sp_close_article(); ?>
	<?php 
	ex_themes_versions();
	sp_devs();
	sp_related();
	sp_related_pcat();
	//ex_themes_related_posts_(); 	
	do_action('komentar_post');
	/* get_template_part('include/info_slider_new'); */ 
	get_template_part('include/single/popup-post');
	?>
	<?php
	sp_close_section();
	sp_close_main();
	?> 
	<!--sidebar-->	
	<?php do_action('single_sidebar'); ?> 
	<!--sidebar--> 
	<?php sp_close_single_row(); ?> 
	<?php
	break; 
	}
	?>
	
	 

	<?php 
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>
	</div>
	<?php
	break; 	
	case 'modyolo':
	?>
	</div>
	<?php
	break; 	
	case 'reborn':
	?>
	</div>
	<?php
	break; 	
	case 'liteapks':
	?>
	
	<?php	
	break; 
	default:
	?>
	</div>
	<?php
	break; 
	}
	?>
<?php
}


function sp_related() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

<?php 
global $wpdb, $post, $opt_themes, $wp_query; 
if($opt_themes['rp_on']){
$the_query = themes_related_posts( get_the_ID(), 'post', 'category', $opt_themes['rp_num'] );
global $cl_from_element;
$cl_from_element['is_related'] = true;	
// Display posts
if ( $the_query->have_posts() ) : 
?>

	<?php 
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>
	
	<section class="mb-4"> 
	<h2 class="h5 font-weight-semibold mb-3 pb-1 ">
	<span class="text-body border-bottom-2 border-secondary d-inline-block pb-1" ><?php _e($opt_themes['rp_title'], TEXT_DOMAIN); ?>  </span> 
	</h2>	
	 <?php 
	break; 
	
	case 'modyolo':
	?>
	<section class="bg-white border rounded shadow-sm pt-3 px-2 px-md-3 mb-3 mx-auto" style="max-width: 880px;"> 
	<header class="d-flex align-items-end mb-3">
	<h2 class="h5 font-weight-semibold mb-0">
	<?php _e($opt_themes['rp_title'], TEXT_DOMAIN); ?>
	</h2>
	</header>
	<?php 
	break; 
	
	case 'reborn':
	?>
	<section class="bg-white pb-3 pt-3 px-2 px-md-3 mt-3 m-2 mx-auto" style="max-width: 920px;"> 
	<div class="d-flex align-items-baseline justify-content-between ">
	<h2 class="h5 font-weight-semibold m-0 p-0 mb-3 cate-title"><?php _e($opt_themes['rp_title'], TEXT_DOMAIN); ?></h2>
	</div>
	<?php 
	break; 
	
	case 'liteapks':
	?>
	 
	<section class="related-posts">
	<h2 class="font-weight-bold mb-4"><?php _e($opt_themes['rp_title'], TEXT_DOMAIN); ?></h2>
	<?php 
	break; 
	
	default:
	?> 
	<section class="mb-4"> 
	<h2 class="h5 font-weight-semibold mb-3 pb-1 ">
	<span class="text-body border-bottom-2 border-secondary d-inline-block pb-1" ><?php _e($opt_themes['rp_title'], TEXT_DOMAIN); ?></span> 
	</h2>	
	<?php 
	break;
	} ?> 
	
	<div class="row">
	<?php 
	while ( $the_query->have_posts() ) : $the_query->the_post(); 
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	get_template_part('loop/item.mdr'); 
	break; 
	
	case 'modyolo':
	get_template_part('loop/item.mdy'); 
	break; 
	
	case 'reborn':
	get_template_part('loop/item.reborn');
	break; 
	
	case 'liteapks':
	get_template_part('loop/item.liteapks'); 
	break; 
	
	default:
	get_template_part('loop/item.mdr'); 
	break;
	}
	endwhile;
	?>	  
	</div>
</section>
<?php 
endif; 
wp_reset_query();
$cl_from_element['is_related'] = false; 
}
?> 

<?php
}

function sp_related_pcat() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

<?php 
global $wpdb, $post, $opt_themes, $wp_query; 
if($opt_themes['rpc_on']){
$the_query = themes_related_posts_by_cat( get_the_ID(), 'post', 'category', $opt_themes['rpc_num'] );
global $cl_from_element;
$cl_from_element['is_related'] = true;	
// Display posts
if ( $the_query->have_posts() ) : 

    $current_post_id = $post->ID;

    // Get the current post's categories
    $categories = get_the_category($current_post_id);
    if (empty($categories)) {
        return; // No categories assigned
    }

    // Assume the first category is the primary one (adjust if your posts have multiple)
    $primary_cat = $categories[0];
    
    // Get the parent category ID (0 if no parent)
    $parent_cat_id = $primary_cat->parent;
    
    // If no parent, fall back to the primary category itself
    if ($parent_cat_id == 0) {
        $parent_cat_id = $primary_cat->term_id;
    }

	//print_r($primary_cat);
	
	$category_id = $parent_cat_id; // Replace with your category ID
	$category_name = get_cat_name( $category_id );
	$category = get_the_category();
	$link_category_parent = get_category_link($category[0]->category_parent);

?>
  
	
	<?php 
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>
	
	<section class="mb-4"> 
	<h2 class="h5 font-weight-semibold mb-3 pb-1 ">
	<span class="text-body border-bottom-2 border-secondary d-inline-block pb-1" ><?php _e($opt_themes['rpc_title'], TEXT_DOMAIN); ?> <?php echo $category_name; ?></span> 
	</h2>	
	 <?php 
	break; 
	
	case 'modyolo':
	?>
	<section class="bg-white border rounded shadow-sm pt-3 px-2 px-md-3 mb-3 mx-auto" style="max-width: 880px;"> 
	<header class="d-flex align-items-end mb-3">
	<h2 class="h5 font-weight-semibold mb-0">
	<?php _e($opt_themes['rpc_title'], TEXT_DOMAIN); ?> <?php echo $category_name; ?>
	</h2>
	</header>
	<?php 
	break; 
	
	case 'reborn':
	?>
	<section class="bg-white pb-3 pt-3 px-2 px-md-3 mt-3 m-2 mx-auto" style="max-width: 920px;"> 
	<div class="d-flex align-items-baseline justify-content-between ">
	<h2 class="h5 font-weight-semibold m-0 p-0 mb-3 cate-title"><?php _e($opt_themes['rpc_title'], TEXT_DOMAIN); ?> <?php echo $category_name; ?></h2>
	</div>
	<?php 
	break; 
	
	case 'liteapks':
	?>
	 
	<section class="related-posts">
	<h2 class="font-weight-bold mb-4"><?php _e($opt_themes['rpc_title'], TEXT_DOMAIN); ?> <?php echo $category_name; ?></h2>
	<?php 
	break; 
	
	default:
	?> 
	<section class="mb-4"> 
	<h2 class="h5 font-weight-semibold mb-3 pb-1 ">
	<span class="text-body border-bottom-2 border-secondary d-inline-block pb-1" ><?php _e($opt_themes['rpc_title'], TEXT_DOMAIN); ?> <?php echo $category_name; ?></span> 
	</h2>	
	<?php 
	break;
	} ?> 
	
	<div class="row">
	<?php 
	while ( $the_query->have_posts() ) : $the_query->the_post(); 
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	get_template_part('loop/item.mdr'); 
	break; 
	
	case 'modyolo':
	get_template_part('loop/item.mdy'); 
	break; 
	
	case 'reborn':
	get_template_part('loop/item.reborn');
	break; 
	
	case 'liteapks':
	get_template_part('loop/item.liteapks'); 
	break; 
	
	default:
	get_template_part('loop/item.mdr'); 
	break;
	}
	endwhile;
	?>	  
	</div>
</section>

<?php 
endif; 
wp_reset_query();
$cl_from_element['is_related'] = false; 
}
?> 

<?php
}


function sp_devs() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

<?php 
global $wpdb, $post, $opt_themes, $wp_query; 
if($opt_themes['sp_dev_on']){
$the_query = themes_related_devs( get_the_ID(), 'post', 'developer', $opt_themes['sp_dev_num'] );
$developer_terms    = get_the_terms( $post->ID , 'developer', 'string');
$term_ids           = wp_list_pluck($developer_terms,'term_id');
//$developer_terms    = get_the_terms( $post->ID , 'developer', 'string'); 
//$term_ids           = wp_list_pluck($developer_terms,'term_id');
global $cl_from_element;
$cl_from_element['is_related'] = true;	
// Display posts
	
if ( $the_query->have_posts() ) : 
?>	  
	 
 
	
	<?php 
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	?>
	
	<section class="mb-4"> 
	<h2 class="h5 font-weight-semibold mb-3 pb-1 ">
	<span class="text-body border-bottom-2 border-secondary d-inline-block pb-1" ><?php
	global $post;
	$developer  = get_option('wp_developers_GP', 'developer');
	$terms      = wp_get_post_terms($post->ID, $developer);
	if ($terms) {
	$output = array();
	foreach ($terms as $term) {
	$output[] = ''.$opt_themes['sp_dev_title'].' '.$term->name.'';
	}
	echo join( ', ', $output );	}
	?></span> 
	</h2>	
	 <?php 
	break; 
	
	case 'modyolo':
	?>
	<section class="bg-white border rounded shadow-sm pt-3 px-2 px-md-3 mb-3 mx-auto" style="max-width: 880px;"> 
	<header class="d-flex align-items-end mb-3">
	<h2 class="h5 font-weight-semibold mb-0"><?php
	global $post;
	$developer  = get_option('wp_developers_GP', 'developer');
	$terms      = wp_get_post_terms($post->ID, $developer);
	if ($terms) {
	$output = array();
	foreach ($terms as $term) {
	$output[] = ''.$opt_themes['sp_dev_title'].' '.$term->name.'';
	}
	echo join( ', ', $output );	}
	?>
	</h2>
	</header>
	<?php 
	break; 
	
	case 'reborn':
	?>
	<section class="bg-white pb-3 pt-3 px-2 px-md-3 mt-3 m-2 mx-auto" style="max-width: 920px;"> 
	<div class="d-flex align-items-baseline justify-content-between ">
	<h2 class="h5 font-weight-semibold m-0 p-0 mb-3 cate-title"><?php
	global $post;
	$developer  = get_option('wp_developers_GP', 'developer');
	$terms      = wp_get_post_terms($post->ID, $developer);
	if ($terms) {
	$output = array();
	foreach ($terms as $term) {
	$output[] = ''.$opt_themes['sp_dev_title'].' '.$term->name.'';
	}
	echo join( ', ', $output );	}
	?></h2>
	</div>
	<?php 
	break; 
	
	case 'liteapks':
	?>
	 
	<section class="related-posts">
	<h2 class="font-weight-bold mb-4"><?php
	global $post;
	$developer  = get_option('wp_developers_GP', 'developer');
	$terms      = wp_get_post_terms($post->ID, $developer);
	if ($terms) {
	$output = array();
	foreach ($terms as $term) {
	$output[] = ''.$opt_themes['sp_dev_title'].' '.$term->name.'';
	}
	echo join( ', ', $output );	}
	?></h2>
	<?php 
	break; 
	
	default:
	?> 
	<section class="mb-4"> 
	<h2 class="h5 font-weight-semibold mb-3 pb-1 ">
	<span class="text-body border-bottom-2 border-secondary d-inline-block pb-1" ><?php
	global $post;
	$developer  = get_option('wp_developers_GP', 'developer');
	$terms      = wp_get_post_terms($post->ID, $developer);
	if ($terms) {
	$output = array();
	foreach ($terms as $term) {
	$output[] = ''.$opt_themes['sp_dev_title'].' '.$term->name.'';
	}
	echo join( ', ', $output );	}
	?></span> 
	</h2>	
	<?php 
	break;
	} ?> 
	
	<div class="row">
	<?php 
	while ( $the_query->have_posts() ) : $the_query->the_post(); 
	switch($opt_themes['themes_styles']){
	case 'moddroid':
	get_template_part('loop/item.mdr'); 
	break; 
	
	case 'modyolo':
	get_template_part('loop/item.mdy'); 
	break; 
	
	case 'reborn':
	get_template_part('loop/item.reborn');
	break; 
	
	case 'liteapks':
	get_template_part('loop/item.liteapks'); 
	break; 
	
	default:
	get_template_part('loop/item.mdr'); 
	break;
	}
	endwhile;
	?>	  
	</div>
</section>

<?php 
endif; 
wp_reset_query();
$cl_from_element['is_related'] = false; 
}
?> 

<?php
}

 