wppaste
WordPress

create_initial_taxonomies()

Since
2.8.0, 5.9.0
Source
wp-includes/taxonomy.php:25
Creates the initial taxonomies.

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

Reads stored settings via get_option(), cached per request but not free on a cold cache.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
288–342

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 347.

Plugin surface
1 hook

Third-party callbacks on 'post_format_rewrite_base' run inside this call, and their cost is not bounded by anything here.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_filters()called directly
  • optionoption read or writeget_option()called directly
  • cacheobject cachewp_cache_get()one call below create_initial_taxonomies()
  • serializeserialisationmaybe_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.

WhenInstructionsCalls 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() && !$value327–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() && !$value331–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() && $value333–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() && !$value335–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() && $value337–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() && $value337–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() && $value341–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

PHPCompiledExecutedBranchesNotes
8.6-dev345288–34062 fewer instructions than PHP 8.5
8.5347288–3426
8.4347288–3426
8.3347288–3426
8.2347288–3426
8.1347288–34261 fewer instruction than PHP 7.4
7.4348288–3436

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:

  1. apply_filters( post_format_rewrite_base )filterline 45 (+20 into the body)

    Filters the post formats rewrite base.

Uses · 8

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.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

5.9.0
Added 'wp_template_part_area' taxonomy.from the docblock
2.8.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.0.4 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.