twentytwenty_theme_support()
- Since
- Twenty Twenty 1.0
- Source
wp-content/themes/twentytwenty/functions.php:39
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 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 twentytwenty_theme_support() 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
- Scaling
- Constant
- Instructions
- 74–96
- 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 104.
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 twentytwenty_theme_support()
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 twentytwenty_theme_support() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!get_theme_mod() && !is_customize_preview() | 74–76 | add_theme_support(), add_theme_support(), add_theme_support(), set_post_thumbnail_size(), add_image_size(), get_theme_mod(), height(), add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), is_customize_preview(), add_theme_support(), add_theme_support(), version_compare() |
get_theme_mod() && !is_customize_preview() | 84–86 | add_theme_support(), add_theme_support(), add_theme_support(), set_post_thumbnail_size(), add_image_size(), get_theme_mod(), floor(), floor(), height(), add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), is_customize_preview(), add_theme_support(), add_theme_support(), version_compare() |
!get_theme_mod() && is_customize_preview() | 84–86 | add_theme_support(), add_theme_support(), add_theme_support(), set_post_thumbnail_size(), add_image_size(), get_theme_mod(), height(), add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), is_customize_preview(), get_template_directory(), twentytwenty_get_starter_content(), add_theme_support(), add_theme_support(), add_theme_support(), version_compare() |
get_theme_mod() && is_customize_preview() | 94–96 | add_theme_support(), add_theme_support(), add_theme_support(), set_post_thumbnail_size(), add_image_size(), get_theme_mod(), floor(), floor(), height(), add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), is_customize_preview(), get_template_directory(), twentytwenty_get_starter_content(), add_theme_support(), add_theme_support(), add_theme_support(), version_compare() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 104 | 74–96 | 4 | |
| 8.5 | 104 | 74–96 | 4 | |
| 8.4 | 104 | 74–96 | 4 | |
| 8.3 | 104 | 74–96 | 4 | |
| 8.2 | 104 | 74–96 | 4 | |
| 8.1 | 104 | 74–96 | 4 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 105 | 75–97 | 4 |
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 · 9
- add_theme_support()Registers theme support for a given feature.
- set_post_thumbnail_size()Registers an image size for the post thumbnail.
- add_image_size()Registers a new image size.
- get_theme_mod()Retrieves theme modification value for the active theme.
- is_customize_preview()Whether the site is being previewed in the Customizer.
- get_template_directory()Retrieves template directory path for the active theme.
- twentytwenty_get_starter_content()Returns the array of starter content for the theme.
- add_filter()Adds a callback function to a filter hook.
- TwentyTwenty_Script_Loader::__construct()
Source code
function twentytwenty_theme_support() { // Add default posts and comments RSS feed links to head. add_theme_support( 'automatic-feed-links' ); // Custom background color. add_theme_support( 'custom-background', array( 'default-color' => 'f5efe0', ) ); // Set content-width. global $content_width; if ( ! isset( $content_width ) ) { $content_width = 580; } /* * 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. set_post_thumbnail_size( 1200, 9999 ); // Add custom image size used in Cover Template. add_image_size( 'twentytwenty-fullscreen', 1980, 9999 ); // Custom logo. $logo_width = 120; $logo_height = 90; // If the retina setting is active, double the recommended width and height. if ( get_theme_mod( 'retina_logo', false ) ) { $logo_width = floor( $logo_width * 2 ); $logo_height = floor( $logo_height * 2 ); } add_theme_support( 'custom-logo', array( 'height' => $logo_height, 'width' => $logo_width, 'flex-height' => true, 'flex-width' => true, ) ); /* * Let WordPress manage the document title. * By adding theme support, we declare that this theme does not use a * hard-coded <title> tag in the document head, and expect WordPress to * provide it for us. */ add_theme_support( 'title-tag' ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'script', 'style', 'navigation-widgets', ) ); // Add support for full and wide align images. add_theme_support( 'align-wide' );Changelog
Introduced in Twenty Twenty 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/twentytwenty/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.