WordPress: How to easily remove the ‘App Shop’ link in The Events Calendar plugin

July 3, 2012

The Events Calendar by Modern Tribe is a great way to create and manage events. Modern Tribe has several sweet add-ons that help with ticket sales, conference management, etc. To make it easier for users of their plugin to get add-ons a convenient ‘App Shop’ link is provided in the WordPress admin, under the Events menu. There may be instances when you you do not want to show this link, however. The following code snippet can be dropped into a plugin or functions.php file to safely remove the link. It even ensures future compatibility by tapping into The Events Calendar libraries to ascertain the correct menu item to remove, instead of having it statically set.

/**
 * Removes the App Shop submenu item under the Events submenu.
 * NOTE: This only works with The Events Calendar plugin!
 * 
 * Need to pull in some of the tribe objects to get at the menu slug. It is
 * important to do it this way so that if the slugs are updated in the future
 * this function will still work
 */
function remove_tribe_app_menu_link() {
    if ( !class_exists( 'TribeEvents' ) ) 
                require_once( WP_PLUGIN_DIR . "/the-events-calendar/lib/the-events-calendar.class.php" );
    if ( !class_exists( 'TribeAppShop' ) ) 
                require_once( WP_PLUGIN_DIR . "/the-events-calendar/lib/tribe-app-shop.class.php" );

    $where = 'edit.php?post_type=' . TribeEvents::POSTTYPE;
    remove_submenu_page( $where, TribeAppShop::MENU_SLUG);
}
add_action( 'admin_menu', 'remove_tribe_app_menu_link', 100);
Leave a Reply

Your email address will not be published. Required fields are marked *