If the sanitized title is empty, fallback to the post ID for the nicename. http://mosquito.wordpress.org/bug_view_page.php?bug_id=0000116

git-svn-id: http://svn.automattic.com/wordpress/trunk@1481 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
rboren 2004-07-24 03:22:49 +00:00
parent 2577287a67
commit 8633ffdba4
2 changed files with 12 additions and 8 deletions

View File

@ -45,6 +45,8 @@ case 'post':
$standalone = 1; $standalone = 1;
require_once('admin-header.php'); require_once('admin-header.php');
$post_ID = $wpdb->get_var("SELECT ID FROM $wpdb->posts ORDER BY ID DESC LIMIT 1") + 1;
$post_pingback = intval($_POST['post_pingback']); $post_pingback = intval($_POST['post_pingback']);
$content = balanceTags($_POST['content']); $content = balanceTags($_POST['content']);
$content = format_to_post($content); $content = format_to_post($content);
@ -71,9 +73,9 @@ case 'post':
$post_password = $_POST['post_password']; $post_password = $_POST['post_password'];
if (empty($post_name)) if (empty($post_name))
$post_name = sanitize_title($post_title); $post_name = sanitize_title($post_title, $post_ID);
else else
$post_name = sanitize_title($post_name); $post_name = sanitize_title($post_name, $post_ID);
$trackback = $_POST['trackback_url']; $trackback = $_POST['trackback_url'];
// Format trackbacks // Format trackbacks
@ -123,8 +125,6 @@ case 'post':
$result = $wpdb->query($postquery); $result = $wpdb->query($postquery);
$post_ID = $wpdb->get_var("SELECT ID FROM $wpdb->posts ORDER BY ID DESC LIMIT 1");
if (!empty($_POST['mode'])) { if (!empty($_POST['mode'])) {
switch($_POST['mode']) { switch($_POST['mode']) {
case 'bookmarklet': case 'bookmarklet':
@ -302,7 +302,7 @@ case 'editpost':
if (empty($ping_status)) $ping_status = 'closed'; if (empty($ping_status)) $ping_status = 'closed';
//if (!$_POST['ping_status']) $ping_status = get_settings('default_ping_status'); //if (!$_POST['ping_status']) $ping_status = get_settings('default_ping_status');
$post_password = $_POST['post_password']; $post_password = $_POST['post_password'];
$post_name = sanitize_title($_POST['post_name']); $post_name = sanitize_title($_POST['post_name'], $post_ID);
if (empty($post_name)) $post_name = sanitize_title($post_title); if (empty($post_name)) $post_name = sanitize_title($post_title);
$trackback = $_POST['trackback_url']; $trackback = $_POST['trackback_url'];
// Format trackbacks // Format trackbacks

View File

@ -1,6 +1,6 @@
<?php <?php
add_action('sanitize_title', 'sanitize_title_with_dashes'); add_filter('sanitize_title', 'sanitize_title_with_dashes');
function wptexturize($text) { function wptexturize($text) {
$output = ''; $output = '';
@ -119,8 +119,12 @@ function remove_accents($string) {
return $string; return $string;
} }
function sanitize_title($title) { function sanitize_title($title, $fallback_title = '') {
$title = do_action('sanitize_title', $title); $title = apply_filters('sanitize_title', $title);
if (empty($title)) {
$title = $fallback_title;
}
return $title; return $title;
} }