Skip to content

Commit

Permalink
wpcom_vip_add_role(): set $capabilities as empty array if not arr…
Browse files Browse the repository at this point in the history
…ay (#5080)
  • Loading branch information
rebeccahum authored Dec 5, 2023
1 parent b4073f2 commit d91159b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vip-helpers/vip-roles.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ function wpcom_vip_get_role_caps( $role ) {
* @param array $capabilities Key/value array of capabilities for the role
*/
function wpcom_vip_add_role( $role, $name, $capabilities ) {
if ( ! is_array( $capabilities ) ) {
$capabilities = array();
}

if ( array_is_list( $capabilities ) && ! array_filter( $capabilities, 'is_bool' ) ) {
$capabilities = array_flip( $capabilities );
$capabilities = array_map( '__return_true', $capabilities );
Expand Down

0 comments on commit d91159b

Please sign in to comment.