Allow underscores in category and author names.

git-svn-id: http://svn.automattic.com/wordpress/trunk@1289 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
rboren 2004-05-16 22:07:26 +00:00
parent f6e35d2384
commit c454490973
2 changed files with 10 additions and 4 deletions

View File

@ -275,7 +275,7 @@ if ('' != $category_name) {
$category_name = $category_name[count($category_name)-2]; // there was a trailling slash $category_name = $category_name[count($category_name)-2]; // there was a trailling slash
} }
} }
$category_name = preg_replace('|[^a-z0-9-]|i', '', $category_name); $category_name = preg_replace('|[^a-z0-9-_]|i', '', $category_name);
$tables = ", $tablepost2cat, $tablecategories"; $tables = ", $tablepost2cat, $tablecategories";
$join = " LEFT JOIN $tablepost2cat ON ($tableposts.ID = $tablepost2cat.post_id) LEFT JOIN $tablecategories ON ($tablepost2cat.category_id = $tablecategories.cat_ID) "; $join = " LEFT JOIN $tablepost2cat ON ($tableposts.ID = $tablepost2cat.post_id) LEFT JOIN $tablecategories ON ($tablepost2cat.category_id = $tablecategories.cat_ID) ";
$whichcat = " AND (category_nicename = '$category_name'"; $whichcat = " AND (category_nicename = '$category_name'";
@ -323,7 +323,7 @@ if ('' != $author_name) {
$author_name = $author_name[count($author_name)-2];#there was a trailling slash $author_name = $author_name[count($author_name)-2];#there was a trailling slash
} }
} }
$author_name = preg_replace('|[^a-z0-9-]|', '', strtolower($author_name)); $author_name = preg_replace('|[^a-z0-9-_]|', '', strtolower($author_name));
$author = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_nicename='".$author_name."'"); $author = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_nicename='".$author_name."'");
$whichauthor .= ' AND (post_author = '.intval($author).')'; $whichauthor .= ' AND (post_author = '.intval($author).')';
} }

View File

@ -1,5 +1,7 @@
<?php <?php
add_action('sanitize_title', 'convert_spaces_to_dashes');
function wptexturize($text) { function wptexturize($text) {
$output = ''; $output = '';
// Capture tags and everything inside them // Capture tags and everything inside them
@ -81,12 +83,16 @@ function sanitize_title($title) {
$title = preg_replace('/&.+?;/', '', $title); // kill entities $title = preg_replace('/&.+?;/', '', $title); // kill entities
$title = preg_replace('/[^a-z0-9 -]/', '', $title); $title = preg_replace('/[^a-z0-9 -]/', '', $title);
$title = preg_replace('/\s+/', ' ', $title); $title = preg_replace('/\s+/', ' ', $title);
$title = do_action('sanitize_title', $title);
$title = trim($title); $title = trim($title);
$title = str_replace(' ', '-', $title);
$title = preg_replace('|-+|', '-', $title);
return $title; return $title;
} }
function convert_spaces_to_dashes($content) {
$content = str_replace(' ', '-', $content);
$content = preg_replace('|-+|', '-', $content);
}
function convert_chars($content, $flag = 'obsolete') { function convert_chars($content, $flag = 'obsolete') {
global $wp_htmltranswinuni; global $wp_htmltranswinuni;