Created
November 4, 2020 22:19
-
-
Save tomusborne/e31af0f7cbc335a96c74553b86e95e18 to your computer and use it in GitHub Desktop.
Make GP search widget search products
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The template for displaying search forms in Generate | |
* | |
* @package GeneratePress | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; // Exit if accessed directly. | |
} | |
?> | |
<form method="get" class="search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>"> | |
<label> | |
<span class="screen-reader-text"><?php echo apply_filters( 'generate_search_label', _x( 'Search for:', 'label', 'generatepress' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span> | |
<input type="search" class="search-field" placeholder="<?php echo esc_attr( apply_filters( 'generate_search_placeholder', _x( 'Search …', 'placeholder', 'generatepress' ) ) ); ?>" value="<?php echo esc_attr( get_search_query() ); ?>" name="s" title="<?php echo esc_attr( apply_filters( 'generate_search_label', _x( 'Search for:', 'label', 'generatepress' ) ) ); ?>"> | |
<input type="hidden" name="post_type" value="product" /> | |
</label> | |
<?php | |
if ( generate_is_using_flexbox() ) { | |
printf( | |
'<button class="search-submit" aria-label="%1$s">%2$s</button>', | |
esc_attr( apply_filters( 'generate_search_button', _x( 'Search', 'submit button', 'generatepress' ) ) ), | |
generate_get_svg_icon( 'search' ) // phpcs:ignore -- Escaping not necessary here. | |
); | |
} else { | |
printf( | |
'<input type="submit" class="search-submit" value="%s">', | |
apply_filters( 'generate_search_button', _x( 'Search', 'submit button', 'generatepress' ) ) // phpcs:ignore -- Escaping not necessary here. | |
); | |
} | |
?> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment