Skip to content

Commit

Permalink
Remove unsupported plugin menu visibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcelloPerathoner committed Jan 8, 2024
1 parent 3fbaf08 commit 0c8e9b6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions themes/Capitularia/functions-include.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,31 @@ function on_do_parse_request ($do_parse, $wp, $extra_query_vars) // phpcs:ignore
return $do_parse;
}

/**
* Removes the login menu if already logged in.
*
* This assumes the menu entry is a top-level one with an URL of: #cap_login_menu#
*
* @param array $items An array of menu item post objects.
* @param object $menu The menu object.
* @param array $args An array of arguments used to retrieve menu item objects.
*
* @return array The modified array of menu item post objects.
*/
function on_wp_get_nav_menu_items ($items, $menu, $args) {
foreach ($items as $key => $item) {
if (isset ($item->url)) {
if (strcmp ($item->url, MAGIC_LOGIN) === 0) {
if (is_user_logged_in()) {
unset ($items[$key]);
}
}
}
}
return $items;
}


/**
* Add dynamic url to login menu. Remove text from twitter and fb logos.
*
Expand Down
1 change: 1 addition & 0 deletions themes/Capitularia/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ function () {
/* add login url to menu */
if (!is_admin ()) {
add_filter ('nav_menu_link_attributes', ns ('on_nav_menu_link_attributes'), 20, 4);
add_filter ('wp_get_nav_menu_items', ns ('on_wp_get_nav_menu_items' ), 10, 3 );
}

/* allow SVG uploads */
Expand Down

0 comments on commit 0c8e9b6

Please sign in to comment.