Skip to content

Instantly share code, notes, and snippets.

@jrbeeman
Created December 11, 2012 22:46
Show Gist options
  • Save jrbeeman/4263048 to your computer and use it in GitHub Desktop.
Save jrbeeman/4263048 to your computer and use it in GitHub Desktop.
Deny access to view Metatag tokens until we can get token memory consumption under control. For example, in a client project site, this trimmed ~40mb off of PHP memory required to render the node/add/article page and took the total HTML payload from 7.18mb to 43.68kb on another content type. Related Drupal.org issues: <http://drupal.org/node/105…
<?php
/**
* Implements hook_form_alter().
*/
function mymodule_form_alter(&$form, &$form_state, $form_id) {
if (!empty($form['#node_edit_form']) && !empty($form['metatags'])) {
$form['metatags']['tokens']['#access'] = FALSE;
}
if ($form_id == 'flag_form') {
$form['messages']['tokens_help']['#access'] = FALSE;
}
if ($form_id == 'pathauto_patterns_form') {
foreach ($form as $key => $value) {
if (is_array($value) && isset($value['token_help'])) {
$form[$key]['token_help']['#access'] = FALSE;
}
}
}
if ($form_id == 'metatag_config_edit_form') {
$form['metatags']['tokens']['#access'] = FALSE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment