PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.4
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.4
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / admin / roles / class-role-manager-vip.php

class-role-manager-vip.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.4, at admin/roles/class-role-manager-vip.php

54 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPSEO plugin file.
4 *
5 * @package WPSEO\Admin\Roles
6 */
7
8 /**
9 * VIP implementation of the Role Manager.
10 */
11 final class WPSEO_Role_Manager_VIP extends WPSEO_Abstract_Role_Manager {
12
13 /**
14 * Adds a role to the system.
15 *
16 * @param string $role Role to add.
17 * @param string $display_name Name to display for the role.
18 * @param array $capabilities Capabilities to add to the role.
19 *
20 * @return void
21 */
22 protected function add_role( $role, $display_name, array $capabilities = [] ) {
23 $enabled_capabilities = [];
24 $disabled_capabilities = [];
25
26 // Build lists of enabled and disabled capabilities.
27 foreach ( $capabilities as $capability => $grant ) {
28 if ( $grant ) {
29 $enabled_capabilities[] = $capability;
30 }
31
32 if ( ! $grant ) {
33 $disabled_capabilities[] = $capability;
34 }
35 }
36
37 wpcom_vip_add_role( $role, $display_name, $enabled_capabilities );
38 if ( $disabled_capabilities !== [] ) {
39 wpcom_vip_remove_role_caps( $role, $disabled_capabilities );
40 }
41 }
42
43 /**
44 * Removes a role from the system.
45 *
46 * @param string $role Role to remove.
47 *
48 * @return void
49 */
50 protected function remove_role( $role ) {
51 remove_role( $role );
52 }
53 }
54