/**
  * Makes sure no required custom field is missing from the data passed.
  *
  * @since 3.2.0
  *
  * @param array $data Array of data to check
  *
  * @return bool|WP_Error False if no field is missing, WP_Error with the list of missing fields otherwise
  */
 public function is_field_missing($data = array())
 {
     if (empty($data) && !empty($_POST)) {
         $data = $_POST;
     }
     $fields = $this->get_custom_fields();
     /* Set the result as true by default, which is the "green light" value */
     $result = false;
     foreach ($fields as $field_id => $field) {
         /**
          * Get the custom field object.
          */
         $custom_field = new WPAS_Custom_Field($field_id, $field);
         /* Prepare the field name as used in the form */
         $field_name = $custom_field->get_field_id();
         if (true === $field['args']['required'] && false === $field['args']['core']) {
             if (!isset($data[$field_name]) || empty($data[$field_name])) {
                 /* Get field title */
                 $title = !empty($field['args']['title']) ? $field['args']['title'] : wpas_get_title_from_id($field['name']);
                 /* Add the error message for this field. */
                 if (!is_object($result)) {
                     $result = new WP_Error('required_field_missing', sprintf(__('The field %s is required.', 'wpas'), "<a href='#{$field_name}'><code>{$title}</code></a>", array('errors' => $field_name)));
                 } else {
                     $result->add('required_field_missing', sprintf(__('The field %s is required.', 'wpas'), "<code>{$title}</code>", array('errors' => $field_name)));
                 }
             }
         }
     }
     return $result;
 }
 public function test_get_field_id_save()
 {
     $this->assertEquals('_wpas_my_test_field', $this->text_field->get_field_id(true));
 }