Skip to content

Instantly share code, notes, and snippets.

@1ucay
Last active June 17, 2016 16:38
Show Gist options
  • Save 1ucay/fadab0dfb7df53937f9748a770a12eb9 to your computer and use it in GitHub Desktop.
Save 1ucay/fadab0dfb7df53937f9748a770a12eb9 to your computer and use it in GitHub Desktop.
Advanced Custom Fields aka ACF - more hide on screen checkboxes for plugin
<?php
add_action('acf/render_field_group_settings', 'acf_hide_metabox', 10, 1);
function acf_hide_metabox( $field_group ) {
acf_render_field_wrap(array(
'label' => __('Hide on screen for plugins','acf'),
'type' => 'checkbox',
'name' => 'hide_on_screen_plugin',
'prefix' => 'acf_field_group',
'value' => $field_group['hide_on_screen_plugin'],
'toggle' => true,
'choices' => array(
'adminpostnav' => __("Admin Post Navigation", 'core'),
'members-cp' => __("Members", 'core'),
'collaboration' => __("Peters Post Notes", 'core'),
'ppn_add_post_note' => __("Peters Post Notes Side", 'core'),
'expirationdatediv' => __("Post Expirator", 'core'),
'wpseo_meta' => __("Yoast SEO", 'core'),
)
));
}
add_action('acf/get_field_group_style', 'acf_hide_metabox_style', 10, 2);
function acf_hide_metabox_style( $e, $field_group ) {
if( in_array('wpseo_meta',$field_group['hide_on_screen_plugin']) )
{
$e .= '#wpseo_meta, #wpseo-score, #screen-meta label[for=wpseo_meta-hide] {display: none;} ';
}
if( in_array('collaboration',$field_group['hide_on_screen_plugin']) )
{
$e .= '#collaboration, #screen-meta label[for=collaboration-hide] {display: none;} ';
}
if( in_array('admin-post-nav',$field_group['hide_on_screen_plugin']) )
{
$e .= '#admin-post-nav {display: none;} ';
}
if( in_array('members-cp',$field_group['hide_on_screen_plugin']) )
{
$e .= '#members-cp, #screen-meta label[for=members-cp-hide] {display: none;} ';
}
if( in_array('expirationdatediv',$field_group['hide_on_screen_plugin']) )
{
$e .= '#expirationdatediv, #screen-meta label[for=expirationdatediv-hide] {display: none;} ';
}
if( in_array('ppn_add_post_note',$field_group['hide_on_screen_plugin']) )
{
$e .= '#ppn_add_post_note {display: none;} ';
}
return $e;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment