Make WordPress Core

Opened 12 years ago

Closed 11 years ago

Last modified 11 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
Priority: normal Milestone: 4.4
Component: Themes Version: 1.2
Severity: normal Keywords: has-patch
Cc: Focuses: template

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 12 years ago.
30355.diff (2.0 KB ) - added by zrothauser 12 years ago.
Updated functions
30355.2.diff (1.9 KB ) - added by wonderboymusic 11 years ago.
30355.3.diff (3.5 KB ) - added by DrewAPicture 11 years ago.
30355.4.diff (3.6 KB ) - added by DrewAPicture 11 years ago.

Download all attachments as: .zip

Change History (13)

#1 @johnbillion
12 years ago

  • Keywords has-patch added

#2 @obenland
12 years ago

  • Focuses template added
  • Milestone Awaiting ReviewFuture 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
12 years ago

Updated functions

#3 @chipbennett
12 years ago

Thanks, @zrothauser, you beat me to it.

#4 @johnbillion
12 years ago

  • Version trunk1.2

#5 @wonderboymusic
11 years ago

  • Milestone Future Release4.4
  • Owner set to DrewAPicture
  • Status newassigned

Refreshed so it doesn't explode 30355.2.diff

#6 @DrewAPicture
11 years ago

  • Status assignedaccepted

#7 @DrewAPicture
11 years ago

  • Resolutionfixed
  • Status acceptedclosed

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
11 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.