如何隐藏搜索栏以及Wordpress菜单

I have a wordpress menu in php, and everything works, however i have a multisite wordpress that has been created, if there is not menu in the Wordpress installation, i want it not to display anything, including the search, my code displays when needed, and when not needed it doesn't display anything but it still displays the search box which is in the menu. Here is my code

<?php $menuClass = 'nav';
$menuID = 'primary-navigation';
$primaryNav = '';
if (function_exists('wp_nav_menu')) {
    $primaryNav = wp_nav_menu( array( 
    'theme_location' => 'primary-nav', 
    'container' => '', 
    'fallback_cb' => '', 
    'menu_class' => $menuClass, 
    'menu_id' => $menuID, 
    'echo' => false ));
};
?>

<nav>
  <div class="navmenu">       
    <div class="wrap">
       <div id="primary-nav">
         <?php echo($primaryNav); ?>
         <div id="header-search" role="search"><form action="bloginfo("url");" method="get" id="search-form"><label><input type="text" name="s" id="site_search" placeholder="Search this site..." /></label><input type="submit" id="search-submit" value="Search" /></form></div>
       </div>
     </div>
  </div>
</nav>

EDIT:

Ok, you need to first look if the nav menu exist

        <?php
        $primaryNav = '';
        if ( has_nav_menu( 'primary-nav' ) ) {
            $primaryNav = wp_nav_menu( array( 
            'theme_location' => 'primary-nav', 
            'container' => '', 
            'fallback_cb' => '', 
            'menu_class' => 'primary-navigation', 
            'menu_id' => 'nav', 
            'echo' => false ));
        }

        $search_out = '<div id="header-search" role="search">
                <form action="bloginfo("url");" method="get" id="search-form">
                    <label><input type="text" name="s" id="site_search" placeholder="Search this site..." /></label>
                    <input type="submit" id="search-submit" value="Search" />
                </form>
            </div>';

        ?>

<nav>
  <div class="navmenu">       
    <div class="wrap">
       <div id="primary-nav">
         <?php ($primaryNav!='') ? _e($primaryNav . $search_out) : '';
         ?>
       </div>
     </div>
  </div>
</nav>

First you check if there is a nav menu in 'primary-nav' location, and if there is, you print it out. Before that, it's empty. And then you check if it's not empty (!=''). If that condition is true it will echo it out, along with search, if not, it won't. You could probably make an if clause that puts the whole <nav> section appear if there is $primaryNav.

EDIT2:

Your old code might also work, just check that it's not empty, with the code above.