Skip to content

Commit 6d7bf5f

Browse files
authored
Avoid a range of PHP Notices when a post/page/custom post type doesn't have a post_author.
1 parent e95f038 commit 6d7bf5f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

inc/fragment.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,13 @@ public static function get_model_from_userdata( $user_data ) {
503503
*/
504504

505505
public static function get_post_user_properties( $_post ) {
506+
if ( ! $_post->post_author ) {
507+
return array(
508+
'userLogin' => '',
509+
'userNicename' => ''
510+
);
511+
}
512+
506513
$user_id = $_post->post_author;
507514
$user_data = get_userdata( $user_id );
508515
self::add_to_user_bootstrap( $user_data );

0 commit comments

Comments
 (0)