function ckeditor_post_update_omit_settings_for_disabled_plugins
Updates Text Editors using CKEditor 4 to omit settings for disabled plugins.
File
-
core/
modules/ ckeditor/ ckeditor.post_update.php, line 14
Code
function ckeditor_post_update_omit_settings_for_disabled_plugins(&$sandbox = []) {
$config_entity_updater = \Drupal::classResolver(ConfigEntityUpdater::class);
$config_entity_updater->update($sandbox, 'editor', function (Editor $editor) : bool {
// Only try to update editors using CKEditor 4.
if ($editor->getEditor() !== 'ckeditor') {
return FALSE;
}
$enabled_plugins = _ckeditor_get_enabled_plugins($editor);
// Only update if the editor has plugin settings for disabled plugins.
$needs_update = FALSE;
$settings = $editor->getSettings();
// Updates are not needed if plugin settings are not defined for the editor.
if (!isset($settings['plugins'])) {
return FALSE;
}
foreach (array_keys($settings['plugins']) as $plugin_id) {
if (!in_array($plugin_id, $enabled_plugins, TRUE)) {
$needs_update = TRUE;
}
}
return $needs_update;
});
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.