Removing show_on* for containers
-
Since Carbon Fields is very limited on it’s inclusions/exclusions for displaying containers on the admin side, I am trying to omit the requirement altogether. Is it possible to do something like the following:
$screen = get_current_screen();
if ($screen == ‘portfolio’) {
$hero_do = array();
if (carbon_get_theme_option(‘do_post_hero’) !== null) {
array_push($hero_do, carbon_get_theme_option(‘do_post_hero’));
}
if (carbon_get_theme_option(‘do_page_hero’) !== null) {
array_push($hero_do, carbon_get_theme_option(‘do_page_hero’));
}
if (carbon_get_theme_option(‘do_portfolio_hero’) !== null) {
array_push($hero_do, carbon_get_theme_option(‘do_portfolio_hero’));
}…then…
Container::make(‘post_meta’, ‘Hero’)
->show_on_post_type(‘page’) <- replacing this with $hero_do or omitting this line altogether in favor of WP built in display options
->set_priority(‘high’)
->add_fields(array(…I hope this makes sense. The goal is to create an admin interface with checkboxes/dropdowns that dictate the show_on* options. Thanks!
- The topic ‘Removing show_on* for containers’ is closed to new replies.