-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix typos in hook_ckeditor_PLUGIN_plugin_check documentation #6821
Comments
Actually, the code in core/modules/ckeditor/ckeditor.api.php is the following one. 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;
}
}
} It does not work because The code used in the PR would not work for the same reason. function hook_ckeditor_PLUGIN_plugin_check($format, $plugin_name) {
$toolbars = $format->editor_settings['toolbar'];
foreach ($toolbars as $toolbar) {
foreach ($toolbar as $group) {
if (in_array('Underline', $group['items'])) {
return TRUE;
}
}
}
} |
Also, core/modules/ckeditor5/ckeditor5.api.php contains the same code, for a similar hook ( The files that need to be changed are two. |
The following code would work. 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', array_keys($row))) {
return TRUE;
}
}
} That is how I would write the code, if I wanted to make the minimum change to fix it. (I assume |
Basing on the code used by function hook_ckeditor_PLUGIN_plugin_check($format, $plugin_name) {
// Automatically enable this plugin if the Underline button is enabled.
foreach (foreach ($format->editor_settings['toolbar'] as $row) {
foreach ($row as $button_group) {
if (in_array('Underline', array_keys($button_group['items']))) {
return TRUE;
}
}
}
} |
Typos and errors in hook_ckeditor_PLUGIN_plugin_check documentation
in site/web/core/modules/ckeditor/ckeditor.api.php
The foreach loop is completely wrong and also there are multiple
$toolbars
available. Additionally, using$row
is confusing.$toolbar[$x]
is the row but then there are button groups defined inside those, so I'd suggest renaming it to$group
Pull request incoming.
The text was updated successfully, but these errors were encountered: