#11624 closed enhancement (fixed)
Stop using $id global
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 3.1 |
| Component: | General | Version: | |
| Severity: | normal | Keywords: | has-patch commit |
| Cc: | scribu@…, mpretty@… |
Description
We already have the $post global which has the ID field.
So the $id global can be replaced with $post->ID everywhere.
Attachments (2)
Change History (18)
that's a big change which might potentially break a lot of themes and plugins.
comment:5
in reply to:
↑ 3
Denis-de-Bernardy — 3 years ago
Replying to scribu:
Such as?
Subscribe to comments comes to mind. Or at least it did in prior versions. I'm sure we'd find a few by looking.
comment:6
prettyboymp — 3 years ago
- Keywords tested added
This shouldn't affect plugins that still use global $id since it will be still be set in setup_post_content(). Core functions will just stop using it. Its at least a small step in getting rid of all the globals.
- Keywords tested commit removed
I would commit this, but we use $id in a lot more places than post.php. It's not a bad idea to reduce our dependence on globals even by one, but we might as well do it across the board if we are to do it.
Should we create a ticket with the grand project of getting rid of all globals for 3.1?
comment:10
in reply to:
↑ 9
;
follow-up:
↓ 11
nacin — 3 years ago
Replying to xibe:
Should we create a ticket with the grand project of getting rid of all globals for 3.1?
Heh, yea, that's not going to happen so easily. :)
comment:11
in reply to:
↑ 10
xibe — 3 years ago
Replying to nacin:
Heh, yea, that's not going to happen so easily. :)
I guess so :)
But that would most certainly appease a lot of developers who like to snark at the "code is poetry" motto.
comment:12
nacin — 3 years ago
- Milestone changed from 3.0 to Future Release
Moving out of 3.0 for now.
comment:14
scribu — 3 years ago
- Keywords commit added
- Milestone changed from Future Release to 3.1
Updated patch removes all instances of $id that I could find.
comment:15
scribu — 3 years ago
- Resolution set to fixed
- Status changed from new to closed

Remove $id global from the_ID(), get_the_ID() and get_the_content()