Remove filter tips

Public

This snippet wille remove the whole fieldset, preventing you to choose the text format. Bu it will default to HTML as long as the text area is flagged as "Filtered text" in its settings.

</> CopyGet raw version
php
  1. /**
  2.  * Implements hook_element_info_alter().
  3.  *
  4.  * Lighweight better formats behavior
  5.  */
  6. function mymodule_element_info_alter(&$type) {
  7. // Our process callback must run immediately after filter_process_format().
  8. $filter_process_format_location = array_search('filter_process_format', $type['text_format']['#process']);
  9. $replacement = array(
  10. 'filter_process_format',
  11. 'mymodule_filter_process_format'
  12. );
  13. array_splice($type['text_format']['#process'], $filter_process_format_location, 1, $replacement);
  14. }
  15.  
  16. /**
  17.  * Process callback for form elements that have a text format selector attached.
  18.  *
  19.  * This callback runs after filter_process_format() and performs additional
  20.  * modifications to the form element.
  21.  *
  22.  * @see filter_process_format()
  23.  */
  24. function mymodule_filter_process_format($element) {
  25. // Remove unnecessary setting about formats
  26. if ('text_format' == $element['#type'] && !isset($element['format']['format']['#default_value'])) {
  27. $element['format']['format']['#default_value'] = 'html';
  28. }
  29. if ('html' == $element['format']['format']['#default_value']) {
  30. $element['format']['#access'] = FALSE;
  31. }
  32.  
  33. return $element;
  34. }