You are here

function yoast_seo_install in Real-time SEO for Drupal 7

Same name and namespace in other branches
  1. 8 yoast_seo.install \yoast_seo_install()

Implements hook_install().

See also

metatag_install()

File

./yoast_seo.install, line 73
Install, update, and uninstall functions for the Yoast SEO for Drupal module.

Code

function yoast_seo_install() {
  $entity_type = 'node';

  // Always enable the node entity.
  variable_set('yoast_seo_enable_' . $entity_type, TRUE);

  // Update each entity bundle too.
  $entity_info = entity_get_info($entity_type);
  if (!empty($entity_info['bundles'])) {
    foreach ($entity_info['bundles'] as $bundle_name => $bundle_info) {
      $fields = field_info_instances($entity_type, $bundle_name);
      $variable_name = 'yoast_seo_enable_' . $entity_type . '__' . $bundle_name;

      // Enable Yoast SEO for Drupal when the body field is present.
      if (isset($fields['body'])) {
        variable_set($variable_name, TRUE);
      }
      else {
        variable_set($variable_name, FALSE);
      }
    }
  }
}