Why do some core functions get wp_ while others do not? What’s the rule?

Is there some guideline or rationale behind why some WP code functions are prefixed with wp_ ? eg: wp_insert_post() vs. update_post_meta()

Related posts

Leave a Reply

4 comments

  1. This makes not that impressive answer, but – none.

    get_ is suffix usually means function returns something, the_ that function echoes something.

    wp_ doesn’t carry technical meaning and inconsistency in naming is from many developers participating and lack of movement to unify (moving forward is considered more important than major cleanups of older stuff to make it neat).

  2. WordPress was and is written by a lot of different people. Patches are discussed inside wordpress trac and whoever submits or assigns to a trac ticket can post patches. If the patch gets accepted and moved into core of an upcoming version it’s simply in there. So sometimes functions, vars, etc. gets the prefix while other times they don’t. It relies on the participating developers.

  3. The wp_ prefix is usually added to avoid naming conflicts with:

    • native PHP functions, such as get_current_user()
    • older/deprecated WP functions, such as get_archives()
    • third-party libraries?
  4. I always assumed the distinction was that – beyond the basic template tags, which generally just have the simplest descriptive name possible:

    1. functions that begin with wp_ are generally high-level public API functions, which are pretty much guaranteed to always be around and retain forwards-compatability.
    2. functions without that prefix are internals, stuff you shouldn’t muck around with unless you know what you’re doing.

    I don’t know if this was ever intentional, though. And like the other two answers have said, it doesn’t hold up consistently. Your example of update_post_meta is a perfect example of something that seems like it should should have a wp_ prefix if my classification held true. But there’s enough deep legacy code in WordPress to throw off any attempt at making sense of any naming convention.