• pg

    (@dethredic)


    I would like to add a drop down menu to the top bar of the wordpress admin area, beside where it says “Howdy, xxxxxxx”. There will be 7 choices that I will add manually, and I want to run some Javascript on selection.

    Firstly, where would I go about adding such code, and secondly, how would I create the drop down?

Viewing 1 replies (of 1 total)
  • Thread Starter pg

    (@dethredic)

    I added the following code in my admin-header.php:

    <?php
    
    do_action('in_admin_header');
    
    $locationlinks = array();
    
    // Generate user profile and info links.
    $locationlinks[5] = 'Change Location';
    
    $locationlinks[8] = '<a href="https://google.ca">google1</a>';
    
    $locationlinks[15] = '<a href="https://google.ca">google2</a>';
    
    $locationlinks = apply_filters( 'admin_user_info_links', $locationlinks, $current_user );
    ksort( $locationlinks );
    
    // Trim whitespace and pipes from links, then convert to list items.
    $locationlinks = array_map( 'trim', $locationlinks, array_fill( 0, count( $locationlinks ), " |\n\t" ) );
    
    $locationlinks_howdy = array_shift( $locationlinks );
    
    $locationlinks_no_js = implode( ' | ', $locationlinks );
    $locationlinks_js = '<li>' . implode( '</li><li>', $locationlinks ) . '</li>';
    
    ?>
    
    <div id="wphead-info">
    <div id="user_info">
    	<p class="hide-if-js"><?php echo "$locationlinks_howdy | $locationlinks_no_js"; ?></p>
    
    	<div class="hide-if-no-js">
    		<p><?php echo $locationlinks_howdy; ?></p>
    		<div id="user_info_arrow"></div>
    		<div id="user_info_links_wrap"><div id="user_info_links">
    			<ul><?php echo $locationlinks_js; ?></ul>
    		</div></div>
    	</div>
    </div>
    </div>

    Which gives me a title, but I can’t click to expand it like the user one.

Viewing 1 replies (of 1 total)
  • The topic ‘Add a drop down menu to the wordpress admin area’ is closed to new replies.