function tinymce_form_wysiwyg_profile_form_alter in TinyMCE 7
Implements hook_form_FORM_ID_alter().
File
- includes/
tinymce.wysiwyg.inc, line 37 - Provides all integration hooks with WYSIWYG module.
Code
function tinymce_form_wysiwyg_profile_form_alter(&$form, $form_state) {
$profile = $form_state['build_info']['args'][0];
$format = filter_format_load($profile->format);
// Set default settings for the profile.
$tinymce_editor_info = tinymce_editor_info();
$profile->settings = (array) $profile->settings + $tinymce_editor_info['tinymce']['default settings'];
// Hide the basic settings, as they affect behavior of the WYSIWYG module.
$form['basic']['#access'] = FALSE;
// We don't need the toggle link as you can just use the source button.
$form['basic']['default']['#default_value'] = TRUE;
$form['basic']['show_toggle']['#default_value'] = FALSE;
// Remove all the settings we either don't use or replace.
unset($form['buttons'], $form['appearance'], $form['output'], $form['css']);
// Block formats need to exist to prevent notices in WYSIWYG module.
$form['block_formats'] = array(
'#type' => 'value',
'#value' => '',
);
// Add an additional submit handler to clean up our modifications.
// This submit handler must be added before tinymce_settings_form() is called
// below, as it adds another submit handler before it.
array_unshift($form['#submit'], 'tinymce_wysiwyg_settings_form_submit');
// Add the TinyMCE specialized form. We place these in "editor_settings" to
// match the Drupal 8 editor.module form structure, which means more
// compatibility in tinymce_settings_form_submit().
$form['editor_settings'] = tinymce_settings_form($form, $form_state, $profile, $format);
$form['editor_settings']['#tree'] = TRUE;
}