function pmpro_admin_init_updates_redirect() { if (is_admin() && !empty($_REQUEST['page']) && $_REQUEST['page'] == 'pmpro-updates' && !pmpro_isUpdateRequired()) { wp_redirect(admin_url('admin.php?page=pmpro-membershiplevels&updatescomplete=1')); exit; } }
function pmpro_add_pages() { global $wpdb; //array of all caps in the menu $pmpro_caps = pmpro_getPMProCaps(); //the top level menu links to the first page they have access to foreach ($pmpro_caps as $cap) { if (current_user_can($cap)) { $top_menu_cap = $cap; break; } } if (empty($top_menu_cap)) { return; } add_menu_page(__('Memberships', 'pmpro'), __('Memberships', 'pmpro'), 'pmpro_memberships_menu', 'pmpro-membershiplevels', $top_menu_cap, 'dashicons-groups'); add_submenu_page('pmpro-membershiplevels', __('Page Settings', 'pmpro'), __('Page Settings', 'pmpro'), 'pmpro_pagesettings', 'pmpro-pagesettings', 'pmpro_pagesettings'); add_submenu_page('pmpro-membershiplevels', __('Payment Settings', 'pmpro'), __('Payment Settings', 'pmpro'), 'pmpro_paymentsettings', 'pmpro-paymentsettings', 'pmpro_paymentsettings'); add_submenu_page('pmpro-membershiplevels', __('Email Settings', 'pmpro'), __('Email Settings', 'pmpro'), 'pmpro_emailsettings', 'pmpro-emailsettings', 'pmpro_emailsettings'); add_submenu_page('pmpro-membershiplevels', __('Advanced Settings', 'pmpro'), __('Advanced Settings', 'pmpro'), 'pmpro_advancedsettings', 'pmpro-advancedsettings', 'pmpro_advancedsettings'); add_submenu_page('pmpro-membershiplevels', __('Add Ons', 'pmpro'), __('Add Ons', 'pmpro'), 'pmpro_addons', 'pmpro-addons', 'pmpro_addons'); add_submenu_page('pmpro-membershiplevels', __('Members List', 'pmpro'), __('Members List', 'pmpro'), 'pmpro_memberslist', 'pmpro-memberslist', 'pmpro_memberslist'); add_submenu_page('pmpro-membershiplevels', __('Reports', 'pmpro'), __('Reports', 'pmpro'), 'pmpro_reports', 'pmpro-reports', 'pmpro_reports'); add_submenu_page('pmpro-membershiplevels', __('Orders', 'pmpro'), __('Orders', 'pmpro'), 'pmpro_orders', 'pmpro-orders', 'pmpro_orders'); add_submenu_page('pmpro-membershiplevels', __('Discount Codes', 'pmpro'), __('Discount Codes', 'pmpro'), 'pmpro_discountcodes', 'pmpro-discountcodes', 'pmpro_discountcodes'); //updates page only if needed if (pmpro_isUpdateRequired()) { add_submenu_page('pmpro-membershiplevels', __('Updates Required', 'pmpro'), __('Updates Required', 'pmpro'), 'pmpro_updates', 'pmpro-updates', 'pmpro_updates'); } //rename the automatically added Memberships submenu item global $submenu; if (!empty($submenu['pmpro-membershiplevels'])) { if (current_user_can("pmpro_membershiplevels")) { $submenu['pmpro-membershiplevels'][0][0] = __('Membership Levels', 'pmpro'); $submenu['pmpro-membershiplevels'][0][3] = __('Membership Levels', 'pmpro'); } elseif (current_user_can($top_menu_cap)) { unset($submenu['pmpro-membershiplevels'][0]); } else { unset($submenu['pmpro-membershiplevels']); } } }