Skip to content

Instantly share code, notes, and snippets.

@brasofilo
Last active April 11, 2017 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brasofilo/5608193 to your computer and use it in GitHub Desktop.
Save brasofilo/5608193 to your computer and use it in GitHub Desktop.
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