1 ckeditor5.admin.inc | _ckeditor5_settings_parse_style_list($style_list_string) |
Parse a string of styles in the format of element.class|Label into an array.
Parameters
string $style_list_string: A list of styles separated by new line characters.
Return value
array: An unindexed array of styles with the following keys:
- name: The label of the style.
- element: The type of element this still will use.
- classes: An array of classes to be applied to the element.
File
- core/
modules/ ckeditor5/ ckeditor5.admin.inc, line 169 - Admin page callbacks for the CKEditor 5 module.
Code
function _ckeditor5_settings_parse_style_list($style_list_string) {
$styles = array();
foreach (explode("\n", $style_list_string) as $style) {
$style = trim($style);
if ($style) {
@list($element, $label) = explode('|', $style, 2);
@list($element, $classes) = explode('.', $element, 2);
$styles[] = array(
'name' => $label,
'element' => $element,
// Note: CKEditor 4 used 'attributes' => array('class' => $class).
// CKEditor 5 simplified this down to just a list of classes.
// We are casting $classes to a string in order to avoid deprecation
// warnings for the second parameter of explode() in PHP >= 8.1.
'classes' => explode(' ', (string) $classes),
);
}
}
return $styles;
}