_remove_theme_support( string $feature ): bool
- Since
- 3.1.0
- Source
wp-includes/theme.php:3091
Compatibility
- WordPress
- since 3.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.
Parameters
$featurestring- The feature being removed. See add_theme_support() for the list of possible values.
Return value
bool- True if support was removed, false if the feature was not registered.
Performance profile
How much work a call to _remove_theme_support() 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
- 7–40
- Plugin surface
- None
- Called by
- 3
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 78.
Nothing here hands control to plugin code.
3 places in core call this, so the cost is paid more often than your own code shows.
What one call costs · 5 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost _remove_theme_support() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 7–14 | none |
$feature == "custom-header-uploads" && isset($_wp_theme_features) | 11 | add_theme_support() |
$feature != "custom-header-uploads" && isset($_wp_theme_features[$feature]) && !did_action() | 13–17 | did_action() |
$feature != "custom-header-uploads" && isset($_wp_theme_features[$feature]) && did_action() && !isset($value) | 22–33 | did_action(), get_theme_support() |
$feature != "custom-header-uploads" && isset($_wp_theme_features[$feature]) && did_action() && isset($value) | 29–40 | did_action(), get_theme_support(), remove_action() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 78 | 7–40 | 11 | |
| 8.5 | 78 | 7–40 | 11 | |
| 8.4 | 78 | 7–40 | 11 | |
| 8.3 | 78 | 7–40 | 11 | |
| 8.2 | 78 | 7–40 | 11 | 1 more instruction than PHP 8.1 |
| 8.1 | 77 | 7–42 | 11 | 5 fewer instructions than PHP 7.4 |
| 7.4 | 82 | 7–45 | 11 |
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.
Uses · 4
- add_theme_support()Registers theme support for a given feature.
- did_action()Retrieves the number of times an action has been fired during the current request.
- get_theme_support()Gets the theme support arguments passed when registering that support.
- remove_action()Removes a callback function from an action hook.
Used by · 3
- remove_editor_styles()Removes all visual editor stylesheets.
- remove_theme_support()Allows a theme to de-register its support of a certain feature
- unregister_nav_menu()Unregisters a navigation menu location for a theme.
Source code
function _remove_theme_support( $feature ) { global $_wp_theme_features; switch ( $feature ) { case 'custom-header-uploads': if ( ! isset( $_wp_theme_features['custom-header'] ) ) { return false; } add_theme_support( 'custom-header', array( 'uploads' => false ) ); return true; // Do not continue - custom-header-uploads no longer exists. } if ( ! isset( $_wp_theme_features[ $feature ] ) ) { return false; } switch ( $feature ) { case 'custom-header': if ( ! did_action( 'wp_loaded' ) ) { break; } $support = get_theme_support( 'custom-header' ); if ( isset( $support[0]['wp-head-callback'] ) ) { remove_action( 'wp_head', $support[0]['wp-head-callback'] ); } if ( isset( $GLOBALS['custom_image_header'] ) ) { remove_action( 'admin_menu', array( $GLOBALS['custom_image_header'], 'init' ) ); unset( $GLOBALS['custom_image_header'] ); } break; case 'custom-background': if ( ! did_action( 'wp_loaded' ) ) { break; } $support = get_theme_support( 'custom-background' ); if ( isset( $support[0]['wp-head-callback'] ) ) { remove_action( 'wp_head', $support[0]['wp-head-callback'] ); } remove_action( 'admin_menu', array( $GLOBALS['custom_background'], 'init' ) ); unset( $GLOBALS['custom_background'] ); break; } unset( $_wp_theme_features[ $feature ] ); return true;}Changelog
Introduced in 3.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-includes/theme.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.