[wp-trac] [WordPress Trac] #2883: allowed_tags() more semantic

WordPress Trac wp-trac at lists.automattic.com
Fri Jun 30 10:27:15 GMT 2006


#2883: allowed_tags() more semantic
-------------------------------+--------------------------------------------
 Reporter:  dave at mad-dave.net  |       Owner:  anonymous
     Type:  defect             |      Status:  new      
 Priority:  low                |   Milestone:           
Component:  Administration     |     Version:  2.0.3    
 Severity:  normal             |    Keywords:           
-------------------------------+--------------------------------------------
 * 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>&lt;'.$tag;
                 if ( 0 < count($attributes) ) {
                         foreach ( $attributes as $attribute => $limits ) {
                                 $allowed .= ' '.$attribute.'=""';
                         }
                 }
                 $allowed .= '&gt;</li>';
         }
         return $pre.$allowed.$end;
 }
 }}}

 Now, it generates this:

 <ul class="allowedtags">

  <li>&lt;em&gt;</li>

  <li>&lt;i&gt;</li>

  <li>&lt;strong&gt;</li>

  <li>&lt;b&gt;</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

-- 
Ticket URL: <http://trac.wordpress.org/ticket/2883>
WordPress Trac <http://wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list