WordPress Snippets at WPcustoms

Search the codex right from your admin bar

A little search dropdown box is added to your admin bar with this code snippet. Enter a search term and it directly sends you to the codex search results pages. If you develop plugins and themes this might be a nice time saver. The searchbox currently does not blend perfectly into the css admin setup so if anyone knows the correct css classes please leave a comment.


/**
 * Snippet Name: Search the codex right from your admin bar
 * Snippet URL: https://wpcustoms.net/snippets/search-codex-right-admin-bar/
 */
  function wpc_codex_search_form() {
    global $wp_admin_bar, $wpdb;

    if ( !is_super_admin() || !is_admin_bar_showing() )
        return;

    $codex_search = '
    
'; /* Add the main siteadmin menu item */ $wp_admin_bar->add_menu( array( 'id' => 'codex_search', 'title' => __( 'Search the Codex', 'textdomain' ), 'href' => FALSE ) ); $wp_admin_bar->add_menu( array( 'parent' => 'codex_search', 'title' => $codex_search, 'href' => FALSE ) ); } add_action( 'admin_bar_menu', 'wpc_codex_search_form', 1000 );