metatag.metatag.inc 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  1. <?php
  2. /**
  3. * Implements hook_metatag_config_default().
  4. */
  5. function metatag_metatag_config_default() {
  6. // Optionally skip loading the defaults.
  7. if (!variable_get('metatag_load_defaults', TRUE)) {
  8. return;
  9. }
  10. $configs = array();
  11. $config = new stdClass();
  12. $config->instance = 'global';
  13. $config->api_version = 1;
  14. $config->disabled = FALSE;
  15. $config->config = array(
  16. 'title' => array('value' => '[current-page:title] | [current-page:pager][site:name]'),
  17. 'generator' => array('value' => 'Drupal 7 (http://drupal.org)'),
  18. 'canonical' => array('value' => '[current-page:url:absolute]'),
  19. 'shortlink' => array('value' => '[current-page:url:unaliased]'),
  20. );
  21. $configs[$config->instance] = $config;
  22. $config = new stdClass();
  23. $config->instance = 'global:frontpage';
  24. $config->api_version = 1;
  25. $config->disabled = FALSE;
  26. $config->config = array(
  27. 'title' => array('value' => variable_get('site_slogan') ? '[site:name] | [current-page:pager][site:slogan]' : '[site:name] | [current-page:pager]'),
  28. 'canonical' => array('value' => '[site:url]'),
  29. 'shortlink' => array('value' => '[site:url]'),
  30. );
  31. $configs[$config->instance] = $config;
  32. $config = new stdClass();
  33. $config->instance = 'global:403';
  34. $config->api_version = 1;
  35. $config->disabled = FALSE;
  36. $config->config = array(
  37. 'canonical' => array('value' => '[site:url]'),
  38. 'shortlink' => array('value' => '[site:url]'),
  39. );
  40. $configs[$config->instance] = $config;
  41. $config = new stdClass();
  42. $config->instance = 'global:404';
  43. $config->api_version = 1;
  44. $config->disabled = FALSE;
  45. $config->config = array(
  46. 'canonical' => array('value' => '[site:url]'),
  47. 'shortlink' => array('value' => '[site:url]'),
  48. );
  49. $configs[$config->instance] = $config;
  50. $config = new stdClass();
  51. $config->instance = 'node';
  52. $config->api_version = 1;
  53. $config->disabled = FALSE;
  54. $config->config = array(
  55. 'title' => array('value' => '[node:title] | [current-page:pager][site:name]'),
  56. 'description' => array('value' => '[node:summary]'),
  57. );
  58. $configs[$config->instance] = $config;
  59. if (module_exists('taxonomy')) {
  60. $config = new stdClass();
  61. $config->instance = 'taxonomy_term';
  62. $config->api_version = 1;
  63. $config->disabled = FALSE;
  64. $config->config = array(
  65. 'title' => array('value' => '[term:name] | [current-page:pager][site:name]'),
  66. 'description' => array('value' => '[term:description]'),
  67. );
  68. $configs[$config->instance] = $config;
  69. }
  70. $config = new stdClass();
  71. $config->instance = 'user';
  72. $config->api_version = 1;
  73. $config->disabled = FALSE;
  74. $config->config = array(
  75. 'title' => array('value' => '[user:name] | [site:name]'),
  76. );
  77. if (variable_get('user_pictures')) {
  78. $config->config['image_src'] = array('value' => '[user:picture:url]');
  79. }
  80. $configs[$config->instance] = $config;
  81. // Before returning these, allow the bundled submodules to override them, thus
  82. // extending the "real" defaults before they can then be altered by other
  83. // modules.
  84. // See hook_metatag_bundled_config_alter() in the API documentation.
  85. drupal_alter('metatag_bundled_config', $configs);
  86. return $configs;
  87. }
  88. /**
  89. * Implements hook_metatag_config_instance_info().
  90. */
  91. function metatag_metatag_config_instance_info() {
  92. $info['global'] = array('label' => t('Global'));
  93. $info['global:frontpage'] = array('label' => t('Front page'));
  94. $info['global:403'] = array('label' => t('403 access denied'));
  95. $info['global:404'] = array('label' => t('404 page not found'));
  96. // Add instance information for entities.
  97. $entity_types = entity_get_info();
  98. foreach ($entity_types as $entity_type => $entity_info) {
  99. if (metatag_entity_supports_metatags($entity_type)) {
  100. $info[$entity_type] = array('label' => $entity_info['label']);
  101. foreach ($entity_info['bundles'] as $bundle => $bundle_info) {
  102. if (count($entity_info['bundles'] == 1) && $bundle == $entity_type) {
  103. // Skip default bundles (entities that do not really have bundles).
  104. continue;
  105. }
  106. if (metatag_entity_supports_metatags($entity_type, $bundle)) {
  107. $info[$entity_type . ':' . $bundle] = array('label' => $bundle_info['label']);
  108. }
  109. }
  110. }
  111. }
  112. return $info;
  113. }
  114. /**
  115. * Implements hook_metatag_info().
  116. */
  117. function metatag_metatag_info() {
  118. $info['groups']['basic'] = array(
  119. 'label' => t('Basic tags'),
  120. 'form' => array(
  121. '#weight' => 1,
  122. '#collapsed' => FALSE,
  123. ),
  124. );
  125. $info['groups']['advanced'] = array(
  126. 'label' => t('Advanced tags'),
  127. 'form' => array(
  128. '#weight' => 2,
  129. ),
  130. );
  131. // "Simple" meta tags go first.
  132. $weight = 0;
  133. $info['tags']['title'] = array(
  134. 'label' => t('Page title'),
  135. 'description' => t("The text to display in the title bar of a visitor's web browser when they view this page. This meta tag may also be used as the title of the page when a visitor bookmarks or favorites this page."),
  136. 'class' => 'DrupalTitleMetaTag',
  137. 'group' => 'basic',
  138. 'weight' => ++$weight,
  139. );
  140. $info['tags']['description'] = array(
  141. 'label' => t('Description'),
  142. 'description' => t("A brief and concise summary of the page's content, preferably 150 characters or less. The description meta tag may be used by search engines to display a snippet about the page in search results."),
  143. 'class' => 'DrupalTextMetaTag',
  144. 'group' => 'basic',
  145. 'weight' => ++$weight,
  146. 'form' => array(
  147. '#type' => 'textarea',
  148. '#rows' => 2,
  149. '#wysiwyg' => FALSE,
  150. ),
  151. );
  152. $info['tags']['abstract'] = array(
  153. 'label' => t('Abstract'),
  154. 'description' => t("A brief and concise summary of the page's content, preferably 150 characters or less. The abstract meta tag may be used by search engines for archiving purposes."),
  155. 'class' => 'DrupalTextMetaTag',
  156. 'group' => 'basic',
  157. 'weight' => ++$weight,
  158. 'form' => array(
  159. '#type' => 'textarea',
  160. '#rows' => 2,
  161. '#wysiwyg' => FALSE,
  162. ),
  163. );
  164. $info['tags']['keywords'] = array(
  165. 'label' => t('Keywords'),
  166. 'description' => t("A comma-separated list of keywords about the page. This meta tag is <em>not</em> supported by most search engines anymore."),
  167. 'class' => 'DrupalTextMetaTag',
  168. 'group' => 'basic',
  169. 'weight' => ++$weight,
  170. );
  171. // More advanced meta tags.
  172. $info['tags']['robots'] = array(
  173. 'label' => t('Robots'),
  174. 'description' => t("Provides search engines with specific directions for what to do when this page is indexed."),
  175. 'class' => 'DrupalListMetaTag',
  176. 'group' => 'advanced',
  177. 'weight' => ++$weight,
  178. 'form' => array(
  179. '#options' => array(
  180. 'index' => t('Allow search engines to index this page (assumed).'),
  181. 'follow' => t('Allow search engines to follow links on this page (assumed).'),
  182. 'noindex' => t('Prevents search engines from indexing this page.'),
  183. 'nofollow' => t('Prevents search engines from following links on this page.'),
  184. 'noarchive' => t('Prevents cached copies of this page from appearing in search results.'),
  185. 'nosnippet' => t('Prevents descriptions from appearing in search results, and prevents page caching.'),
  186. 'noodp' => t('Blocks the <a href="!opendirectory">Open Directory Project</a> description from appearing in search results.', array('!opendirectory' => 'http://www.dmoz.org/')),
  187. 'noydir' => t('Prevents Yahoo! from listing this page in the <a href="@ydir">Yahoo! Directory</a>.', array('@ydir' => 'http://dir.yahoo.com/')),
  188. 'noimageindex' => t('Prevent search engines from indexing images on this page.'),
  189. 'notranslate' => t('Prevent search engines from offering to translate this page in search results.'),
  190. ),
  191. ),
  192. );
  193. $info['tags']['news_keywords'] = array(
  194. 'label' => t('Google News Keywords'),
  195. 'description' => t('A comma-separated list of keywords about the page. This meta tag is used as an indicator in <a href="@google_news">Google News</a>.', array('@google_news' => 'http://support.google.com/news/publisher/bin/answer.py?hl=en&answer=68297')),
  196. 'class' => 'DrupalTextMetaTag',
  197. 'group' => 'advanced',
  198. 'weight' => ++$weight,
  199. );
  200. $info['tags']['standout'] = array(
  201. 'label' => t('Google Standout'),
  202. 'description' => t("Highlight standout journalism on the web, especially for breaking news; used as an indicator in <a href=\"@google_news\">Google News</a>. Warning: Don't abuse it, to be used a maximum of 7 times per calendar week!", array('@google_news' => 'https://support.google.com/news/publisher/answer/191283?hl=en&ref_topic=2484650')),
  203. 'class' => 'DrupalTextMetaTag',
  204. 'group' => 'advanced',
  205. 'weight' => ++$weight,
  206. );
  207. $info['tags']['rating'] = array(
  208. 'label' => t('Content rating'),
  209. 'description' => t('Used to indicate the intended audience for the content.'),
  210. 'class' => 'DrupalTextMetaTag',
  211. 'group' => 'advanced',
  212. 'select_or_other' => TRUE,
  213. 'form' => array(
  214. '#type' => 'select',
  215. '#options' => array(
  216. 'general' => t('General'),
  217. 'mature' => t("Mature"),
  218. 'restricted' => t("Restricted"),
  219. '14 years' => t("14 years or Older"),
  220. 'safe for kids' => t("Safe for kids"),
  221. ),
  222. '#empty_option' => t('- None -'),
  223. ),
  224. 'weight' => ++$weight,
  225. );
  226. $info['tags']['referrer'] = array(
  227. 'label' => t('Referrer policy'),
  228. 'description' => t('Indicate to search engines and other page scrapers whether or not links should be followed. See <a href="http://w3c.github.io/webappsec/specs/referrer-policy/">the W3C specifications</a> for further details.'),
  229. 'class' => 'DrupalTextMetaTag',
  230. 'group' => 'advanced',
  231. 'select_or_other' => TRUE,
  232. 'form' => array(
  233. '#type' => 'select',
  234. '#options' => array(
  235. 'no-referrer' => t('No Referrer'),
  236. 'origin' => t('Origin'),
  237. 'no-referrer-when-downgrade' => t('No Referrer When Downgrade'),
  238. 'origin-when-cross-origin' => t('Origin When Cross-Origin'),
  239. 'unsafe-url' => t('Unsafe URL'),
  240. ),
  241. '#empty_option' => t('- None -'),
  242. ),
  243. 'weight' => ++$weight,
  244. );
  245. $info['tags']['generator'] = array(
  246. 'label' => t('Generator'),
  247. 'description' => t("Describes the name and version number of the software or publishing tool used to create the page."),
  248. 'class' => 'DrupalTextMetaTag',
  249. 'header' => 'X-Generator',
  250. 'context' => array('global'),
  251. 'group' => 'advanced',
  252. 'weight' => ++$weight,
  253. );
  254. $info['tags']['rights'] = array(
  255. 'label' => t('Rights'),
  256. 'description' => t("Details about intellectual property, such as copyright or trademarks; does not automatically protect the site's content or intellectual property."),
  257. 'class' => 'DrupalTextMetaTag',
  258. 'group' => 'advanced',
  259. 'weight' => ++$weight,
  260. 'replaces' => array(
  261. 'copyright',
  262. ),
  263. );
  264. $info['tags']['image_src'] = array(
  265. 'label' => t('Image'),
  266. 'description' => t("An image associated with this page, for use as a thumbnail in social networks and other services."),
  267. 'class' => 'DrupalLinkMetaTag',
  268. 'group' => 'advanced',
  269. 'weight' => ++$weight,
  270. 'image' => TRUE,
  271. 'devel_generate' => array(
  272. 'type' => 'image',
  273. ),
  274. );
  275. $info['tags']['canonical'] = array(
  276. 'label' => t('Canonical URL'),
  277. 'description' => t("Preferred page location or URL to help eliminate duplicate content for search engines."),
  278. 'class' => 'DrupalLinkMetaTag',
  279. 'group' => 'advanced',
  280. 'weight' => ++$weight,
  281. 'devel_generate' => array(
  282. 'type' => 'canonical',
  283. ),
  284. );
  285. $info['tags']['shortlink'] = array(
  286. 'label' => t('Shortlink URL'),
  287. 'description' => t('A brief URL, often created by a URL shortening service.'),
  288. 'class' => 'DrupalLinkMetaTag',
  289. 'group' => 'advanced',
  290. 'weight' => ++$weight,
  291. 'replaces' => array(
  292. 'shorturl',
  293. ),
  294. 'devel_generate' => array(
  295. 'type' => 'shortlink',
  296. ),
  297. );
  298. $info['tags']['publisher'] = array(
  299. 'label' => t('Publisher URL'),
  300. 'description' => '',
  301. 'class' => 'DrupalLinkMetaTag',
  302. 'group' => 'advanced',
  303. 'weight' => ++$weight,
  304. 'devel_generate' => array(
  305. 'type' => 'url',
  306. ),
  307. );
  308. $info['tags']['author'] = array(
  309. 'label' => t('Author URL'),
  310. 'description' => t("Used by some search engines to confirm authorship of the content on a page. Should be either the full URL for the author's Google+ profile page or a local page with information about the author."),
  311. 'class' => 'DrupalLinkMetaTag',
  312. 'group' => 'advanced',
  313. 'weight' => ++$weight,
  314. 'devel_generate' => array(
  315. 'type' => 'url',
  316. ),
  317. );
  318. $info['tags']['original-source'] = array(
  319. 'label' => t('Original Source'),
  320. 'description' => '',
  321. 'class' => 'DrupalTextMetaTag',
  322. 'group' => 'advanced',
  323. 'description' => t("Used to indicate the URL that broke the story, and can link to either an internal URL or an external source. If the full URL is not known it is acceptable to use a partial URL or just the domain name."),
  324. 'weight' => ++$weight,
  325. 'devel_generate' => array(
  326. 'type' => 'url',
  327. ),
  328. );
  329. $info['tags']['prev'] = array(
  330. 'label' => t('Previous page URL'),
  331. 'description' => t('Used for paginated content. Meet Google recommendations to <a href="@google_pagination">indicate paginated content</a> by providing URL with rel="prev" link.', array('@google_pagination' => 'https://support.google.com/webmasters/answer/1663744')),
  332. 'class' => 'DrupalLinkMetaTag',
  333. 'group' => 'advanced',
  334. 'weight' => ++$weight,
  335. 'devel_generate' => array(
  336. 'type' => 'url',
  337. ),
  338. );
  339. $info['tags']['next'] = array(
  340. 'label' => t('Next page URL'),
  341. 'description' => t('Used for paginated content. Meet Google recommendations to <a href="@google_pagination">indicate paginated content</a> by providing URL with rel="next" link.', array('@google_pagination' => 'https://support.google.com/webmasters/answer/1663744')),
  342. 'class' => 'DrupalLinkMetaTag',
  343. 'group' => 'advanced',
  344. 'weight' => ++$weight,
  345. 'devel_generate' => array(
  346. 'type' => 'url',
  347. ),
  348. );
  349. $info['tags']['content-language'] = array(
  350. 'label' => t('Content language'),
  351. 'description' => t("A deprecated meta tag for defining this page's two-letter language code(s)."),
  352. 'class' => 'DrupalTextMetaTag',
  353. 'group' => 'advanced',
  354. 'weight' => ++$weight,
  355. 'is_language' => TRUE,
  356. 'element' => array(
  357. '#theme' => 'metatag_http_equiv',
  358. ),
  359. );
  360. $info['tags']['geo.position'] = array(
  361. 'label' => t('Geo position'),
  362. 'description' => t('Geo-spatial information in "latitude;longitude" format, e.g. "50.167958;-97.133185"; <a href="http://en.wikipedia.org/wiki/Geotagging#HTML_pages">see Wikipedia for details</a>.'),
  363. 'class' => 'DrupalTextMetaTag',
  364. 'group' => 'advanced',
  365. 'weight' => ++$weight,
  366. );
  367. $info['tags']['geo.placename'] = array(
  368. 'label' => t('Geo place name'),
  369. 'description' => t("A location's formal name."),
  370. 'class' => 'DrupalTextMetaTag',
  371. 'group' => 'advanced',
  372. 'weight' => ++$weight,
  373. );
  374. $info['tags']['geo.region'] = array(
  375. 'label' => t('Geo region'),
  376. 'description' => t("A location's two-letter international country code, with an optional two-letter region, e.g. \"US-NH\" for New Hampshire in the USA."),
  377. 'class' => 'DrupalTextMetaTag',
  378. 'group' => 'advanced',
  379. 'weight' => ++$weight,
  380. );
  381. $info['tags']['icbm'] = array(
  382. 'label' => t('ICBM'),
  383. 'description' => t('Geo-spatial information in "latitude, longitude" format, e.g. "50.167958, -97.133185"; <a href="http://en.wikipedia.org/wiki/ICBM">see Wikipedia for details</a>.'),
  384. 'class' => 'DrupalTextMetaTag',
  385. 'group' => 'advanced',
  386. 'weight' => ++$weight,
  387. );
  388. $info['tags']['refresh'] = array(
  389. 'label' => t('Refresh'),
  390. 'description' => t('The number of seconds to wait before refreshing the page. May also force redirect to another page using the format "5; url=http://example.com/", which would be triggered after five seconds.'),
  391. 'class' => 'DrupalTextMetaTag',
  392. 'group' => 'advanced',
  393. 'weight' => ++$weight,
  394. 'element' => array(
  395. '#theme' => 'metatag_http_equiv',
  396. ),
  397. );
  398. $info['tags']['revisit-after'] = array(
  399. 'label' => t('Revisit After'),
  400. 'description' => t('Tell search engines when to index the page again. Very few search engines support this tag, it is more useful to use an <a href="@xmlsitemap">XML Sitemap</a> file.', array('@xmlsitemap' => 'https://www.drupal.org/project/xmlsitemap')),
  401. 'class' => 'DrupalDateIntervalMetaTag',
  402. 'group' => 'advanced',
  403. 'weight' => ++$weight,
  404. 'devel_generate' => array(
  405. 'type' => 'date',
  406. ),
  407. );
  408. $info['tags']['pragma'] = array(
  409. 'label' => t('Pragma'),
  410. 'description' => t('Used to control whether a browser caches a specific page locally. Little used today. Should be used in conjunction with the Cache-Control meta tag.'),
  411. 'class' => 'DrupalTextMetaTag',
  412. 'group' => 'advanced',
  413. 'weight' => ++$weight,
  414. 'element' => array(
  415. '#theme' => 'metatag_http_equiv',
  416. ),
  417. );
  418. $info['tags']['cache-control'] = array(
  419. 'label' => t('Cache-Control'),
  420. 'description' => t('Used to control whether a browser caches a specific page locally. Little used today. Should be used in conjunction with the Pragma meta tag.'),
  421. 'class' => 'DrupalTextMetaTag',
  422. 'group' => 'advanced',
  423. 'weight' => ++$weight,
  424. 'element' => array(
  425. '#theme' => 'metatag_http_equiv',
  426. ),
  427. );
  428. $info['tags']['expires'] = array(
  429. 'label' => t('Expires'),
  430. 'description' => t("Control when the browser's internal cache of the current page should expire. The date must to be an <a href=\"@rfc\">RFC-1123</a>-compliant date string that is represented in Greenwich Mean Time (GMT), e.g. '@date'. Set to '0' to stop the page being cached entirely.", array('@rfc' => 'http://www.csgnetwork.com/timerfc1123calc.html', '@date' => gmdate("D, d M Y H:i:s \G\M\T"))),
  431. 'class' => 'DrupalTextMetaTag',
  432. 'weight' => ++$weight,
  433. 'group' => 'advanced',
  434. 'devel_generate' => array(
  435. 'type' => 'date',
  436. ),
  437. );
  438. return $info;
  439. }