twenty_twenty_one_setup(): void
- Since
- Twenty Twenty-One 1.0, Twenty Twenty-One 2.8 Removed editor stylesheet for Internet Explorer.
- Source
wp-content/themes/twentytwentyone/functions.php:34
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 for post thumbnails.
Compatibility
- WordPress
- since Twenty Twenty-One 2.8 Removed editor stylesheet for Internet Explorer.
- 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.
Return value
void
Performance profile
How much work a call to twenty_twenty_one_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
- Light
- Scaling
- Constant
- Instructions
- 393–406
- Plugin surface
- None
- Called by
- 0
Touches nothing outside its own arguments.
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 406.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()one call below twenty_twenty_one_setup()
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 twenty_twenty_one_setup() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!is_customize_preview() | 393 | add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), set_post_thumbnail_size(), esc_html__(), esc_html__(), primary(), add_theme_support(), height(), add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), get_theme_mod(), ::Twenty_Twenty_One_Custom_Colors(), add_editor_style(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), name(), add_theme_support(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), name(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), name(), is_customize_preview(), add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), add_filter() |
!is_customize_preview() | 396 | add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), set_post_thumbnail_size(), esc_html__(), esc_html__(), primary(), add_theme_support(), height(), add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), get_theme_mod(), ::Twenty_Twenty_One_Custom_Colors(), add_theme_support(), add_editor_style(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), name(), add_theme_support(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), name(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), name(), is_customize_preview(), add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), add_filter() |
is_customize_preview() | 403 | add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), set_post_thumbnail_size(), esc_html__(), esc_html__(), primary(), add_theme_support(), height(), add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), get_theme_mod(), ::Twenty_Twenty_One_Custom_Colors(), add_editor_style(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), name(), add_theme_support(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), name(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), name(), is_customize_preview(), get_template_directory(), twenty_twenty_one_get_starter_content(), add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), add_filter() |
is_customize_preview() | 406 | add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), set_post_thumbnail_size(), esc_html__(), esc_html__(), primary(), add_theme_support(), height(), add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), get_theme_mod(), ::Twenty_Twenty_One_Custom_Colors(), add_theme_support(), add_editor_style(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), esc_html__(), esc_html_x(), name(), add_theme_support(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), name(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), esc_html__(), name(), is_customize_preview(), get_template_directory(), twenty_twenty_one_get_starter_content(), add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), add_filter() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 406 instructions, 393–406 executed per call, 2 branches. The work does not change between versions.
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.
Uses · 12
- add_theme_support()Registers theme support for a given feature.
- set_post_thumbnail_size()Registers an image size for the post thumbnail.
- register_nav_menus()Registers navigation menu locations for a theme.
- esc_html__()Retrieves the translation of $text and escapes it for safe use in HTML output.
- get_theme_mod()Retrieves theme modification value for the active theme.
- add_editor_style()Adds callback for custom TinyMCE editor stylesheets.
- esc_html_x()Translates string with gettext context, and escapes it for safe use in HTML output.
- is_customize_preview()Whether the site is being previewed in the Customizer.
- get_template_directory()Retrieves template directory path for the active theme.
- twenty_twenty_one_get_starter_content()Returns the array of starter content for the theme.
- add_filter()Adds a callback function to a filter hook.
- Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex()Gets luminance from a HEX color.
Source code
function twenty_twenty_one_setup() { // Add default posts and comments RSS feed links to head. add_theme_support( 'automatic-feed-links' ); /* * Let WordPress manage the document title. * This theme does not use a hard-coded <title> tag in the document head, * WordPress will provide it for us. */ add_theme_support( 'title-tag' ); /** * Add post-formats support. */ add_theme_support( 'post-formats', array( 'link', 'aside', 'gallery', 'image', 'quote', 'status', 'video', 'audio', 'chat', ) ); /* * Enable support for Post Thumbnails on posts and pages. * * @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/ */ add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 1568, 9999 ); register_nav_menus( array( 'primary' => esc_html__( 'Primary menu', 'twentytwentyone' ), 'footer' => esc_html__( 'Secondary menu', 'twentytwentyone' ), ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( 'comment-form', 'comment-list', 'gallery', 'caption', 'style', 'script', 'navigation-widgets', ) ); /* * Add support for core custom logo. * * @link https://codex.wordpress.org/Theme_Logo */ $logo_width = 300; $logo_height = 100; add_theme_support( 'custom-logo', array( 'height' => $logo_height, 'width' => $logo_width, 'flex-width' => true, 'flex-height' => true, 'unlink-homepage-logo' => true, ) );Changelog
Introduced in Twenty Twenty-One 2.8 Removed editor stylesheet for Internet Explorer.. 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/twentytwentyone/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.