current_theme_supports( string $feature, mixed $args ): bool
- Since
- 2.9.0, 5.3.0
- Source
wp-includes/theme.php:3172
Checks a theme's support for a given feature.
Description
Example usage:
current_theme_supports( 'custom-logo' );
current_theme_supports( 'html5', 'comment-form' );Parameters
$featurestring- The feature being checked. See add_theme_support() for the list of possible values.
$argsmixed- Optional extra arguments to be checked against certain features.
Return
bool- True if the active theme supports the feature, false otherwise.
Hooks fired · 2
2 hooks fire while current_theme_supports() runs, in this order:
- apply_filters( current_theme_supports-{$feature} )filterline 3186 (+14 into the body)
Filters whether the active theme supports a specific feature.
- apply_filters( current_theme_supports-{$feature} )filterline 3232 (+60 into the body)
Filters whether the active theme supports a specific feature.
Uses · 2
- current_theme_supports()Checks a theme's support for a given feature.
- apply_filters()Calls the callback functions that have been added to a filter hook.
Used by · 50
- Custom_Background::admin_page()Displays the custom background page.
- Custom_Image_Header::ajax_header_crop()Gets attachment uploaded by Media Manager, crops it, then saves it as a new object. Returns JSON-encoded object details.
- Custom_Image_Header::css_includes()Sets up the enqueue for the CSS files.
- Custom_Image_Header::get_header_dimensions()Calculates width and height based on what the currently selected theme supports.
- Custom_Image_Header::js()Executes JavaScript depending on step.
- Custom_Image_Header::js_1()Displays JavaScript based on Step 1 and 3.
- Custom_Image_Header::js_2()Displays JavaScript based on Step 2.
- Custom_Image_Header::js_includes()Sets up the enqueue for the JavaScript files.
- Custom_Image_Header::step_1()Displays first step of custom header image page.
- Custom_Image_Header::step_2()Displays second step of custom header image page.
- Custom_Image_Header::step_3()Displays third step of custom header image page.
- WP_Admin_Bar::initialize()Initializes the admin bar.
Show all 50
- WP_Customize_Header_Image_Control::render_content()
- WP_Customize_Manager::register_controls()Registers some default controls.
- WP_Customize_Nav_Menu_Locations_Control::content_template()JS/Underscore template for the control UI.
- WP_Customize_Nav_Menus::available_item_types()Returns an array of all the available item types.
- WP_Customize_Nav_Menus::customize_register()Adds the customizer settings and controls.
- WP_Customize_Panel::check_capabilities()Checks required user capabilities and whether the theme has the feature support required by the panel.
- WP_Customize_Section::check_capabilities()Checks required user capabilities and whether the theme has the feature support required by the section.
- WP_Customize_Setting::check_capabilities()Validate user capabilities whether the theme supports the setting.
- WP_Customize_Widgets::customize_dynamic_partial_args()Filters arguments for dynamic widget partials.
- WP_Customize_Widgets::get_selective_refreshable_widgets()List whether each registered widget can be use selective refresh.
- WP_Customize_Widgets::get_setting_args()Retrieves common arguments to supply when constructing a Customizer setting.
- WP_Customize_Widgets::selective_refresh_init()Adds hooks for selective refresh.
- WP_Font_Face::__construct()Creates and initializes an instance of WP_Font_Face.
- WP_Nav_Menu_Widget::widget()Outputs the content for the current Navigation Menu widget instance.
- WP_Posts_List_Table::inline_edit()Outputs the hidden row displayed when inline editing
- WP_REST_Attachments_Controller::handle_featured_media()Determines the featured media based on a request param.
- WP_REST_Themes_Controller::prepare_item_for_response()Prepares a single theme output for response.
- WP_Styles::__construct()Constructor.
- WP_Theme::get_post_templates()Returns the theme's post templates.
- WP_Theme_JSON::get_layout_styles()Gets the CSS layout rules for a particular block from theme.json layout definitions.
- WP_Theme_JSON_Resolver::get_theme_data()Returns the theme's data.
- WP_Widget_Archives::widget()Outputs the content for the current Archives widget instance.
- WP_Widget_Categories::widget()Outputs the content for the current Categories widget instance.
- WP_Widget_Meta::widget()Outputs the content for the current Meta widget instance.
- WP_Widget_Pages::widget()Outputs the content for the current Pages widget instance.
- WP_Widget_RSS::widget()Outputs the content for the current RSS widget instance.
- WP_Widget_Recent_Comments::recent_comments_style()Outputs the default styles for the Recent Comments widget.
- WP_Widget_Recent_Comments::widget()Outputs the content for the current Recent Comments widget instance.
- WP_Widget_Recent_Posts::widget()Outputs the content for the current Recent Posts widget instance.
- WP_Widget_Tag_Cloud::widget()Outputs the content for the current Tag Cloud widget instance.
- _add_default_theme_supports()Adds default theme supports for block themes when the 'after_setup_theme' action fires.
- _add_template_loader_filters()Adds necessary hooks to resolve '_wp-find-template' requests.
- _admin_bar_bump_cb()Prints default admin bar callback.
- _custom_background_cb()Default custom background callback.
- _custom_header_background_just_in_time()Registers the internal custom header and background routines.
- _custom_logo_header_styles()Adds CSS to hide header text for custom logo, based on Customizer setting.
- _get_random_header_data()Gets random header image data from registered images in theme.
- _print_scripts()Prints scripts (internal use only)
Source
function current_theme_supports( $feature, ...$args ) { global $_wp_theme_features; if ( 'custom-header-uploads' === $feature ) { return current_theme_supports( 'custom-header', 'uploads' ); } if ( ! isset( $_wp_theme_features[ $feature ] ) ) { return false; } // If no args passed then no extra checks need to be performed. if ( ! $args ) { /** This filter is documented in wp-includes/theme.php */ return apply_filters( "current_theme_supports-{$feature}", true, $args, $_wp_theme_features[ $feature ] ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores } switch ( $feature ) { case 'post-thumbnails': /* * post-thumbnails can be registered for only certain content/post types * by passing an array of types to add_theme_support(). * If no array was passed, then any type is accepted. */ if ( true === $_wp_theme_features[ $feature ] ) { // Registered for all types. return true; } $content_type = $args[0]; return in_array( $content_type, $_wp_theme_features[ $feature ][0], true ); case 'html5': case 'post-formats': /* * Specific post formats can be registered by passing an array of types * to add_theme_support(). * * Specific areas of HTML5 support *must* be passed via an array to add_theme_support(). */ $type = $args[0]; return in_array( $type, $_wp_theme_features[ $feature ][0], true ); case 'custom-logo': case 'custom-header': case 'custom-background': // Specific capabilities can be registered by passing an array to add_theme_support(). return ( isset( $_wp_theme_features[ $feature ][0][ $args[0] ] ) && $_wp_theme_features[ $feature ][0][ $args[0] ] ); } /** * Filters whether the active theme supports a specific feature. * * The dynamic portion of the hook name, `$feature`, refers to the specific * theme feature. See add_theme_support() for the list of possible values. * * @since 3.4.0 * * @param bool $supports Whether the active theme supports the given feature. Default true. * @param array $args Array of arguments for the feature. * @param string $feature The theme feature. */ return apply_filters( "current_theme_supports-{$feature}", true, $args, $_wp_theme_features[ $feature ] ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores}History
Introduced in 2.9.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
5.3.0
Formalized the existing and already documented
...$args parameter by adding it to the function signature.from the docblock2.9.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 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.