twentynineteen_custom_colors_css()
- Source
wp-content/themes/twentynineteen/inc/color-patterns.php:13
Compatibility
- WordPress
- core
- 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 twentynineteen_custom_colors_css() 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
- 140–152
- Plugin surface
- 6 hooks
- Called by
- 2
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 152.
Third-party callbacks on 'twentynineteen_custom_colors_saturation', 'twentynineteen_custom_colors_saturation_selection', 'twentynineteen_custom_colors_lightness' run inside this call, and their cost is not bounded by anything here.
2 places in core call this, so the cost is paid more often than your own code shows.
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 twentynineteen_custom_colors_css() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!function_exists() | 140 | get_theme_mod(), apply_filters(), absint(), apply_filters(), absint(), apply_filters(), absint(), apply_filters(), absint(), apply_filters(), absint(), function_exists(), apply_filters() |
function_exists() | 143–144 | get_theme_mod(), apply_filters(), absint(), apply_filters(), absint(), apply_filters(), absint(), apply_filters(), absint(), apply_filters(), absint(), function_exists(), is_admin(), apply_filters() |
!function_exists() | 148 | get_theme_mod(), get_theme_mod(), absint(), apply_filters(), absint(), apply_filters(), absint(), apply_filters(), absint(), apply_filters(), absint(), apply_filters(), absint(), function_exists(), apply_filters() |
function_exists() | 151–152 | get_theme_mod(), get_theme_mod(), absint(), apply_filters(), absint(), apply_filters(), absint(), apply_filters(), absint(), apply_filters(), absint(), apply_filters(), absint(), function_exists(), is_admin(), apply_filters() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 152 | 140–152 | 3 | |
| 8.5 | 152 | 140–152 | 3 | |
| 8.4 | 152 | 140–152 | 3 | |
| 8.3 | 152 | 140–152 | 3 | |
| 8.2 | 152 | 140–152 | 3 | |
| 8.1 | 152 | 140–152 | 3 | 1 more instruction than PHP 7.4 |
| 7.4 | 151 | 139–151 | 3 |
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 · 6
6 hooks fire while twentynineteen_custom_colors_css() runs, in this order:
- apply_filters( twentynineteen_custom_colors_saturation )filterline 27 (+14 into the body)
Filters Twenty Nineteen default saturation level.
- apply_filters( twentynineteen_custom_colors_saturation_selection )filterline 37 (+24 into the body)
Filters Twenty Nineteen default selection saturation level.
- apply_filters( twentynineteen_custom_colors_lightness )filterline 47 (+34 into the body)
Filters Twenty Nineteen default lightness level.
- apply_filters( twentynineteen_custom_colors_lightness_hover )filterline 57 (+44 into the body)
Filters Twenty Nineteen default hover lightness level.
- apply_filters( twentynineteen_custom_colors_lightness_selection )filterline 67 (+54 into the body)
Filters Twenty Nineteen default selection lightness level.
- apply_filters( twentynineteen_custom_colors_css )filterline 271 (+258 into the body)
Filters Twenty Nineteen custom colors CSS.
Uses · 4
- get_theme_mod()Retrieves theme modification value for the active theme.
- absint()Converts a value to non-negative integer.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- is_admin()Determines whether the current request is for an administrative interface page.
Used by · 2
- twentynineteen_colors_css_wrap()Displays custom color CSS in customizer and on frontend.
- twentynineteen_editor_customizer_styles()Enqueues supplemental block editor styles.
Source code
<?phpfunction twentynineteen_custom_colors_css() { $primary_color = 199; if ( 'default' !== get_theme_mod( 'primary_color', 'default' ) ) { $primary_color = absint( get_theme_mod( 'primary_color_hue', 199 ) ); } /** * Filters Twenty Nineteen default saturation level. * * @since Twenty Nineteen 1.0 * * @param int $saturation Color saturation level. */ $saturation = apply_filters( 'twentynineteen_custom_colors_saturation', 100 ); $saturation = absint( $saturation ) . '%'; /** * Filters Twenty Nineteen default selection saturation level. * * @since Twenty Nineteen 1.0 * * @param int $saturation_selection Selection color saturation level. */ $saturation_selection = absint( apply_filters( 'twentynineteen_custom_colors_saturation_selection', 50 ) ); $saturation_selection = $saturation_selection . '%'; /** * Filters Twenty Nineteen default lightness level. * * @since Twenty Nineteen 1.0 * * @param int $lightness Color lightness level. */ $lightness = apply_filters( 'twentynineteen_custom_colors_lightness', 33 ); $lightness = absint( $lightness ) . '%'; /** * Filters Twenty Nineteen default hover lightness level. * * @since Twenty Nineteen 1.0 * * @param int $lightness_hover Hover color lightness level. */ $lightness_hover = apply_filters( 'twentynineteen_custom_colors_lightness_hover', 23 ); $lightness_hover = absint( $lightness_hover ) . '%'; /** * Filters Twenty Nineteen default selection lightness level. * * @since Twenty Nineteen 1.0 * * @param int $lightness_selection Selection color lightness level. */ $lightness_selection = apply_filters( 'twentynineteen_custom_colors_lightness_selection', 90 ); $lightness_selection = absint( $lightness_selection ) . '%'; $theme_css = ' /* * Set background for: * - featured image :before * - featured image :before * - post thumbnail :before * - post thumbnail :before * - Submenu * - Sticky Post * - buttons * - WP Block Button * - Blocks */ .image-filters-enabled .site-header.featured-image .site-featured-image:before, .image-filters-enabled .site-header.featured-image .site-featured-image:after, .image-filters-enabled .entry .post-thumbnail:before, .image-filters-enabled .entry .post-thumbnail:after, .main-navigation .sub-menu, .sticky-post, .entry .entry-content .wp-block-button .wp-block-button__link:not(.has-background), .entry .button, button, input[type="button"], input[type="reset"], input[type="submit"], .entry .entry-content > .has-primary-background-color, .entry .entry-content > *[class^="wp-block-"].has-primary-background-color,Changelog
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/twentynineteen/inc/color-patterns.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.