Checks a theme’s support for a given feature before loading the functions which implement it.
$featurestringrequired
'admin-bar''align-wide''appearance-tools''automatic-feed-links''block-templates''block-template-parts''border''core-block-patterns''custom-background''custom-header''custom-line-height''custom-logo''customize-selective-refresh-widgets''custom-spacing''custom-units''dark-editor-style''disable-custom-colors''disable-custom-font-sizes''disable-custom-gradients''disable-layout-styles''editor-color-palette''editor-gradient-presets''editor-font-sizes''editor-spacing-sizes''editor-styles''featured-content''html5''link-color''menus''post-formats''post-thumbnails''responsive-embeds''starter-content''title-tag''widgets''widgets-block-editor''wp-block-styles'$filestringrequired
function require_if_theme_supports( $feature, $file ) {
if ( current_theme_supports( $feature ) ) {
require $file;
return true;
}
return false;
}
| Version | Description |
|---|---|
| 2.9.0 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/require_if_theme_supports