1 ckeditor5.api.php | hook_ckeditor5_PLUGIN_plugin_check($format, $plugin_name) |
Enabled callback for hook_ckeditor5_plugins().
Note: This is not really a hook. The function name is manually specified via 'enabled callback' in hook_ckeditor5_plugins(), with this recommended callback name pattern. It is called from ckeditor5_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
ckeditor5_add_settings()
Related topics
File
- core/
modules/ ckeditor5/ ckeditor5.api.php, line 275 - Documentation for CKEditor module APIs.
Code
function hook_ckeditor5_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;
}
}
}