forked from hesabix/arc
107 lines
5.1 KiB
PHP
107 lines
5.1 KiB
PHP
<?php
|
|
/**
|
|
* پوستهٔ HTML کاتالوگ (قابل override در قالب: shabake-tamin/catalog-wrapper.php).
|
|
*
|
|
* @package Shabake_Tamin
|
|
*
|
|
* @var array<string, mixed> $st_config پیکربندی نمونه.
|
|
*/
|
|
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
$cfg = isset( $st_config ) && is_array( $st_config ) ? $st_config : array();
|
|
$cfg = wp_parse_args(
|
|
$cfg,
|
|
array(
|
|
'businessId' => null,
|
|
'categoryId' => null,
|
|
'province' => null,
|
|
'city' => null,
|
|
'brand' => null,
|
|
'locationFilters' => false,
|
|
'brandFilters' => false,
|
|
'provinceSuggestions' => false,
|
|
'showProductDetails' => true,
|
|
'columns' => 4,
|
|
'search' => true,
|
|
'take' => 20,
|
|
'pageLayout' => false,
|
|
)
|
|
);
|
|
|
|
$uid = 'st-' . preg_replace( '/[^a-zA-Z0-9_-]/', '', uniqid( '', true ) );
|
|
|
|
$json_flags = JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT;
|
|
$json = wp_json_encode( $cfg, $json_flags );
|
|
if ( false === $json ) {
|
|
$json = '{}';
|
|
}
|
|
|
|
$cols = (int) $cfg['columns'];
|
|
$page_layout = ! empty( $cfg['pageLayout'] );
|
|
$show_search = ! empty( $cfg['search'] );
|
|
$show_loc_ui = ! empty( $cfg['locationFilters'] );
|
|
$show_brand_ui = ! empty( $cfg['brandFilters'] );
|
|
$show_toolbar = $show_search || $show_loc_ui || $show_brand_ui;
|
|
$prov_val = isset( $cfg['province'] ) && is_string( $cfg['province'] ) ? $cfg['province'] : '';
|
|
$city_val = isset( $cfg['city'] ) && is_string( $cfg['city'] ) ? $cfg['city'] : '';
|
|
$brand_val = isset( $cfg['brand'] ) && is_string( $cfg['brand'] ) ? $cfg['brand'] : '';
|
|
$provinces_list_id = $uid . '-provinces';
|
|
$show_province_datalist = $show_loc_ui && ! empty( $cfg['provinceSuggestions'] );
|
|
?>
|
|
<div class="st-catalog-root<?php echo $page_layout ? ' st-page-layout' : ''; ?>" id="<?php echo esc_attr( $uid ); ?>" data-st-root="1" style="--st-columns: <?php echo esc_attr( (string) $cols ); ?>;">
|
|
<script type="application/json" class="st-json-config"><?php echo $json; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></script>
|
|
<?php if ( $show_toolbar ) : ?>
|
|
<div class="st-toolbar-stack">
|
|
<?php if ( $show_search ) : ?>
|
|
<div class="st-toolbar">
|
|
<label class="st-sr-only" for="<?php echo esc_attr( $uid ); ?>-q"><?php esc_html_e( 'جستجو', 'shabake-tamin' ); ?></label>
|
|
<input type="search" class="st-search-input" id="<?php echo esc_attr( $uid ); ?>-q" autocomplete="off" placeholder="" />
|
|
<button type="button" class="st-search-btn button"><?php esc_html_e( 'جستجو', 'shabake-tamin' ); ?></button>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if ( $show_loc_ui || $show_brand_ui ) : ?>
|
|
<div class="st-toolbar st-toolbar--filters">
|
|
<div class="st-filter-fields">
|
|
<?php if ( $show_brand_ui ) : ?>
|
|
<label class="st-filter-label">
|
|
<span class="st-filter-label-text"><?php esc_html_e( 'برند / مدل', 'shabake-tamin' ); ?></span>
|
|
<input type="search" class="st-filter-brand" maxlength="255" value="<?php echo esc_attr( $brand_val ); ?>" autocomplete="off" />
|
|
</label>
|
|
<?php endif; ?>
|
|
<?php if ( $show_loc_ui ) : ?>
|
|
<label class="st-filter-label">
|
|
<span class="st-filter-label-text"><?php esc_html_e( 'استان', 'shabake-tamin' ); ?></span>
|
|
<input type="text" class="st-filter-province" maxlength="100" value="<?php echo esc_attr( $prov_val ); ?>" autocomplete="address-level1"<?php echo $show_province_datalist ? ' list="' . esc_attr( $provinces_list_id ) . '"' : ''; ?> />
|
|
</label>
|
|
<label class="st-filter-label">
|
|
<span class="st-filter-label-text"><?php esc_html_e( 'شهر', 'shabake-tamin' ); ?></span>
|
|
<input type="text" class="st-filter-city" maxlength="100" value="<?php echo esc_attr( $city_val ); ?>" autocomplete="address-level2" />
|
|
</label>
|
|
<?php endif; ?>
|
|
</div>
|
|
<button type="button" class="st-filter-apply button"><?php esc_html_e( 'اعمال فیلتر', 'shabake-tamin' ); ?></button>
|
|
<?php if ( $show_loc_ui && $show_province_datalist ) : ?>
|
|
<?php require_once ST_PLUGIN_DIR . 'includes/iran-provinces-list.php'; ?>
|
|
<datalist id="<?php echo esc_attr( $provinces_list_id ); ?>">
|
|
<?php foreach ( shabake_tamin_get_iran_provinces() as $st_province_name ) : ?>
|
|
<option value="<?php echo esc_attr( $st_province_name ); ?>"></option>
|
|
<?php endforeach; ?>
|
|
</datalist>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
<?php if ( $page_layout ) : ?>
|
|
<div class="st-pub-meta" aria-live="polite">
|
|
<span class="st-pub-result-stats"></span>
|
|
</div>
|
|
<?php endif; ?>
|
|
<div class="st-supplier-banner" hidden aria-live="polite"></div>
|
|
<div class="st-catalog-status" hidden></div>
|
|
<div class="st-grid" aria-live="polite"></div>
|
|
<div class="st-loadmore-wrap">
|
|
<button type="button" class="st-loadmore button" hidden><?php esc_html_e( 'بارگذاری بیشتر', 'shabake-tamin' ); ?></button>
|
|
</div>
|
|
</div>
|