You are here

function _yoast_seo_process_field in Real-time SEO for Drupal 7

Helper function that extracts field values and id's.

Parameters

array $field:

Return value

array

1 call to _yoast_seo_process_field()
yoast_seo_configuration_form_after_build in ./yoast_seo.module
In this afterbuild function we add the configuration to the JavaScript.

File

./yoast_seo.module, line 381
Primary hook implementations for Yoast SEO for Drupal module.

Code

function _yoast_seo_process_field(array $field) {
  $fields_content = array();
  if ((int) $field['#cardinality'] === 1) {

    // Single filed
    // Store the id of field, it can be filled later and we need them for js.
    $fields_content[$field[0]['value']['#id']] = '';
    if (isset($field[0]['value']['#default_value']) && !empty($field[0]['value']['#default_value'])) {
      $fields_content[$field[0]['value']['#id']] = $field[0]['value']['#default_value'];
    }
  }
  else {

    // Multi field.
    for ($i = 0; $i <= $field['#max_delta']; $i++) {
      $fields_content[$field[$i]['value']['#id']] = '';
      if (isset($field[$i]['value']['#default_value']) && !empty($field[$i]['value']['#default_value'])) {
        $fields_content[$field[$i]['value']['#id']] = $field[$i]['value']['#default_value'];
      }
    }
  }
  return $fields_content;
}