Ticket #31186: 31186(1).patch
File 31186(1).patch, 1.8 KB (added by , 9 years ago) |
---|
-
author-template.php
69 69 * Retrieve the author who last edited the current post. 70 70 * 71 71 * @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'. 72 74 * 73 75 * @return string The author's display name. 74 76 */ 75 function get_the_modified_author( ) {77 function get_the_modified_author( $field = 'display_name' ) { 76 78 if ( $last_id = get_post_meta( get_post()->ID, '_edit_last', true) ) { 77 79 $last_user = get_userdata($last_id); 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 $field = ''; 78 85 79 86 /** 80 87 * Filter the display name of the author who last edited the current post. … … 83 90 * 84 91 * @param string $last_user->display_name The author's display name. 85 92 */ 86 return apply_filters('the_modified_author', $last_user-> display_name);93 return apply_filters('the_modified_author', $last_user->$field); 87 94 } 88 95 } 89 96 … … 91 98 * Display the name of the author who last edited the current post. 92 99 * 93 100 * @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'. 94 103 * 95 104 * @see get_the_author() 96 105 * @return string The author's display name, from get_the_modified_author(). 97 106 */ 98 function the_modified_author( ) {99 echo get_the_modified_author( );107 function the_modified_author( $field = 'display_name' ) { 108 echo get_the_modified_author( $field ); 100 109 } 101 110 102 111 /**