Last active
August 29, 2015 14:12
-
-
Save schlessera/0ce16ea021260e63d2c2 to your computer and use it in GitHub Desktop.
Add one or more classes to the Genesis search form's 'Submit' button
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 | |
/** | |
* Add one or more classes to the Genesis search form's 'Submit' button | |
* @author Alain Schlesser ([email protected]) | |
* @link http://www.brightnucleus.com/add-class-wordpress-search-button/ | |
* | |
* @param string $form the search form HTML output | |
* @param string $search_text text inside the search text entry box | |
* @param string $button_text caption of the search button | |
* @param string $label label displayed above the search entry box | |
* @return string modified version of the search form HTML output | |
* | |
* @see http://codex.wordpress.org/Function_Reference/get_search_form | |
* @see http://developer.wordpress.org/reference/hooks/get_search_form/ | |
*/ | |
function as_adapt_search_form( $form, $search_text, $button_text, $label ) { | |
// $form contains the rendered HTML output of the search form | |
// the exact output is changed if your theme has declared HTML5 support | |
// with the following minimum settings: | |
// | |
// add_theme_support( 'html5', array( 'search-form' ) ); | |
// | |
// see http://codex.wordpress.org/Function_Reference/add_theme_support | |
// add Foundation classes to the button class we do a string replace and | |
// search for '<input type="submit"', which is the form declaration of the | |
// button, and then we add a class definition to it | |
$form = str_replace( | |
'<input type="submit"', | |
'<input type="submit" class="small radius button"', | |
$form | |
); | |
// return the modified string | |
return $form; | |
} | |
// run the search form HTML output through the newly defined filter | |
add_filter( 'genesis_search_form', 'as_adapt_search_form' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See article at the Bright Nucleus Homepage: