| @@ 22-35 (lines=14) @@ | ||
| 19 | $user = wp_get_current_user(); |
|
| 20 | $roles = $user ? $user->roles : array(); |
|
| 21 | ||
| 22 | switch ( $this->get_comparison_operator() ) { |
|
| 23 | case '=': |
|
| 24 | return in_array( $this->get_value(), $roles ); |
|
| 25 | break; |
|
| 26 | case '!=': |
|
| 27 | return ! in_array( $this->get_value(), $roles ); |
|
| 28 | break; |
|
| 29 | case 'IN': |
|
| 30 | return count( array_intersect( $roles, $this->get_value() ) ) > 0; |
|
| 31 | break; |
|
| 32 | case 'NOT IN': |
|
| 33 | return count( array_intersect( $roles, $this->get_value() ) ) === 0; |
|
| 34 | break; |
|
| 35 | } |
|
| 36 | ||
| 37 | return $this->first_supported_comparer_is_correct( |
|
| 38 | $roles, |
|
| @@ 21-34 (lines=14) @@ | ||
| 18 | public function is_fulfilled( $environment ) { |
|
| 19 | $roles = $environment['roles']; |
|
| 20 | ||
| 21 | switch ( $this->get_comparison_operator() ) { |
|
| 22 | case '=': |
|
| 23 | return in_array( $this->get_value(), $roles ); |
|
| 24 | break; |
|
| 25 | case '!=': |
|
| 26 | return ! in_array( $this->get_value(), $roles ); |
|
| 27 | break; |
|
| 28 | case 'IN': |
|
| 29 | return count( array_intersect( $roles, $this->get_value() ) ) > 0; |
|
| 30 | break; |
|
| 31 | case 'NOT IN': |
|
| 32 | return count( array_intersect( $roles, $this->get_value() ) ) === 0; |
|
| 33 | break; |
|
| 34 | } |
|
| 35 | ||
| 36 | return $this->first_supported_comparer_is_correct( |
|
| 37 | $roles, |
|