/** * Collect metadata from all boxes. */ function save_post($post_id, $post) { if ('revision' == $post->post_type || defined('DOING_AJAX')) { return; } if (isset($_POST['p2p_connections'])) { // Loop through the hidden fields instead of through $_POST['p2p_meta'] because empty checkboxes send no data. foreach ($_POST['p2p_connections'] as $p2p_id) { $data = scbForms::get_value(array('p2p_meta', $p2p_id), $_POST, array()); $connection = p2p_get_connection($p2p_id); if (!$connection) { continue; } $fields = p2p_type($connection->p2p_type)->fields; foreach ($fields as $key => &$field) { $field['name'] = $key; } $data = scbForms::validate_post_data($fields, $data); scbForms::update_meta($fields, $data, $p2p_id, 'p2p'); } } // Ordering if (isset($_POST['p2p_order'])) { foreach ($_POST['p2p_order'] as $key => $list) { foreach ($list as $i => $p2p_id) { p2p_update_meta($p2p_id, $key, $i); } } } }