Create a gist now

Instantly share code, notes, and snippets.

Customer Area menu hack: Keep submenu open when editing the CPT.
<?php
/*
Plugin Name: Customer Area menu hack
Description: Keep submenu open when editing the CPT.
To be used with the plugin http://wordpress.org/extend/plugins/customer-area/
*/
add_action( "admin_footer-post.php", 'b5f_highlight_menu_item' );
function b5f_highlight_menu_item()
{
// Not our post type, bail out
global $typenow;
if( !in_array( $typenow, array( 'cuar_private_file', 'cuar_private_page' ) ) )
return;
?>
<script type="text/javascript">
jQuery(document).ready( function($)
{
$('#toplevel_page_customer-area')
.removeClass('wp-not-current-submenu')
.addClass('wp-has-current-submenu wp-menu-open menu-top');
$('#toplevel_page_customer-area a[href="admin.php?page=customer-area"]:first')
.removeClass('wp-not-current-submenu')
.addClass('wp-has-current-submenu wp-menu-open');
if( !$('a[href="edit.php?post_type=<?php echo $typenow; ?>"]').parent().hasClass('current') )
$('a[href="edit.php?post_type=<?php echo $typenow; ?>"]').parent().addClass('current');
});
</script>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment