static function sanitize_access_caps($caps)
 {
     $return_caps = array();
     foreach ($caps as $post_type => $post_type_caps) {
         /// check is_post_type()
         if (!isset($return_caps[$post_type]) && post_type_exists($post_type)) {
             $return_caps[$post_type] = array();
         }
         foreach ($post_type_caps as $action => $cap) {
             $return_caps[$post_type][$action] = wpaa_sanitize_access_cap($cap);
         }
     }
     return $return_caps;
 }
 static function edit_attachment($attachment_ID)
 {
     $attachment = get_post($attachment_ID);
     $post_edit_cap = isset($_POST['post_edit_cap']) ? wpaa_sanitize_access_cap($_POST['post_edit_cap']) : $attachment->post_edit_cap;
     $post_comment_cap = isset($_POST['post_comment_cap']) ? wpaa_sanitize_access_cap($_POST['post_comment_cap']) : $attachment->post_comment_cap;
     if ($attachment && $post_edit_cap != $attachment->post_edit_cap || $post_comment_cap != $attachment->post_comment_cap) {
         // use $wpdb instead of wp_update_post to avoid inifinite do_action
         global $wpdb;
         $data = array('post_edit_cap' => $post_edit_cap, 'post_comment_cap' => $post_comment_cap);
         $wpdb->update($wpdb->posts, $data, array('ID' => $attachment_ID), array('%s', '%s'), array('%d'));
     }
 }