wpml-st-element-slug-translation-ui.php
1.27 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
<?php
class WPML_ST_Element_Slug_Translation_UI {
const TEMPLATE_FILE = 'slug-translation-ui.twig';
/** @var WPML_ST_Element_Slug_Translation_UI_Model $model */
private $model;
/** @var IWPML_Template_Service $template_service */
private $template_service;
public function __construct(
WPML_ST_Element_Slug_Translation_UI_Model $model,
IWPML_Template_Service $template_service
) {
$this->model = $model;
$this->template_service = $template_service;
}
/** @return WPML_ST_Element_Slug_Translation_UI */
public function init() {
wp_enqueue_script(
'wpml-custom-type-slug-ui',
WPML_ST_URL . '/res/js/wpml-custom-type-slug-ui.js',
array( 'jquery' ),
WPML_ST_VERSION,
true
);
return $this;
}
/**
* @param string $type_name
* @param WP_Post_Type|WP_Taxonomy $custom_type
*
* @return string
*/
public function render( $type_name, $custom_type ) {
$model = $this->model->get( $type_name, $custom_type );
if ( ! $model ) {
return '';
}
if ( ! empty( $model['has_missing_translations_message'] ) ) {
ICL_AdminNotifier::displayInstantMessage(
$model['has_missing_translations_message'],
'error',
true,
false
);
}
return $this->template_service->show( $model, self::TEMPLATE_FILE );
}
}