• 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-integration.php
1
<?php
2
/**
3
 * WPSEO plugin file.
4
 *
5
 * @package WPSEO\Admin\Capabilities
6
 */
7

8
/**
9
 * Integrates Yoast SEO capabilities with third party role manager plugins.
10
 *
11
 * Integrates with: Members
12
 * Integrates with: User Role Editor
13
 */
14
class WPSEO_Capability_Manager_Integration implements WPSEO_WordPress_Integration {
15

16
        /**
17
         * Capability manager to use.
18
         *
19
         * @var WPSEO_Capability_Manager
20
         */
21
        public $manager;
22

23
        /**
24
         * WPSEO_Capability_Manager_Integration constructor.
25
         *
26
         * @param WPSEO_Capability_Manager $manager The capability manager to use.
27
         */
28
        public function __construct( WPSEO_Capability_Manager $manager ) {
×
29
                $this->manager = $manager;
×
30
        }
31

32
        /**
33
         * Registers the hooks.
34
         *
35
         * @return void
36
         */
37
        public function register_hooks() {
×
38
                add_filter( 'members_get_capabilities', [ $this, 'get_capabilities' ] );
×
39
                add_action( 'members_register_cap_groups', [ $this, 'action_members_register_cap_group' ] );
×
40

41
                add_filter( 'ure_capabilities_groups_tree', [ $this, 'filter_ure_capabilities_groups_tree' ] );
×
42
                add_filter( 'ure_custom_capability_groups', [ $this, 'filter_ure_custom_capability_groups' ], 10, 2 );
×
43
        }
44

45
        /**
46
         * Get the Yoast SEO capabilities.
47
         * Optionally append them to an existing array.
48
         *
49
         * @param  array $caps Optional existing capability list.
50
         * @return array
51
         */
52
        public function get_capabilities( array $caps = [] ) {
×
53
                if ( ! did_action( 'wpseo_register_capabilities' ) ) {
×
54
                        do_action( 'wpseo_register_capabilities' );
×
55
                }
56

57
                return array_merge( $caps, $this->manager->get_capabilities() );
×
58
        }
59

60
        /**
61
         * Add capabilities to its own group in the Members plugin.
62
         *
63
         * @see members_register_cap_group()
64
         *
65
         * @return void
66
         */
67
        public function action_members_register_cap_group() {
×
68
                if ( ! function_exists( 'members_register_cap_group' ) ) {
×
69
                        return;
×
70
                }
71

72
                // Register the yoast group.
73
                $args = [
74
                        'label'      => esc_html__( 'Yoast SEO', 'wordpress-seo' ),
×
75
                        'caps'       => $this->get_capabilities(),
×
76
                        'icon'       => 'dashicons-admin-plugins',
×
77
                        'diff_added' => true,
78
                ];
79
                members_register_cap_group( 'wordpress-seo', $args );
×
80
        }
81

82
        /**
83
         * Adds Yoast SEO capability group in the User Role Editor plugin.
84
         *
85
         * @see URE_Capabilities_Groups_Manager::get_groups_tree()
86
         *
87
         * @param array $groups Current groups.
88
         *
89
         * @return array Filtered list of capabilty groups.
90
         */
91
        public function filter_ure_capabilities_groups_tree( $groups = [] ) {
×
92
                $groups = (array) $groups;
×
93

94
                $groups['wordpress-seo'] = [
×
95
                        'caption' => 'Yoast SEO',
96
                        'parent'  => 'custom',
97
                        'level'   => 3,
98
                ];
99

100
                return $groups;
×
101
        }
102

103
        /**
104
         * Adds capabilities to the Yoast SEO group in the User Role Editor plugin.
105
         *
106
         * @see URE_Capabilities_Groups_Manager::get_cap_groups()
107
         *
108
         * @param array  $groups Current capability groups.
109
         * @param string $cap_id Capability identifier.
110
         *
111
         * @return array List of filtered groups.
112
         */
113
        public function filter_ure_custom_capability_groups( $groups = [], $cap_id = '' ) {
×
114
                if ( in_array( $cap_id, $this->get_capabilities(), true ) ) {
×
115
                        $groups   = (array) $groups;
×
116
                        $groups[] = 'wordpress-seo';
×
117
                }
118

119
                return $groups;
×
120
        }
121
}
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