twentyfourteen_setup()
- Since
- Twenty Fourteen 1.0
- Source
wp-content/themes/twentyfourteen/functions.php:62
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
- Scaling
- Constant
- Instructions
- 145–148
- Plugin surface
- 1 hook
- 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 148.
Third-party callbacks on 'twentyfourteen_custom_background_args' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_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.
| When | Instructions | Calls it makes |
|---|---|---|
!version_compare() | 145 | version_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() | 148 | version_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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 148 | 145–148 | 1 | |
| 8.5 | 148 | 145–148 | 1 | |
| 8.4 | 148 | 145–148 | 1 | 4 fewer instructions than PHP 8.3 |
| 8.3 | 152 | 149–152 | 1 | |
| 8.2 | 152 | 149–152 | 1 | |
| 8.1 | 152 | 149–152 | 1 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 153 | 150–153 | 1 |
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:
- apply_filters( twentyfourteen_custom_background_args )filterline 203 (+141 into the body)
Filters Twenty Fourteen custom-background support arguments.
Uses · 12
- load_theme_textdomain()Loads the theme's translated strings.
- get_template_directory_uri()Retrieves template directory URI for the active theme.
- get_stylesheet_directory_uri()Retrieves stylesheet directory URI for the active theme.
- twentyfourteen_font_url()Registers Lato font for Twenty Fourteen.
- add_editor_style()Adds callback for custom TinyMCE editor stylesheets.
- add_theme_support()Registers theme support for a given feature.
- __()Retrieves the translation of $text.
- set_post_thumbnail_size()Registers an image size for the post thumbnail.
- add_image_size()Registers a new image size.
- register_nav_menus()Registers navigation menu locations for a theme.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- add_filter()Adds a callback function to a filter hook.
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.
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.