@@ -229,24 +229,29 @@ function the_author_meta( $field = '', $user_id = false ) {
229229 * the author's name.
230230 *
231231 * @since 3.0.0
232+ * @since 7.0.0 Added `$use_title_attr` parameter.
232233 *
233234 * @global WP_User $authordata The current author's data.
234235 *
236+ * @param bool $use_title_attr Optional. Whether to add a title attribute.
237+ * Default true.
235238 * @return string An HTML link if the author's URL exists in user meta,
236239 * otherwise the result of get_the_author().
237240 */
238- function get_the_author_link () {
241+ function get_the_author_link ( $ use_title_attr = true ) {
239242 if ( get_the_author_meta ( 'url ' ) ) {
240243 global $ authordata ;
241244
242245 $ author_url = get_the_author_meta ( 'url ' );
243246 $ author_display_name = get_the_author ();
244247
248+ /* translators: %s: Author's display name. */
249+ $ author_title = sprintf ( __ ( 'Visit %s’s website ' ), $ author_display_name );
250+
245251 $ link = sprintf (
246- '<a href="%1$s" title=" %2$s" rel="author external">%3$s</a> ' ,
252+ '<a href="%1$s"%2$s rel="author external">%3$s</a> ' ,
247253 esc_url ( $ author_url ),
248- /* translators: %s: Author's display name. */
249- esc_attr ( sprintf ( __ ( 'Visit %s’s website ' ), $ author_display_name ) ),
254+ $ use_title_attr ? ' title=" ' . esc_attr ( $ author_title ) . '" ' : '' ,
250255 $ author_display_name
251256 );
252257
@@ -274,9 +279,13 @@ function get_the_author_link() {
274279 * @link https://developer.wordpress.org/reference/functions/the_author_link/
275280 *
276281 * @since 2.1.0
282+ * @since 7.0.0 Added `$use_title_attr` parameter.
283+ *
284+ * @param bool $use_title_attr Optional. Whether to add a title attribute.
285+ * Default true.
277286 */
278- function the_author_link () {
279- echo get_the_author_link ();
287+ function the_author_link ( $ use_title_attr = true ) {
288+ echo get_the_author_link ( $ use_title_attr );
280289}
281290
282291/**
@@ -310,6 +319,7 @@ function the_author_posts() {
310319 * Returns an HTML-formatted link using get_author_posts_url().
311320 *
312321 * @since 4.4.0
322+ * @since 7.0.0 Removed title attribute.
313323 *
314324 * @global WP_User $authordata The current author's data.
315325 *
@@ -322,22 +332,27 @@ function get_the_author_posts_link() {
322332 return '' ;
323333 }
324334
335+ $ author = get_the_author ();
336+ /* translators: %s: Author's display name. */
337+ $ title = sprintf ( __ ( 'Posts by %s ' ), $ author );
338+
325339 $ link = sprintf (
326- '<a href="%1$s" title="%2$s" rel="author">%3 $s</a> ' ,
340+ '<a href="%1$s" rel="author">%2 $s</a> ' ,
327341 esc_url ( get_author_posts_url ( $ authordata ->ID , $ authordata ->user_nicename ) ),
328- /* translators: %s: Author's display name. */
329- esc_attr ( sprintf ( __ ( 'Posts by %s ' ), get_the_author () ) ),
330- get_the_author ()
342+ $ author
331343 );
332344
333345 /**
334346 * Filters the link to the author page of the author of the current post.
335347 *
336348 * @since 2.9.0
349+ * @since 7.0.0 Added `$author` and `$title` parameters.
337350 *
338- * @param string $link HTML link.
351+ * @param string $link HTML link.
352+ * @param string $author Author's display name.
353+ * @param string $title Text originally used for a title attribute.
339354 */
340- return apply_filters ( 'the_author_posts_link ' , $ link );
355+ return apply_filters ( 'the_author_posts_link ' , $ link, $ author , $ title );
341356}
342357
343358/**
@@ -536,10 +551,8 @@ function wp_list_authors( $args = '' ) {
536551 }
537552
538553 $ link = sprintf (
539- '<a href="%1$s" title="%2$s">%3 $s</a> ' ,
554+ '<a href="%1$s">%2 $s</a> ' ,
540555 esc_url ( get_author_posts_url ( $ author ->ID , $ author ->user_nicename ) ),
541- /* translators: %s: Author's display name. */
542- esc_attr ( sprintf ( __ ( 'Posts by %s ' ), $ author ->display_name ) ),
543556 $ name
544557 );
545558
0 commit comments