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

Yoast / wordpress-seo / 5ccfd2603220c02e5d11fd1608b7ae9f1994dda0

21 May 2024 08:28AM UTC coverage: 48.302% (-4.3%) from 52.636%
5ccfd2603220c02e5d11fd1608b7ae9f1994dda0

push

github

web-flow
Merge pull request #21388 from Yoast/217-adapt-yoast-seo-for-elementor-notification-to-elementor-top-bar-navigation

Create a new introduction for the new Elementor editor

7399 of 13455 branches covered (54.99%)

Branch coverage included in aggregate %.

0 of 24 new or added lines in 2 files covered. (0.0%)

3706 existing lines in 106 files now uncovered.

24971 of 53561 relevant lines covered (46.62%)

41937.12 hits per line

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

0.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
         * @return void
28
         */
29
        public function register( $capability, array $roles, $overwrite = false ) {
×
30
                if ( $overwrite || ! isset( $this->capabilities[ $capability ] ) ) {
×
31
                        $this->capabilities[ $capability ] = $roles;
×
32

33
                        return;
×
34
                }
35

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

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

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

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

65
                return array_filter( $wp_roles );
×
66
        }
67

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

84
                // Make sure we have the expected type.
UNCOV
85
                if ( ! is_array( $filtered ) ) {
×
86
                        return [];
×
87
                }
88

UNCOV
89
                return $filtered;
×
90
        }
91
}
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