Opened 18 years ago
Closed 17 years ago
#2883 closed defect (bug) (wontfix)
allowed_tags() more semantic
Reported by: | Owned by: | rob1n | |
---|---|---|---|
Milestone: | Priority: | low | |
Severity: | normal | Version: | 2.0.3 |
Component: | Template | Keywords: | has-patch dev-feedback 2nd-opinion |
Focuses: | Cc: |
Description
- File: template-functions-general.php
- Function: allowed_tags()
The function allowed_tags() gereates a long line of tags which are allowed in comments.
function allowed_tags() { global $allowedtags; $allowed = ''; foreach ( $allowedtags as $tag => $attributes ) { $allowed .= '<'.$tag; if ( 0 < count($attributes) ) { foreach ( $attributes as $attribute => $limits ) { $allowed .= ' '.$attribute.'=""'; } } $allowed .= '> '; } return htmlentities($allowed); }
This generates for example: <em> <i> <b> <strong> ...
But imo, this should be an unordered list, so i modified the function:
function allowed_tags() { global $allowedtags; $allowed = ''; $pre = '<ul class="allowedtags">'; $end = '</ul>'; foreach ( $allowedtags as $tag => $attributes ) { $allowed .= '<li><'.$tag; if ( 0 < count($attributes) ) { foreach ( $attributes as $attribute => $limits ) { $allowed .= ' '.$attribute.'=""'; } } $allowed .= '></li>'; } return $pre.$allowed.$end; }
Now, it generates this:
<ul class="allowedtags">
<li><em></li>
<li><i></li>
<li><strong></li>
<li><b></li>
</ul>
To make the whole thing html valid, change comments.php the allowed_tags part to:
<p><strong>XHTML:</strong> You can use these tags:</p> <?php echo allowed_tags(); ?>
Greetings
Attachments (1)
Change History (9)
#1
@
18 years ago
- Component changed from Administration to Template
- Keywords bg|has-patch added
- Owner changed from anonymous to leftjustified
#3
@
18 years ago
Just for comparison, I've put the suggested mod on my test1 blog with the "Flashy" theme in place:
http://test1.ptvguy.com/?p=1#comments
Here's what the same theme looks like normally:
http://blog.leenarts.net/2006/06/30/naked-presentations/#comments
Review the allowed comment tags between the website input box and the comment input box.
#5
@
18 years ago
- Keywords bg|needs-testing added
- Status changed from new to assigned
Patch modified to address Ryan's concerns.
#6
@
17 years ago
- Keywords has-patch dev-feedback 2nd-opinion added; bg|has-patch bg|needs-testing removed
- Milestone set to 2.3
- Owner changed from leftjustified to rob1n
- Status changed from assigned to new
I think it's fine the way we do it, IMO. I think we include it in <code />, which is good enough. Devs?
I'm concerned about breaking themes that process the return value. Are there any such themes out there? We could always add an optional $format arg that allows theme authors to request a list.