title: When I move a Wordpress custom option menu to the top level it stop saving input settings?
body: <p>This code adds a menu in the Settings section of Wordpress' administrator </p>
  
  <p>Right now <code>add_options_page</code> is declared, so the custom menu appears inside <strong>Settings</strong></p>
  
  <p>I changed <strong>add_options_page</strong> to <strong>add_menu_page</strong> in order to bring that menu to the top-level, but then it stopped working (when I click the custom menu opens, but can't save settings anymore).</p>
  
  <p>What's the remaining code I have to change in order to make this work?</p>
  
  <p>Thanks in advance!</p>
  
  <pre><code>&lt;?php
  
  add_action('admin_menu', 'create_theme_options_page');
  add_action('admin_init', 'register_and_build_fields');
  
  function create_theme_options_page() {
     add_options_page('Theme Options', 'Theme Options', 'administrator', __FILE__, 'options_page_fn');
  }
  
  function register_and_build_fields() {
     register_setting('plugin_options', 'plugin_options', 'validate_setting');
  
     add_settings_section('main_section', 'Main Settings', 'section_cb', __FILE__);
  
     add_settings_field('color_scheme', 'Color Scheme:', 'color_scheme_setting', __FILE__, 'main_section');
     add_settings_field('logo', 'Logo:', 'logo_setting', __FILE__, 'main_section'); // LOGO
     add_settings_field('banner_heading', 'Banner Heading:', 'banner_heading_setting', __FILE__, 'main_section');
     add_settings_field('adverting_information', 'Advertising Info:', 'advertising_information_setting', __FILE__, 'main_section');
  
     add_settings_field('ad_one', 'Ad:', 'ad_setting_one', __FILE__, 'main_section'); // Ad1
     add_settings_field('ad_two', 'Second Ad:', 'ad_setting_two', __FILE__, 'main_section'); // Ad2
  }
  
  function options_page_fn() {
  ?&gt;
  &lt;div id="theme-options-wrap" class="widefat"&gt;
  &lt;div class="icon32" id="icon-tools"&gt;&lt;/div&gt;
  
  &lt;h2&gt;My Theme Options&lt;/h2&gt;
  &lt;p&gt;Take control of your theme, by overriding the default settings with your own specific preferences.&lt;/p&gt;
  
  &lt;form method="post" action="options.php" enctype="multipart/form-data"&gt;
  &lt;?php settings_fields('plugin_options'); ?&gt;
  &lt;?php do_settings_sections(__FILE__); ?&gt;
  &lt;p class="submit"&gt;
  &lt;input name="Submit" type="submit" class="button-primary" value="&lt;?php esc_attr_e('Save Changes'); ?&gt;" /&gt;
  &lt;/p&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  &lt;?php
  }
  
  // Banner Heading
  function banner_heading_setting() {
     $options = get_option('plugin_options');
     echo "&lt;input name='plugin_options[banner_heading]' type='text' value='{$options['banner_heading']}' /&gt;";
  }
  
  // Color Scheme
  function color_scheme_setting() {
     $options = get_option('plugin_options');
     $items = array("White", "Black", "#DDDDDD", "#444444");
  
     echo "&lt;select name='plugin_options[color_scheme]'&gt;";
     foreach ($items as $item) {
        $selected = ( $options['color_scheme'] === $item ) ? 'selected = "selected"' : '';
        echo "&lt;option value='$item' $selected&gt;$item&lt;/option&gt;";
     }
     echo "&lt;/select&gt;";
  }
  
  // Advertising info
  function advertising_information_setting() {
     $options = get_option('plugin_options');
     echo "&lt;textarea name='plugin_options[advertising_information]' rows='10' cols='60' type='textarea'&gt;{$options['advertising_information']}&lt;/textarea&gt;";
  }
  
  // Ad one
  function ad_setting_one() {
     echo '&lt;input type="file" name="ad_one" /&gt;';
  }
  
  // Ad two
  function ad_setting_two() {
     echo '&lt;input type="file" name="ad_two" /&gt;';
  }
  
  // Logo
  function logo_setting() {
     echo '&lt;input type="file" name="logo" /&gt;';
  }
  
  function validate_setting($plugin_options) {
     $keys = array_keys($_FILES);
     $i = 0;
  
     foreach ($_FILES as $image) {
        // if a files was upload
        if ($image['size']) {
           // if it is an image
           if (preg_match('/(jpg|jpeg|png|gif)$/', $image['type'])) {
              $override = array('test_form' =&gt; false);
              $file = wp_handle_upload($image, $override);
  
              $plugin_options[$keys[$i]] = $file['url'];
           } else {
              $options = get_option('plugin_options');
              $plugin_options[$keys[$i]] = $options[$logo];
              wp_die('No image was uploaded.');
           }
        }
  
        // else, retain the image that's already on file.
        else {
           $options = get_option('plugin_options');
           $plugin_options[$keys[$i]] = $options[$keys[$i]];
        }
        $i++;
     }
  
     return $plugin_options;
  }
  
  function section_cb() {}
  
  // Add stylesheet
  add_action('admin_head', 'admin_register_head');
  
  function admin_register_head() {
     $url = get_bloginfo('template_directory') . '/functions/options_page.css';
     echo "&lt;link rel='stylesheet' href='$url' /&gt;\n";
  }
  </code></pre>