Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wordpres.../admin/capabili...
File: class-capability-utils.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WPSEO plugin file.
[2] Fix | Delete
*
[3] Fix | Delete
* @package WPSEO\Admin\Capabilities
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
/**
[7] Fix | Delete
* Capability Utils collection.
[8] Fix | Delete
*/
[9] Fix | Delete
class WPSEO_Capability_Utils {
[10] Fix | Delete
[11] Fix | Delete
/**
[12] Fix | Delete
* Checks if the user has the proper capabilities.
[13] Fix | Delete
*
[14] Fix | Delete
* @param string $capability Capability to check.
[15] Fix | Delete
*
[16] Fix | Delete
* @return bool True if the user has the proper rights.
[17] Fix | Delete
*/
[18] Fix | Delete
public static function current_user_can( $capability ) {
[19] Fix | Delete
if ( $capability === 'wpseo_manage_options' ) {
[20] Fix | Delete
return self::has( $capability );
[21] Fix | Delete
}
[22] Fix | Delete
[23] Fix | Delete
return self::has_any( [ 'wpseo_manage_options', $capability ] );
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
/**
[27] Fix | Delete
* Retrieves the users that have the specified capability.
[28] Fix | Delete
*
[29] Fix | Delete
* @param string $capability The name of the capability.
[30] Fix | Delete
*
[31] Fix | Delete
* @return array The users that have the capability.
[32] Fix | Delete
*/
[33] Fix | Delete
public static function get_applicable_users( $capability ) {
[34] Fix | Delete
$applicable_roles = self::get_applicable_roles( $capability );
[35] Fix | Delete
[36] Fix | Delete
if ( $applicable_roles === [] ) {
[37] Fix | Delete
return [];
[38] Fix | Delete
}
[39] Fix | Delete
[40] Fix | Delete
return get_users( [ 'role__in' => $applicable_roles ] );
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* Retrieves the roles that have the specified capability.
[45] Fix | Delete
*
[46] Fix | Delete
* @param string $capability The name of the capability.
[47] Fix | Delete
*
[48] Fix | Delete
* @return array The names of the roles that have the capability.
[49] Fix | Delete
*/
[50] Fix | Delete
public static function get_applicable_roles( $capability ) {
[51] Fix | Delete
$roles = wp_roles();
[52] Fix | Delete
$role_names = $roles->get_names();
[53] Fix | Delete
[54] Fix | Delete
$applicable_roles = [];
[55] Fix | Delete
foreach ( array_keys( $role_names ) as $role_name ) {
[56] Fix | Delete
$role = $roles->get_role( $role_name );
[57] Fix | Delete
[58] Fix | Delete
if ( ! $role ) {
[59] Fix | Delete
continue;
[60] Fix | Delete
}
[61] Fix | Delete
[62] Fix | Delete
// Add role if it has the capability.
[63] Fix | Delete
if ( array_key_exists( $capability, $role->capabilities ) && $role->capabilities[ $capability ] === true ) {
[64] Fix | Delete
$applicable_roles[] = $role_name;
[65] Fix | Delete
}
[66] Fix | Delete
}
[67] Fix | Delete
[68] Fix | Delete
return $applicable_roles;
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
/**
[72] Fix | Delete
* Checks if the current user has at least one of the supplied capabilities.
[73] Fix | Delete
*
[74] Fix | Delete
* @param array $capabilities Capabilities to check against.
[75] Fix | Delete
*
[76] Fix | Delete
* @return bool True if the user has at least one capability.
[77] Fix | Delete
*/
[78] Fix | Delete
protected static function has_any( array $capabilities ) {
[79] Fix | Delete
foreach ( $capabilities as $capability ) {
[80] Fix | Delete
if ( self::has( $capability ) ) {
[81] Fix | Delete
return true;
[82] Fix | Delete
}
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
return false;
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
/**
[89] Fix | Delete
* Checks if the user has a certain capability.
[90] Fix | Delete
*
[91] Fix | Delete
* @param string $capability Capability to check against.
[92] Fix | Delete
*
[93] Fix | Delete
* @return bool True if the user has the capability.
[94] Fix | Delete
*/
[95] Fix | Delete
protected static function has( $capability ) {
[96] Fix | Delete
return current_user_can( $capability );
[97] Fix | Delete
}
[98] Fix | Delete
}
[99] Fix | Delete
[100] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function