Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
Created August 24, 2020 03:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaineLabs/13716529ff397c698522d9e561bee5c3 to your computer and use it in GitHub Desktop.
Save KaineLabs/13716529ff397c698522d9e561bee5c3 to your computer and use it in GitHub Desktop.
Hide Members Directory Search Form If Input is Empty
<?php
/**
* Hide Members Directory Search Form If Input is Empty.
*/
function yzc_hide_search_button() { ?>
<style type="text/css">#yz-directory-search-box form input#members_search_submit{display: none;}</style>
<script type="text/javascript">
( function( $ ) {
'use strict';
$( document ).ready( function() {
$( document ).on( 'keypress keyup paste', '#members_search', function() {
if ( $ ( this ).val() == '' ) {
$( '#members_search_submit' ).fadeOut();
} else {
$( '#members_search_submit' ).fadeIn();
}
});
});
})( jQuery );
</script>
<?php
}
add_action( 'wp_head' , 'yzc_hide_search_button', 999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment