Changeset 53147
- Timestamp:
- 04/11/2022 11:36:56 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/author-template.php
r52568 r53147 225 225 * @since 3.0.0 226 226 * 227 * @global WP_User $authordata The current author's data. 228 * 227 229 * @return string|null An HTML link if the author's url exist in user meta, 228 230 * else the result of get_the_author(). … … 230 232 function get_the_author_link() { 231 233 if ( get_the_author_meta( 'url' ) ) { 232 return sprintf( 234 global $authordata; 235 236 $author_url = get_the_author_meta( 'url' ); 237 $author_display_name = get_the_author(); 238 239 $link = sprintf( 233 240 '<a href="%1$s" title="%2$s" rel="author external">%3$s</a>', 234 esc_url( get_the_author_meta( 'url' )),241 esc_url( $author_url ), 235 242 /* translators: %s: Author's display name. */ 236 esc_attr( sprintf( __( 'Visit %s’s website' ), get_the_author()) ),237 get_the_author()243 esc_attr( sprintf( __( 'Visit %s’s website' ), $author_display_name ) ), 244 $author_display_name 238 245 ); 246 247 /** 248 * Filters the author URL link HTML. 249 * 250 * @since 6.0.0 251 * 252 * @param string $link The default rendered author HTML link. 253 * @param string $author_url Author's URL. 254 * @param WP_User $authordata Author user data. 255 */ 256 return apply_filters( 'the_author_link', $link, $author_url, $authordata ); 239 257 } else { 240 258 return get_the_author(); -
trunk/tests/phpunit/tests/user/author.php
r52389 r53147 20 20 'display_name' => 'Test Author', 21 21 'description' => 'test_author', 22 'user_url' => 'http://example.com', 22 23 ) 23 24 ); … … 145 146 } 146 147 148 /** 149 * @ticket 51859 150 * 151 * @covers ::get_the_author_link 152 */ 153 public function test_get_the_author_link() { 154 $author_url = get_the_author_meta( 'url' ); 155 $author_display_name = get_the_author(); 156 157 $link = get_the_author_link(); 158 159 $this->assertStringContainsString( $author_url, $link, 'The link does not contain the author URL' ); 160 $this->assertStringContainsString( $author_display_name, $link, 'The link does not contain the author display name' ); 161 } 162 163 /** 164 * @ticket 51859 165 * 166 * @covers ::get_the_author_link 167 */ 168 public function test_filtered_get_the_author_link() { 169 $filter = new MockAction(); 170 171 add_filter( 'the_author_link', array( &$filter, 'filter' ) ); 172 173 get_the_author_link(); 174 175 $this->assertSame( 1, $filter->get_call_count() ); 176 $this->assertSame( array( 'the_author_link' ), $filter->get_tags() ); 177 } 147 178 }
Note: See TracChangeset
for help on using the changeset viewer.