From d3c2c2852f8c7c082d6552e8ad3b285edde996c8 Mon Sep 17 00:00:00 2001 From: rboren Date: Mon, 17 Jan 2005 20:16:22 +0000 Subject: [PATCH] Fix $id arg processing for get_the_title(). Also, mark "Protected:" for translation. Bug 706. Props: morganiq git-svn-id: http://svn.automattic.com/wordpress/trunk@2099 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/template-functions-post.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/wp-includes/template-functions-post.php b/wp-includes/template-functions-post.php index 8a4be9b1c4..c5cd8e3ecb 100644 --- a/wp-includes/template-functions-post.php +++ b/wp-includes/template-functions-post.php @@ -41,13 +41,17 @@ function the_title($before = '', $after = '', $echo = true) { function get_the_title($id = 0) { global $post, $wpdb; - $title = $post->post_title; - - if ( 0 != $id ) - $title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID = $id"); - - if ( !empty($post->post_password) ) { // if there's a password - $title = 'Protected: ' . $title; + + if ( 0 != $id ) { + $id_post = $wpdb->get_row("SELECT post_title, post_password FROM $wpdb->posts WHERE ID = $id"); + $title = $id_post->post_title; + if (!empty($id_post->post_password)) + $title = sprintf(__('Protected: %s'), $title); + } + else { + $title = $post->post_title; + if (!empty($post->post_password)) + $title = sprintf(__('Protected: %s'), $title); } return $title; } @@ -57,7 +61,7 @@ function get_the_guid( $id = 0 ) { $guid = $post->guid; if ( 0 != $id ) - $title = $wpdb->get_var("SELECT guid FROM $wpdb->posts WHERE ID = $id"); + $guid = $wpdb->get_var("SELECT guid FROM $wpdb->posts WHERE ID = $id"); $guid = apply_filters('get_the_guid', $guid); return $guid; }