Make WordPress Core

Opened 17 years ago

Closed 14 years ago

#8779 closed enhancement (wontfix)

Standardize get_*, add_*, delete_*, and update_* function names

Reported by: filosofo's profile filosofo 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)

standardized_function_names.1.diff (331 bytes) - added by filosofo 17 years ago.
standardized_function_names.2.diff (49.0 KB) - added by filosofo 17 years ago.
standardized_function_names.diff (37.8 KB) - added by filosofo 17 years ago.
standardized_function_names.3.diff (10.7 KB) - added by filosofo 17 years ago.

Download all attachments as: .zip

Change History (10)

#1 follow-up: @Denis-de-Bernardy
16 years ago

  • Type changed from defect (bug) to enhancement

-1 on the _user_meta functions. they behave too differently from the _post_meta functions.

see: #7540

#2 in reply to: ↑ 1 @filosofo
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 @Denis-de-Bernardy
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)

#4 @Denis-de-Bernardy
16 years ago

  • Keywords needs-patch added; has-patch removed
  • Milestone changed from 2.8 to Future Release

patches no longer all apply cleanly.

#5 @Denis-de-Bernardy
16 years ago

  • Component changed from General to Template

#6 @ryan
14 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from new to closed

Some of these have been cleaned up. The rest likely won't be. Resolving.

Note: See TracTickets for help on using tickets.