Skip to content

Commit

Permalink
Scan: Use admin menu API to register menu item (#17757)
Browse files Browse the repository at this point in the history
  • Loading branch information
obenland authored Nov 11, 2020
1 parent 5f13597 commit 4e538a6
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions modules/scan/class-admin-sidebar-link.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,6 @@ public function maybe_add_admin_link() {
return;
}

$new_link = $this->get_new_link();

// Splice the nav menu item into the Jetpack nav.
global $submenu;
array_splice( $submenu['jetpack'], $this->get_link_offset(), 0, array( $new_link ) );
}

/**
* Retuns the new link.
*
* @return array Link array to be added to the sidebar.
*/
private function get_new_link() {
$has_scan = $this->has_scan();
$has_backup = $this->has_backup();

Expand All @@ -92,16 +79,11 @@ private function get_new_link() {
$menu_label = __( 'Backup & Scan', 'jetpack' );
}

return array(
esc_html( $menu_label ) . ' <span class="dashicons dashicons-external"></span>',
'manage_options', // Check permissions here.
esc_url( $url ),
);

add_submenu_page( 'jetpack', $menu_label, esc_html( $menu_label ) . ' <span class="dashicons dashicons-external"></span>', 'manage_options', esc_url( $url ), null, $this->get_link_offset() );
}

/**
* We create a menu offset by counting all the pages that have a jetpack_admin_page set as the link.
* We create a menu offset by counting all the pages that have a jetpack_admin_page set as the capability.
*
* This makes it so that the highlight of the pages works as expected. When you click on the Setting or Dashboard.
*
Expand Down

0 comments on commit 4e538a6

Please sign in to comment.