|  | @@ -1,4 +1,5 @@
 | 
											
												
													
														|  |  <?php
 |  |  <?php
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  |   * @file
 |  |   * @file
 | 
											
												
													
														|  |   * Primary hook implementations for Metatag.
 |  |   * Primary hook implementations for Metatag.
 | 
											
										
											
												
													
														|  | @@ -329,7 +330,14 @@ function metatag_config_load_multiple(array $instances) {
 | 
											
												
													
														|  |      foreach ($configs as $instance => &$config) {
 |  |      foreach ($configs as $instance => &$config) {
 | 
											
												
													
														|  |        foreach ($config->config as $tag => &$value) {
 |  |        foreach ($config->config as $tag => &$value) {
 | 
											
												
													
														|  |          if (isset($value['value']) && is_string($value['value'])) {
 |  |          if (isset($value['value']) && is_string($value['value'])) {
 | 
											
												
													
														|  | -          $value['value'] = i18n_string_translate(array('metatag', 'metatag_config', $instance, $tag), $value['value'], $options);
 |  | 
 | 
											
												
													
														|  | 
 |  | +          $value['value'] = i18n_string_translate(array(
 | 
											
												
													
														|  | 
 |  | +            'metatag',
 | 
											
												
													
														|  | 
 |  | +            'metatag_config',
 | 
											
												
													
														|  | 
 |  | +            $instance,
 | 
											
												
													
														|  | 
 |  | +            $tag,
 | 
											
												
													
														|  | 
 |  | +          ),
 | 
											
												
													
														|  | 
 |  | +          $value['value'],
 | 
											
												
													
														|  | 
 |  | +          $options);
 | 
											
												
													
														|  |          }
 |  |          }
 | 
											
												
													
														|  |        }
 |  |        }
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
										
											
												
													
														|  | @@ -432,7 +440,7 @@ function metatag_config_cache_clear() {
 | 
											
												
													
														|  |   * @param mixed $revision_id
 |  |   * @param mixed $revision_id
 | 
											
												
													
														|  |   *   Optional revision ID to load instead of the entity ID.
 |  |   *   Optional revision ID to load instead of the entity ID.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * @return
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @return array
 | 
											
												
													
														|  |   *   An array of tag data keyed by language for the entity's current active
 |  |   *   An array of tag data keyed by language for the entity's current active
 | 
											
												
													
														|  |   *   revision.
 |  |   *   revision.
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
										
											
												
													
														|  | @@ -445,7 +453,7 @@ function metatag_metatags_load($entity_type, $entity_id, $revision_id = NULL) {
 | 
											
												
													
														|  |      $entities = entity_load($entity_type, array($entity_id));
 |  |      $entities = entity_load($entity_type, array($entity_id));
 | 
											
												
													
														|  |      if (!empty($entities[$entity_id])) {
 |  |      if (!empty($entities[$entity_id])) {
 | 
											
												
													
														|  |        // We only care about the revision_id.
 |  |        // We only care about the revision_id.
 | 
											
												
													
														|  | -      list(, $revision_id, ) = entity_extract_ids($entity_type, $entities[$entity_id]);
 |  | 
 | 
											
												
													
														|  | 
 |  | +      list(, $revision_id,) = entity_extract_ids($entity_type, $entities[$entity_id]);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -470,10 +478,10 @@ function metatag_metatags_load($entity_type, $entity_id, $revision_id = NULL) {
 | 
											
												
													
														|  |   *   The entity type to load.
 |  |   *   The entity type to load.
 | 
											
												
													
														|  |   * @param array $entity_ids
 |  |   * @param array $entity_ids
 | 
											
												
													
														|  |   *   The list of entity IDs.
 |  |   *   The list of entity IDs.
 | 
											
												
													
														|  | - * @param array $revision_id
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @param array $revision_ids
 | 
											
												
													
														|  |   *   Optional revision ID to load instead of the entity ID.
 |  |   *   Optional revision ID to load instead of the entity ID.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * @return
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @return array
 | 
											
												
													
														|  |   *   An array of tag data, keyed by entity ID, revision ID and language.
 |  |   *   An array of tag data, keyed by entity ID, revision ID and language.
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  function metatag_metatags_load_multiple($entity_type, array $entity_ids, array $revision_ids = array()) {
 |  |  function metatag_metatags_load_multiple($entity_type, array $entity_ids, array $revision_ids = array()) {
 | 
											
										
											
												
													
														|  | @@ -518,9 +526,7 @@ function metatag_metatags_load_multiple($entity_type, array $entity_ids, array $
 | 
											
												
													
														|  |    // Get all translations of tag data for this entity.
 |  |    // Get all translations of tag data for this entity.
 | 
											
												
													
														|  |    $query = db_select('metatag', 'm')
 |  |    $query = db_select('metatag', 'm')
 | 
											
												
													
														|  |      ->fields('m', array('entity_id', 'revision_id', 'language', 'data'))
 |  |      ->fields('m', array('entity_id', 'revision_id', 'language', 'data'))
 | 
											
												
													
														|  | -    ->condition('m.entity_type', $entity_type)
 |  | 
 | 
											
												
													
														|  | -    ->orderBy('entity_id')
 |  | 
 | 
											
												
													
														|  | -    ->orderBy('revision_id');
 |  | 
 | 
											
												
													
														|  | 
 |  | +    ->condition('m.entity_type', $entity_type);
 | 
											
												
													
														|  |    // Filter by revision_ids if they are available. If not, filter by entity_ids.
 |  |    // Filter by revision_ids if they are available. If not, filter by entity_ids.
 | 
											
												
													
														|  |    if (!empty($revision_ids)) {
 |  |    if (!empty($revision_ids)) {
 | 
											
												
													
														|  |      $query->condition('m.revision_id', $revision_ids, 'IN');
 |  |      $query->condition('m.revision_id', $revision_ids, 'IN');
 | 
											
										
											
												
													
														|  | @@ -575,9 +581,11 @@ function metatag_metatags_load_multiple($entity_type, array $entity_ids, array $
 | 
											
												
													
														|  |   *         'value' => "[node:field_thumbnail]",
 |  |   *         'value' => "[node:field_thumbnail]",
 | 
											
												
													
														|  |   *       ),
 |  |   *       ),
 | 
											
												
													
														|  |   *     ),
 |  |   *     ),
 | 
											
												
													
														|  | - *   );
 |  | 
 | 
											
												
													
														|  | 
 |  | + *   );.
 | 
											
												
													
														|  | 
 |  | + * @param string|null $bundle
 | 
											
												
													
														|  | 
 |  | + *   The bundle of the entity that is being saved. Optional.
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  | -function metatag_metatags_save($entity_type, $entity_id, $revision_id, $metatags) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +function metatag_metatags_save($entity_type, $entity_id, $revision_id, $metatags, $bundle = NULL) {
 | 
											
												
													
														|  |    // Check that $entity_id is numeric because of Entity API and string IDs.
 |  |    // Check that $entity_id is numeric because of Entity API and string IDs.
 | 
											
												
													
														|  |    if (!is_numeric($entity_id)) {
 |  |    if (!is_numeric($entity_id)) {
 | 
											
												
													
														|  |      return;
 |  |      return;
 | 
											
										
											
												
													
														|  | @@ -588,17 +596,17 @@ function metatag_metatags_save($entity_type, $entity_id, $revision_id, $metatags
 | 
											
												
													
														|  |      return;
 |  |      return;
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -  // Verify that the entity can be loaded.
 |  | 
 | 
											
												
													
														|  | -  $entity = entity_load($entity_type, array($entity_id));
 |  | 
 | 
											
												
													
														|  | -  if (empty($entity)) {
 |  | 
 | 
											
												
													
														|  | -    return;
 |  | 
 | 
											
												
													
														|  | 
 |  | +  // Verify the entity bundle is supported, if not available just check the
 | 
											
												
													
														|  | 
 |  | +  // entity type.
 | 
											
												
													
														|  | 
 |  | +  if (!empty($bundle)) {
 | 
											
												
													
														|  | 
 |  | +    if (!metatag_entity_supports_metatags($entity_type, $bundle)) {
 | 
											
												
													
														|  | 
 |  | +      return;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  | -  $entity = reset($entity);
 |  | 
 | 
											
												
													
														|  | -  list(, , $bundle) = entity_extract_ids($entity_type, $entity);
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -  // Don't do anything if the entity bundle is not supported.
 |  | 
 | 
											
												
													
														|  | -  if (!metatag_entity_supports_metatags($entity_type, $bundle)) {
 |  | 
 | 
											
												
													
														|  | -    return;
 |  | 
 | 
											
												
													
														|  | 
 |  | +  else {
 | 
											
												
													
														|  | 
 |  | +    if (!metatag_entity_supports_metatags($entity_type)) {
 | 
											
												
													
														|  | 
 |  | +      return;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |    // The revision_id must be a numeric value; some entities use NULL for the
 |  |    // The revision_id must be a numeric value; some entities use NULL for the
 | 
											
										
											
												
													
														|  | @@ -672,13 +680,13 @@ function metatag_metatags_save($entity_type, $entity_id, $revision_id, $metatags
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  |   * Delete an entity's tags.
 |  |   * Delete an entity's tags.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * @param $entity_type
 |  | 
 | 
											
												
													
														|  | - *   The entity type
 |  | 
 | 
											
												
													
														|  | - * @param $entity_id
 |  | 
 | 
											
												
													
														|  | - *   The entity's ID
 |  | 
 | 
											
												
													
														|  | - * @param $revision_id
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @param string $entity_type
 | 
											
												
													
														|  | 
 |  | + *   The entity type.
 | 
											
												
													
														|  | 
 |  | + * @param int $entity_id
 | 
											
												
													
														|  | 
 |  | + *   The entity's ID.
 | 
											
												
													
														|  | 
 |  | + * @param int $revision_id
 | 
											
												
													
														|  |   *   The entity's VID.
 |  |   *   The entity's VID.
 | 
											
												
													
														|  | - * @param $langcode
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @param string $langcode
 | 
											
												
													
														|  |   *   The language ID of the entry to delete. If left blank, all language
 |  |   *   The language ID of the entry to delete. If left blank, all language
 | 
											
												
													
														|  |   *   entries for this entity will be deleted.
 |  |   *   entries for this entity will be deleted.
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
										
											
												
													
														|  | @@ -699,11 +707,11 @@ function metatag_metatags_delete($entity_type, $entity_id, $revision_id = NULL,
 | 
											
												
													
														|  |   *   The list of IDs.
 |  |   *   The list of IDs.
 | 
											
												
													
														|  |   * @param array $revision_ids
 |  |   * @param array $revision_ids
 | 
											
												
													
														|  |   *   An optional list of revision IDs; if omitted all revisions will be deleted.
 |  |   *   An optional list of revision IDs; if omitted all revisions will be deleted.
 | 
											
												
													
														|  | - * @param $langcode
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @param string $langcode
 | 
											
												
													
														|  |   *   The language ID of the entities to delete. If left blank, all language
 |  |   *   The language ID of the entities to delete. If left blank, all language
 | 
											
												
													
														|  |   *   entries for the enities will be deleted.
 |  |   *   entries for the enities will be deleted.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * @return boolean
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @return bool
 | 
											
												
													
														|  |   *   If any problems were encountered will return FALSE, otherwise TRUE.
 |  |   *   If any problems were encountered will return FALSE, otherwise TRUE.
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  function metatag_metatags_delete_multiple($entity_type, array $entity_ids, array $revision_ids = array(), $langcode = NULL) {
 |  |  function metatag_metatags_delete_multiple($entity_type, array $entity_ids, array $revision_ids = array(), $langcode = NULL) {
 | 
											
										
											
												
													
														|  | @@ -829,7 +837,15 @@ function metatag_entity_load($entities, $entity_type) {
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |    catch (Exception $e) {
 |  |    catch (Exception $e) {
 | 
											
												
													
														|  | -    watchdog('metatag', 'Error loading meta tag data, do the <a href="@update">database updates</a> need to be run? The error occurred when loading record(s) %ids for the %type entity type. The error message was: %error', array('@update' => base_path() . 'update.php', '%ids' => implode(', ', array_keys($entities)), '%type' => $entity_type, '%error' => $e->getMessage()), WATCHDOG_WARNING);
 |  | 
 | 
											
												
													
														|  | 
 |  | +    watchdog('metatag', 'Error loading meta tag data, do the <a href="@update">database updates</a> need to be run? The error occurred when loading record(s) %ids for the %type entity type. The error message was: %error',
 | 
											
												
													
														|  | 
 |  | +      array(
 | 
											
												
													
														|  | 
 |  | +        '@update' => base_path() . 'update.php',
 | 
											
												
													
														|  | 
 |  | +        '%ids' => implode(', ', array_keys($entities)),
 | 
											
												
													
														|  | 
 |  | +        '%type' => $entity_type,
 | 
											
												
													
														|  | 
 |  | +        '%error' => $e->getMessage(),
 | 
											
												
													
														|  | 
 |  | +      ),
 | 
											
												
													
														|  | 
 |  | +    WATCHDOG_WARNING);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |      // Don't display the same message twice for Drush.
 |  |      // Don't display the same message twice for Drush.
 | 
											
												
													
														|  |      if (drupal_is_cli()) {
 |  |      if (drupal_is_cli()) {
 | 
											
												
													
														|  |        drupal_set_message(t('Run your updates, like drush updb.'));
 |  |        drupal_set_message(t('Run your updates, like drush updb.'));
 | 
											
										
											
												
													
														|  | @@ -877,12 +893,12 @@ function metatag_entity_insert($entity, $entity_type) {
 | 
											
												
													
														|  |        unset($entity->metatags[LANGUAGE_NONE]);
 |  |        unset($entity->metatags[LANGUAGE_NONE]);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    // Support for Workbench Moderation v1.
 |  | 
 | 
											
												
													
														|  | 
 |  | +    // Support for Workbench Moderation.
 | 
											
												
													
														|  |      if ($entity_type == 'node' && _metatag_isdefaultrevision($entity)) {
 |  |      if ($entity_type == 'node' && _metatag_isdefaultrevision($entity)) {
 | 
											
												
													
														|  |        return;
 |  |        return;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    metatag_metatags_save($entity_type, $entity_id, $revision_id, $entity->metatags);
 |  | 
 | 
											
												
													
														|  | 
 |  | +    metatag_metatags_save($entity_type, $entity_id, $revision_id, $entity->metatags, $bundle);
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -937,13 +953,13 @@ function metatag_entity_update($entity, $entity_type) {
 | 
											
												
													
														|  |        }
 |  |        }
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -    // Support for Workbench Moderation v1.
 |  | 
 | 
											
												
													
														|  | 
 |  | +    // Support for Workbench Moderation.
 | 
											
												
													
														|  |      if ($entity_type == 'node' && _metatag_isdefaultrevision($entity)) {
 |  |      if ($entity_type == 'node' && _metatag_isdefaultrevision($entity)) {
 | 
											
												
													
														|  |        return;
 |  |        return;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      // Save the record.
 |  |      // Save the record.
 | 
											
												
													
														|  | -    metatag_metatags_save($entity_type, $entity_id, $revision_id, $entity->metatags);
 |  | 
 | 
											
												
													
														|  | 
 |  | +    metatag_metatags_save($entity_type, $entity_id, $revision_id, $entity->metatags, $bundle);
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |    else {
 |  |    else {
 | 
											
												
													
														|  |      // Still ensure the meta tag output is cached.
 |  |      // Still ensure the meta tag output is cached.
 | 
											
										
											
												
													
														|  | @@ -973,10 +989,8 @@ function metatag_field_attach_delete_revision($entity_type, $entity) {
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  |   * @param object $entity
 |  |   * @param object $entity
 | 
											
												
													
														|  |   *   The entity object to generate the metatags instance name for.
 |  |   *   The entity object to generate the metatags instance name for.
 | 
											
												
													
														|  | - *
 |  | 
 | 
											
												
													
														|  |   * @param string $entity_type
 |  |   * @param string $entity_type
 | 
											
												
													
														|  |   *   The entity type of the entity.
 |  |   *   The entity type of the entity.
 | 
											
												
													
														|  | - *
 |  | 
 | 
											
												
													
														|  |   * @param string $bundle
 |  |   * @param string $bundle
 | 
											
												
													
														|  |   *   The bundle of the entity.
 |  |   *   The bundle of the entity.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
										
											
												
													
														|  | @@ -1050,8 +1064,9 @@ function metatag_entity_view($entity, $entity_type, $view_mode, $langcode, $forc
 | 
											
												
													
														|  |   *   TRUE if metatags can be loaded from and saved to the cache. FALSE if the
 |  |   *   TRUE if metatags can be loaded from and saved to the cache. FALSE if the
 | 
											
												
													
														|  |   *   cache should be bypassed.
 |  |   *   cache should be bypassed.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * @return array
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @return mixed
 | 
											
												
													
														|  |   *   A renderable array of metatags for the given entity.
 |  |   *   A renderable array of metatags for the given entity.
 | 
											
												
													
														|  | 
 |  | + *   If this entity object isn't allowed meta tags, return FALSE (empty).
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  function metatag_generate_entity_metatags($entity, $entity_type, $langcode = NULL, $view_mode = 'full', $cached = TRUE) {
 |  |  function metatag_generate_entity_metatags($entity, $entity_type, $langcode = NULL, $view_mode = 'full', $cached = TRUE) {
 | 
											
												
													
														|  |    // Obtain some details of the entity that are needed elsewhere.
 |  |    // Obtain some details of the entity that are needed elsewhere.
 | 
											
										
											
												
													
														|  | @@ -1107,7 +1122,7 @@ function metatag_generate_entity_metatags($entity, $entity_type, $langcode = NUL
 | 
											
												
													
														|  |    $metatag_variants = array();
 |  |    $metatag_variants = array();
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |    // Caching is enabled.
 |  |    // Caching is enabled.
 | 
											
												
													
														|  | -  if ($cached && variable_get('metatag_cache_output', TRUE)) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +  if ($cached && variable_get('metatag_cache_output', FALSE)) {
 | 
											
												
													
														|  |      // All possible variants of the metatags for this entity are stored in a
 |  |      // All possible variants of the metatags for this entity are stored in a
 | 
											
												
													
														|  |      // single cache entry.
 |  |      // single cache entry.
 | 
											
												
													
														|  |      $cid = "output:$entity_type:$entity_id";
 |  |      $cid = "output:$entity_type:$entity_id";
 | 
											
										
											
												
													
														|  | @@ -1210,7 +1225,6 @@ function metatags_get_entity_metatags($entity_id, $entity_type, $langcode = NULL
 | 
											
												
													
														|  |  function metatag_metatags_view($instance, array $metatags = array(), array $options = array()) {
 |  |  function metatag_metatags_view($instance, array $metatags = array(), array $options = array()) {
 | 
											
												
													
														|  |    $output = array();
 |  |    $output = array();
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |    // Convert language codes to a language object.
 |  |    // Convert language codes to a language object.
 | 
											
												
													
														|  |    if (isset($options['language']) && is_string($options['language'])) {
 |  |    if (isset($options['language']) && is_string($options['language'])) {
 | 
											
												
													
														|  |      $languages = language_list();
 |  |      $languages = language_list();
 | 
											
										
											
												
													
														|  | @@ -1265,7 +1279,7 @@ function metatag_metatags_view($instance, array $metatags = array(), array $opti
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  |   * Get the pager string for the current page.
 |  |   * Get the pager string for the current page.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * return @string
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @return string
 | 
											
												
													
														|  |   *   Returns a string based upon the 'metatag_pager_string' variable and the
 |  |   *   Returns a string based upon the 'metatag_pager_string' variable and the
 | 
											
												
													
														|  |   *   current page number.
 |  |   *   current page number.
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
										
											
												
													
														|  | @@ -1279,6 +1293,9 @@ function metatag_get_current_pager() {
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +/**
 | 
											
												
													
														|  | 
 |  | + * Returns metatags values.
 | 
											
												
													
														|  | 
 |  | + */
 | 
											
												
													
														|  |  function metatag_metatags_values($instance, array $metatags = array(), array $options = array()) {
 |  |  function metatag_metatags_values($instance, array $metatags = array(), array $options = array()) {
 | 
											
												
													
														|  |    $values = array();
 |  |    $values = array();
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -1441,13 +1458,15 @@ function metatag_metatags_form(array &$form, $instance, array $metatags = array(
 | 
											
												
													
														|  |          $group = $info['groups'][$group_key] + array('form' => array(), 'description' => NULL);
 |  |          $group = $info['groups'][$group_key] + array('form' => array(), 'description' => NULL);
 | 
											
												
													
														|  |          $form['metatags'][$langcode][$group_key] = $group['form'] + array(
 |  |          $form['metatags'][$langcode][$group_key] = $group['form'] + array(
 | 
											
												
													
														|  |            '#type' => 'fieldset',
 |  |            '#type' => 'fieldset',
 | 
											
												
													
														|  | -          '#title' => t($group['label']),
 |  | 
 | 
											
												
													
														|  | -          '#description' => !empty($group['description']) ? t($group['description']) : '',
 |  | 
 | 
											
												
													
														|  | 
 |  | +          '#title' => $group['label'],
 | 
											
												
													
														|  | 
 |  | +          '#description' => !empty($group['description']) ? $group['description'] : '',
 | 
											
												
													
														|  |            '#collapsible' => TRUE,
 |  |            '#collapsible' => TRUE,
 | 
											
												
													
														|  |            '#collapsed' => TRUE,
 |  |            '#collapsed' => TRUE,
 | 
											
												
													
														|  |          );
 |  |          );
 | 
											
												
													
														|  |        }
 |  |        }
 | 
											
												
													
														|  | -      $form['metatags'][$langcode][$group_key][$metatag] = $metatag_form + array('#parents' => array('metatags', $langcode, $metatag));
 |  | 
 | 
											
												
													
														|  | 
 |  | +      $form['metatags'][$langcode][$group_key][$metatag] = $metatag_form + array(
 | 
											
												
													
														|  | 
 |  | +        '#parents' => array('metatags', $langcode, $metatag),
 | 
											
												
													
														|  | 
 |  | +      );
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |        // Hide the fieldset itself if there is not at least one of the meta tag
 |  |        // Hide the fieldset itself if there is not at least one of the meta tag
 | 
											
												
													
														|  |        // fields visible.
 |  |        // fields visible.
 | 
											
										
											
												
													
														|  | @@ -1551,7 +1570,7 @@ function metatag_metatags_form_submit($form, &$form_state) {
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  |   * Form API submission callback for Commerce product.
 |  |   * Form API submission callback for Commerce product.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * Unlike metatag_metatags_form_submit
 |  | 
 | 
											
												
													
														|  | 
 |  | + * Unlike metatag_metatags_form_submit.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  |   * @see metatag_metatags_save()
 |  |   * @see metatag_metatags_save()
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
										
											
												
													
														|  | @@ -1565,8 +1584,11 @@ function metatag_commerce_product_form_submit($form, &$form_state) {
 | 
											
												
													
														|  |    $entity_id = $product->product_id;
 |  |    $entity_id = $product->product_id;
 | 
											
												
													
														|  |    $revision_id = $product->revision_id;
 |  |    $revision_id = $product->revision_id;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +  // Get the full entity details.
 | 
											
												
													
														|  | 
 |  | +  list(, , $bundle) = entity_extract_ids($entity_type, $product);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |    // Update the meta tags for this entity type.
 |  |    // Update the meta tags for this entity type.
 | 
											
												
													
														|  | -  metatag_metatags_save($entity_type, $entity_id, $revision_id, $form_state['values']['metatags']);
 |  | 
 | 
											
												
													
														|  | 
 |  | +  metatag_metatags_save($entity_type, $entity_id, $revision_id, $form_state['values']['metatags'], $bundle);
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
										
											
												
													
														|  | @@ -1597,7 +1619,7 @@ function metatag_field_extra_fields() {
 | 
											
												
													
														|  |   * enabled during installation. If an entity type is enabled it is assumed that
 |  |   * enabled during installation. If an entity type is enabled it is assumed that
 | 
											
												
													
														|  |   * the entity bundles will also be enabled by default.
 |  |   * the entity bundles will also be enabled by default.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * @see metatag_entity_type_is_suitable().
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @see metatag_entity_type_is_suitable()
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  function metatag_entity_supports_metatags($entity_type = NULL, $bundle = NULL) {
 |  |  function metatag_entity_supports_metatags($entity_type = NULL, $bundle = NULL) {
 | 
											
												
													
														|  |    $entity_types = &drupal_static(__FUNCTION__);
 |  |    $entity_types = &drupal_static(__FUNCTION__);
 | 
											
										
											
												
													
														|  | @@ -1616,7 +1638,7 @@ function metatag_entity_supports_metatags($entity_type = NULL, $bundle = NULL) {
 | 
											
												
													
														|  |          // 'metatag_enable_{$entity_type}' the value FALSE, e.g.:
 |  |          // 'metatag_enable_{$entity_type}' the value FALSE, e.g.:
 | 
											
												
													
														|  |          //
 |  |          //
 | 
											
												
													
														|  |          // // Disable metatags for file_entity.
 |  |          // // Disable metatags for file_entity.
 | 
											
												
													
														|  | -        // $conf['metatag_enable_file'] = FALSE;
 |  | 
 | 
											
												
													
														|  | 
 |  | +        // $conf['metatag_enable_file'] = FALSE;.
 | 
											
												
													
														|  |          //
 |  |          //
 | 
											
												
													
														|  |          // @see Settings page.
 |  |          // @see Settings page.
 | 
											
												
													
														|  |          if (variable_get('metatag_enable_' . $entity_name, FALSE) == FALSE) {
 |  |          if (variable_get('metatag_enable_' . $entity_name, FALSE) == FALSE) {
 | 
											
										
											
												
													
														|  | @@ -1638,7 +1660,7 @@ function metatag_entity_supports_metatags($entity_type = NULL, $bundle = NULL) {
 | 
											
												
													
														|  |              // 'metatag_enable_{$entity_type}__{$bundle}' the value FALSE, e.g.:
 |  |              // 'metatag_enable_{$entity_type}__{$bundle}' the value FALSE, e.g.:
 | 
											
												
													
														|  |              //
 |  |              //
 | 
											
												
													
														|  |              // // Disable metatags for carousel nodes.
 |  |              // // Disable metatags for carousel nodes.
 | 
											
												
													
														|  | -            // $conf['metatag_enable_node__carousel'] = FALSE;
 |  | 
 | 
											
												
													
														|  | 
 |  | +            // $conf['metatag_enable_node__carousel'] = FALSE;.
 | 
											
												
													
														|  |              //
 |  |              //
 | 
											
												
													
														|  |              // @see Settings page.
 |  |              // @see Settings page.
 | 
											
												
													
														|  |              if (variable_get('metatag_enable_' . $entity_name . '__' . $bundle_name, TRUE) == FALSE) {
 |  |              if (variable_get('metatag_enable_' . $entity_name . '__' . $bundle_name, TRUE) == FALSE) {
 | 
											
										
											
												
													
														|  | @@ -1674,30 +1696,51 @@ function metatag_entity_supports_metatags($entity_type = NULL, $bundle = NULL) {
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  | - * Enable support for a specific entity type.
 |  | 
 | 
											
												
													
														|  | 
 |  | + * Enable support for a specific entity type if setting does not exist.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  |   * @param string $entity_type
 |  |   * @param string $entity_type
 | 
											
												
													
														|  | 
 |  | + *    The entity type.
 | 
											
												
													
														|  |   * @param string $bundle
 |  |   * @param string $bundle
 | 
											
												
													
														|  | 
 |  | + *    The bundle of the entity.
 | 
											
												
													
														|  | 
 |  | + * @param bool $force_enable
 | 
											
												
													
														|  | 
 |  | + *   If TRUE, then the type is enabled regardless of any stored variables.
 | 
											
												
													
														|  | 
 |  | + *
 | 
											
												
													
														|  | 
 |  | + * @return bool
 | 
											
												
													
														|  | 
 |  | + *   TRUE if either the bundle or entity type was enabled by this function.
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  | -function metatag_entity_type_enable($entity_type, $bundle = NULL) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +function metatag_entity_type_enable($entity_type, $bundle = NULL, $force_enable = FALSE) {
 | 
											
												
													
														|  |    // The bundle was defined.
 |  |    // The bundle was defined.
 | 
											
												
													
														|  | 
 |  | +  $bundle_set = FALSE;
 | 
											
												
													
														|  |    if (isset($bundle)) {
 |  |    if (isset($bundle)) {
 | 
											
												
													
														|  | -    variable_set('metatag_enable_' . $entity_type . '__' . $bundle, TRUE);
 |  | 
 | 
											
												
													
														|  | 
 |  | +    $stored_bundle = variable_get('metatag_enable_' . $entity_type . '__' . $bundle, NULL);
 | 
											
												
													
														|  | 
 |  | +    if ($force_enable || !isset($stored_bundle)) {
 | 
											
												
													
														|  | 
 |  | +      variable_set('metatag_enable_' . $entity_type . '__' . $bundle, TRUE);
 | 
											
												
													
														|  | 
 |  | +      $bundle_set = TRUE;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |    // Always enable the entity type, because otherwise there's no point in
 |  |    // Always enable the entity type, because otherwise there's no point in
 | 
											
												
													
														|  |    // enabling the bundle.
 |  |    // enabling the bundle.
 | 
											
												
													
														|  | -  variable_set('metatag_enable_' . $entity_type, TRUE);
 |  | 
 | 
											
												
													
														|  | 
 |  | +  $entity_type_set = FALSE;
 | 
											
												
													
														|  | 
 |  | +  $stored_entity_type = variable_get('metatag_enable_' . $entity_type, NULL);
 | 
											
												
													
														|  | 
 |  | +  if ($force_enable || !isset($stored_entity_type)) {
 | 
											
												
													
														|  | 
 |  | +    variable_set('metatag_enable_' . $entity_type, TRUE);
 | 
											
												
													
														|  | 
 |  | +    $entity_type_set = TRUE;
 | 
											
												
													
														|  | 
 |  | +  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |    // Clear the static cache so that the entity type / bundle will work.
 |  |    // Clear the static cache so that the entity type / bundle will work.
 | 
											
												
													
														|  |    drupal_static_reset('metatag_entity_supports_metatags');
 |  |    drupal_static_reset('metatag_entity_supports_metatags');
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +  return $bundle_set || $entity_type_set;
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  |   * Disable support for a specific entity type.
 |  |   * Disable support for a specific entity type.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  |   * @param string $entity_type
 |  |   * @param string $entity_type
 | 
											
												
													
														|  | 
 |  | + *    The entity type.
 | 
											
												
													
														|  |   * @param string $bundle
 |  |   * @param string $bundle
 | 
											
												
													
														|  | 
 |  | + *    The bundle of the entity.
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  function metatag_entity_type_disable($entity_type, $bundle = NULL) {
 |  |  function metatag_entity_type_disable($entity_type, $bundle = NULL) {
 | 
											
												
													
														|  |    // The bundle was defined.
 |  |    // The bundle was defined.
 | 
											
										
											
												
													
														|  | @@ -1744,6 +1787,12 @@ function metatag_page_build(&$page) {
 | 
											
												
													
														|  |      return;
 |  |      return;
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +  // Special consideration for the Me module, which uses the "user/me" path and
 | 
											
												
													
														|  | 
 |  | +  // will cause problems.
 | 
											
												
													
														|  | 
 |  | +  if (arg(0) == 'user' && arg(1) == 'me' && function_exists('me_menu_alter')) {
 | 
											
												
													
														|  | 
 |  | +    return;
 | 
											
												
													
														|  | 
 |  | +  }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |    // The page region can be changed.
 |  |    // The page region can be changed.
 | 
											
												
													
														|  |    $region = variable_get('metatag_page_region', 'content');
 |  |    $region = variable_get('metatag_page_region', 'content');
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -1772,7 +1821,10 @@ function metatag_page_build(&$page) {
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |      else {
 |  |      else {
 | 
											
												
													
														|  |        $metatags = metatag_metatags_view($instance, array());
 |  |        $metatags = metatag_metatags_view($instance, array());
 | 
											
												
													
														|  | -      metatag_cache_set($cid, $metatags);
 |  | 
 | 
											
												
													
														|  | 
 |  | +      // If output caching is enabled, save this for later.
 | 
											
												
													
														|  | 
 |  | +      if (variable_get('metatag_cache_output', FALSE)) {
 | 
											
												
													
														|  | 
 |  | +        metatag_cache_set($cid, $metatags);
 | 
											
												
													
														|  | 
 |  | +      }
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      $page[$region]['metatags'][$instance] = $metatags;
 |  |      $page[$region]['metatags'][$instance] = $metatags;
 | 
											
										
											
												
													
														|  | @@ -1801,7 +1853,10 @@ function metatag_page_build(&$page) {
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |      else {
 |  |      else {
 | 
											
												
													
														|  |        $metatags = metatag_metatags_view($instance, array());
 |  |        $metatags = metatag_metatags_view($instance, array());
 | 
											
												
													
														|  | -      metatag_cache_set($cid, $metatags);
 |  | 
 | 
											
												
													
														|  | 
 |  | +      // If output caching is enabled, save this for later.
 | 
											
												
													
														|  | 
 |  | +      if (variable_get('metatag_cache_output', FALSE)) {
 | 
											
												
													
														|  | 
 |  | +        metatag_cache_set($cid, $metatags);
 | 
											
												
													
														|  | 
 |  | +      }
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |      $page[$region]['metatags'][$instance] = $metatags;
 |  |      $page[$region]['metatags'][$instance] = $metatags;
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
										
											
												
													
														|  | @@ -1810,14 +1865,14 @@ function metatag_page_build(&$page) {
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  |   * Returns whether the current page is the page of the passed in entity.
 |  |   * Returns whether the current page is the page of the passed in entity.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * @param $entity_type
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @param string $entity_type
 | 
											
												
													
														|  |   *    The entity type; e.g. 'node' or 'user'.
 |  |   *    The entity type; e.g. 'node' or 'user'.
 | 
											
												
													
														|  | - * @param $entity
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @param object $entity
 | 
											
												
													
														|  |   *    The entity object.
 |  |   *    The entity object.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * @return
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @return mixed
 | 
											
												
													
														|  |   *   TRUE if the current page is the page of the specified entity, or FALSE
 |  |   *   TRUE if the current page is the page of the specified entity, or FALSE
 | 
											
												
													
														|  | - *   otherwise.
 |  | 
 | 
											
												
													
														|  | 
 |  | + *   otherwise. If $entity_type == 'comment' return empty (FALSE).
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  function _metatag_entity_is_page($entity_type, $entity) {
 |  |  function _metatag_entity_is_page($entity_type, $entity) {
 | 
											
												
													
														|  |    // Exclude comment entities as this conflicts with comment_fragment.module.
 |  |    // Exclude comment entities as this conflicts with comment_fragment.module.
 | 
											
										
											
												
													
														|  | @@ -1828,8 +1883,8 @@ function _metatag_entity_is_page($entity_type, $entity) {
 | 
											
												
													
														|  |    $uri = entity_uri($entity_type, $entity);
 |  |    $uri = entity_uri($entity_type, $entity);
 | 
											
												
													
														|  |    $current_path = current_path();
 |  |    $current_path = current_path();
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -  // Support for Workbench Moderation v1 - if this is a node, check if the
 |  | 
 | 
											
												
													
														|  | -  // content type supports moderation.
 |  | 
 | 
											
												
													
														|  | 
 |  | +  // Support for Workbench Moderation - if this is a node, check if the content
 | 
											
												
													
														|  | 
 |  | +  // type supports moderation.
 | 
											
												
													
														|  |    if ($entity_type == 'node' && function_exists('workbench_moderation_node_type_moderated') && workbench_moderation_node_type_moderated($entity->type) === TRUE) {
 |  |    if ($entity_type == 'node' && function_exists('workbench_moderation_node_type_moderated') && workbench_moderation_node_type_moderated($entity->type) === TRUE) {
 | 
											
												
													
														|  |      return !empty($uri['path']) && ($current_path == $uri['path'] || $current_path == $uri['path'] . '/draft');
 |  |      return !empty($uri['path']) && ($current_path == $uri['path'] || $current_path == $uri['path'] . '/draft');
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
										
											
												
													
														|  | @@ -1929,8 +1984,7 @@ function metatag_field_attach_form($entity_type, $entity, &$form, &$form_state,
 | 
											
												
													
														|  |    $options['context'] = $entity_type;
 |  |    $options['context'] = $entity_type;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |    // @todo Remove metatag_form_alter() when https://www.drupal.org/node/1284642 is fixed in core.
 |  |    // @todo Remove metatag_form_alter() when https://www.drupal.org/node/1284642 is fixed in core.
 | 
											
												
													
														|  | -  //metatag_metatags_form($form, $instance, $metatags, $options);
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | 
 |  | +  // metatag_metatags_form($form, $instance, $metatags, $options);
 | 
											
												
													
														|  |    $form['#metatags'] = array(
 |  |    $form['#metatags'] = array(
 | 
											
												
													
														|  |      'instance' => $instance,
 |  |      'instance' => $instance,
 | 
											
												
													
														|  |      'metatags' => $metatags,
 |  |      'metatags' => $metatags,
 | 
											
										
											
												
													
														|  | @@ -1954,7 +2008,7 @@ function metatag_form_alter(&$form, $form_state, $form_id) {
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  |   * Get the meta tag information array of a meta tag.
 |  |   * Get the meta tag information array of a meta tag.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * @param $metatag
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @param string $name
 | 
											
												
													
														|  |   *   The meta tag name, e.g. description, for which the info shall be returned,
 |  |   *   The meta tag name, e.g. description, for which the info shall be returned,
 | 
											
												
													
														|  |   *   or NULL to return an array with info about all meta tags.
 |  |   *   or NULL to return an array with info about all meta tags.
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
										
											
												
													
														|  | @@ -1968,8 +2022,8 @@ function metatag_get_info($type = NULL, $name = NULL) {
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |    global $language;
 |  |    global $language;
 | 
											
												
													
														|  |    if (!isset($info)) {
 |  |    if (!isset($info)) {
 | 
											
												
													
														|  | -    // hook_metatag_info() includes translated strings, so each language is cached
 |  | 
 | 
											
												
													
														|  | -    // separately.
 |  | 
 | 
											
												
													
														|  | 
 |  | +    // hook_metatag_info() includes translated strings, so each language is
 | 
											
												
													
														|  | 
 |  | +    // cached separately.
 | 
											
												
													
														|  |      $cid = 'info:' . $language->language;
 |  |      $cid = 'info:' . $language->language;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      if ($cache = metatag_cache_get($cid)) {
 |  |      if ($cache = metatag_cache_get($cid)) {
 | 
											
										
											
												
													
														|  | @@ -2009,6 +2063,9 @@ function metatag_get_info($type = NULL, $name = NULL) {
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +/**
 | 
											
												
													
														|  | 
 |  | + * Return instance of metatag.
 | 
											
												
													
														|  | 
 |  | + */
 | 
											
												
													
														|  |  function metatag_get_instance($metatag, array $data = array()) {
 |  |  function metatag_get_instance($metatag, array $data = array()) {
 | 
											
												
													
														|  |    $info = metatag_get_info('tags', $metatag);
 |  |    $info = metatag_get_info('tags', $metatag);
 | 
											
												
													
														|  |    if (!empty($info['class']) && class_exists($info['class'])) {
 |  |    if (!empty($info['class']) && class_exists($info['class'])) {
 | 
											
										
											
												
													
														|  | @@ -2020,16 +2077,16 @@ function metatag_get_instance($metatag, array $data = array()) {
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  |   * Return the string value of a meta tag.
 |  |   * Return the string value of a meta tag.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * @param $metatag
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @param string $metatag
 | 
											
												
													
														|  |   *   The meta tag string.
 |  |   *   The meta tag string.
 | 
											
												
													
														|  | - * @param $data
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @param array $data
 | 
											
												
													
														|  |   *   The array of data for the meta tag class instance.
 |  |   *   The array of data for the meta tag class instance.
 | 
											
												
													
														|  | - * @param $options
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @param array $options
 | 
											
												
													
														|  |   *   An optional array of additional options to pass to the getValue() method
 |  |   *   An optional array of additional options to pass to the getValue() method
 | 
											
												
													
														|  |   *   of the meta tag class instance.
 |  |   *   of the meta tag class instance.
 | 
											
												
													
														|  |   *   - raw: A boolean if TRUE will not perform token replacement.
 |  |   *   - raw: A boolean if TRUE will not perform token replacement.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * @return
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @return string
 | 
											
												
													
														|  |   *   A string value.
 |  |   *   A string value.
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  function metatag_get_value($metatag, array $data, array $options = array()) {
 |  |  function metatag_get_value($metatag, array $data, array $options = array()) {
 | 
											
										
											
												
													
														|  | @@ -2144,7 +2201,7 @@ function metatag_html_head_alter(&$elements) {
 | 
											
												
													
														|  |        'canonical',
 |  |        'canonical',
 | 
											
												
													
														|  |        'shortlink',
 |  |        'shortlink',
 | 
											
												
													
														|  |        // Leave the shortcut icon, that's more of a theming thing.
 |  |        // Leave the shortcut icon, that's more of a theming thing.
 | 
											
												
													
														|  | -      // 'shortcut icon',
 |  | 
 | 
											
												
													
														|  | 
 |  | +      // 'shortcut icon',.
 | 
											
												
													
														|  |      );
 |  |      );
 | 
											
												
													
														|  |      foreach ($elements as $name => &$element) {
 |  |      foreach ($elements as $name => &$element) {
 | 
											
												
													
														|  |        // Ignore meta tags provided by Metatag.
 |  |        // Ignore meta tags provided by Metatag.
 | 
											
										
											
												
													
														|  | @@ -2166,11 +2223,17 @@ function metatag_html_head_alter(&$elements) {
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +/**
 | 
											
												
													
														|  | 
 |  | + * Implements hook_get_form().
 | 
											
												
													
														|  | 
 |  | + */
 | 
											
												
													
														|  |  function metatag_metatag_get_form($metatag, array $data = array(), array $options = array()) {
 |  |  function metatag_metatag_get_form($metatag, array $data = array(), array $options = array()) {
 | 
											
												
													
														|  |    $instance = metatag_get_instance($metatag, $data);
 |  |    $instance = metatag_get_instance($metatag, $data);
 | 
											
												
													
														|  |    return $instance->getForm($options);
 |  |    return $instance->getForm($options);
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +/**
 | 
											
												
													
														|  | 
 |  | + * Returns Instance info if exists otherwise return FALSE.
 | 
											
												
													
														|  | 
 |  | + */
 | 
											
												
													
														|  |  function metatag_config_instance_info($instance = NULL) {
 |  |  function metatag_config_instance_info($instance = NULL) {
 | 
											
												
													
														|  |    global $language;
 |  |    global $language;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -2231,10 +2294,10 @@ function metatag_filter_values_from_defaults(array &$values, array $defaults = a
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  |   * Return all the parents of a given configuration instance.
 |  |   * Return all the parents of a given configuration instance.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * @param $instance
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @param string $instance
 | 
											
												
													
														|  |   *   A meta tag configuration instance.
 |  |   *   A meta tag configuration instance.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * @return
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @return array
 | 
											
												
													
														|  |   *   An array of instances starting with the $instance parameter, with the end
 |  |   *   An array of instances starting with the $instance parameter, with the end
 | 
											
												
													
														|  |   *   of the array being the global instance.
 |  |   *   of the array being the global instance.
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
										
											
												
													
														|  | @@ -2255,7 +2318,7 @@ function metatag_config_get_parent_instances($instance, $include_global = TRUE)
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  |   * Get the proper label of a configuration instance.
 |  |   * Get the proper label of a configuration instance.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * @param $instance
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @param string $instance
 | 
											
												
													
														|  |   *   A meta tag configuration instance.
 |  |   *   A meta tag configuration instance.
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  function metatag_config_instance_label($instance) {
 |  |  function metatag_config_instance_label($instance) {
 | 
											
										
											
												
													
														|  | @@ -2344,19 +2407,19 @@ function metatag_config_is_enabled($instance, $include_defaults = FALSE, $includ
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  | - * Wrapper around entity_language() to use LANGUAGE_NONE if the entity does not
 |  | 
 | 
											
												
													
														|  | - * have a language assigned.
 |  | 
 | 
											
												
													
														|  | 
 |  | + * Wrapper around entity_language().
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * @param $entity_type
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @param mixed $entity_type
 | 
											
												
													
														|  |   *   An entity type's machine name.
 |  |   *   An entity type's machine name.
 | 
											
												
													
														|  | - * @param $entity
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @param object $entity
 | 
											
												
													
														|  |   *   The entity to review; will be typecast to an object if an array is passed.
 |  |   *   The entity to review; will be typecast to an object if an array is passed.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * @return
 |  | 
 | 
											
												
													
														|  | - *   A string indicating the language code to be used.
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @return string
 | 
											
												
													
														|  | 
 |  | + *   A string indicating the language code to be used; returns LANGUAGE_NONE if
 | 
											
												
													
														|  | 
 |  | + *   the entity does not have a language assigned.
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  function metatag_entity_get_language($entity_type, $entity) {
 |  |  function metatag_entity_get_language($entity_type, $entity) {
 | 
											
												
													
														|  | -  // Determine the entity's language, af
 |  | 
 | 
											
												
													
														|  | 
 |  | +  // Determine the entity's language, af.
 | 
											
												
													
														|  |    $langcode = entity_language($entity_type, (object) $entity);
 |  |    $langcode = entity_language($entity_type, (object) $entity);
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |    // If no matching language was found, which will happen for e.g. terms and
 |  |    // If no matching language was found, which will happen for e.g. terms and
 | 
											
										
											
												
													
														|  | @@ -2509,6 +2572,8 @@ function metatag_ctools_render_alter(&$info, $page, $context) {
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  |   * Checks if this entity is the default revision (published).
 |  |   * Checks if this entity is the default revision (published).
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | 
 |  | + * Only needed when running Workbench Moderation v1; v3 is skipped.
 | 
											
												
													
														|  | 
 |  | + *
 | 
											
												
													
														|  |   * @param object $entity
 |  |   * @param object $entity
 | 
											
												
													
														|  |   *   The entity object, e.g., $node.
 |  |   *   The entity object, e.g., $node.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
										
											
												
													
														|  | @@ -2535,11 +2600,16 @@ function _metatag_isdefaultrevision($entity) {
 | 
											
												
													
														|  |    // Every moderation module saving a forward revision needs to return FALSE.
 |  |    // Every moderation module saving a forward revision needs to return FALSE.
 | 
											
												
													
														|  |    // @todo: Refactor this workaround under D8.
 |  |    // @todo: Refactor this workaround under D8.
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -  // Support for Workbench Moderation v1 - if this is a node, check if the
 |  | 
 | 
											
												
													
														|  | -  // content type supports moderation.
 |  | 
 | 
											
												
													
														|  | -  if (function_exists('workbench_moderation_node_type_moderated') && workbench_moderation_node_type_moderated($entity->type) === TRUE) {
 |  | 
 | 
											
												
													
														|  | -    return !empty($entity->workbench_moderation['updating_live_revision']);
 |  | 
 | 
											
												
													
														|  | 
 |  | +  // Workbench Moderation v1 uses the hook_node_presave() for some custom logic.
 | 
											
												
													
														|  | 
 |  | +  // This was replaced with hook_entity_presave() in v3, so only proceed if the
 | 
											
												
													
														|  | 
 |  | +  // old hook implementation is present.
 | 
											
												
													
														|  | 
 |  | +  if (function_exists('workbench_moderation_node_presave')) {
 | 
											
												
													
														|  | 
 |  | +    // If this is a node, check if the content type supports moderation.
 | 
											
												
													
														|  | 
 |  | +    if (function_exists('workbench_moderation_node_type_moderated') && workbench_moderation_node_type_moderated($entity->type) === TRUE) {
 | 
											
												
													
														|  | 
 |  | +      return !empty($entity->workbench_moderation['updating_live_revision']);
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  |    return FALSE;
 |  |    return FALSE;
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -2595,17 +2665,21 @@ function metatag_cache_default_cid_parts(array $cid_parts = array()) {
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  |   * Wrapper for cache_set.
 |  |   * Wrapper for cache_set.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * @see cache_set().
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @see cache_set()
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  function metatag_cache_set($cid, $data) {
 |  |  function metatag_cache_set($cid, $data) {
 | 
											
												
													
														|  | -  // Cache the data for later.
 |  | 
 | 
											
												
													
														|  | -  return cache_set($cid, $data, 'cache_metatag');
 |  | 
 | 
											
												
													
														|  | 
 |  | +  // By default the cached data will not expire.
 | 
											
												
													
														|  | 
 |  | +  $expire = CACHE_PERMANENT;
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +  // Triggers hook_metatag_cache_set_expire_alter().
 | 
											
												
													
														|  | 
 |  | +  drupal_alter("metatag_cache_set_expire", $expire, $cid, $data);
 | 
											
												
													
														|  | 
 |  | +  return cache_set($cid, $data, 'cache_metatag', $expire);
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  |   * Wrapper for cache_get.
 |  |   * Wrapper for cache_get.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  | - * @see cache_get().
 |  | 
 | 
											
												
													
														|  | 
 |  | + * @see cache_get()
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  function metatag_cache_get($cid) {
 |  |  function metatag_cache_get($cid) {
 | 
											
												
													
														|  |    // Try to load the object.
 |  |    // Try to load the object.
 | 
											
										
											
												
													
														|  | @@ -2616,6 +2690,7 @@ function metatag_cache_get($cid) {
 | 
											
												
													
														|  |   * Determines if we are in an error page and return the appropriate instance.
 |  |   * Determines if we are in an error page and return the appropriate instance.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  |   * @return string
 |  |   * @return string
 | 
											
												
													
														|  | 
 |  | + *   String of error.
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  function metatag_is_error_page() {
 |  |  function metatag_is_error_page() {
 | 
											
												
													
														|  |    $known_errors = array(
 |  |    $known_errors = array(
 | 
											
										
											
												
													
														|  | @@ -2651,9 +2726,12 @@ function metatag_admin_menu_cache_info() {
 | 
											
												
													
														|  |   * modes, must be fieldable, and may not be a configuration entity.
 |  |   * modes, must be fieldable, and may not be a configuration entity.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  |   * @param string $entity_type
 |  |   * @param string $entity_type
 | 
											
												
													
														|  | 
 |  | + *    The entity type.
 | 
											
												
													
														|  |   * @param array $entity_info
 |  |   * @param array $entity_info
 | 
											
												
													
														|  | 
 |  | + *    Entity information.
 | 
											
												
													
														|  |   *
 |  |   *
 | 
											
												
													
														|  |   * @return bool
 |  |   * @return bool
 | 
											
												
													
														|  | 
 |  | + *    Return TRUE if suitable.
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  function metatag_entity_type_is_suitable($entity_type, $entity_info = array()) {
 |  |  function metatag_entity_type_is_suitable($entity_type, $entity_info = array()) {
 | 
											
												
													
														|  |    $suitable = TRUE;
 |  |    $suitable = TRUE;
 | 
											
										
											
												
													
														|  | @@ -2719,8 +2797,9 @@ function metatag_entity_type_is_suitable($entity_type, $entity_info = array()) {
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  function metatag_node_type_insert($info) {
 |  |  function metatag_node_type_insert($info) {
 | 
											
												
													
														|  |    if (metatag_entity_supports_metatags('node')) {
 |  |    if (metatag_entity_supports_metatags('node')) {
 | 
											
												
													
														|  | -    metatag_entity_type_enable('node', $info->type);
 |  | 
 | 
											
												
													
														|  | -    drupal_set_message(t('Metatag support has been enabled for the @label content type.', array('@label' => $info->name)));
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (metatag_entity_type_enable('node', $info->type)) {
 | 
											
												
													
														|  | 
 |  | +      drupal_set_message(t('Metatag support has been enabled for the @label content type.', array('@label' => $info->name)));
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -2740,8 +2819,9 @@ function metatag_node_type_delete($info) {
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  function metatag_taxonomy_vocabulary_insert($vocabulary) {
 |  |  function metatag_taxonomy_vocabulary_insert($vocabulary) {
 | 
											
												
													
														|  |    if (metatag_entity_supports_metatags('taxonomy_term')) {
 |  |    if (metatag_entity_supports_metatags('taxonomy_term')) {
 | 
											
												
													
														|  | -    metatag_entity_type_enable('taxonomy_term', $vocabulary->machine_name);
 |  | 
 | 
											
												
													
														|  | -    drupal_set_message(t('Metatag support has been enabled for the @label vocabulary.', array('@label' => $vocabulary->name)));
 |  | 
 | 
											
												
													
														|  | 
 |  | +    if (metatag_entity_type_enable('taxonomy_term', $vocabulary->machine_name)) {
 | 
											
												
													
														|  | 
 |  | +      drupal_set_message(t('Metatag support has been enabled for the @label vocabulary.', array('@label' => $vocabulary->name)));
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  |    }
 |  |    }
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -2764,7 +2844,7 @@ function metatag_workbench_moderation_transition($node, $previous_state, $new_st
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  | - * sort callback for sorting by metatag instance string values.
 |  | 
 | 
											
												
													
														|  | 
 |  | + * Sort callback for sorting by metatag instance string values.
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  function _metatag_config_instance_sort($a, $b) {
 |  |  function _metatag_config_instance_sort($a, $b) {
 | 
											
												
													
														|  |    $a_contexts = explode(':', $a);
 |  |    $a_contexts = explode(':', $a);
 | 
											
										
											
												
													
														|  | @@ -3030,6 +3110,8 @@ function metatag_translations_delete($metatags, $context) {
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  | 
 |  | + * Implements hook_config_insert().
 | 
											
												
													
														|  | 
 |  | + *
 | 
											
												
													
														|  |   * Implements hook_metatag_config_insert() on behalf of i18n_string.
 |  |   * Implements hook_metatag_config_insert() on behalf of i18n_string.
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  function i18n_string_metatag_config_insert($config) {
 |  |  function i18n_string_metatag_config_insert($config) {
 | 
											
										
											
												
													
														|  | @@ -3038,6 +3120,8 @@ function i18n_string_metatag_config_insert($config) {
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  | 
 |  | + * Implements hook_config_update().
 | 
											
												
													
														|  | 
 |  | + *
 | 
											
												
													
														|  |   * Implements hook_metatag_config_update() on behalf of i18n_string.
 |  |   * Implements hook_metatag_config_update() on behalf of i18n_string.
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  function i18n_string_metatag_config_update($config) {
 |  |  function i18n_string_metatag_config_update($config) {
 | 
											
										
											
												
													
														|  | @@ -3046,6 +3130,8 @@ function i18n_string_metatag_config_update($config) {
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |  /**
 |  |  /**
 | 
											
												
													
														|  | 
 |  | + * Implements hook_config_delete().
 | 
											
												
													
														|  | 
 |  | + *
 | 
											
												
													
														|  |   * Implements hook_metatag_config_delete() on behalf of i18n_string.
 |  |   * Implements hook_metatag_config_delete() on behalf of i18n_string.
 | 
											
												
													
														|  |   */
 |  |   */
 | 
											
												
													
														|  |  function i18n_string_metatag_config_delete($config) {
 |  |  function i18n_string_metatag_config_delete($config) {
 |