Leave a Reply

1 comment

  1. function save_portfolio_meta($post_id, $post)
    {
       if (!wp_verify_nonce($_POST['portfoliometa_noncename'], plugin_basename(__FILE__))) return $post->ID;
    
       if (!current_user_can('edit_post', $post_id))
          return $post_id;
    
       $portfolio_meta['_link'] = $_POST['_link'];
       $portfolio_meta['_class'] = $_POST['_class'];
    
       foreach($portfolio_meta as $key => $value)
       {    
          $value = implode(',', (array)$value);
    
          if (get_post_meta($post->ID, $key, FALSE))
          {
             update_post_meta($post->ID, $key, $value);
          }
          else
          {
             add_post_meta($post->ID, $key, $value);
          }
    
          if (!$value)
             delete_post_meta($post->ID, $key);
       }
    }
    
    add_action('save_post', 'save_portfolio_meta', 1, 2);