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

Yoast / wordpress-seo / 6987097851

25 Nov 2023 04:49AM UTC coverage: 49.206% (-0.1%) from 49.302%
6987097851

push

github

web-flow
Merge pull request #20878 from Yoast/JRF/ghactions-minor-tweak

GH Actions: update a few links in inline comments

15305 of 31104 relevant lines covered (49.21%)

4.03 hits per line

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

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

8
/**
9
 * Abstract Capability Manager shared code.
10
 */
11
abstract class WPSEO_Abstract_Capability_Manager implements WPSEO_Capability_Manager {
12

13
        /**
14
         * Registered capabilities.
15
         *
16
         * @var array
17
         */
18
        protected $capabilities = [];
19

20
        /**
21
         * Registers a capability.
22
         *
23
         * @param string $capability Capability to register.
24
         * @param array  $roles      Roles to add the capability to.
25
         * @param bool   $overwrite  Optional. Use add or overwrite as registration method.
26
         */
27
        public function register( $capability, array $roles, $overwrite = false ) {
×
28
                if ( $overwrite || ! isset( $this->capabilities[ $capability ] ) ) {
×
29
                        $this->capabilities[ $capability ] = $roles;
×
30

31
                        return;
×
32
                }
33

34
                // Combine configurations.
35
                $this->capabilities[ $capability ] = array_merge( $roles, $this->capabilities[ $capability ] );
×
36

37
                // Remove doubles.
38
                $this->capabilities[ $capability ] = array_unique( $this->capabilities[ $capability ] );
×
39
        }
40

41
        /**
42
         * Returns the list of registered capabilitities.
43
         *
44
         * @return string[] Registered capabilities.
45
         */
46
        public function get_capabilities() {
×
47
                return array_keys( $this->capabilities );
×
48
        }
49

50
        /**
51
         * Returns a list of WP_Role roles.
52
         *
53
         * The string array of role names are converted to actual WP_Role objects.
54
         * These are needed to be able to use the API on them.
55
         *
56
         * @param array $roles Roles to retrieve the objects for.
57
         *
58
         * @return WP_Role[] List of WP_Role objects.
59
         */
60
        protected function get_wp_roles( array $roles ) {
×
61
                $wp_roles = array_map( 'get_role', $roles );
×
62

63
                return array_filter( $wp_roles );
×
64
        }
65

66
        /**
67
         * Filter capability roles.
68
         *
69
         * @param string $capability Capability to filter roles for.
70
         * @param array  $roles      List of roles which can be filtered.
71
         *
72
         * @return array Filtered list of roles for the capability.
73
         */
74
        protected function filter_roles( $capability, array $roles ) {
4✔
75
                /**
76
                 * Filter: Allow changing roles that a capability is added to.
77
                 *
78
                 * @api array $roles The default roles to be filtered.
79
                 */
80
                $filtered = apply_filters( $capability . '_roles', $roles );
4✔
81

82
                // Make sure we have the expected type.
83
                if ( ! is_array( $filtered ) ) {
4✔
84
                        return [];
×
85
                }
86

87
                return $filtered;
4✔
88
        }
89
}
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

© 2026 Coveralls, Inc