Skip to content

Instantly share code, notes, and snippets.

@zackpyle
Last active May 18, 2023 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zackpyle/ab72b8b819130de1b5d46b4b9fda1469 to your computer and use it in GitHub Desktop.
Save zackpyle/ab72b8b819130de1b5d46b4b9fda1469 to your computer and use it in GitHub Desktop.
Remove All Custom Taxonomy Sidebar Metaboxes #cptui #wordpress
<?php // ignore - for formatting only
// Useful if you are creating custom taxonomines and controlling them with ACF. This will remove all the metaboxes for your custom taxonomies
function edit_taxonomy_args( $args, $tax_slug, $cptui_tax_args ) {
// Set to false for all taxonomies created with CPTUI.
$args['meta_box_cb'] = false;
return $args;
}
add_filter( 'cptui_pre_register_taxonomy', 'edit_taxonomy_args', 10, 3 );
add_filter( 'rest_prepare_taxonomy', function( $response, $taxonomy, $request ){
$context = ! empty( $request['context'] ) ? $request['context'] : 'view';
// Context is edit in the editor
if( $context === 'edit' && $taxonomy->meta_box_cb === false ){
$data_response = $response->get_data();
$data_response['visibility']['show_ui'] = false;
$response->set_data( $data_response );
}
return $response;
}, 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment