HEX
Server: Apache
System: Linux ecngx285.inmotionhosting.com 4.18.0-553.79.1.lve.el8.x86_64 #1 SMP Wed Oct 15 17:59:35 UTC 2025 x86_64
User: zeusxp5 (3862)
PHP: 8.3.28
Disabled: NONE
Upload Files
File: /home/zeusxp5/zenoxpressjobs.com/wp-content/plugins/shopengine/widgets/prod-short-code.php
<?php

namespace ShopEngine\Widgets;
defined('ABSPATH') || exit;

class Prod_Short_Code extends \WC_Shortcode_Products {

	public function __construct($settings = array(), $type = 'products') {

		$this->settings = $settings;
		$this->type     = $type;

		$this->attributes = $this->parse_attributes([
			'columns'  => $settings['shopengine_columns'],
			'rows'     => $settings['shopengine_rows'],
			'paginate' => $settings['shopengine_paginate'],
			'cache'    => false,
		]);

		$this->query_args = $this->parse_query_args();
	}


	protected function parse_query_args() {

		$query_args = [
			'post_type'           => 'product',
			'post_status'         => 'publish',
			'ignore_sticky_posts' => true,
			'no_found_rows'       => false === wc_string_to_bool($this->attributes['paginate']),
		];

		$settings = $this->settings;

		if($settings['shopengine_paginate'] === 'yes') {
			//phpcs:ignore WordPress.Security.NonceVerification.Recommended -- It's a fronted user part, not possible to verify nonce here
			$page = empty( $_GET['product-page'] ) ? 1 : absint($_GET['product-page']);

			if ($page > 1) {
				$query_args['paged'] = $page;
			}

			$ord_arg = WC()->query->get_catalog_ordering_args();

			$query_args['orderby'] = $ord_arg['orderby'];
			$query_args['order']   = $ord_arg['order'];
		}


		$query_args['fields']         = 'ids';
		$query_args['post_type']      = 'product';
		$query_args['posts_per_page'] = intval($settings['shopengine_columns'] * $settings['shopengine_rows']);


		return $query_args;
	}


	protected function get_query_results() {

		$results = parent::get_query_results();

		return $results;
	}
}