• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / 49cdf70e861509c37a279de77f1105ee59c0f57f

20 Feb 2024 09:17AM UTC coverage: 53.172%. First build
49cdf70e861509c37a279de77f1105ee59c0f57f

push

github

YoastBot
Bump version to 22.1 on free

7564 of 13903 branches covered (54.41%)

Branch coverage included in aggregate %.

29067 of 54988 relevant lines covered (52.86%)

40245.15 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/admin/capabilities/class-capability-manager-vip.php
1
<?php
2
/**
3
 * WPSEO plugin file.
4
 *
5
 * @package WPSEO\Admin\Capabilities
6
 */
7

8
/**
9
 * VIP implementation of the Capability Manager.
10
 */
11
final class WPSEO_Capability_Manager_VIP extends WPSEO_Abstract_Capability_Manager {
12

13
        /**
14
         * Adds the registered capabilities to the system.
15
         *
16
         * @return void
17
         */
18
        public function add() {
×
19
                $role_capabilities = [];
×
20
                foreach ( $this->capabilities as $capability => $roles ) {
×
21
                        $role_capabilities = $this->get_role_capabilities( $role_capabilities, $capability, $roles );
×
22
                }
23

24
                foreach ( $role_capabilities as $role => $capabilities ) {
×
25
                        wpcom_vip_add_role_caps( $role, $capabilities );
×
26
                }
27
        }
28

29
        /**
30
         * Removes the registered capabilities from the system
31
         *
32
         * @return void
33
         */
34
        public function remove() {
×
35
                // Remove from any role it has been added to.
36
                $roles = wp_roles()->get_names();
×
37
                $roles = array_keys( $roles );
×
38

39
                $role_capabilities = [];
×
40
                foreach ( array_keys( $this->capabilities ) as $capability ) {
×
41
                        // Allow filtering of roles.
42
                        $role_capabilities = $this->get_role_capabilities( $role_capabilities, $capability, $roles );
×
43
                }
44

45
                foreach ( $role_capabilities as $role => $capabilities ) {
×
46
                        wpcom_vip_remove_role_caps( $role, $capabilities );
×
47
                }
48
        }
49

50
        /**
51
         * Returns the roles which the capability is registered on.
52
         *
53
         * @param array  $role_capabilities List of all roles with their capabilities.
54
         * @param string $capability        Capability to filter roles for.
55
         * @param array  $roles             List of default roles.
56
         *
57
         * @return array List of capabilities.
58
         */
59
        protected function get_role_capabilities( $role_capabilities, $capability, $roles ) {
×
60
                // Allow filtering of roles.
61
                $filtered_roles = $this->filter_roles( $capability, $roles );
×
62

63
                foreach ( $filtered_roles as $role ) {
×
64
                        if ( ! isset( $add_role_caps[ $role ] ) ) {
×
65
                                $role_capabilities[ $role ] = [];
×
66
                        }
67

68
                        $role_capabilities[ $role ][] = $capability;
×
69
                }
70

71
                return $role_capabilities;
×
72
        }
73
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc