function panopoly_wysiwyg_update_8206 in Panopoly WYSIWYG 8.2
Add anchor plugin to standard and full input format and WYSIWYG.
File
- ./
panopoly_wysiwyg.install, line 201 - Install hooks for Panopoly WYSIWYG.
Code
function panopoly_wysiwyg_update_8206() {
// Tweak allowed HTML config.
$format = FilterFormat::load('panopoly_wysiwyg_basic');
$filter = $format
->filters('filter_html');
$val = $filter->settings['allowed_html'];
if (preg_match('/<a(| [^>]+)>/', $val, $matches)) {
$attrs = array_filter(explode(' ', $matches[1]));
if (!in_array('name', $attrs)) {
$attrs[] = 'name';
}
$attrs = ' ' . implode(' ', $attrs);
// Only replace if the original tag had attributes defined.
if ($matches[1]) {
$new_tag = str_replace($matches[1], $attrs, $matches[0]);
$val = str_replace($matches[0], $new_tag, $val);
}
}
else {
// No <a> tag set, append to the end.
$val = trim($val) . ' <a name>';
}
if ($val != $filter->settings['allowed_html']) {
$filter->settings['allowed_html'] = $val;
$format
->save();
}
// Set anchor in editors.
_panopoly_wysiwyg_set_editor_anchor('panopoly_wysiwyg_basic');
_panopoly_wysiwyg_set_editor_anchor('panopoly_wysiwyg_full');
}