class-wpml-post-element.php
1.35 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
<?php
/**
* @author OnTheGo Systems
*/
class WPML_Post_Element extends WPML_Translation_Element implements WPML_Duplicable_Element {
/**
* @return WP_Post
*/
function get_wp_object() {
return get_post( $this->id );
}
/**
* @param WP_Post $post
*
* @return string
*/
function get_type( $post = null ) {
if ( $post ) {
return $post->post_type;
}
return $this->get_wp_object()->post_type;
}
public function get_wpml_element_type() {
$element_type = '';
if ( ! is_wp_error( $this->get_wp_element_type() ) ) {
$element_type = 'post_' . $this->get_wp_element_type();
}
return $element_type;
}
function get_element_id() {
return $this->id;
}
/**
* @param null|stdClass $element_data null, or a standard object containing at least the `translation_id`, `language_code`, `element_id`, `source_language_code`, `element_type`, and `original` properties.
*
* @return WPML_Post_Element
* @throws \InvalidArgumentException
*/
function get_new_instance( $element_data ) {
return new WPML_Post_Element( $element_data->element_id, $this->sitepress, $this->wpml_cache );
}
function is_translatable() {
return $this->sitepress->is_translated_post_type( $this->get_wp_element_type() );
}
function is_display_as_translated() {
return $this->sitepress->is_display_as_translated_post_type( $this->get_wp_element_type() );
}
}