Skip to content

Commit

Permalink
Removes unneeded menus.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierre-Lannoy committed Aug 11, 2021
1 parent 8fe5642 commit e97de24
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
9 changes: 9 additions & 0 deletions admin/class-hsiss-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ public function finalize_admin_menus() {
Menus::finalize();
}

/**
* Removes unneeded items from the settings menu.
*
* @since 2.0.0
*/
public function normalize_admin_menus() {
Menus::normalize();
}

/**
* Set the items in the settings menu.
*
Expand Down
3 changes: 2 additions & 1 deletion includes/plugin/class-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ private function define_admin_hooks() {
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
$this->loader->add_action( 'admin_menu', $plugin_admin, 'init_admin_menus' );
$this->loader->add_action( 'admin_menu', $plugin_admin, 'finalize_admin_menus', PHP_INT_MAX );
$this->loader->add_action( 'admin_menu', $plugin_admin, 'finalize_admin_menus', PHP_INT_MAX - 1 );
$this->loader->add_action( 'admin_menu', $plugin_admin, 'normalize_admin_menus', PHP_INT_MAX );
$this->loader->add_action( 'admin_init', $plugin_admin, 'init_settings_sections' );
$this->loader->add_filter( 'plugin_action_links_' . plugin_basename( HSISS_PLUGIN_DIR . HSISS_SLUG . '.php' ), $plugin_admin, 'add_actions_links', 10, 4 );
$this->loader->add_filter( 'plugin_row_meta', $plugin_admin, 'add_row_meta', 10, 2 );
Expand Down
14 changes: 14 additions & 0 deletions perfopsone/class-menus.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,20 @@ public static function initialize() {
}
}

/**
* Dispatch the admin menus.
*
* @since 2.0.0
*/
public static function normalize() {
$current = apply_filters( 'init_perfopsone_admin_menus', [] );
foreach ( self::$menus_positions as $menu ) {
if ( ! array_key_exists( $menu, $current ) ) {
remove_submenu_page( 'perfopsone-dashboard', 'perfopsone-' . $menu );
}
}
}

/**
* Dispatch the admin menus.
*
Expand Down

0 comments on commit e97de24

Please sign in to comment.