<?php

global $wpdb, $post, $opt_themes;  
$image_id	= get_post_thumbnail_id(); 
$image_url	= wp_get_attachment_image_src($image_id,'full', true); 
$image_url_default	= $image_url[0];
$thumbnail_images	= $image_url;
$post_id	= get_the_ID();
$url	= wp_get_attachment_url( get_post_thumbnail_id($post->ID), '64' );
$defaults_no_images	= $opt_themes['ex_themes_defaults_no_images_']['url'];
$thumb_id	= get_post_thumbnail_id( $id );
if ( '' != $thumb_id ) {
$thumb_url	= wp_get_attachment_image_src( $thumb_id, '64', true );
$image	= $thumb_url[0];
	} else {
$image	= $defaults_no_images;
	}
$urlimages2	= $image;

$thumbnails_gp	= get_post_meta( get_the_ID(), 'wp_poster_GP', true );
$thumbnails	= str_replace( 'http://', '', $thumbnails_gp );
$thumbnails	= str_replace( 'https://', '', $thumbnails_gp );
$randoms	= mt_rand(0, 2);
$cdn_thumbnails	= '//i'.$randoms.'.wp.com/'.$thumbnails.'';
$thumbnails	= get_post_meta( get_the_ID(), 'wp_poster_GP', true );
$defaults_no_images	= $opt_themes['ex_themes_defaults_no_images_']['url'];
$developer	= get_option('wp_developers_GP', 'developer');
$terms	= wp_get_post_terms(get_the_ID(), $developer);
$sizes	= get_post_meta( get_the_ID(), 'wp_sizes', true ); 
$sizes_alt	= get_post_meta( get_the_ID(), 'wp_sizes_GP', true );
if ( $sizes === FALSE or $sizes == '' ) $sizes = $sizes_alt;
$version	= get_post_meta( get_the_ID(), 'wp_version', true );
$versionX1	= get_post_meta( get_the_ID(), 'wp_version_GP', true ); 
$versionX	= '-';
if ( $version === FALSE or $version == '' ) $version = $versionX1;
$version1	= get_post_meta( get_the_ID(), 'wp_version', true );
$versionX1	= get_post_meta( get_the_ID(), 'wp_version_GP', true );
$versionX	= '-';
if ( $version1 === FALSE or $version1 == '' ) $version1 = $versionX1;
$wp_installs_GP	= get_post_meta( get_the_ID(), 'wp_installs_GP', true );
$wp_installs_GP1	= get_post_meta( get_the_ID(), 'wp_installs_GP', true );
if ( $wp_installs_GP === FALSE or $wp_installs_GP == '' ) $wp_installs_GP = $wp_installs_GP1;
$wp_contentrated_GP	= get_post_meta( get_the_ID(), 'wp_contentrated_GP', true );
$wp_contentrated_GP1	= get_post_meta( get_the_ID(), 'wp_contentrated_GP', true );
if ( $wp_contentrated_GP === FALSE or $wp_contentrated_GP == '' ) $wp_contentrated_GP = $wp_contentrated_GP1;
$updates	= get_post_meta( get_the_ID(), 'wp_updates_GP', true );
$updatesX1	= get_post_meta( get_the_ID(), 'wp_updates_GP', true );
$updatesX	= '-';
if ( $updates === FALSE or $updates == '' ) $updates = $updatesX;	
$wp_mods	= get_post_meta( get_the_ID(), 'wp_mods1', true );
$wp_mods1	= get_post_meta( get_the_ID(), 'wp_mods', true );
if ( $wp_mods === FALSE or $wp_mods == '' ) $wp_mods = $wp_mods1; 
$background_on	= $opt_themes['ex_themes_backgrounds_activate_'];   
$title_ps	= get_post_meta( get_the_ID(), 'wp_title_GP', true );
$developer_ps	= get_post_meta( get_the_ID(), 'wp_developers_GP', true );
$apk_text_name	= $opt_themes['exthemes_NameAPK'];
$apk_text_publiser	= $opt_themes['exthemes_PublisherAPK'];
$apk_text_genre	= $opt_themes['exthemes_GenreAPK'];
$apk_text_size	= $opt_themes['exthemes_SizeAPK'];
$apk_text_version	= $opt_themes['exthemes_VersionAPK'];
$apk_text_update	= $opt_themes['exthemes_UpdateAPK'];
$apk_text_mod	= $opt_themes['exthemes_MODAPK'];
$apk_text_gps	= $opt_themes['exthemes_GPSAPK'];
$playstore_id		= get_post_meta(get_the_ID(), 'wp_GP_ID', true);
$url_ps_sources		= 'https://play.google.com/store/apps/details?id='.$playstore_id; 
$apk_mods	= get_post_meta( get_the_ID(), 'wp_mods', true );
$image_ids	= get_post_thumbnail_id($post->ID); 
 
$full	= 'thumbnails-alt-120'; 
 
$image_urls	= wp_get_attachment_image_src($image_ids, $full, true); 
$poster_imgs	= $image_urls[0]; 
$title	= get_post_meta( get_the_ID(), 'wp_title_GP', true );
$title_alt	= get_the_title();
$x_time	= get_the_time('c');
$u_time	= get_the_time('U');
$x_modified_time	= get_the_modified_time('c');
$u_modified_time	= get_the_modified_time('U');

$author_id	= $post->post_author;
$author_link	= get_author_posts_url( $author_id );
$author_avatar	= get_avatar_url( $author_id ); 
//$author	= get_the_author( $author_id );
$author	= get_the_author();
$authorx	= get_the_author_meta('display_name', $author_id);
$display_name	= $authorx;
/* 
$passthis_id	= $curauth->ID;
$user_info	= get_userdata(1);
$username	= $user_info->user_login;
$first_name	= $user_info->first_name;
$last_name	= $user_info->last_name;
$display_name	= $user_info->display_name;
 */
$desck_GPs	= get_post_meta( get_the_ID(), 'wp_desck_GP', true ); 
if ( $desck_GPs === FALSE or $desck_GPs == '' ) $desck_GPs = $post->post_content;	
$des_post	= trim(strip_tags( $desck_GPs ));
$des_post	= trim(strip_tags( $desck_GPs ));
$des_post	= preg_replace('~[\r\n]+~', '', $des_post);
$des_post	= str_replace('"', '', $des_post);
$des_post	= mb_substr( $des_post, 0, 200, 'utf8' );

$text_latest_update	= $opt_themes['text_latest_update'];
$text_post_on	= $opt_themes['text_post_on'];
$text_edit_post	= $opt_themes['text_edit_post'];
?>

<div class="row align-items-center">
	<div class="col-3 col-md-2 text-center"> 
	 
	<img width="96" height="96" src="<?php if (get_the_post_thumbnail( get_the_ID() )) { echo wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' )[0]; } elseif(get_post_meta( get_the_ID(), 'wp_poster_GP', true )) { echo get_post_meta( get_the_ID(), 'wp_poster_GP', true ); } else { echo $opt_themes['no_img']['url']; } ?>" class=" rounded-lg mb-3  " alt="<?php the_title(); ?>" >
	 
	</div>
	<div class="col-9 col-md-10">
	<h1 class="h5 font-weight-semibold mb-1">
	<?php if($opt_themes['single_appname']){ echo get_post_meta( get_the_ID(), 'wp_title_GP', true); ?> <?php _e($opt_themes['text_18'], TEXT_DOMAIN); ?> <?php if(get_post_meta( get_the_ID(), 'wp_version_GP', true )){ echo 'v'.get_post_meta( get_the_ID(), 'wp_version_GP', true ); } ?> <?php if(get_post_meta( get_the_ID(), 'wp_mods', true )){?>(<?php echo trim(strip_tags(ucwords(get_post_meta( get_the_ID(), 'wp_mods', true )))); ?>)<?php } } else { the_title(); } ?></h1>
	<div class="mb-3 text-secondary small">
	
	<?php if ($u_modified_time >= $u_time + 1) { echo "<time class=\"text-muted d-block\" datetime=\"".$x_modified_time."\"><em> ".$text_latest_update." "; the_modified_time('F j, Y'); ?> (<?php echo human_time_diff(get_the_modified_time('U'),current_time('U') ). ' ago '; ?>) <?php echo edit_post_link( __( $text_edit_post, THEMES_NAMES ), ' ', ' ' ); echo "</em></time>"; } else { ?><time class='text-muted d-block' datetime='<?php echo $x_time; ?>'><em> <?php echo $text_post_on; ?> <?php echo get_the_time('F j, Y'); ?> (<?php echo human_time_diff(get_the_modified_time('U'),current_time('U') ). ' ago '; ?>) <?php echo edit_post_link( __( $text_edit_post, THEMES_NAMES ), ' ', ' ' ); ?></em> </time><?php } ?>

	<?php if($opt_themes['single_appname']){ ?>
	<span style="color: var(--accent);"><?php if (get_post_meta( get_the_ID(), 'wp_version_GP', true )) { ?>v<?php echo trim(get_post_meta( get_the_ID(), 'wp_version_GP', true )); ?><?php } ?></span> 
	<?php } ?>
	
	<?php
	if ($terms) { ?>
	<?php _e(' by ', THEMES_NAMES); ?> 
	<?php
	$output = array();
	foreach ($terms as $term) {
	$output[] = '<a href="'.get_term_link( $term->slug, $developer).'" title="Developer by '.$term->name.'">'.$term->name.'</a>';
	}
	echo join( ', ', $output );	
	}
	?>
	</div>
	</div>
	</div>
	<style>
	table.table.table-striped.table-borderless tr th {  font-weight: bold !important;  font-family: 'Roboto', sans-serif;}
	</style>
	<a class="btn btn-secondary btn-block mb-3" 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 _e($opt_themes['exthemes_Download'], TEXT_DOMAIN); ?> <?php
	if (get_post_meta( get_the_ID(), 'wp_sizes', true )) { ?>(<?php echo get_post_meta( get_the_ID(), 'wp_sizes', true ); ?>)<?php
	} ?></span></a>

	<figure>
	<table class="table table-striped table-borderless">
	<tbody> 
	<tr>
	<th>
	<?php _e($opt_themes['exthemes_NameAPK'], TEXT_DOMAIN); ?>
	</th>
	<td itemprop="name" class="text-truncate " >
	<?php echo get_post_meta( get_the_ID(), 'wp_title_GP', true ); ?>
	</td>
	<td itemprop="description" style='display:none'>
	<?php echo get_post_meta( get_the_ID(), 'wp_title_GP', true ); ?> is the most famous version in the <?php echo get_post_meta( get_the_ID(), 'wp_title_GP', true ); ?> series of publisher <?php echo get_post_meta( get_the_ID(), 'wp_developers_GP', true ); ?>
	</td>
	</tr>
	<tr>
	<th>
	<?php _e($opt_themes['exthemes_PublisherAPK'], TEXT_DOMAIN); ?> 
	</th>
	<?php	
	if ($terms) {
	$output = array();
	foreach ($terms as $term) {
	$output[] = '<td  class="text-truncate "><a href="'.get_term_link( $term->slug, $developer).'" title="Developer by '.$term->name.'">'.$term->name.'</a></td>';
	}
	echo join( ', ', $output );	}
	?>
	</tr>
	<tr>
	<th>
	<?php _e($opt_themes['exthemes_GenreAPK'], TEXT_DOMAIN); ?>  
	</th>
	<td  class="text-truncate ">
	<?php
	$i = 0;
	foreach((get_the_category()) as $cat) {
	echo '<a class="label" href="'.get_category_link($cat->cat_ID).'">'.$cat->cat_name.'</a>';
	if (++$i == 1) break;
	}
	?>
	</td>
	</tr>
	<?php if (get_post_meta( get_the_ID(), 'wp_sizes', true )) { ?> 
	<tr>
	<th>
	<?php _e($opt_themes['exthemes_SizeAPK'], TEXT_DOMAIN); ?>   
	</th>
	<td> 
	<?php echo get_post_meta( get_the_ID(), 'wp_sizes', true ); ?>  
	</td>
	</tr>
	<?php } ?>
	<tr>
	<th>
	<?php _e($opt_themes['exthemes_VersionAPK'], TEXT_DOMAIN); ?>    
	</th>
	<td> 
	<?php echo trim(get_post_meta( get_the_ID(), 'wp_version_GP', true )); ?>
	</td>
	</tr>  
	<?php if (get_post_meta( get_the_ID(), 'wp_updates_GP', true )) { ?>  
	<tr>	 
	<th>
	<?php _e($opt_themes['exthemes_UpdateAPK'], TEXT_DOMAIN); ?>   
	</th>
	<td>	 
	<?php echo get_post_meta( $post->ID, 'wp_updates_GP', true ); ?>
	</td> 
	</tr>
	<?php } if (get_post_meta( get_the_ID(), 'wp_mods', true )) { ?> 
	<tr>
	<th>
	<?php _e($opt_themes['exthemes_MODAPK'], TEXT_DOMAIN); ?>    
	</th>
	<td>
	<?php echo trim(strip_tags(get_post_meta( get_the_ID(), 'wp_mods', true ))); ?>
	</td>
	</tr>
	<?php } if (get_post_meta( get_the_ID(), 'wp_playstore_link', true )) { ?>
	<tr>
	<th>
	<?php _e($opt_themes['exthemes_GPSAPK'], TEXT_DOMAIN); ?>   
	</th>
	<td>
	<a href="<?php echo get_post_meta( get_the_ID(), 'wp_playstore_link', true ); ?>" target="_blank" rel="nofollow"><?php echo get_post_meta( get_the_ID(), 'wp_GP_ID', true ); ?></a>
	</td>
	</tr>
	<?php } if($opt_themes['rep_text_1']){ ?> 
	<tr>
	<th>
	<?php _e($opt_themes['rep_text_1'], TEXT_DOMAIN); ?> 
	</th>
	<td>
	<strong class="report-post-link" data-post-id="<?php the_ID(); ?>"><?php echo $opt_themes['text_report_post_2']; ?> </strong>
	</td>
	</tr> 
	<?php } if($opt_themes['rating_on']){ ?> 
	<tr>
	<th>
	<?php _e($opt_themes['rating_titlex'], TEXT_DOMAIN); ?> 
	</th>
	<td>
	<?php
	if (function_exists('display_post_rating')) {
		display_post_rating(get_the_ID());
	}
	?>	 
	</td>
	</tr> 
	<?php } ?>
	
	</tbody>
	</table>
</figure>
 