WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/23/2010 12:55:55 PM (10 years ago)
Author:
scribu
Message:

Introduce sanitize_title_for_query(). See #9591

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/formatting.php

    r15816 r15929  
    629629        chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
    630630        chr(197).chr(190) => 'z', chr(197).chr(191) => 's',
     631        chr(200).chr(153) => 's', chr(200).chr(155) => 't',
    631632        // Euro Sign
    632633        chr(226).chr(130).chr(172) => 'E',
     
    784785 * @param string $title The string to be sanitized.
    785786 * @param string $fallback_title Optional. A title to use if $title is empty.
     787 * @param string $context Optional. The operation for which the string is sanitized
    786788 * @return string The sanitized string.
    787789 */
    788 function sanitize_title($title, $fallback_title = '') {
     790function sanitize_title($title, $fallback_title = '', $context = 'save') {
    789791    $raw_title = $title;
    790     $title = strip_tags($title);
    791     $title = apply_filters('sanitize_title', $title, $raw_title);
     792
     793    if ( 'save' == $context )
     794        $title = remove_accents($title);
     795
     796    $title = apply_filters('sanitize_title', $title, $raw_title, $context);
    792797
    793798    if ( '' === $title || false === $title )
     
    795800
    796801    return $title;
     802}
     803
     804function sanitize_title_for_query($title) {
     805    return sanitize_title($title, '', 'query');
    797806}
    798807
     
    817826    $title = preg_replace('|---([a-fA-F0-9][a-fA-F0-9])---|', '%$1', $title);
    818827
    819     $title = remove_accents($title);
    820828    if (seems_utf8($title)) {
    821829        if (function_exists('mb_strtolower')) {
Note: See TracChangeset for help on using the changeset viewer.