class-wpml-translation-manager-records.php
804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
use WPML\FP\Relation;
class WPML_Translation_Manager_Records extends WPML_Translation_Roles_Records {
/**
* @return string
*/
protected function get_capability() {
return \WPML\LIB\WP\User::CAP_MANAGE_TRANSLATIONS;
}
/**
* @return array
*/
protected function get_required_wp_roles() {
return wpml_collect( $this->wp_roles->role_objects )
->filter( [ $this, 'is_required_role' ] )
->keys()
->reject( Relation::equals( 'administrator' ) ) // Admins always have Translation Manager caps.
->all();
}
/**
* Determine if the role can be used for a manager.
*
* @param \WP_Role $role The role definition.
*
* @return bool
*/
public function is_required_role( WP_Role $role ) {
return array_key_exists( 'edit_private_posts', $role->capabilities );
}
}