Files
wc-bootstrap/templates/product-searchform.html.twig
magdev 98359d4cfb
All checks were successful
Create Release Package / PHP Lint (push) Successful in 1m41s
Create Release Package / Build Release (push) Successful in 1m47s
Security audit fixes: fn() whitelist, escaping, and performance (v0.1.4)
- WooCommerceExtension: ALLOWED_FUNCTIONS whitelist for fn() Twig function
- Notice templates: data attributes use wp_kses_post instead of raw
- Search form: esc_attr on search query value attribute
- Per-request ContextBuilder caching via static variable
- Shared wc_bootstrap_render_in_page_shell() helper (DRY)
- Removed unused WC_BOOTSTRAP_VERSION and WC_BOOTSTRAP_URL constants

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 01:02:43 +01:00

33 lines
1.2 KiB
Twig

{#
# Product Search Form (Bootstrap 5 Override)
#
# Renders the WooCommerce product search form as a Bootstrap 5 input-group.
#
# Expected context:
# index - Unique form index (for multiple search forms on a page)
#
# WooCommerce PHP equivalent: product-searchform.php
#
# @package WcBootstrap
# @since 0.1.0
#}
{% set field_id = 'woocommerce-product-search-field-' ~ (index|default(0)) %}
<form role="search" method="get" class="woocommerce-product-search" action="{{ home_url('/') }}">
<label class="visually-hidden" for="{{ field_id }}">{{ __('Search for:') }}</label>
<div class="input-group">
<input type="search"
id="{{ field_id }}"
class="form-control"
placeholder="{{ __('Search products…') }}"
value="{{ get_search_query()|esc_attr }}"
name="s" />
<button type="submit" class="btn btn-outline-primary" aria-label="{{ __('Search') }}">
<i class="bi bi-search" aria-hidden="true"></i>
<span class="d-none d-sm-inline ms-1">{{ __('Search') }}</span>
</button>
</div>
<input type="hidden" name="post_type" value="product" />
</form>