Permalinks: Avoid a PHP notice in `get_permalink()` if default category is unavailable.

Props Presskopp.
Fixes #36529.

git-svn-id: https://develop.svn.wordpress.org/trunk@37707 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2016-06-14 23:11:33 +00:00
parent 2e79b18178
commit 57d2c46591
1 changed files with 3 additions and 1 deletions

View File

@ -191,7 +191,9 @@ function get_permalink( $post = 0, $leavename = false ) {
// having to assign it explicitly
if ( empty($category) ) {
$default_category = get_term( get_option( 'default_category' ), 'category' );
$category = is_wp_error( $default_category ) ? '' : $default_category->slug;
if ( $default_category && ! is_wp_error( $default_category ) ) {
$category = $default_category->slug;
}
}
}