wppaste
WordPress

twentyfifteen_setup()

Since
Twenty Fifteen 1.0
Source
wp-content/themes/twentyfifteen/functions.php:58
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 Fifteen 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 twentyfifteen_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
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
293–296

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

Plugin surface
1 hook

Third-party callbacks on 'twentyfifteen_custom_background_args' 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

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 · 2 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost twentyfifteen_setup() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
!version_compare()293version_compare(), add_theme_support(), add_theme_support(), add_theme_support(), set_post_thumbnail_size(), __(), __(), primary(), add_theme_support(), add_theme_support(), add_theme_support(), twentyfifteen_get_color_scheme(), default-color(), apply_filters(), get_template_directory_uri(), get_stylesheet_directory_uri(), twentyfifteen_fonts_url(), css/editor-style.css(), add_theme_support(), add_theme_support(), add_theme_support(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name(), add_theme_support()
version_compare()296version_compare(), load_theme_textdomain(), add_theme_support(), add_theme_support(), add_theme_support(), set_post_thumbnail_size(), __(), __(), primary(), add_theme_support(), add_theme_support(), add_theme_support(), twentyfifteen_get_color_scheme(), default-color(), apply_filters(), get_template_directory_uri(), get_stylesheet_directory_uri(), twentyfifteen_fonts_url(), css/editor-style.css(), add_theme_support(), add_theme_support(), add_theme_support(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), name(), add_theme_support()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev296293–2961
8.5296293–2961
8.4296293–29618 fewer instructions than PHP 8.3
8.3304301–3041
8.2304301–3041
8.1304301–30411 fewer instruction than PHP 7.4
7.4305302–3051

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 · 1

One hook fires while twentyfifteen_setup() runs, in this order:

  1. apply_filters( twentyfifteen_custom_background_args )filterline 174 (+116 into the body)

    Filters Twenty Fifteen custom-background support arguments.

Uses · 11

Source code

	function twentyfifteen_setup() { 		/*		 * Make theme available for translation.		 * Translations can be filed at WordPress.org. See: https://translate.wordpress.org/projects/wp-themes/twentyfifteen		 * If you're building a theme based on twentyfifteen, use a find and replace		 * to change 'twentyfifteen' 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( 'twentyfifteen' );		} 		// Add default posts and comments RSS feed links to head.		add_theme_support( 'automatic-feed-links' ); 		/*		 * 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' ); 		/*		 * Enable support for Post Thumbnails on posts and pages.		 *		 * See: https://developer.wordpress.org/reference/functions/add_theme_support/#post-thumbnails		 */		add_theme_support( 'post-thumbnails' );		set_post_thumbnail_size( 825, 510, true ); 		// This theme uses wp_nav_menu() in two locations.		register_nav_menus(			array(				'primary' => __( 'Primary Menu', 'twentyfifteen' ),				'social'  => __( 'Social Links Menu', 'twentyfifteen' ),			)		); 		/*		 * 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',			)		); 		/*		 * Enable support for Post Formats.		 *		 * See: https://developer.wordpress.org/advanced-administration/wordpress/post-formats/		 */		add_theme_support(			'post-formats',			array(				'aside',				'image',				'video',				'quote',				'link',				'gallery',				'status',				'audio',				'chat',

Changelog

Introduced in Twenty Fifteen 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/twentyfifteen/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.