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


<?php //last entry

for($i=0;$i<1;$i++) {

	$entry = $entries[0];

	$creation_date	= sanitize_text_field( get_post_meta( $entry, 'creation_date', true) );
	$last_update	= sanitize_text_field( get_post_meta( $entry, 'last_update', true) );
	$now			= time();
	$delta			= $now - intval($last_update);
	$delta_create	= $now - intval($creation_date);

	$asin			= sanitize_text_field( get_post_meta( $entry, 'asin', true) );

	$default = array(
		'shortcoded'                    => 0,
		'productid' 					=> '',
		'search'						=> '',
		'customtitle' 					=> '',
		'customcontentbefore' 		=> '',
		'showdetails'					=> 3,
		'showdescription'				=> 0,
		'showtable'					=> 0,
		'customcontentafter' 			=> '',	
		'noprice' 						=> false,
		'nobuybutton' 				=> false,
		'wrappertitle' 				=> '',
		'wrappercolor' 				=> '',
		'rating' 						=> 0,
	);

	$atts = array(
		'shortcoded'                    => 0,
		'productid' 					=> $entry,
		'search'                        => '',
		'rating' 						=> -1,
		'showdetails'					=> 3,
		'wrappercolor' 				=> 'limegreen',
		'wrappertitle' 				=> 'Added: ' . intval( $delta_create / 60 / 60 / 24 ) . ' days ago - Updated: ' . intval( $delta / 60 ) . ' minutes ago',
	);

	$inputs = shortcode_atts($default, $atts);

?>

<div class="product_container product_block">

	<div class="product_toolbar">
		<button
				class="product_update"
				onclick="product_update('<?php echo esc_html( $asin ); ?>' , '<?php echo esc_html( $entry ); ?>' , this);" 
				data-asin="<?php echo esc_attr( $asin ); ?>" data-prod_id="<?php echo esc_attr( $entry ); ?>"
				title="Force refresh this product wth the Amazon APIs"
				>
			<img alt="" width="28" height="28" src="<?php echo esc_attr( AMAZINGAFFILIATES_PLUGIN_URL . '/admin/img/update.jpg' ); ?>" >
		</button>
		<a 
		   class="product_edit"
		   target="_blank"
		   rel="noopener"
		   href="<?php echo esc_url( site_url() . '/wp-admin/post.php?post=' . $entry . '&action=edit' ); ?>"
		   title="Edit this product"
		   >
			<img alt="" width="28" height="28" src="<?php echo esc_attr( AMAZINGAFFILIATES_PLUGIN_URL . '/admin/img/edit.jpg' ); ?>" >
		</a>
		<button
				class="product_delete"
				onclick="product_delete(this);"
				data-asin="<?php echo esc_attr( $asin ); ?>"
				title="Delete this product from your database"
				>
			<img alt="" width="28" height="28" src="<?php echo esc_attr( AMAZINGAFFILIATES_PLUGIN_URL . '/admin/img/delete.jpg' ); ?>" >
		</button>
	</div>

	<?php require( AMAZINGAFFILIATES_PLUGIN_URI . '/public/blocks/product/product_block.php' );	?>

</div>


<?php

}

$skip_first_entry = true;

