You are here

function hook_tinymce_PLUGIN_plugin_check in TinyMCE 7

Enabled callback for hook_tinymce_plugins().

Note: This is not really a hook. The function name is manually specified via 'enabled callback' in hook_tinymce_plugins(), with this recommended callback name pattern. It is called from tinymce_add_settings().

This callback should determine if a plugin should be enabled for a TinyMCE instance. Plugins may be enabled based off an explicit setting, or enable themselves based on the configuration of another setting, such as enabling based on a particular button being present in the toolbar.

Parameters

object $editor: An editor instance as returned by editor_load(). The editor's settings may be found in $editor->settings.

string $plugin_name: String name of the plugin that is being checked.

Return value

boolean Boolean TRUE if the plugin should be enabled, FALSE otherwise.

See also

hook_tinymce_plugins()

tinymce_add_settings()

File

./tinymce.api.php, line 149
Documentation for TinyMCE module APIs.

Code

function hook_tinymce_PLUGIN_plugin_check($editor, $plugin_name) {

  // Automatically enable this plugin if the Underline button is enabled.
  foreach ($editor->settings['toolbar']['buttons'] as $row) {
    if (in_array('Underline', $row)) {
      return TRUE;
    }
  }
}