create_initial_post_types()
- Since
- 2.9.0
- Source
wp-includes/post.php:20
Description
See 'init'.
Compatibility
- WordPress
- since 2.9.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Performance profile
How much work a call to create_initial_post_types() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Heavy
- Scaling
- Constant
- Instructions
- 955–956
- Plugin surface
- None
- Called by
- 0
Reads stored settings via get_option(), cached per request but not free on a cold cache.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 960.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- optionoption read or write
get_option()called directly - hookthird-party callbacks
do_action()one call below create_initial_post_types() - cacheobject cache
wp_cache_get()one call below create_initial_post_types() - serializeserialisation
maybe_unserialize()one call below create_initial_post_types()
Further down the call graph this can also reach query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost create_initial_post_types() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 955–956 | ::WP_Post_Type(), _x(), labels(), _x(), labels(), _x(), _x(), __(), __(), get_option(), __(), __(), labels(), add_post_type_support(), add_post_type_support(), __(), __(), labels(), __(), __(), labels(), __(), __(), labels(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), labels(), __(), __(), labels(), __(), __(), labels(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), labels(), build_query(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), labels(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), labels(), _x(), __(), label(), remove_post_type_support(), build_query(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), labels(), __(), __(), labels(), __(), __(), labels(), _x(), _n_noop(), label(), _x(), _n_noop(), label(), _x(), _n_noop(), label(), _x(), _n_noop(), label(), _x(), _n_noop(), label(), _x(), _n_noop(), label(), register_post_status(), register_post_status(), _x(), _n_noop(), label(), _x(), _n_noop(), label(), _x(), _n_noop(), label(), _x(), _n_noop(), label() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 958 | 954–955 | 1 | 2 fewer instructions than PHP 8.5 |
| 8.5 | 960 | 955–956 | 1 | |
| 8.4 | 960 | 955–956 | 1 | |
| 8.3 | 960 | 955–956 | 1 | |
| 8.2 | 960 | 955–956 | 1 | |
| 8.1 | 960 | 955–956 | 1 | |
| 7.4 | 960 | 955–956 | 1 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 10
- register_post_type()Registers a post type.
- _x()Retrieves translated string with gettext context.
- __()Retrieves the translation of $text.
- get_option()Retrieves an option value based on an option name.
- add_post_type_support()Registers support of certain features for a post type.
- build_query()Builds URL query based on an associative and, or indexed array.
- remove_post_type_support()Removes support for a feature from a post type.
- register_post_status()Registers a post status. Do not use before init.
- _n_noop()Registers plural strings in POT file, but does not translate them.
- WP_Post_Type::reset_default_labels()Resets the cache for the default labels.
Source code
function create_initial_post_types() { WP_Post_Type::reset_default_labels(); register_post_type( 'post', array( 'labels' => array( 'name_admin_bar' => _x( 'Post', 'add new from admin bar' ), ), 'public' => true, '_builtin' => true, /* internal use only. don't use this when registering your own post type. */ '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */ 'capability_type' => 'post', 'map_meta_cap' => true, 'menu_position' => 5, 'menu_icon' => 'dashicons-admin-post', 'hierarchical' => false, 'rewrite' => false, 'query_var' => false, 'delete_with_user' => true, 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ), 'show_in_rest' => true, 'rest_base' => 'posts', 'rest_controller_class' => 'WP_REST_Posts_Controller', ) ); register_post_type( 'page', array( 'labels' => array( 'name_admin_bar' => _x( 'Page', 'add new from admin bar' ), ), 'public' => true, 'publicly_queryable' => false, '_builtin' => true, /* internal use only. don't use this when registering your own post type. */ '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */ 'capability_type' => 'page', 'map_meta_cap' => true, 'menu_position' => 20, 'menu_icon' => 'dashicons-admin-page', 'hierarchical' => true, 'rewrite' => false, 'query_var' => false, 'delete_with_user' => true, 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions' ), 'show_in_rest' => true, 'rest_base' => 'pages', 'rest_controller_class' => 'WP_REST_Posts_Controller', ) ); register_post_type( 'attachment', array( 'labels' => array( 'name' => _x( 'Media', 'post type general name' ), 'name_admin_bar' => _x( 'Media', 'add new from admin bar' ), 'add_new' => __( 'Add Media File' ), 'edit_item' => __( 'Edit Media' ), 'view_item' => ( '1' === get_option( 'wp_attachment_pages_enabled' ) ) ? __( 'View Attachment Page' ) : __( 'View Media File' ), 'attributes' => __( 'Attachment Attributes' ), ), 'public' => true, 'show_ui' => true, '_builtin' => true, /* internal use only. don't use this when registering your own post type. */ '_edit_link' => 'post.php?post=%d', /* internal use only. don't use this when registering your own post type. */ 'capability_type' => 'post', 'capabilities' => array( 'create_posts' => 'upload_files', ), 'map_meta_cap' => true, 'menu_icon' => 'dashicons-admin-media', 'hierarchical' => false, 'rewrite' => false, 'query_var' => false, 'show_in_nav_menus' => false, 'delete_with_user' => true, 'supports' => array( 'title', 'author', 'comments' ), 'show_in_rest' => true,Changelog
Introduced in 2.9.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.8.8 tag, from
src/wp-includes/post.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.