Download wp-calypso/client/state/selectors/can-current-user.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 798 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/selectors/can-current-user.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/selectors/can-current-user.js
-
curl -L -o can-current-user.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/selectors/can-current-user.js
798 Bytes
| /** | |
| * Returns: | |
| * - `true` if the current user has the specified capability for the site; | |
| * - `false` if the user does not have the capability, or if specifying an invalid capability; | |
| * - `null` if the capability cannot be determined (the site is not currently known) | |
| * @see https://codex.wordpress.org/Function_Reference/current_user_can | |
| * @param {Object|unknown} state Global state tree | |
| * @param {number|undefined|null} siteId Site ID | |
| * @param {string} capability Capability label | |
| * @returns {boolean} Whether current user has capability | |
| */ | |
| export function canCurrentUser( state, siteId, capability ) { | |
| const capabilities = state.currentUser.capabilities[ siteId ]; | |
| if ( ! capabilities ) { | |
| return null; | |
| } | |
| return capabilities[ capability ] || false; | |
| } | |