class-wpml-tm-translation-roles-section.php
2.04 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
use WPML\TranslationRoles\UI\Initializer;
use WPML\TM\Menu\TranslationServices\Section;
use WPML\TM\Menu\TranslationMethod\TranslationMethodSettings;
use WPML\FP\Relation;
use WPML\LIB\WP\User;
class WPML_TM_Translation_Roles_Section implements IWPML_TM_Admin_Section {
const SLUG = 'translators';
/**
* @var Section
*/
private $translation_services_section;
public function __construct( Section $translation_services_section ) {
$this->translation_services_section = $translation_services_section;
TranslationMethodSettings::addHooks();
}
/**
* Returns a value which will be used for sorting the sections.
*
* @return int
*/
public function get_order() {
return 300;
}
/**
* Returns the unique slug of the sections which is used to build the URL for opening this section.
*
* @return string
*/
public function get_slug() {
return self::SLUG;
}
/**
* Returns one or more capabilities required to display this section.
*
* @return string|array
*/
public function get_capabilities() {
return [ User::CAP_MANAGE_TRANSLATIONS, User::CAP_ADMINISTRATOR ];
}
/**
* Returns the caption to display in the section.
*
* @return string
*/
public function get_caption() {
return __( 'Translators', 'wpml-translation-management' );
}
/**
* Returns the callback responsible for rendering the content of the section.
*
* @return callable
*/
public function get_callback() {
return [ $this, 'render' ];
}
/**
* This method is hooked to the `admin_enqueue_scripts` action.
*
* @param string $hook The current page.
*/
public function admin_enqueue_scripts( $hook ) {
if ( Relation::propEq( 'sm', 'translators', $_GET ) ) {
Initializer::loadJS();
}
}
/**
* Used to extend the logic for displaying/hiding the section.
*
* @return bool
*/
public function is_visible() {
return true;
}
/**
* Outputs the content of the section.
*/
public function render() {
?>
<div id="wpml-translation-roles-ui-container"></div>
<?php
$this->translation_services_section->render();
}
}