twentyten_setup()
- Since
- Twenty Ten 1.0
- Source
wp-content/themes/twentyten/functions.php:78
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 post thumbnails.
To override twentyten_setup() in a child theme, add your own twentyten_setup to your child theme's functions.php file.
Compatibility
- WordPress
- since Twenty Ten 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 twentyten_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
- 181–213
- Plugin surface
- 2 hooks
- 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 213.
Third-party callbacks on 'twentyten_header_image_width', 'twentyten_header_image_height' 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 · 4 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost twentyten_setup() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!version_compare() && function_exists() | 181 | add_editor_style(), add_theme_support(), add_theme_support(), __(), __(), __(), __(), __(), name(), add_theme_support(), add_theme_support(), add_theme_support(), version_compare(), __(), primary(), add_theme_support(), apply_filters(), apply_filters(), add_theme_support(), function_exists(), set_post_thumbnail_size(), __(), __(), __(), __(), __(), __(), __(), __(), %s/images/headers/sunset.jpg() |
version_compare() && function_exists() | 188 | add_editor_style(), add_theme_support(), add_theme_support(), __(), __(), __(), __(), __(), name(), add_theme_support(), add_theme_support(), add_theme_support(), version_compare(), get_template_directory(), load_theme_textdomain(), __(), primary(), add_theme_support(), apply_filters(), apply_filters(), add_theme_support(), function_exists(), set_post_thumbnail_size(), __(), __(), __(), __(), __(), __(), __(), __(), %s/images/headers/sunset.jpg() |
!version_compare() && !function_exists() | 206 | add_editor_style(), add_theme_support(), add_theme_support(), __(), __(), __(), __(), __(), name(), add_theme_support(), add_theme_support(), add_theme_support(), version_compare(), __(), primary(), add_theme_support(), apply_filters(), apply_filters(), add_theme_support(), function_exists(), define(), define(), define(), add_custom_image_header(), add_custom_background(), set_post_thumbnail_size(), __(), __(), __(), __(), __(), __(), __(), __(), %s/images/headers/sunset.jpg() |
version_compare() && !function_exists() | 213 | add_editor_style(), add_theme_support(), add_theme_support(), __(), __(), __(), __(), __(), name(), add_theme_support(), add_theme_support(), add_theme_support(), version_compare(), get_template_directory(), load_theme_textdomain(), __(), primary(), add_theme_support(), apply_filters(), apply_filters(), add_theme_support(), function_exists(), define(), define(), define(), add_custom_image_header(), add_custom_background(), set_post_thumbnail_size(), __(), __(), __(), __(), __(), __(), __(), __(), %s/images/headers/sunset.jpg() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 213 | 181–213 | 2 | |
| 8.5 | 213 | 181–213 | 2 | |
| 8.4 | 213 | 181–213 | 2 | |
| 8.3 | 213 | 181–213 | 2 | |
| 8.2 | 213 | 181–213 | 2 | |
| 8.1 | 213 | 181–213 | 2 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 214 | 182–214 | 2 |
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 · 2
2 hooks fire while twentyten_setup() runs, in this order:
- apply_filters( twentyten_header_image_width )filterline 175 (+97 into the body)
Filters the Twenty Ten default header image width.
- apply_filters( twentyten_header_image_height )filterline 183 (+105 into the body)
Filters the Twenty Ten default header image height.
Uses · 11
- 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.
- load_theme_textdomain()Loads the theme's translated strings.
- get_template_directory()Retrieves template directory path for the active theme.
- 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_custom_image_header()Add callbacks for image header display.
- add_custom_background()Add callbacks for background image display.
- set_post_thumbnail_size()Registers an image size for the post thumbnail.
- register_default_headers()Registers a selection of default headers to be displayed by the custom header admin UI.
Source code
function twentyten_setup() { // This theme styles the visual editor with editor-style.css to match the theme style. add_editor_style(); // 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 custom color scheme. add_theme_support( 'editor-color-palette', array( array( 'name' => __( 'Blue', 'twentyten' ), 'slug' => 'blue', 'color' => '#0066cc', ), array( 'name' => __( 'Black', 'twentyten' ), 'slug' => 'black', 'color' => '#000', ), array( 'name' => __( 'Medium Gray', 'twentyten' ), 'slug' => 'medium-gray', 'color' => '#666', ), array( 'name' => __( 'Light Gray', 'twentyten' ), 'slug' => 'light-gray', 'color' => '#f1f1f1', ), array( 'name' => __( 'White', 'twentyten' ), 'slug' => 'white', 'color' => '#fff', ), ) ); // Post Format support. You can also use the legacy "gallery" or "asides" (note the plural) categories. add_theme_support( 'post-formats', array( 'aside', 'gallery' ) ); // This theme uses post thumbnails. add_theme_support( 'post-thumbnails' ); // Add default posts and comments RSS feed links to head. add_theme_support( 'automatic-feed-links' ); /* * Make theme available for translation. * Translations can be filed in the /languages/ directory. * * 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( 'twentyten', get_template_directory() . '/languages' ); } // This theme uses wp_nav_menu() in one location. register_nav_menus( array( 'primary' => __( 'Primary Navigation', 'twentyten' ), ) ); // This theme allows users to set a custom background. add_theme_support( 'custom-background', array( // Let WordPress know what our default background color is. 'default-color' => 'f1f1f1', ) );Changelog
Introduced in Twenty Ten 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/twentyten/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.