Skip to content

Instantly share code, notes, and snippets.

@enishant
Forked from trepmal/!notice.md
Created March 11, 2014 10:24
Show Gist options
  • Save enishant/9483081 to your computer and use it in GitHub Desktop.
Save enishant/9483081 to your computer and use it in GitHub Desktop.
<?php
/*
* Plugin Name: My Sites Search
* Plugin URI: trepmal.com
* Description:
* Version:
* Author: Kailey Lampert
* Author URI: kaileylampert.com
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* TextDomain: mss
* DomainPath:
* Network:
*/
add_action( 'admin_bar_menu', 'mss_admin_bar_menu' );
function mss_admin_bar_menu( $wp_admin_bar ) {
$wp_admin_bar->add_menu( array(
'parent' => 'my-sites-list',
'id' => 'my-sites-search',
'title' => '<input type="text" placeholder="Search sites" />',
) );
}
add_action( 'admin_footer', 'mss_admin_footer' );
function mss_admin_footer() {
// This should suck less, but alas...
?>
<style>
#wp-admin-bar-my-sites-search {
height: 34px;
}
</style>
<script>
jQuery(document).ready( function($) {
$('#wp-admin-bar-my-sites-search input').keyup( function( ) {
var searchValRegex = new RegExp( $(this).val(), 'i');
$('#wp-admin-bar-my-sites-list > li.menupop').hide().filter(function() {
return searchValRegex.test( $(this).find('> a').text() );
}).show();
});
});
</script>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment