403Webshell
Server IP : 104.171.130.249  /  Your IP : 216.73.216.146
Web Server : nginx/1.25.5
System : Linux 0dac65491b7e 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64
User : root ( 0)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /var/www/html/wp-content/themes/matreshka/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/wp-content/themes/matreshka/page-new-products.php
<?php
/*
Template Name: Новинки
*/

get_header();

// Pagination
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;

// First, get the 100 newest product IDs
$newest_100_ids = get_posts( array(
	'post_type'      => 'product',
	'posts_per_page' => 100,
	'post_status'    => 'publish',
	'orderby'        => 'date',
	'order'          => 'DESC',
	'fields'         => 'ids',
	'meta_query'     => array(
		array(
			'key'     => '_stock_status',
			'value'   => 'instock',
			'compare' => '=',
		),
	),
) );

// Query for newest products with pagination
$args = array(
	'post_type'      => 'product',
	'posts_per_page' => 50,
	'paged'          => $paged,
	'post_status'    => 'publish',
	'post__in'       => $newest_100_ids,
	'orderby'        => 'post__in',
);

$new_products = new WP_Query( $args );
?>

<!-- bread-crumb -->
<section class="bread-crumb d-none d-md-flex mt-4">
	<div class="container">
		<p class="montserrat-medium">
			<a href="<?php echo esc_url( home_url( '/' ) ); ?>" class="text-decoration-none text-dark">Главная</a> 
			<span class="dot">●</span>
			<span class="bread-crumb-product">Новинки</span>
		</p>
	</div>
</section>

<!-- header -->
<section>
	<div class="container mt-3">
		<div class="d-flex align-items-center justify-content-between">
			<div class="d-flex align-items-center">
				<a href="javascript:history.back()" class="d-block d-md-none me-3">
					<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/icons/AltArrowLeft.svg' ); ?>" alt="arrow left icon">
				</a>
				<h2 class="montserrat-semibold mb-0">Новинки</h2>
			</div>
			<?php if ( $new_products->found_posts > 0 ) : ?>
				<span class="montserrat-medium text-dark-opacity">
					<?php echo esc_html( $new_products->found_posts ); ?> товаров
				</span>
			<?php endif; ?>
		</div>
	</div>
</section>

<!-- products -->
<section>
	<div class="container mb-5 mt-4">
		<?php if ( $new_products->have_posts() ) : ?>
			<div class="new-products-grid">
				<?php
				while ( $new_products->have_posts() ) : $new_products->the_post();
					global $product;
					
					$product_id = get_the_ID();
					$product_link = get_permalink();
					$product_image = wp_get_attachment_image_url( $product->get_image_id(), 'woocommerce_thumbnail' );
					$product_title = get_the_title();
					
					$weight = $product->get_weight();
					$weight_text = $weight ? $weight . 'г' : '';
					
					// Check if product is in wishlist
					$is_liked = matreshka_is_in_wishlist( $product_id );
					$like_icon = $is_liked ? get_template_directory_uri() . '/assets/icons/Heart.svg' : get_template_directory_uri() . '/assets/icons/like.svg';
					
					// Get sale percentage
					$sale_badge = matreshka_get_sale_badge( $product, 'card' );
				?>
					<div class="product-card" data-product-id="<?php echo esc_attr( $product_id ); ?>">
						<a class="link-product" href="<?php echo esc_url( $product_link ); ?>">
							<div class="product-card-img">
								<?php echo matreshka_get_product_card_image_html( $product, $product_title ); ?>
								
								<?php echo $sale_badge; ?>
							</div>
							<p class="montserrat-medium product-title">
								<?php echo esc_html( $product_title ); ?>
							</p>
							<?php if ( $weight_text ) : ?>
								<span class="montserrat-medium text-dark-opacity"><?php echo esc_html( $weight_text ); ?></span>
							<?php endif; ?>
						</a>
						<div class="product-card-bottom">
							<?php echo matreshka_get_product_price_html( $product ); ?>
							<img src="<?php echo esc_url( $like_icon ); ?>"
								 alt="like icon"
								 class="like-icon <?php echo $is_liked ? 'active' : ''; ?>">
						</div>
						<button class="btn w-100 btn-secondary montserrat-bold add-to-cart-btn" 
								data-product_id="<?php echo esc_attr( $product_id ); ?>" 
								data-product_sku="<?php echo esc_attr( $product->get_sku() ); ?>">
							В корзину
						</button>
					</div>
				<?php endwhile; ?>
			</div>

			<!-- Pagination -->
			<?php if ( $new_products->max_num_pages > 1 ) : ?>
				<nav class="matreshka-pagination mt-5" aria-label="Page navigation">
					<ul class="pagination justify-content-center">
						<?php
						$current_page = max( 1, $paged );
						$total_pages = $new_products->max_num_pages;
						
						// Previous page link
						if ( $current_page > 1 ) :
							$prev_link = get_pagenum_link( $current_page - 1 );
						?>
							<li class="page-item">
								<a class="page-link" href="<?php echo esc_url( $prev_link ); ?>" aria-label="Previous">
									<span aria-hidden="true">«</span>
								</a>
							</li>
						<?php else : ?>
							<li class="page-item disabled">
								<span class="page-link">«</span>
							</li>
						<?php endif; ?>

						<?php
						// Page numbers
						$range = 2; // How many pages to show on each side of current page
						
						for ( $i = 1; $i <= $total_pages; $i++ ) :
							// Show first page, last page, current page and pages around current
							if ( $i == 1 || $i == $total_pages || ( $i >= $current_page - $range && $i <= $current_page + $range ) ) :
								if ( $i == $current_page ) :
						?>
									<li class="page-item active" aria-current="page">
										<span class="page-link"><?php echo $i; ?></span>
									</li>
								<?php else : ?>
									<li class="page-item">
										<a class="page-link" href="<?php echo esc_url( get_pagenum_link( $i ) ); ?>">
											<?php echo $i; ?>
										</a>
									</li>
								<?php endif; ?>
							<?php
							// Show ellipsis
							elseif ( $i == $current_page - $range - 1 || $i == $current_page + $range + 1 ) :
							?>
								<li class="page-item disabled">
									<span class="page-link">...</span>
								</li>
							<?php
							endif;
						endfor;
						?>

						<?php
						// Next page link
						if ( $current_page < $total_pages ) :
							$next_link = get_pagenum_link( $current_page + 1 );
						?>
							<li class="page-item">
								<a class="page-link" href="<?php echo esc_url( $next_link ); ?>" aria-label="Next">
									<span aria-hidden="true">»</span>
								</a>
							</li>
						<?php else : ?>
							<li class="page-item disabled">
								<span class="page-link">»</span>
							</li>
						<?php endif; ?>
					</ul>
				</nav>
			<?php endif; ?>
			
		<?php else : ?>
			<div class="text-center py-5">
				<img src="<?php echo esc_url( get_template_directory_uri() . '/assets/img/notfount.png' ); ?>" alt="No products" class="mb-3" style="max-width: 200px;">
				<h3 class="montserrat-semibold mb-3">Новинок пока нет</h3>
				<p class="montserrat-medium text-dark-opacity mb-4">Скоро появятся новые товары</p>
				<a href="<?php echo esc_url( wc_get_page_permalink( 'shop' ) ); ?>" class="btn btn-red-primary montserrat-bold">
					Перейти в каталог
				</a>
			</div>
		<?php endif; ?>
		
		<?php wp_reset_postdata(); ?>
	</div>
</section>

<?php get_footer(); ?>

Youez - 2016 - github.com/yon3zu
LinuXploit