WordPress.org

Make WordPress Core

Ticket #31186: 33186.3.patch

File 33186.3.patch, 1.8 KB (added by alexandruias, 5 years ago)

the same as the_author_meta

  • author-template.php

     
    6969 * Retrieve the author who last edited the current post.
    7070 *
    7171 * @since 2.8.0
     72 * @since 4.3.0 Added the `$field` parameter.
     73 * @param string $field Optional. User field to retrieve for the modified author. Accepts any WP_User field. Default 'display_name'.
    7274 *
    7375 * @return string The author's display name.
    7476 */
    75 function get_the_modified_author() {
     77function get_the_modified_author( $field = 'display_name' ) {
    7678        if ( $last_id = get_post_meta( get_post()->ID, '_edit_last', true) ) {
    7779                $last_user = get_userdata($last_id);
    78 
     80               
     81                if ( in_array ( $field, array( 'login', 'pass', 'nicename', 'email', 'url', 'registered', 'activation_key', 'status' ) ) )
     82                $field = 'user_' . $field;
     83                if ( ! isset ( $last_user->$field ) )
     84                                '';
     85                       
    7986                /**
    8087                 * Filter the display name of the author who last edited the current post.
    8188                 *
     
    8390                 *
    8491                 * @param string $last_user->display_name The author's display name.
    8592                 */
    86                 return apply_filters('the_modified_author', $last_user->display_name);
     93                return apply_filters('the_modified_author', $last_user->$field);
    8794        }
    8895}
    8996
     
    9198 * Display the name of the author who last edited the current post.
    9299 *
    93100 * @since 2.8.0
     101 * @since 4.3.0 Added the `$field` parameter.
     102 * @param string $field Optional. User field to retrieve for the modified author. Accepts any WP_User field. Default 'display_name'.
    94103 *
    95104 * @see get_the_author()
    96105 * @return string The author's display name, from get_the_modified_author().
    97106 */
    98 function the_modified_author() {
    99         echo get_the_modified_author();
     107function the_modified_author( $field = 'display_name' ) {
     108        echo get_the_modified_author( $field );
    100109}
    101110
    102111/**