1

Will current_theme_supports() return TRUE with a nonstandard add_theme_support() string?

If I do this in my theme:

add_theme_support( 'my_funky_new_thing' );

Can someone else writing a plugin do this?

if( current_theme_supports( 'my_funky_new_thing' ) ){
    // ...
}
2

Yes. You can take advantage of this to enable or disable features in your plugin if a theme does or does not declare support for a feature. WooCommmerce is an example of a plugin that does this.

| improve this answer | |
3

As a side note for those interested, you can also pass parameters with your custom theme support.

// theme functions.php
add_theme_support( 'some_feature', array(
  'arg_foo',
  'arg_bar'
) );

// plugin.php
$feature_args = get_theme_support( 'some_feature' );
var_dump( $feature_args );
// array(
//   array(
//     'arg_foo',
//     'arg_bar'
//   )
// );
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.