wppaste
WordPress

twentytwenty_theme_support()

Since
Twenty Twenty 1.0
Source
wp-content/themes/twentytwenty/functions.php:39
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 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

Touches nothing outside its own arguments.

Scaling
Constant

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

Instructions
74–96

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

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_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.

WhenInstructionsCalls it makes
!get_theme_mod() && !is_customize_preview()74–76add_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–86add_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–86add_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–96add_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

PHPCompiledExecutedBranchesNotes
8.6-dev10474–964
8.510474–964
8.410474–964
8.310474–964
8.210474–964
8.110474–9641 fewer instruction than PHP 7.4
7.410575–974

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

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.

  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/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.