From 125c0c1a0ce7c7b5c292a2cc1312bfe720fd0e23 Mon Sep 17 00:00:00 2001 From: helgatheviking <507025+helgatheviking@users.noreply.github.com> Date: Fri, 26 Jul 2024 13:50:19 -0400 Subject: [PATCH] update readme.md --- readme.md | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/readme.md b/readme.md index de84c16..a0eafac 100644 --- a/readme.md +++ b/readme.md @@ -162,7 +162,7 @@ The roles in NMR are filterable distinct from the global `$wp_roles`. This allow * param: $roles an array of all available roles, by default is global $wp_roles * return: array */ - function kia_new_roles( $roles ){ + function kia_new_roles( $roles ) { $roles['new-role-key'] = 'new-role'; return $roles; } @@ -174,16 +174,17 @@ Note, if you want to add a WordPress capability the above is literally all you n In case you *do* need to check your visibility status against something very custom, here is how you'd go about it: - /* + /** * Change visibility of each menu item - * param: $visible boolean - * param: $item object, the complete menu object. Nav Menu Roles adds its info to $item->roles - * $item->roles can be "in" (all logged in), "out" (all logged out) or an array of specific roles + * @param bool $visible + * @param obj $item The complete menu object. Nav Menu Roles adds its info to the following keys { + * roles - Possible value: "in" (all logged in) | "out" (all logged out) | an array of specific roles, ex: [ "administrator", "editor" ] + * display_mode - Possible values: "show" (show if conditions met) | "hide" (hide if conditions met) * return boolean */ - function kia_item_visibility( $visible, $item ){ - if( isset( $item->roles ) && is_array( $item->roles ) && in_array( 'new-role-key', $item->roles ) ){ - /* if ( // your own custom check on the current user versus 'new-role' status ){ + function kia_item_visibility( $visible, $item ) { + if ( isset( $item->roles ) && is_array( $item->roles ) && in_array( 'new-role-key', $item->roles ) ) { + /* if ( // your own custom check on the current user versus 'new-role' status ) { $visible = true; } else { $visible = false; @@ -201,13 +202,13 @@ Note that you have to generate your own if/then logic. I can't provide free supp Add the following snippet to your theme's `functions.php` file: - /* + /** * Sort the NMR roles - * @param: $roles an array of all available roles with ID=>Name - * @return: array + * @param array $roles An array of all available roles with ID=>Name. + * @return array */ - function kia_sort_roles( $roles ){ - if( is_admin() ) { + function kia_sort_roles( $roles ) { + if ( is_admin() ) { $array_lowercase = array_map( 'strtolower', $roles ); array_multisort( $array_lowercase, SORT_ASC, SORT_STRING, $roles ); return $roles;