metatag_google_cse.module 928 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * @file
  4. * Primary hook implementations for Metatag:Google CSE.
  5. */
  6. /**
  7. * Implements hook_ctools_plugin_api().
  8. */
  9. function metatag_google_cse_ctools_plugin_api($owner, $api) {
  10. if ($owner == 'metatag' && $api == 'metatag') {
  11. return array('version' => 1);
  12. }
  13. }
  14. /**
  15. * Implements hook_theme().
  16. */
  17. function metatag_google_cse_theme() {
  18. $info['metatag_google_cse'] = array(
  19. 'render element' => 'element',
  20. );
  21. return $info;
  22. }
  23. /**
  24. * Theme callback for a normal meta tag.
  25. *
  26. * The format is:
  27. * <meta name="[name]" content="[value]" />
  28. */
  29. function theme_metatag_google_cse($variables) {
  30. $element = &$variables['element'];
  31. if ($element['#name'] === 'google_rating') {
  32. $element['#name'] = 'rating';
  33. }
  34. $args = array(
  35. '#name' => 'name',
  36. '#value' => 'content',
  37. );
  38. element_set_attributes($element, $args);
  39. unset($element['#value']);
  40. return theme('html_tag', $variables);
  41. }