WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#34234 closed task (blessed) (fixed)

Rename `id` param in get_the_permalink, get_permalink, and the_permalink

Reported by: chriscct7 Owned by: DrewAPicture
Milestone: 4.4 Priority: normal
Severity: normal Version:
Component: General Keywords: has-patch
Focuses: template Cc:

Description

The id param in get_the_permalink, get_permalink, and the_permalink isn't very intuitive. id is not a really good parameter name, partially because it doesn't actually describe what it is. Is it a post id? A user id? A random number called id? A serial number for a bikeshed? A MySQL column that autoincrements value?

If the id param was renamed to post it'd make the functions more self-documenting, and would require a minimal effort patch, making the functions more easily understood for newer developers by saving them the time of figuring out what exactly id is.

Attachments (1)

34234.diff (2.5 KB) - added by DrewAPicture 4 years ago.

Download all attachments as: .zip

Change History (5)

#1 @DrewAPicture
4 years ago

  • Focuses template added
  • Keywords needs-codex removed
  • Milestone changed from Awaiting Review to 4.4
  • Owner set to DrewAPicture
  • Status changed from new to accepted
  • Type changed from enhancement to task (blessed)

@DrewAPicture
4 years ago

#2 @DrewAPicture
4 years ago

  • Keywords has-patch added; needs-patch needs-docs removed

#3 @DrewAPicture
4 years ago

In 35001:

Template: Rename the $id parameters in the_permalink(), get_the_permalink(), and get_permalink() to $post.

In all three cases, the functions can accept a post ID, a WP_Post object, or a falsey value, which defaults to the value of the global $post. Switching to $post in this context allows the parameters to better self-document and removes ambiguity in the code they are subsequently used in.

Props chriscct7 for the initial patch.
See #34234.

#4 @DrewAPicture
4 years ago

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

In 35002:

Template: Pass the $post parameter to the the_permalink filter.

Props chriscct7.
Fixes #34234. See #23882.

Note: See TracTickets for help on using tickets.