• 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

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
        public function action_members_register_cap_group() {
×
66
                if ( ! function_exists( 'members_register_cap_group' ) ) {
×
67
                        return;
×
68
                }
69

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

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

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

98
                return $groups;
×
99
        }
100

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

117
                return $groups;
×
118
        }
119
}
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