/** * relate_field * Determine the default object id to relate to a field. * * @param array $field The field object. * * @access public * @static * @since 1.0 */ public static function relate_field($field) { global $wpdb; if (!isset($field['relate']) || !isset($field['relate']['scope'])) { return $field; } // Get the id of what we are relating the field to if (!isset($field['relate']['field'])) { switch ($field['relate']['scope']) { case 'post': case 'post_meta': $field['relate_to'] = piklist_admin::is_post(); break; case 'user': case 'user_meta': $field['relate_to'] = piklist_admin::is_user(); break; case 'comment': case 'comment_meta': $field['relate_to'] = piklist_admin::is_comment(); break; } } if (in_array($field['scope'], array('post_meta', 'user_meta', 'comment_meta'))) { $field['value'] = self::get_object_ids($field['object_id'], $field['scope'], $field['relate']['scope']); } else { $field['object_id'] = self::get_object_ids($field['object_id'], $field['scope'], $field['relate']['scope']); } return $field; }