twentyeleven_setup()
- Since
- Twenty Eleven 1.0
- Source
wp-content/themes/twentyeleven/functions.php:76
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
- Scaling
- Constant
- Instructions
- 232–269
- Plugin surface
- 2 hooks
- 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 270.
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.
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()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.
| When | Instructions | Calls it makes |
|---|---|---|
!version_compare() && function_exists() | 232–233 | version_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–240 | version_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–262 | version_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–269 | version_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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 270 | 232–269 | 3 | |
| 8.5 | 270 | 232–269 | 3 | |
| 8.4 | 270 | 232–269 | 3 | |
| 8.3 | 270 | 232–269 | 3 | |
| 8.2 | 270 | 232–269 | 3 | |
| 8.1 | 270 | 232–269 | 3 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 271 | 233–270 | 3 |
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:
- apply_filters( twentyeleven_header_image_width )filterline 195 (+119 into the body)
Filters the Twenty Eleven default header image width.
- apply_filters( twentyeleven_header_image_height )filterline 203 (+127 into the body)
Filters the Twenty Eleven default header image height.
Uses · 13
- load_theme_textdomain()Loads the theme's translated strings.
- get_template_directory()Retrieves template directory path for the active theme.
- add_editor_style()Adds callback for custom TinyMCE editor stylesheets.
- add_theme_support()Registers theme support for a given feature.
- __()Retrieves the translation of $text.
- register_nav_menu()Registers a navigation menu location for a theme.
- twentyeleven_get_theme_options()Returns the options array for Twenty Eleven.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- add_custom_image_header()Add callbacks for image header display.
- add_custom_background()Add callbacks for background image display.
- set_post_thumbnail_size()Registers an image size for the post thumbnail.
- add_image_size()Registers a new image size.
Show all 13
- register_default_headers()Registers a selection of default headers to be displayed by the custom header admin UI.
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.
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.