twentyseventeen_setup()
- Since
- Twenty Seventeen 1.0
- Source
wp-content/themes/twentyseventeen/functions.php:33
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 Seventeen 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 twentyseventeen_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
- 136
- 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. The body compiles to 136.
Third-party callbacks on 'twentyseventeen_starter_content' 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 · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost twentyseventeen_setup() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 136 | add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), add_image_size(), add_image_size(), __(), __(), top(), add_theme_support(), add_theme_support(), add_theme_support(), add_theme_support(), get_template_directory_uri(), get_stylesheet_directory_uri(), twentyseventeen_fonts_url(), assets/css/editor-style.css(), add_theme_support(), add_theme_support(), add_theme_support(), _x(), _x(), _x(), __(), __(), apply_filters(), add_theme_support() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 136 | 136 | 0 | |
| 8.5 | 136 | 136 | 0 | |
| 8.4 | 136 | 136 | 0 | 4 fewer instructions than PHP 8.3 |
| 8.3 | 140 | 140 | 0 | |
| 8.2 | 140 | 140 | 0 | |
| 8.1 | 140 | 140 | 0 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 141 | 141 | 0 |
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 twentyseventeen_setup() runs, in this order:
- apply_filters( twentyseventeen_starter_content )filterline 246 (+213 into the body)
Filters Twenty Seventeen array of starter content.
Uses · 10
- add_theme_support()Registers theme support for a given feature.
- add_image_size()Registers a new image size.
- register_nav_menus()Registers navigation menu locations for a theme.
- __()Retrieves the translation of $text.
- get_template_directory_uri()Retrieves template directory URI for the active theme.
- get_stylesheet_directory_uri()Retrieves stylesheet directory URI for the active theme.
- twentyseventeen_fonts_url()Registers custom fonts.
- add_editor_style()Adds callback for custom TinyMCE editor stylesheets.
- _x()Retrieves translated string with gettext context.
- apply_filters()Calls the callback functions that have been added to a filter hook.
Source code
function twentyseventeen_setup() { // 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' ); /* * Enables custom line height for blocks */ add_theme_support( 'custom-line-height' ); /* * 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' ); add_image_size( 'twentyseventeen-featured-image', 2000, 1200, true ); add_image_size( 'twentyseventeen-thumbnail-avatar', 100, 100, true ); // Set the default content width. $GLOBALS['content_width'] = 525; // This theme uses wp_nav_menu() in two locations. register_nav_menus( array( 'top' => __( 'Top Menu', 'twentyseventeen' ), 'social' => __( 'Social Links Menu', 'twentyseventeen' ), ) ); /* * Switch default core markup for search form, comment form, and comments * to output valid HTML5. */ add_theme_support( 'html5', array( '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', 'audio', ) ); // Add theme support for Custom Logo. add_theme_support( 'custom-logo', array( 'width' => 250,Changelog
Introduced in Twenty Seventeen 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/twentyseventeen/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.