require_if_theme_supports() WordPress Function
The require_if_theme_supports() function is used to include a file only if the current theme supports a certain feature. This can be useful for child themes that need to include files that the parent theme doesn't include by default.
require_if_theme_supports( string $feature, string $include ) #
Checks a theme’s support for a given feature before loading the functions which implement it.
Parameters
- $feature
(string)(Required)The feature being checked. See add_theme_support() for the list of possible values.
- $include
(string)(Required)Path to the file.
Return
(bool) True if the active theme supports the supplied feature, false otherwise.
Source
File: wp-includes/theme.php
function require_if_theme_supports( $feature, $include ) { if ( current_theme_supports( $feature ) ) { require $include; return true; } return false; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
2.9.0 | Introduced. |