wppaste
WordPress

twentyfourteen_setup()

Since
Twenty Fourteen 1.0
Source
wp-content/themes/twentyfourteen/functions.php:62
Twenty Fourteen setup.

Description

Set up theme defaults and registers support for various WordPress features.

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.

Compatibility

WordPress
since Twenty Fourteen 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 twentyfourteen_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
145–148

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

Plugin surface
1 hook

Third-party callbacks on 'twentyfourteen_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 twentyfourteen_setup() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
!version_compare()145version_compare(), get_template_directory_uri(), get_stylesheet_directory_uri(), twentyfourteen_font_url(), css/editor-style.css(), add_theme_support(), add_theme_support(), add_theme_support(), __(), __(), __(), __(), __(), __(), name(), add_theme_support(), add_theme_support(), set_post_thumbnail_size(), add_image_size(), __(), __(), primary(), add_theme_support(), add_theme_support(), apply_filters(), add_theme_support(), add_theme_support(), add_filter(), add_theme_support()
version_compare()148version_compare(), load_theme_textdomain(), get_template_directory_uri(), get_stylesheet_directory_uri(), twentyfourteen_font_url(), css/editor-style.css(), add_theme_support(), add_theme_support(), add_theme_support(), __(), __(), __(), __(), __(), __(), name(), add_theme_support(), add_theme_support(), set_post_thumbnail_size(), add_image_size(), __(), __(), primary(), add_theme_support(), add_theme_support(), apply_filters(), add_theme_support(), add_theme_support(), add_filter(), add_theme_support()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev148145–1481
8.5148145–1481
8.4148145–14814 fewer instructions than PHP 8.3
8.3152149–1521
8.2152149–1521
8.1152149–15211 fewer instruction than PHP 7.4
7.4153150–1531

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 twentyfourteen_setup() runs, in this order:

  1. apply_filters( twentyfourteen_custom_background_args )filterline 203 (+141 into the body)

    Filters Twenty Fourteen custom-background support arguments.

Uses · 12

Source code

	function twentyfourteen_setup() { 		/*		 * Make Twenty Fourteen available for translation.		 *		 * Translations can be filed at WordPress.org. See: https://translate.wordpress.org/projects/wp-themes/twentyfourteen		 * If you're building a theme based on Twenty Fourteen, use a find and		 * replace to change 'twentyfourteen' to the name of your theme in all		 * 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( 'twentyfourteen' );		} 		/*		 * This theme styles the visual editor to resemble the theme style.		 * When fonts are self-hosted, the theme directory needs to be removed first.		 */		$font_stylesheet = str_replace(			array( get_template_directory_uri() . '/', get_stylesheet_directory_uri() . '/' ),			'',			(string) twentyfourteen_font_url()		);		add_editor_style( array( 'css/editor-style.css', $font_stylesheet, 'genericons/genericons.css' ) ); 		// 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'  => __( 'Green', 'twentyfourteen' ),					'slug'  => 'green',					'color' => '#24890d',				),				array(					'name'  => __( 'Black', 'twentyfourteen' ),					'slug'  => 'black',					'color' => '#000',				),				array(					'name'  => __( 'Dark Gray', 'twentyfourteen' ),					'slug'  => 'dark-gray',					'color' => '#2b2b2b',				),				array(					'name'  => __( 'Medium Gray', 'twentyfourteen' ),					'slug'  => 'medium-gray',					'color' => '#767676',				),				array(					'name'  => __( 'Light Gray', 'twentyfourteen' ),					'slug'  => 'light-gray',					'color' => '#f5f5f5',				),				array(					'name'  => __( 'White', 'twentyfourteen' ),					'slug'  => 'white',					'color' => '#fff',				),			)		); 		// Add RSS feed links to <head> for posts and comments.		add_theme_support( 'automatic-feed-links' ); 		// Enable support for Post Thumbnails, and declare two sizes.

Changelog

Introduced in Twenty Fourteen 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/twentyfourteen/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.