PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.9
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.9
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 / capabilities / class-capability-manager-wp.php

class-capability-manager-wp.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.9, at admin/capabilities/class-capability-manager-wp.php

52 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\Capabilities
6 */
7
8 /**
9 * Default WordPress capability manager implementation.
10 */
11 final class WPSEO_Capability_Manager_WP extends WPSEO_Abstract_Capability_Manager {
12
13 /**
14 * Adds the capabilities to the roles.
15 *
16 * @return void
17 */
18 public function add() {
19 foreach ( $this->capabilities as $capability => $roles ) {
20 $filtered_roles = $this->filter_roles( $capability, $roles );
21
22 $wp_roles = $this->get_wp_roles( $filtered_roles );
23 foreach ( $wp_roles as $wp_role ) {
24 $wp_role->add_cap( $capability );
25 }
26 }
27 }
28
29 /**
30 * Unregisters the capabilities from the system.
31 *
32 * @return void
33 */
34 public function remove() {
35 // Remove from any roles it has been added to.
36 $roles = wp_roles()->get_names();
37 $roles = array_keys( $roles );
38
39 foreach ( $this->capabilities as $capability => $_roles ) {
40 $registered_roles = array_unique( array_merge( $roles, $this->capabilities[ $capability ] ) );
41
42 // Allow filtering of roles.
43 $filtered_roles = $this->filter_roles( $capability, $registered_roles );
44
45 $wp_roles = $this->get_wp_roles( $filtered_roles );
46 foreach ( $wp_roles as $wp_role ) {
47 $wp_role->remove_cap( $capability );
48 }
49 }
50 }
51 }
52