1 ckeditor.api.php hook_ckeditor_PLUGIN_plugin_check($format, $plugin_name)

Enabled callback for hook_ckeditor_plugins().

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

This callback should determine if a plugin should be enabled for a CKEditor 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 $format: An format object as returned by filter_format_load(). The editor's settings may be found in $format->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_ckeditor_plugins()

ckeditor_add_settings()

Related topics

File

core/modules/ckeditor/ckeditor.api.php, line 207
Documentation for CKEditor 4 module APIs.

Code

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