plugin development - Will current_theme_supports return TRUE with a nonstandard add_theme_support?

Will current_theme_supports() return TRUE with a nonstandard add_theme_support() string?If I do this in my theme:add_the

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' ) ){
    // ...
}

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' ) ){
    // ...
}
Share Improve this question edited Jun 28, 2019 at 19:14 Matthew Brown aka Lord Matt asked Jun 27, 2019 at 23:00 Matthew Brown aka Lord MattMatthew Brown aka Lord Matt 1,0683 gold badges13 silver badges34 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 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.

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'
//   )
// );

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745360090a4624318.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信