Make WordPress Core


Ignore:
Timestamp:
04/15/2022 01:45:25 PM (3 years ago)
Author:
audrasjb
Message:

Users: Avoid warning on the_modified_author when get_userdata() returns false.

This change adds a check of the value returned by get_userdata() before using it in get_the_modified_author(). It avoids a warning when retrieving the last author who edited the current post.

Props juanlopez4691, mukesh27.
Fixes #55420.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/author-template.php

    r53147 r53187  
    8787 * @since 2.8.0
    8888 *
    89  * @return string|void The author's display name.
     89 * @return string|void The author's display name, empty string if unkown.
    9090 */
    9191function get_the_modified_author() {
     
    100100         * @since 2.8.0
    101101         *
    102          * @param string $display_name The author's display name.
     102         * @param string $display_name The author's display name, empty string if unkown.
    103103         */
    104         return apply_filters( 'the_modified_author', $last_user->display_name );
     104        return apply_filters( 'the_modified_author', $last_user ? $last_user->display_name : '' );
    105105    }
    106106}
Note: See TracChangeset for help on using the changeset viewer.