title: Metabox save function looks like that it doesn't work
body: <p>I'm currently working on creating meta boxes. I used the following tutorial and some self-adapted. Link of tutorial: <a href="http://wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-1-intro-and-basic-fields/" rel="nofollow noreferrer">http://wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-part-1-intro-and-basic-fields/</a></p>
  
  <p>Now I get the following error message:</p>
  
  <blockquote>
    <p>Notice: Undefined index: dsmeta_image in
    /customers/0/d/a/xxx/httpd.www/wordpress/wp-content/plugins/ds-flexslider/includes/cpt-manager.php
    on line 181 Notice: Undefined index: dsmeta_image_caption in
    /customers/0/d/a/xxx/httpd.www/wordpress/wp-content/plugins/ds-flexslider/includes/cpt-manager.php
    on line 181</p>
  </blockquote>
  
  <p>It seems that the variable does not exist, I'm using an array fields for Metabox and created a foreach loop walk you through it if I understand correctly.</p>
  
  <p>How is this problem.
  It is in any event error when saving the meta boxes ...</p>
  
  <p>The part of setting up the fields array:</p>
  
  <pre><code>// Create the fields array
  $prefix = 'dsmeta_';
  $custom_meta_fields = array(
      array(
          'label' =&gt; 'Image',
          'desc' =&gt; '',
          'id' =&gt; $prefix . 'image',
          'type' =&gt; 'image'
      ),
      array(
          'label' =&gt; 'Image caption',
          'desc' =&gt; '',
          'id' =&gt; $prefix . 'image_caption',
          'type' =&gt; 'text'
      )
  );
  </code></pre>
  
  <p>Part of the saving function:</p>
  
  <pre><code>add_action('save_post', 'dsslider_manager_save_extras');
  function dsslider_manager_save_extras($post_id) {
      global $custom_meta_fields;
  
      if (defined('DOING_AUTOSAVE') &amp;&amp; DOING_AUTOSAVE) {
          return $post_id;
      }
  
      // loop through fields and save the data
      foreach ($custom_meta_fields as $field) {
          $old = get_post_meta($post_id, $field['id'], true);
          $new = $_POST[$field['id']];
          if ($new &amp;&amp; $new != $old) {
              update_post_meta($post_id, $field['id'], $new);
          } elseif ('' == $new &amp;&amp; $old) {
              delete_post_meta($post_id, $field['id'], $old);
          }
      } // end foreach
  }
  </code></pre>
  
  <h2>Update after request</h2>
  
  <p>Here I add the meta box for the fields :</p>
  
  <pre><code>    // Add meta box support
  // This registers a function to be called when the WordPress admin interface is visited
  add_action("admin_init", "dsslider_manager_add_meta");
  function dsslider_manager_add_meta(){
  
      // Create this cool new meta box for Portfolio Options
      add_meta_box("dsslider-meta", "Brandbox Options", "dsslider_manager_meta_options", "brandbox-slider", "normal", "high");
  }
  </code></pre>
  
  <p>And here is the function for building the meta fields :</p>
  
  <pre><code>function dsslider_manager_meta_options(){
  
      global $custom_meta_fields, $post;
      if(defined('DOING_AUTOSAVE') &amp;&amp; DOING_AUTOSAVE )
          // (integer) (optional) The post ID whose custom fields will be retrieved. 
          // Default: Current post
          return $post_id;
  ?&gt;
  
  &lt;div class="dsslider_manager_extras"&gt;
  
      &lt;div class="ds-metabox" data-max_rows="5" data-min_rows="0"&gt;
  
          &lt;table class="meta ds-input-table"&gt;
  
  &lt;?php
  
  
          foreach ($custom_meta_fields as $field) {
              $custom = get_post_meta($post-&gt;ID, $field['id'], true); // Returns a multidimensional array with all custom fields of a particular post or page. 
  
              // Past HTML markup
  ?&gt;          
  
              &lt;tbody class="ui-sortable"&gt;
              &lt;?php 
  
                  echo '&lt;tr class="row"&gt;';
                  echo '&lt;td class="order"&gt;&lt;/td&gt;';
                  echo '&lt;td&gt;';
  
                  switch($field['type']) {
                      // case items will go here
  
                      // image
                      case 'image':
                          $image = get_template_directory_uri().'/images/image.png';
                          echo '&lt;span class="custom_default_image" style="display:none"&gt;'.$image.'&lt;/span&gt;';
  
                          if($custom) { 
                              $image = wp_get_attachment_image_src($custom, 'thumbnail'); 
                              $image = $image[0]; 
  
                          } // end if statement
  
                          echo '&lt;img src="' . $image . '" class="custom_preview_image" alt="" /&gt;
  
                          &lt;input type="button" class="button add-image" name="' . $field['id'] . '" value="' . $custom . '"&gt;&lt;a href="#" class="remove-image"&gt;Remove Image&lt;/a&gt;';
                      break;
  
                      // text
                      case 'text':
  
                          echo '&lt;input type="text" class="text" name="' . $field['id'] . '" value="' . $custom . '"&gt;';
  
                      break;
  
                  } //end switch
  
                  echo '&lt;/td&gt;';
                  echo '&lt;/tr&gt;';
  
          } // End foreach loop
               ?&gt;
              &lt;/tbody&gt;
          &lt;/table&gt;&lt;!-- End .meta ds-input-table --&gt;
  
          &lt;ul class="ds-repeater-footer hl clearfix"&gt;
              &lt;li class="right"&gt;
                  &lt;a href="#" class="repeatable-add ds-button"&gt;Add New Slide&lt;/a&gt;
              &lt;/li&gt;
          &lt;/ul&gt;&lt;!-- End ul.hl clearfix repeater-footer --&gt;
  
      &lt;/div&gt;&lt;!-- End .ds-metabox --&gt;
  
  &lt;/div&gt;&lt;!-- End .dsslider_manager_extras --&gt;
  
  &lt;?php           
  }
  </code></pre>