Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hello,
Thank you for this module !
if the entered tag for nolink is <a href="#">
, the following code removes all attributes for the a tag when it should keep them.
//special_menu_items.module @ 66
if ($tag != '<a>') {
// <a> tags can have these but a <span> cannot, so we remove them.
foreach (array('accesskey', 'target', 'rel', 'name') as $attribute) {
$attributes = preg_replace("/ $attribute=\".*\"/i", "", $attributes);
}
}
Something clever has to made.. for this if() statement.
Take care !
Comment | File | Size | Author |
---|---|---|---|
#4 | replace_preg_replace_with_array_diff_key.patch | 749 bytes | matpoppl |
#2 | 1841836-Fixes_regex_on_element_replace-2.patch | 588 bytes | energee |
Comments
Comment #1
coxw CreditAttribution: coxw commentedI agree, I'm not sure the attributes should be stripped since even accesskey is a global attribute.
Comment #1.0
coxw CreditAttribution: coxw commentedbetter code formatting
Comment #2
energee CreditAttribution: energee commentedFixes preg_replace
Comment #3
energee CreditAttribution: energee as a volunteer commentedComment #4
matpoppl CreditAttribution: matpoppl as a volunteer commentedHello.
The purpose of the preg_replace is to remove unwanted attributes in non-anchor tags. I think that it would be better to drop preg_replace and use array_diff_key a step before the attributes are converted to string.