Last active
February 24, 2016 04:17
-
-
Save srikat/8486571 to your computer and use it in GitHub Desktop.
Expanding Search Box in Genesis. http://sridharkatakam.com/expanding-search-box-genesis/
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
//* Make Font Awesome available | |
add_action( 'wp_enqueue_scripts', 'enqueue_font_awesome' ); | |
function enqueue_font_awesome() { | |
wp_enqueue_style( 'font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css' ); | |
} | |
//* Customize search form input box text | |
add_filter( 'genesis_search_text', 'sp_search_text' ); | |
function sp_search_text( $text ) { | |
return esc_attr( 'Search' ); | |
} | |
//* Customize search form input button text | |
add_filter( 'genesis_search_button_text', 'sk_search_button_text' ); | |
function sk_search_button_text( $text ) { | |
return esc_attr( '' ); | |
} |
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
input:focus::-webkit-input-placeholder { color:transparent; } | |
input:focus:-moz-placeholder { color:transparent; } /* Firefox 18- */ | |
input:focus::-moz-placeholder { color:transparent; } /* Firefox 19+ */ | |
input:focus:-ms-input-placeholder { color:transparent; } /* oldIE ;) */ | |
.genesis-nav-menu .search-form input[type="search"] { | |
padding-right: 3rem; | |
-moz-transition: 400ms width ease; | |
-webkit-transition-duration: 400ms; | |
-webkit-transition-property: width; | |
-webkit-transition-timing-function: ease; | |
-o-transition-duration: 400ms; | |
-o-transition-property: width; | |
-o-transition-timing-function: ease; | |
width: 92px; | |
} | |
.genesis-nav-menu .search-form input[type="search"]:focus { | |
width: 189px; | |
} | |
.search-form { | |
position: relative; | |
} | |
.search-form input[type="submit"] { | |
position: absolute; | |
font-family: FontAwesome; | |
clip: inherit; | |
width: 16px; | |
height: 16px; | |
background: transparent; | |
color: #999; | |
right: 10px; | |
top: 18px; | |
} | |
.search-form input[type="submit"]:hover { | |
color: #F15123; | |
} |
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
//* Add a right aligned search form in Secondary Navigation | |
add_filter( 'genesis_nav_items', 'sk_search_form', 10, 2 ); | |
add_filter( 'wp_nav_menu_items', 'sk_search_form', 10, 2 ); | |
function sk_search_form($menu, $args) { | |
$args = (array)$args; | |
if ( 'secondary' !== $args['theme_location'] ) | |
return $menu; | |
ob_start(); | |
get_search_form(); | |
$search_form = ob_get_clean(); | |
return $menu . '<li class="right">' . $search_form . '</li>'; | |
} |
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
.menu-secondary > .right { | |
padding: 0; | |
margin-top: 1.4rem; | |
} |
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
//* Enqueue Dashicons | |
add_action( 'wp_enqueue_scripts', 'enqueue_dashicons' ); | |
function enqueue_dashicons() { | |
wp_enqueue_style( 'dashicons' ); | |
} | |
//* Customize search form input box text | |
add_filter( 'genesis_search_text', 'sp_search_text' ); | |
function sp_search_text( $text ) { | |
return esc_attr( 'Search' ); | |
} | |
//* Customize search form input button text | |
add_filter( 'genesis_search_button_text', 'sk_search_button_text' ); | |
function sk_search_button_text( $text ) { | |
return esc_attr( '' ); | |
} |
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
.search-form input[type="submit"] { | |
position: absolute; | |
display: inline-block; | |
-webkit-font-smoothing: antialiased; | |
font: normal 20px/1 'dashicons'; | |
vertical-align: top; | |
clip: inherit; | |
width: 20px; | |
height: 20px; | |
background: transparent; | |
color: #999; | |
right: 10px; | |
top: 18px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment