Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Created December 12, 2016 11:52
Show Gist options
  • Save Pebblo/c1e5dcd995afee332f973b9140f67b3b to your computer and use it in GitHub Desktop.
Save Pebblo/c1e5dcd995afee332f973b9140f67b3b to your computer and use it in GitHub Desktop.
Example of filtering the Seconard blocks plugin when viewing EE admin pages. If admin_head returns no post type and secondary blocks runs then it returns ALL blocks, lets stop this for Event Espresso pages.
<?php //Please do not include the opening PHP tag if you already have one.
function tw_ee_stop_secondary_blocks_plugin( $secondary_blocks ) {
//Get the currency screen
$screen = get_current_screen();
//Check if within EE using the current parent_base and see if we have a post type
if($screen->parent_base == 'espresso_events' && empty($screen->post_type) ) {
//If within EE and we don't have a post type return no secondary_blocks
return array();
}
return $secondary_blocks;
}
add_filter( 'secondary_html_blocks_pre_editor', 'tw_ee_stop_secondary_blocks_plugin');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment