Server IP : 192.158.238.246 / Your IP : 216.73.216.68 Web Server : LiteSpeed System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64 User : jenniferflocom ( 1321) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/7779/task/7779/cwd/plugins/woocommerce/vendor/automattic/jetpack-roles/src/ |
Upload File : |
<?php /** * A user roles class for Jetpack. * * @package automattic/jetpack-roles */ namespace Automattic\Jetpack; /** * Class Automattic\Jetpack\Roles * * Contains utilities for translating user roles to capabilities and vice versa. */ class Roles { /** * Map of roles we care about, and their corresponding minimum capabilities. * * @access protected * * @var array */ protected $capability_translations = array( 'administrator' => 'manage_options', 'editor' => 'edit_others_posts', 'author' => 'publish_posts', 'contributor' => 'edit_posts', 'subscriber' => 'read', ); /** * Get the role of the current user. * * @access public * * @return string|boolean Current user's role, false if not enough capabilities for any of the roles. */ public function translate_current_user_to_role() { foreach ( $this->capability_translations as $role => $cap ) { if ( current_user_can( $role ) || current_user_can( $cap ) ) { return $role; } } return false; } /** * Get the role of a particular user. * * @access public * * @param \WP_User $user User object. * @return string|boolean User's role, false if not enough capabilities for any of the roles. */ public function translate_user_to_role( $user ) { foreach ( $this->capability_translations as $role => $cap ) { if ( user_can( $user, $role ) || user_can( $user, $cap ) ) { return $role; } } return false; } /** * Get the minimum capability for a role. * * @access public * * @param string $role Role name. * @return string|boolean Capability, false if role isn't mapped to any capabilities. */ public function translate_role_to_cap( $role ) { if ( ! isset( $this->capability_translations[ $role ] ) ) { return false; } return $this->capability_translations[ $role ]; } }