PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.0
Kubio AI Page Builder v2.8.0
2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / lib / integrations / multilanguage / wpml.php
kubio / lib / integrations / multilanguage Last commit date
multilanguage.php 1 year ago polylang.php 1 year ago wpml.php 1 year ago
wpml.php
64 lines
1 <?php
2
3 function kubio_wpml_is_active() {
4 static $is_active = null;
5 if ( $is_active === null ) {
6 $is_active = defined( 'ICL_SITEPRESS_VERSION' );
7 }
8
9 return $is_active && ! kubio_polylang_is_active();
10 }
11
12
13 function kubio_wpml_get_translated_string( $string ) {
14 if ( ! kubio_wpml_is_active() || ! is_string( $string ) ) {
15 return $string;
16 }
17 return apply_filters( 'wpml_translate_single_string', $string, KUBIO_WPML_BLOCK_DEFAULTS_ID, $string );
18 }
19
20 function kubio_wpml_get_translated_media_id( $id ) {
21 if ( ! kubio_wpml_is_active() ) {
22 return $id;
23
24 }
25 $current_language = apply_filters( 'wpml_current_language', null );
26
27 $translated_attachment_id = apply_filters( 'wpml_object_id', $id, 'attachment', true, $current_language );
28
29 return $translated_attachment_id;
30 }
31
32 function kubio_wpml_get_translated_media_url( $url ) {
33 if ( ! kubio_wpml_is_active() || empty( $url ) ) {
34 return $url;
35 }
36 $image_id = attachment_url_to_postid( $url );
37 if ( ! $image_id ) {
38 return $url;
39 }
40
41 $translated_image_id = \kubio_wpml_get_translated_media_id( $image_id );
42 if ( ! $translated_image_id ) {
43 return $url;
44 }
45 $new_url = wp_get_attachment_url( $translated_image_id );
46 if ( $new_url ) {
47 return $new_url;
48 }
49 return $url;
50 }
51
52 function kubio_wpml_get_original_language_post_id( $post_id, $post_type ) {
53 if ( ! kubio_wpml_is_active() ) {
54 return $post_id;
55 }
56
57 $translated_id = apply_filters( 'wpml_object_id', $post_id, $post_type, true, wpml_get_default_language() );
58 if ( ! empty( $translated_id ) && $translated_id !== 0 && $translated_id !== $post_id ) {
59 $post_id = $translated_id;
60 }
61
62 return $post_id;
63 }
64