Opened 17 years ago
Closed 14 years ago
#8779 closed enhancement (wontfix)
Standardize get_*, add_*, delete_*, and update_* function names
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 2.8 |
Component: | Template | Keywords: | deprecated needs-patch functions naming |
Focuses: | Cc: |
Description
Of the approximately 500 or so functions like get_*, add_*, delete_*, and update_*, all except about 20 follow the format of separating each word with underscores, like so: get_attached_file
(as opposed to get_attachedfile
).
Those 20 that don't make things confusing and should be deprecated. This has already happened to some degree (take a look at the existing functions in wp-includes/deprecated.php).
This is not just a pedantic fix. Is it get_user_meta
or get_usermeta
, get_post_meta
or get_postmeta
? (One uses underscores, the other doesn't. I have to look up which is which almost every time I use them, and that's a lot).
To make things more confusing, we have similar-yet-inconsistently-named functions such as update_post_meta
and update_postmeta_cache
.
Someone may object that some of these are too much a part of WordPress to be changed. Not to worry--they can sit in deprecated.php for a long time, if you want. Besides, it won't be the first time that well-used functions have been deprecated (get_postdata
and the user_can*
functions, for example).
So please, let's deprecate these while it's early in 2.8 development.
Attachments (4)
Change History (10)
#2
in reply to:
↑ 1
@
16 years ago
Replying to Denis-de-Bernardy:
-1 on the _user_meta functions. they behave too differently from the _post_meta functions.
I think perhaps I wasn't very clear. I want to change the names because of syntax, not semantics: it doesn't matter whether the functions are exactly parallel in meaning or behavior (Will's patch could go either way and I'd recommend the same thing).
The point is that something like 95% of WordPress functions follow the syntax of separating nouns and verbs with underscores. That overwhelming majority in practice suggests, to me, a standard.
#3
@
16 years ago
oh, I should have been more clear. I wasn't meaning it was a bad idea, just that it would make sense to reserve those user_meta names for fixed up versions of those functions (see the other ticket)
-1 on the _user_meta functions. they behave too differently from the _post_meta functions.
see: #7540