| Server IP : 194.61.116.167 / Your IP : 216.73.217.84 Web Server : Apache/2 System : Linux nimbus2000.evosiber.com 5.14.0-503.11.1.el9_5.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Nov 12 09:26:13 EST 2024 x86_64 User : evoplastik ( 1130) PHP Version : 8.1.34 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home/evoplastik/public_html/wp-content/plugins/wordpress-seo/src/helpers/ |
Upload File : |
<?php
namespace Yoast\WP\SEO\Helpers;
/**
* A helper object for user capabilities.
*/
class Capability_Helper {
/**
* Checks if the user has at least one of the proper capabilities.
*
* @param string $capability Capability to check.
*
* @return bool True if the user has at least one of the proper rights.
*/
public function current_user_can( $capability ) {
if ( $capability === 'wpseo_manage_options' ) {
return \current_user_can( $capability );
}
return $this->has_any( [ 'wpseo_manage_options', $capability ] );
}
/**
* Retrieves the users that have the specified capability.
*
* @param string $capability The name of the capability.
*
* @return array The users that have the capability.
*/
public function get_applicable_users( $capability ) {
$applicable_roles = $this->get_applicable_roles( $capability );
if ( $applicable_roles === [] ) {
return [];
}
return \get_users( [ 'role__in' => $applicable_roles ] );
}
/**
* Retrieves the roles that have the specified capability.
*
* @param string $capability The name of the capability.
*
* @return array The names of the roles that have the capability.
*/
public function get_applicable_roles( $capability ) {
$roles = \wp_roles();
$role_names = $roles->get_names();
$applicable_roles = [];
foreach ( \array_keys( $role_names ) as $role_name ) {
$role = $roles->get_role( $role_name );
if ( ! $role ) {
continue;
}
// Add role if it has the capability.
if ( \array_key_exists( $capability, $role->capabilities ) && $role->capabilities[ $capability ] === true ) {
$applicable_roles[] = $role_name;
}
}
return $applicable_roles;
}
/**
* Checks if the current user has at least one of the supplied capabilities.
*
* @param array $capabilities Capabilities to check against.
*
* @return bool True if the user has at least one capability.
*/
private function has_any( array $capabilities ) {
foreach ( $capabilities as $capability ) {
if ( \current_user_can( $capability ) ) {
return true;
}
}
return false;
}
}