Changeset 11433
- Timestamp:
- 05/22/2009 05:44:26 PM (15 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/comment-template.php
r11383 r11433 295 295 // For all registered users, 'byuser' 296 296 $classes[] = 'byuser'; 297 $classes[] = 'comment-author-' . $comment->user_id;297 $classes[] = 'comment-author-' . sanitise_css_classname($user->user_nicename, $comment->user_id); 298 298 // For comment authors who are the author of the post 299 299 if ( $post = get_post($post_id) ) { -
trunk/wp-includes/formatting.php
r11414 r11433 717 717 return false; 718 718 return $orderby; 719 } 720 721 /** 722 * Santises a css classname to ensure it only contains valid characters 723 * 724 * Strips the classname down to A-Z,a-z,0-9,'-' if this results in an empty 725 * string then it will return the alternative value supplied. 726 * 727 * @param string $classname The classname to be sanitised 728 * @param string $alternative The value to return if the sanitisation end's up as an empty string. 729 * @return string The sanitised value 730 */ 731 function sanitise_css_classname($classname, $alternative){ 732 //Strip out any % encoded octets 733 $sanitised = preg_replace('|%[a-fA-F0-9][a-fA-F0-9]|', '', $classname); 734 735 //Limit to A-Z,a-z,0-9,'-' 736 $sanitised = preg_replace('/[^A-Za-z0-9-]/', '', $sanitised); 737 738 if ('' == $sanitised) 739 $sanitised = $alternative; 740 741 return apply_filters('sanitise_css_classname',$sanitised, $classname, $alternative); 719 742 } 720 743 -
trunk/wp-includes/post-template.php
r11398 r11433 325 325 // Categories 326 326 foreach ( (array) get_the_category($post->ID) as $cat ) { 327 if ( empty($cat-> cat_ID) )327 if ( empty($cat->slug ) ) 328 328 continue; 329 $classes[] = 'category-' . $cat->cat_ID;329 $classes[] = 'category-' . sanitise_css_classname($cat->slug, $cat->cat_ID); 330 330 } 331 331 332 332 // Tags 333 333 foreach ( (array) get_the_tags($post->ID) as $tag ) { 334 if ( empty($tag-> term_id) )334 if ( empty($tag->slug ) ) 335 335 continue; 336 $classes[] = 'tag-' . $tag->term_id;336 $classes[] = 'tag-' . sanitise_css_classname($tag->slug, $tag->term_id); 337 337 } 338 338 … … 408 408 $author = $wp_query->get_queried_object(); 409 409 $classes[] = 'author'; 410 $classes[] = 'author-' . $author->user_id;410 $classes[] = 'author-' . sanitise_css_classname($author->user_nicename , $author->user_id); 411 411 } elseif ( is_category() ) { 412 412 $cat = $wp_query->get_queried_object(); 413 413 $classes[] = 'category'; 414 $classes[] = 'category-' . $cat->cat_ID;414 $classes[] = 'category-' . sanitise_css_classname($cat->slug, $cat->cat_ID); 415 415 } elseif ( is_tag() ) { 416 416 $tags = $wp_query->get_queried_object(); 417 417 $classes[] = 'tag'; 418 $classes[] = 'tag-' . $tags->term_id;418 $classes[] = 'tag-' . sanitise_css_classname($tags->slug, $tags->term_id); 419 419 } 420 420 } elseif ( is_page() ) {
Note: See TracChangeset
for help on using the changeset viewer.