| @@ 682-693 (lines=12) @@ | ||
| 679 | ); |
|
| 680 | $update_capabilities_map = false; |
|
| 681 | // if not reset, see what caps are new for each role. if they're new, add them. |
|
| 682 | foreach ($capabilities_to_add as $role => $caps_for_role) { |
|
| 683 | if (is_array($caps_for_role)) { |
|
| 684 | foreach ($caps_for_role as $cap) { |
|
| 685 | if ( |
|
| 686 | ! $this->capHasBeenAddedToRole($role, $cap) |
|
| 687 | && $this->add_cap_to_role($role, $cap, true, false) |
|
| 688 | ) { |
|
| 689 | $update_capabilities_map = true; |
|
| 690 | } |
|
| 691 | } |
|
| 692 | } |
|
| 693 | } |
|
| 694 | // now let's just save the cap that has been set but only if there's been a change. |
|
| 695 | $updated = $this->updateCapabilitiesMap($update_capabilities_map); |
|
| 696 | $this->flushWpUser($updated); |
|
| @@ 717-728 (lines=12) @@ | ||
| 714 | return false; |
|
| 715 | } |
|
| 716 | $update_capabilities_map = false; |
|
| 717 | foreach ($caps_map as $role => $caps_for_role) { |
|
| 718 | if (is_array($caps_for_role)) { |
|
| 719 | foreach ($caps_for_role as $cap) { |
|
| 720 | if ($this->capHasBeenAddedToRole($role, $cap) |
|
| 721 | && $this->remove_cap_from_role($role, $cap, false) |
|
| 722 | ) { |
|
| 723 | $update_capabilities_map = true; |
|
| 724 | } |
|
| 725 | } |
|
| 726 | } |
|
| 727 | } |
|
| 728 | // maybe resave the caps |
|
| 729 | $updated = $this->updateCapabilitiesMap($update_capabilities_map); |
|
| 730 | $this->flushWpUser($updated); |
|
| 731 | return $updated; |
|