You are here

function hook_wysiwyg_editor_settings_alter in Wysiwyg 7.2

Same name and namespace in other branches
  1. 6.2 wysiwyg.api.php \hook_wysiwyg_editor_settings_alter()

Act on editor profile settings.

This hook is invoked from wysiwyg_get_editor_config() after the JavaScript settings have been generated for an editor profile and before the settings are added to the page. The settings may be customized or enhanced; typically with options that cannot be controlled through Wysiwyg module's administrative UI currently.

Modules implementing this hook to enforce settings that can also be controlled through the UI should also implement hook_form_wysiwyg_profile_form_alter() to adjust or at least indicate on the editor profile configuration form that certain/affected settings cannot be changed.

Parameters

$settings: An associative array of JavaScript settings to pass to the editor.

$context: An associative array containing additional context information:

  • editor: The plugin definition array of the editor.
  • profile: The editor profile object, as loaded from the database.
  • theme: The name of the editor theme/skin.
1 invocation of hook_wysiwyg_editor_settings_alter()
wysiwyg_get_editor_config in ./wysiwyg.module
Return an array of initial editor settings for a Wysiwyg profile.

File

./wysiwyg.api.php, line 319
API documentation for Wysiwyg module.

Code

function hook_wysiwyg_editor_settings_alter(&$settings, $context) {

  // Each editor has its own collection of native settings that may be extended
  // or overridden. Please consult the respective official vendor documentation
  // for details.
  if ($context['profile']->editor == 'tinymce') {

    // Supported values to JSON data types.
    $settings['cleanup_on_startup'] = TRUE;

    // Function references (callbacks) need special care.
    // @see wysiwyg_wrap_js_callback()
    $settings['file_browser_callback'] = wysiwyg_wrap_js_callback('myFileBrowserCallback');

    // Regular Expressions need special care.
    // @see wysiwyg_wrap_js_regexp()
    $settings['stylesheetParser_skipSelectors'] = wysiwyg_wrap_js_regexp('(^body\\.|^caption\\.|\\.high|^\\.)', 'i');
  }
}