WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Many Wordpress functions follow naming conventions, probably the most well known of these would be the the_*() functions, such as the_post(), used in The Loop.

Obviously the is_*() family of functions belong to the Conditionals. However, what are the common themes represented by the following function prefixes:

  • add_*()
  • register_*()
  • wp_*()
  • wp_insert_*()

It seems to me that the wp_insert_*() functions all perform INSERT statements on the database. That is, they change the state of the application. Is this correct?

It seems to me that the register_*() functions do not affect the database. That is, they make constructs available for the current page call only. Is this correct?

Is there a common theme for the wp_*() functions? Is this just an old pseudo-namespace that is no longer enforced?

The add_*() functions seem to be the most illogical. Some affect the database, such as add_post_meta(), and some don't add_theme_support(). What is common among the add_*() functions, and why aren't they called i.e. wp_insert_post_meta() and register_theme_support() for consistency?

share|improve this question
up vote 7 down vote accepted

The sweet and short is to not break your head over naming conventions or consistency in WordPress, as these are non existant "standards".

To be really honest, WordPress does not follow any fixed set of rules or standards, even though there is a handbook on coding standard available for WordPress developers. Yes, it would have being nice if they would have stuck to a certain pattern which was predictable, but they don't.

WordPress is over 10 years old and was never intended to be as big as it is today. Over that period, many core developers came and went, and because WordPress today is a community project to which anyone can submit ideas on improvements, new functionality, etc to, you'll find a lot of different coding styles and "standards" (like naming conventions) within core.

You are totally on the wrong track here if you are going to use naming conventions alone to find some common patterns between functions just based on leading words like add, register and the.

share|improve this answer
    
Thanks, Pieter. It seems that you speak the truth that I feared. – dotancohen Feb 24 at 12:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.