wppaste
WordPress

twentyeleven_setup()

Since
Twenty Eleven 1.0
Source
wp-content/themes/twentyeleven/functions.php:76
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 twentyeleven_setup() in a child theme, add your own twentyeleven_setup to your child theme's functions.php file.

Compatibility

WordPress
since Twenty Eleven 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 twentyeleven_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
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
232–269

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

Plugin surface
2 hooks

Third-party callbacks on 'twentyeleven_header_image_width', 'twentyeleven_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
  • optionoption read or writeget_option()one call below twentyeleven_setup()

Further down the call graph this can also reach 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 twentyeleven_setup() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
!version_compare() && function_exists()232–233version_compare(), add_editor_style(), add_theme_support(), add_theme_support(), add_theme_support(), __(), __(), __(), __(), __(), __(), name(), get_template_directory(), get_template_directory(), get_template_directory(), add_theme_support(), __(), register_nav_menu(), add_theme_support(), twentyeleven_get_theme_options(), default-color(), add_theme_support(), apply_filters(), apply_filters(), add_theme_support(), function_exists(), set_post_thumbnail_size(), add_image_size(), add_image_size(), __(), __(), __(), __(), __(), __(), __(), __(), %s/images/headers/hanoi.jpg(), add_theme_support()
version_compare() && function_exists()239–240version_compare(), get_template_directory(), load_theme_textdomain(), add_editor_style(), add_theme_support(), add_theme_support(), add_theme_support(), __(), __(), __(), __(), __(), __(), name(), get_template_directory(), get_template_directory(), get_template_directory(), add_theme_support(), __(), register_nav_menu(), add_theme_support(), twentyeleven_get_theme_options(), default-color(), add_theme_support(), apply_filters(), apply_filters(), add_theme_support(), function_exists(), set_post_thumbnail_size(), add_image_size(), add_image_size(), __(), __(), __(), __(), __(), __(), __(), __(), %s/images/headers/hanoi.jpg(), add_theme_support()
!version_compare() && !function_exists()261–262version_compare(), add_editor_style(), add_theme_support(), add_theme_support(), add_theme_support(), __(), __(), __(), __(), __(), __(), name(), get_template_directory(), get_template_directory(), get_template_directory(), add_theme_support(), __(), register_nav_menu(), add_theme_support(), twentyeleven_get_theme_options(), default-color(), 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(), add_image_size(), add_image_size(), __(), __(), __(), __(), __(), __(), __(), __(), %s/images/headers/hanoi.jpg(), add_theme_support()
version_compare() && !function_exists()268–269version_compare(), get_template_directory(), load_theme_textdomain(), add_editor_style(), add_theme_support(), add_theme_support(), add_theme_support(), __(), __(), __(), __(), __(), __(), name(), get_template_directory(), get_template_directory(), get_template_directory(), add_theme_support(), __(), register_nav_menu(), add_theme_support(), twentyeleven_get_theme_options(), default-color(), 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(), add_image_size(), add_image_size(), __(), __(), __(), __(), __(), __(), __(), __(), %s/images/headers/hanoi.jpg(), add_theme_support()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev270232–2693
8.5270232–2693
8.4270232–2693
8.3270232–2693
8.2270232–2693
8.1270232–26931 fewer instruction than PHP 7.4
7.4271233–2703

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 twentyeleven_setup() runs, in this order:

  1. apply_filters( twentyeleven_header_image_width )filterline 195 (+119 into the body)

    Filters the Twenty Eleven default header image width.

  2. apply_filters( twentyeleven_header_image_height )filterline 203 (+127 into the body)

    Filters the Twenty Eleven default header image height.

Uses · 13

Show all 13

Source code

	function twentyeleven_setup() { 		/*		 * Make Twenty Eleven available for translation.		 * Translations can be added to the /languages/ directory.		 * If you're building a theme based on Twenty Eleven, use		 * a find and replace to change 'twentyeleven' to the name		 * of your theme in all the template files.		 *		 * 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( 'twentyeleven', get_template_directory() . '/languages' );		} 		// 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 responsive embeds.		add_theme_support( 'responsive-embeds' ); 		// Add support for custom color scheme.		add_theme_support(			'editor-color-palette',			array(				array(					'name'  => __( 'Blue', 'twentyeleven' ),					'slug'  => 'blue',					'color' => '#1982d1',				),				array(					'name'  => __( 'Black', 'twentyeleven' ),					'slug'  => 'black',					'color' => '#000',				),				array(					'name'  => __( 'Dark Gray', 'twentyeleven' ),					'slug'  => 'dark-gray',					'color' => '#373737',				),				array(					'name'  => __( 'Medium Gray', 'twentyeleven' ),					'slug'  => 'medium-gray',					'color' => '#666',				),				array(					'name'  => __( 'Light Gray', 'twentyeleven' ),					'slug'  => 'light-gray',					'color' => '#e2e2e2',				),				array(					'name'  => __( 'White', 'twentyeleven' ),					'slug'  => 'white',					'color' => '#fff',				),			)		); 		// Load up our theme options page and related code.		require get_template_directory() . '/inc/theme-options.php'; 		// Grab Twenty Eleven's Ephemera widget.		require get_template_directory() . '/inc/widgets.php'; 		// Load block patterns.		require get_template_directory() . '/inc/block-patterns.php'; 		// Add default posts and comments RSS feed links to <head>.		add_theme_support( 'automatic-feed-links' ); 		// This theme uses wp_nav_menu() in one location.

Changelog

Introduced in Twenty Eleven 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/twentyeleven/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.