Do not include wp-admin/includes/template.php to get add_meta_box()

Don’t include wp-adminadmin (and super admin)/includes/template.php to get add_meta_box() defined. This is a very wrong way to go about adding metaMeta Meta is a term that refers to the inside workings of a group. For us, this is the team that works on internal WordPress sites like WordCamp Central and Make WordPress. boxes.

The proper way to call add_meta_box() is to consider it to be admin-only (because it is). What you do is call add_meta_box() on the admin_init hook, or even better, the add_meta_boxes or add_meta_boxes_{$page} hooksHooks In WordPress theme and development, hooks are functions that can be applied to an action or a Filter in WordPress. Actions are functions performed when a certain event occurs in WordPress. Filters allow you to modify certain functions. Arguments used to hook both filters and actions look the same.. (Where $page is either a post type or ‘link’ or ‘comments’.)

Then there’s no need to include an admin file — the function will always exist when it is called.

During 3.3’s development, we noticed that some plugins were doing this, so we wanted to make the PSA.

#3-3, #dev-notes