Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#24273 closed enhancement (fixed)

Provide a way for Theme/Plugin developers to get a list of user contact methods

Reported by: johnnyb Owned by: nacin
Milestone: 3.7 Priority: normal
Severity: normal Version:
Component: Users Keywords: has-patch
Focuses: Cc:


When templating an author page it is useful to be able to provide a list of social media links. There's great support for adding custom links using the user_contactmethods filter, but there's no public way to get a list of those contact methods without the user's other info mixed in.

There is a private function _wp_get_user_contactmethods(), that does this. Why not make it public?

Attachments (2)

24273-public-contactmethods.diff (2.3 KB) - added by johnnyb 2 years ago.
Make the method public.
24273-user.php.diff (583 bytes) - added by johnnyb 2 years ago.
Public wrapper for private method.

Download all attachments as: .zip

Change History (9)

comment:1 @johnnyb2 years ago

I'll submit a patch in a few minutes.

@johnnyb2 years ago

Make the method public.

comment:2 follow-up: @johnnyb2 years ago

  • Keywords has-patch added

Patch added. It simply declares the function public, and removes the _ from the beginning of the function name, (and from calls to the function).

We could also provide a private wrapper for the public function if we need to reserve the right to modify the private implementation at some point.

comment:3 in reply to: ↑ 2 @SergeyBiryukov2 years ago

I guess the cleaner approach would be to leave the private function as is and introduce a public wrapper.

@johnnyb2 years ago

Public wrapper for private method.

comment:4 @johnnyb2 years ago

The new patch uses the public wrapper instead of renaming the private method.

comment:5 @ramiy2 years ago

Related: #24952

comment:6 @SergeyBiryukov2 years ago

  • Milestone changed from Awaiting Review to 3.7

comment:7 @nacin2 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 25606:

Introduce wp_get_user_contact_methods() as a public version of _wp_get_user_contactmethods.

props johnnyb.
fixes #24273.

Note: See TracTickets for help on using tickets.