create_initial_taxonomies()
- Since
- 2.8.0, 5.9.0
- Source
wp-includes/taxonomy.php:25
Description
This function fires twice: in wp-settings.php before plugins are loaded (for backward compatibility reasons), and again on the 'init' action. We must avoid registering rewrite rules before the 'init' action.
Compatibility
- WordPress
- since 5.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_taxonomies() 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
- Moderate
- Scaling
- Constant
- Instructions
- 288–342
- Plugin surface
- 1 hook
- 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 347.
Third-party callbacks on 'post_format_rewrite_base' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()called directly - optionoption read or write
get_option()called directly - cacheobject cache
wp_cache_get()one call below create_initial_taxonomies() - serializeserialisation
maybe_unserialize()one call below create_initial_taxonomies()
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 · 15 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost create_initial_taxonomies() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!did_action() | 288 | ::WP_Taxonomy(), did_action(), hierarchical(), hierarchical(), __(), __(), name(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name(), _x(), _x(), current_theme_supports(), name(), __(), __(), name(), __(), __(), name(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name() |
did_action() && !get_option() && !$value | 327–328 | ::WP_Taxonomy(), did_action(), apply_filters(), get_option(), get_option(), get_option(), get_option(), hierarchical(), hierarchical(), __(), __(), name(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name(), _x(), _x(), current_theme_supports(), name(), __(), __(), name(), __(), __(), name(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name() |
did_action() && !get_option() | 330–331 | ::WP_Taxonomy(), did_action(), apply_filters(), get_option(), get_option(), get_option(), get_option(), ->using_index_permalinks(), hierarchical(), hierarchical(), __(), __(), name(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name(), _x(), _x(), current_theme_supports(), name(), __(), __(), name(), __(), __(), name(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name() |
did_action() && !get_option() | 330–331 | ::WP_Taxonomy(), did_action(), apply_filters(), get_option(), get_option(), ->using_index_permalinks(), get_option(), get_option(), hierarchical(), hierarchical(), __(), __(), name(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name(), _x(), _x(), current_theme_supports(), name(), __(), __(), name(), __(), __(), name(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name() |
did_action() && !$value | 331–332 | ::WP_Taxonomy(), did_action(), apply_filters(), get_option(), get_option(), get_option(), get_option(), get_option(), hierarchical(), hierarchical(), __(), __(), name(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name(), _x(), _x(), current_theme_supports(), name(), __(), __(), name(), __(), __(), name(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name() |
did_action() && !get_option() && $value | 333–334 | ::WP_Taxonomy(), did_action(), apply_filters(), get_option(), get_option(), ->using_index_permalinks(), get_option(), get_option(), ->using_index_permalinks(), hierarchical(), hierarchical(), __(), __(), name(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name(), _x(), _x(), current_theme_supports(), name(), __(), __(), name(), __(), __(), name(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name() |
did_action() | 334–335 | ::WP_Taxonomy(), did_action(), apply_filters(), get_option(), get_option(), get_option(), get_option(), get_option(), ->using_index_permalinks(), hierarchical(), hierarchical(), __(), __(), name(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name(), _x(), _x(), current_theme_supports(), name(), __(), __(), name(), __(), __(), name(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name() |
did_action() | 334–335 | ::WP_Taxonomy(), did_action(), apply_filters(), get_option(), get_option(), ->using_index_permalinks(), get_option(), get_option(), get_option(), hierarchical(), hierarchical(), __(), __(), name(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name(), _x(), _x(), current_theme_supports(), name(), __(), __(), name(), __(), __(), name(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name() |
did_action() | 334–335 | ::WP_Taxonomy(), did_action(), apply_filters(), get_option(), get_option(), get_option(), ->using_index_permalinks(), get_option(), get_option(), hierarchical(), hierarchical(), __(), __(), name(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name(), _x(), _x(), current_theme_supports(), name(), __(), __(), name(), __(), __(), name(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name() |
did_action() && get_option() && !$value | 335–336 | ::WP_Taxonomy(), did_action(), apply_filters(), get_option(), get_option(), get_option(), get_option(), get_option(), get_option(), hierarchical(), hierarchical(), __(), __(), name(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name(), _x(), _x(), current_theme_supports(), name(), __(), __(), name(), __(), __(), name(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name() |
did_action() && $value | 337–338 | ::WP_Taxonomy(), did_action(), apply_filters(), get_option(), get_option(), ->using_index_permalinks(), get_option(), get_option(), get_option(), ->using_index_permalinks(), hierarchical(), hierarchical(), __(), __(), name(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name(), _x(), _x(), current_theme_supports(), name(), __(), __(), name(), __(), __(), name(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name() |
did_action() && $value | 337–338 | ::WP_Taxonomy(), did_action(), apply_filters(), get_option(), get_option(), get_option(), ->using_index_permalinks(), get_option(), get_option(), ->using_index_permalinks(), hierarchical(), hierarchical(), __(), __(), name(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name(), _x(), _x(), current_theme_supports(), name(), __(), __(), name(), __(), __(), name(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name() |
3 further outcomes, up to 342 instructions
did_action() && get_option() | 338–339 | ::WP_Taxonomy(), did_action(), apply_filters(), get_option(), get_option(), get_option(), get_option(), get_option(), get_option(), ->using_index_permalinks(), hierarchical(), hierarchical(), __(), __(), name(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name(), _x(), _x(), current_theme_supports(), name(), __(), __(), name(), __(), __(), name(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name() |
did_action() && get_option() | 338–339 | ::WP_Taxonomy(), did_action(), apply_filters(), get_option(), get_option(), get_option(), ->using_index_permalinks(), get_option(), get_option(), get_option(), hierarchical(), hierarchical(), __(), __(), name(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name(), _x(), _x(), current_theme_supports(), name(), __(), __(), name(), __(), __(), name(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name() |
did_action() && get_option() && $value | 341–342 | ::WP_Taxonomy(), did_action(), apply_filters(), get_option(), get_option(), get_option(), ->using_index_permalinks(), get_option(), get_option(), get_option(), ->using_index_permalinks(), hierarchical(), hierarchical(), __(), __(), name(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name(), _x(), _x(), current_theme_supports(), name(), __(), __(), name(), __(), __(), name(), _x(), _x(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 345 | 288–340 | 6 | 2 fewer instructions than PHP 8.5 |
| 8.5 | 347 | 288–342 | 6 | |
| 8.4 | 347 | 288–342 | 6 | |
| 8.3 | 347 | 288–342 | 6 | |
| 8.2 | 347 | 288–342 | 6 | |
| 8.1 | 347 | 288–342 | 6 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 348 | 288–343 | 6 |
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.
Hooks and filters fired · 1
One hook fires while create_initial_taxonomies() runs, in this order:
- apply_filters( post_format_rewrite_base )filterline 45 (+20 into the body)
Filters the post formats rewrite base.
Uses · 8
- did_action()Retrieves the number of times an action has been fired during the current request.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- get_option()Retrieves an option value based on an option name.
- register_taxonomy()Creates or modifies a taxonomy object.
- __()Retrieves the translation of $text.
- _x()Retrieves translated string with gettext context.
- current_theme_supports()Checks a theme's support for a given feature.
- WP_Taxonomy::reset_default_labels()Resets the cache for the default labels.
Source code
function create_initial_taxonomies() { global $wp_rewrite; WP_Taxonomy::reset_default_labels(); if ( ! did_action( 'init' ) ) { $rewrite = array( 'category' => false, 'post_tag' => false, 'post_format' => false, ); } else { /** * Filters the post formats rewrite base. * * @since 3.1.0 * * @param string $context Context of the rewrite base. Default 'type'. */ $post_format_base = apply_filters( 'post_format_rewrite_base', 'type' ); $rewrite = array( 'category' => array( 'hierarchical' => true, 'slug' => get_option( 'category_base' ) ? get_option( 'category_base' ) : 'category', 'with_front' => ! get_option( 'category_base' ) || $wp_rewrite->using_index_permalinks(), 'ep_mask' => EP_CATEGORIES, ), 'post_tag' => array( 'hierarchical' => false, 'slug' => get_option( 'tag_base' ) ? get_option( 'tag_base' ) : 'tag', 'with_front' => ! get_option( 'tag_base' ) || $wp_rewrite->using_index_permalinks(), 'ep_mask' => EP_TAGS, ), 'post_format' => $post_format_base ? array( 'slug' => $post_format_base ) : false, ); } register_taxonomy( 'category', 'post', array( 'hierarchical' => true, 'query_var' => 'category_name', 'rewrite' => $rewrite['category'], 'public' => true, 'show_ui' => true, 'show_admin_column' => true, '_builtin' => true, 'capabilities' => array( 'manage_terms' => 'manage_categories', 'edit_terms' => 'edit_categories', 'delete_terms' => 'delete_categories', 'assign_terms' => 'assign_categories', ), 'show_in_rest' => true, 'rest_base' => 'categories', 'rest_controller_class' => 'WP_REST_Terms_Controller', ) ); register_taxonomy( 'post_tag', 'post', array( 'hierarchical' => false, 'query_var' => 'tag', 'rewrite' => $rewrite['post_tag'], 'public' => true, 'show_ui' => true, 'show_admin_column' => true, '_builtin' => true, 'capabilities' => array( 'manage_terms' => 'manage_post_tags', 'edit_terms' => 'edit_post_tags', 'delete_terms' => 'delete_post_tags', 'assign_terms' => 'assign_post_tags', ), 'show_in_rest' => true, 'rest_base' => 'tags',Changelog
Introduced in 2.8.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
'wp_template_part_area' taxonomy.from the docblockAbout this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-includes/taxonomy.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.