Created
December 4, 2016 12:48
-
-
Save ciaranha/c045df3504d8fba050d32c3e3e6cda05 to your computer and use it in GitHub Desktop.
search form
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 | |
// search-form same behavior as genesis with additional classes | |
// for bootstrap styling | |
add_filter( 'genesis_search_form', 'bsg_search_form', 10, 4); | |
function bsg_search_form( $form, $search_text, $button_text, $label ) { | |
$value_or_placeholder = ( get_search_query() == '' ) ? 'placeholder' : 'value'; | |
$format = <<<EOT | |
<form method="get" class="search-form form-inline" action="%s" role="search"> | |
<div class="form-group"> | |
<label class="sr-only sr-only-focusable" for="bsg-search-form">%s</label> | |
<div class="input-group"> | |
<input type="search" class="search-field form-control" id="bsg-search-form" name="s" %s="%s"> | |
<span class="input-group-btn"> | |
<button type="submit btn-icon"> | |
<i class="fa fa-search"></i> | |
</button> | |
</span> | |
</div> | |
</div> | |
</form> | |
EOT; | |
return sprintf( $format, home_url( '/' ), esc_html( $label ), $value_or_placeholder, esc_attr( $search_text ), esc_attr( $button_text ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment