WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#30355 closed enhancement (fixed)

Create get_author_posts_link() function to return rather than echo HTML-formatted author posts link

Reported by: chipbennett Owned by: DrewAPicture
Milestone: 4.4 Priority: normal
Severity: normal Version: 1.2
Component: Themes Keywords: has-patch
Focuses: template Cc:

Description

Patch is fairly simple:

  1. Create get_author_posts_link() function, which is identical to current the_author_posts_link() function, except that the output is *returned* instead of *echoed*.
  2. Change the_author_posts_link() to echo the output of get_author_posts_link().

The primary purpose for creating the patch is to allow for the return value to be used in translation strings via sprintf(). Though, I'm sure there will be other uses.

Attachments (5)

get_author_posts_link.diff (1.8 KB) - added by chipbennett 5 years ago.
30355.diff (2.0 KB) - added by zrothauser 5 years ago.
Updated functions
30355.2.diff (1.9 KB) - added by wonderboymusic 4 years ago.
30355.3.diff (3.5 KB) - added by DrewAPicture 4 years ago.
30355.4.diff (3.6 KB) - added by DrewAPicture 4 years ago.

Download all attachments as: .zip

Change History (13)

#1 @johnbillion
5 years ago

  • Keywords has-patch added

#2 @obenland
5 years ago

  • Focuses template added
  • Milestone changed from Awaiting Review to Future Release

I like it, sounds like a sound improvement.

A few things I noticed:

  • We should probably call it get_the_author_posts_link().
  • The comment for the_author_posts_link() can start with "Display" again, rather than "Get".
  • the_author_posts_link() would need to continue accepting the deprecated argument.
  • We can drop the deprecated argument from get_the_author_posts_link() and don't need to pass it to it in the display function.
  • The double line break between the two functions should probably just remain one.
  • I'm not sure we need to update the function body with current coding guidelines, since it doesn't really need alterations, except for returning the result.

@zrothauser
5 years ago

Updated functions

#3 @chipbennett
5 years ago

Thanks, @zrothauser, you beat me to it.

#4 @johnbillion
5 years ago

  • Version changed from trunk to 1.2

#5 @wonderboymusic
4 years ago

  • Milestone changed from Future Release to 4.4
  • Owner set to DrewAPicture
  • Status changed from new to assigned

Refreshed so it doesn't explode 30355.2.diff

#6 @DrewAPicture
4 years ago

  • Status changed from assigned to accepted

@DrewAPicture
4 years ago

@DrewAPicture
4 years ago

#7 @DrewAPicture
4 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 34677:

Introduce get_the_author_posts_link(), which returns the HTML link to the author page for the current post's author.

the_author_posts_link() has in-turn been converted into a wrapper, with most of its logic moved to the new function.

Adds tests for the new function.

Props chipbennett, zrothauser, wonderboymusic, DrewAPicture.
Fixes #30355.

#8 @DrewAPicture
4 years ago

In 34678:

Tests: Flush rewrite rules between tests in an attempt to avoid permalinks pollution in Tests_Author_Template.

See #30355.

Note: See TracTickets for help on using tickets.