WordPress.org

Make WordPress Core

Ticket #3843: unicode-punctuation-removal.diff

File unicode-punctuation-removal.diff, 1.6 KB (added by noel, 10 years ago)

Permalink filter for unicode punctuation.

  • wp-includes/formatting.php

     
    367367        return $title;
    368368}
    369369
     370function sanitize_title_permalink($title) {
     371
     372        #remove unicode characters that are in the wrong unicode category
     373        $title = sanitize_title_with_dashes(preg_replace( '/[\p{P}\p{So}\p{M}\p{No}\p{Nl}]/u', '-', $title) );
     374
     375        return $title;
     376}
     377
    370378// ensures a string is a valid SQL order by clause like: post_name ASC, ID DESC
    371379// accepts one or more columns, with or without ASC/DESC, and also accepts RAND()
    372380function sanitize_sql_orderby( $orderby ){
  • wp-admin/includes/post.php

     
    574574        if (in_array($post->post_status, array('draft', 'pending'))) {
    575575                $post->post_status = 'publish';
    576576                $post->post_date = date('Y-m-d H:i:s');
    577                 $post->post_name = sanitize_title($post->post_name? $post->post_name : $post->post_title, $post->ID);
     577                $post->post_name = sanitize_title_permalink($post->post_name? $post->post_name : $post->post_title, $post->ID);
    578578        }
    579579
    580580        // If the user wants to set a new name -- override the current one
    581581        // Note: if empty name is supplied -- use the title instead, see #6072
    582582        if (!is_null($name)) {
    583                 $post->post_name = sanitize_title($name? $name : $title, $post->ID);
     583                $post->post_name = sanitize_title_permalink($name? $name : $title, $post->ID);
    584584        }
    585585
    586586        $permalink = get_permalink($post, true);