Fix notices in get_the_title() when passed an invalid id. Also ensure that the filter gets the invalid id so a plugin can supply a default title instead. Fixes #11435 props filosofo.

git-svn-id: http://svn.automattic.com/wordpress/trunk@12550 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
westi 2009-12-27 08:57:33 +00:00
parent 95b7f66b45
commit 33dc129208
1 changed files with 3 additions and 2 deletions

View File

@ -106,7 +106,8 @@ function the_title_attribute( $args = '' ) {
function get_the_title( $id = 0 ) { function get_the_title( $id = 0 ) {
$post = &get_post($id); $post = &get_post($id);
$title = $post->post_title; $title = isset($post->post_title) ? $post->post_title : '';
$id = isset($post->ID) ? $post->ID : (int) $id;
if ( !is_admin() ) { if ( !is_admin() ) {
if ( !empty($post->post_password) ) { if ( !empty($post->post_password) ) {
@ -117,7 +118,7 @@ function get_the_title( $id = 0 ) {
$title = sprintf($private_title_format, $title); $title = sprintf($private_title_format, $title);
} }
} }
return apply_filters( 'the_title', $title, $post->ID ); return apply_filters( 'the_title', $title, $id );
} }
/** /**