wppaste
WordPress

twentyten_setup()

Since
Twenty Ten 1.0
Source
wp-content/themes/twentyten/functions.php:78
Sets up theme defaults and registers support for various WordPress features.

Description

Note that this function is hooked into the after_setup_theme hook, which runs before the init hook. The init hook is too late for some features, such as indicating support post thumbnails.

To override twentyten_setup() in a child theme, add your own twentyten_setup to your child theme's functions.php file.

Compatibility

WordPress
since Twenty Ten 1.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 twentyten_setup() 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
Trivial

Touches nothing outside its own arguments.

Scaling
Constant

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

Instructions
181–213

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

Plugin surface
2 hooks

Third-party callbacks on 'twentyten_header_image_width', 'twentyten_header_image_height' 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

Further down the call graph this can also reach option, cache, serialize, transient and query. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 4 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost twentyten_setup() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
!version_compare() && function_exists()181add_editor_style(), add_theme_support(), add_theme_support(), __(), __(), __(), __(), __(), name(), add_theme_support(), add_theme_support(), add_theme_support(), version_compare(), __(), primary(), add_theme_support(), apply_filters(), apply_filters(), add_theme_support(), function_exists(), set_post_thumbnail_size(), __(), __(), __(), __(), __(), __(), __(), __(), %s/images/headers/sunset.jpg()
version_compare() && function_exists()188add_editor_style(), add_theme_support(), add_theme_support(), __(), __(), __(), __(), __(), name(), add_theme_support(), add_theme_support(), add_theme_support(), version_compare(), get_template_directory(), load_theme_textdomain(), __(), primary(), add_theme_support(), apply_filters(), apply_filters(), add_theme_support(), function_exists(), set_post_thumbnail_size(), __(), __(), __(), __(), __(), __(), __(), __(), %s/images/headers/sunset.jpg()
!version_compare() && !function_exists()206add_editor_style(), add_theme_support(), add_theme_support(), __(), __(), __(), __(), __(), name(), add_theme_support(), add_theme_support(), add_theme_support(), version_compare(), __(), primary(), add_theme_support(), apply_filters(), apply_filters(), add_theme_support(), function_exists(), define(), define(), define(), add_custom_image_header(), add_custom_background(), set_post_thumbnail_size(), __(), __(), __(), __(), __(), __(), __(), __(), %s/images/headers/sunset.jpg()
version_compare() && !function_exists()213add_editor_style(), add_theme_support(), add_theme_support(), __(), __(), __(), __(), __(), name(), add_theme_support(), add_theme_support(), add_theme_support(), version_compare(), get_template_directory(), load_theme_textdomain(), __(), primary(), add_theme_support(), apply_filters(), apply_filters(), add_theme_support(), function_exists(), define(), define(), define(), add_custom_image_header(), add_custom_background(), set_post_thumbnail_size(), __(), __(), __(), __(), __(), __(), __(), __(), %s/images/headers/sunset.jpg()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev213181–2132
8.5213181–2132
8.4213181–2132
8.3213181–2132
8.2213181–2132
8.1213181–21321 fewer instruction than PHP 7.4
7.4214182–2142

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 · 2

2 hooks fire while twentyten_setup() runs, in this order:

  1. apply_filters( twentyten_header_image_width )filterline 175 (+97 into the body)

    Filters the Twenty Ten default header image width.

  2. apply_filters( twentyten_header_image_height )filterline 183 (+105 into the body)

    Filters the Twenty Ten default header image height.

Uses · 11

Source code

	function twentyten_setup() { 		// This theme styles the visual editor with editor-style.css to match the theme style.		add_editor_style(); 		// Load regular editor styles into the new block-based editor.		add_theme_support( 'editor-styles' ); 		// Load default block styles.		add_theme_support( 'wp-block-styles' ); 		// Add support for custom color scheme.		add_theme_support(			'editor-color-palette',			array(				array(					'name'  => __( 'Blue', 'twentyten' ),					'slug'  => 'blue',					'color' => '#0066cc',				),				array(					'name'  => __( 'Black', 'twentyten' ),					'slug'  => 'black',					'color' => '#000',				),				array(					'name'  => __( 'Medium Gray', 'twentyten' ),					'slug'  => 'medium-gray',					'color' => '#666',				),				array(					'name'  => __( 'Light Gray', 'twentyten' ),					'slug'  => 'light-gray',					'color' => '#f1f1f1',				),				array(					'name'  => __( 'White', 'twentyten' ),					'slug'  => 'white',					'color' => '#fff',				),			)		); 		// Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories.		add_theme_support( 'post-formats', array( 'aside', 'gallery' ) ); 		// This theme uses post thumbnails.		add_theme_support( 'post-thumbnails' ); 		// Add default posts and comments RSS feed links to head.		add_theme_support( 'automatic-feed-links' ); 		/*		 * Make theme available for translation.		 * Translations can be filed in the /languages/ directory.		 *		 * Manual loading of text domain is not required after the introduction of		 * just in time translation loading in WordPress version 4.6.		 *		 * @ticket 58318		 */		if ( version_compare( $GLOBALS['wp_version'], '4.6', '<' ) ) {			load_theme_textdomain( 'twentyten', get_template_directory() . '/languages' );		} 		// This theme uses wp_nav_menu() in one location.		register_nav_menus(			array(				'primary' => __( 'Primary Navigation', 'twentyten' ),			)		); 		// This theme allows users to set a custom background.		add_theme_support(			'custom-background',			array(				// Let WordPress know what our default background color is.				'default-color' => 'f1f1f1',			)		);

Changelog

Introduced in Twenty Ten 1.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.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-content/themes/twentyten/functions.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.