WordPress Function to Add a codex search form to the dashboard header

Add a codex search form to the dashboard header

This is a simple way to add a codex search form to the dashboard header, on the top-right next to the quicklinks drop-down.

/**
 * ADD WP CODEX SEARCH FORM TO DASHBOARD HEADER
 */
function wp_codex_search_form() {
    echo '<form target="_blank" method="get" action="http://wordpress.org/search/do-search.php" class="alignright" style="margin: 11px 5px 0;">
        <input type="text" onblur="this.value=(this.value==\'\') ? \'Search the Codex\' : this.value;" onfocus="this.value=(this.value==\'Search the Codex\') ? \'\' : this.value;" maxlength="150" value="Search the Codex" name="search" class="text"> <input type="submit" value="Go" class="button" />
    </form>';
}

if( current_user_can( 'manage_plugins' )) {
// The number 11 needs to be a 10 for this to work!
    add_filter( 'in_admin_header', 'wp_codex_search_form', 11 );
}

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *