current_theme_supports

Checks a theme's support for a given feature.

Description

current_theme_supports( (string) $feature ); 

Parameters (1)

0. $feature (string)
The feature being checked

Usage

  1. if ( !function_exists( 'current_theme_supports' ) ) { 
  2. require_once ABSPATH . WPINC . '/theme.php'; 
  3.  
  4. // the feature being checked 
  5. $feature = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = current_theme_supports($feature); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/theme.php  
  1. function current_theme_supports( $feature ) { 
  2. global $_wp_theme_features; 
  3.  
  4. if ( 'custom-header-uploads' == $feature ) 
  5. return current_theme_supports( 'custom-header', 'uploads' ); 
  6.  
  7. if ( !isset( $_wp_theme_features[$feature] ) ) 
  8. return false; 
  9.  
  10. // If no args passed then no extra checks need be performed 
  11. if ( func_num_args() <= 1 ) 
  12. return true; 
  13.  
  14. $args = array_slice( func_get_args(), 1 ); 
  15.  
  16. switch ( $feature ) { 
  17. case 'post-thumbnails': 
  18. // post-thumbnails can be registered for only certain content/post types by passing 
  19. // an array of types to add_theme_support(). If no array was passed, then 
  20. // any type is accepted 
  21. if ( true === $_wp_theme_features[$feature] ) // Registered for all types 
  22. return true; 
  23. $content_type = $args[0]; 
  24. return in_array( $content_type, $_wp_theme_features[$feature][0] ); 
  25.  
  26. case 'html5': 
  27. case 'post-formats': 
  28. // specific post formats can be registered by passing an array of types to 
  29.  
  30. // Specific areas of HTML5 support *must* be passed via an array to add_theme_support() 
  31.  
  32. $type = $args[0]; 
  33. return in_array( $type, $_wp_theme_features[$feature][0] ); 
  34.  
  35. case 'custom-logo': 
  36. case 'custom-header': 
  37. case 'custom-background': 
  38. // Specific capabilities can be registered by passing an array to add_theme_support(). 
  39. return ( isset( $_wp_theme_features[ $feature ][0][ $args[0] ] ) && $_wp_theme_features[ $feature ][0][ $args[0] ] ); 
  40.  
  41. /** 
  42. * Filters whether the current theme supports a specific feature. 
  43. * The dynamic portion of the hook name, `$feature`, refers to the specific theme 
  44. * feature. Possible values include 'post-formats', 'post-thumbnails', 'custom-background',  
  45. * 'custom-header', 'menus', 'automatic-feed-links', 'html5',  
  46. * 'starter-content', and 'customize-selective-refresh-widgets'. 
  47. * @since 3.4.0 
  48. * @param bool true Whether the current theme supports the given feature. Default true. 
  49. * @param array $args Array of arguments for the feature. 
  50. * @param string $feature The theme feature. 
  51. */ 
  52. return apply_filters( "current_theme_supports-{$feature}", true, $args, $_wp_theme_features[$feature] );