Created
September 28, 2016 03:26
-
-
Save kasng/a6da6aa37f334d8be72313945a39bf67 to your computer and use it in GitHub Desktop.
Hide all meta boxes in post type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Hide all metaboxes in the global $wp_meta_boxes | |
*/ | |
add_filter( 'hidden_meta_boxes', function( $hidden, $screen, $use_defaults ) | |
{ | |
global $wp_meta_boxes; | |
$cpt = 'post'; // Modify this to your needs! | |
if( $cpt === $screen->id && isset( $wp_meta_boxes[$cpt] ) ) | |
{ | |
$tmp = array(); | |
foreach( (array) $wp_meta_boxes[$cpt] as $context_key => $context_item ) | |
{ | |
foreach( $context_item as $priority_key => $priority_item ) | |
{ | |
foreach( $priority_item as $metabox_key => $metabox_item ) | |
$tmp[] = $metabox_key; | |
} | |
} | |
$hidden = $tmp; // Override the current user option here. | |
} | |
return $hidden; | |
}, 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment