Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
$10
Stop the 'rel' field in menu system from filtering characters
Specifically, I'm trying to pass a hex color through that field which requires the use of a hashtag at the front of the 6 digit color code. For example, the color '#cccccc' is being outputted as 'cccccc'. The hashtag is required for what I'm trying to do.
Is it possible to change the filter of the 'rel' field so that it allows for the hashtag to go through?
This question has been answered.
beowulf | 06/12/11 at 2:25pm
Edit
(2) Possible Answers Submitted...
See a chronological view of answers?
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
-

Last edited:
06/12/11
2:33pmCaroline Keim says:Can you show us the code you're trying to use?
- 06/12/11 2:42pm
beowulf says:I'm not sure how that's relevant. Wordpress is stripping out everything from the 'Link Relationship (XFN)' field other than standard characters regardless of the code I'm using.
- 06/12/11 2:49pm
Caroline Keim says:I was going to say it's relevant, because we could add a script to add the # after Wordpress removed it.
- 06/12/11 2:55pm
beowulf says:Ah, yes. I see your point now. :)
The only thing is that I'm not sure that I want to paste it here. It's a jQuery function that I'd rather keep out of the public domain for now.
- 06/12/11 2:42pm
-

Last edited:
06/12/11
2:49pmUtkarsh Kukreti says:WordPress is splitting the xfn value by a space, and then running the `sanitize_html_class` function over it, which strips anything but alphanumeric characters.
wp-includes/nav-menu.php
$args['menu-item-xfn'] = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['menu-item-xfn'] ) ) );
There are no filters around that, so the only way I can think of doing this, if you _really_ want to, is by commenting out this line.
Edit:
sanitize_html_class does have a filter. One way is to not filter any class that starts with a # sign. Let me know if that would work for you.Previous versions of this answer: 06/12/11 at 2:49pm | 06/12/11 at 2:49pm
- 06/12/11 2:53pm
beowulf says:Interesting.
I definitely wouldn't want to make changes to core WP files (it would just be overwritten on the next upgrade anyway).
A function would be ideal although I'm not really sure how to go about that. - 06/12/11 2:57pm
Utkarsh Kukreti says:add_filter( 'sanitize_html_class', 'dont_filter_hash', 10, 2 );
function dont_filter_hash($sanitized, $raw) {
if(preg_match("/^#[0-9a-fA-F]{6}$/", $raw)) {
return $raw;
} else {
return $sanitized;
}
}
This code will not filter any hex value, with the format "#abcdef".
- 06/12/11 3:05pm
beowulf says:Nice!! That filter totally worked! :)
- 06/12/11 3:07pm
beowulf says:You just made my night with that. Ok, now I need to mark it as answered. Thanks again!
- 06/12/11 2:53pm
This question has expired.
beowulf voted on this question.
Current status of this question: Completed
Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.
If the asker does not get an answer then they have 10 days to request a refund.
