PluginProbe
Easy Elements for Elementor – Addons & Website Templates / 1.3.0
Easy Elements for Elementor – Addons & Website Templates v1.3.0
1.5.3 1.5.2 1.5.1 1.5.0 1.4.9 1.4.6 1.4.7 1.4.8 1.4.5 1.4.4 1.4.3 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 All 47 releases
easy-elements / includes / Header_Footer_Builder / compatibility / class-wpml-compatibility.php

class-wpml-compatibility.php in Easy Elements for Elementor – Addons & Website Templates 1.3.0, at includes/Header_Footer_Builder/compatibility/class-wpml-compatibility.php

89 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPML Compatibility for Header Footer Elementor.
4 *
5 * @package EASYEL
6 * @author EASYEL
7 * @copyright Copyright (c) 2018, EASYEL
8 * @since EASYEL 1.0.0
9 */
10
11 defined( 'ABSPATH' ) || exit;
12
13 /**
14 * Set up WPML Compatibiblity Class.
15 */
16 class EASYEL_WPML_Compatibility {
17
18 /**
19 * Instance of EASYEL_WPML_Compatibility.
20 *
21 * @since 1.0.9
22 * @var null
23 */
24 private static $_instance = null;
25
26 /**
27 * Get instance of EASYEL_WPML_Compatibility
28 *
29 * @since 1.0.9
30 * @return EASYEL_WPML_Compatibility
31 */
32 public static function instance() {
33 if ( ! isset( self::$_instance ) ) {
34 self::$_instance = new self();
35 }
36
37 return self::$_instance;
38 }
39
40 /**
41 * Setup actions and filters.
42 *
43 * @since 1.0.9
44 */
45 private function __construct() {
46 add_filter( 'easyel_get_settings_type_header', [ $this, 'easyel_wpml_object' ] );
47 add_filter( 'easyel_get_settings_type_easy_after__header', [ $this, 'easyel_wpml_object' ] );
48 add_filter( 'easyel_get_settings_type_footer', [ $this, 'easyel_wpml_object' ] );
49 add_filter( 'easyel_get_settings_type_before_footer', [ $this, 'easyel_wpml_object' ] );
50 add_filter( 'easyel_get_settings_type_easy_topbar', [ $this, 'easyel_wpml_object' ] );
51 add_filter( 'hfe_render_template_id', [ $this, 'easyel_wpml_object' ] );
52 }
53
54 /**
55 * Pass the final header and footer ID from the WPML's object filter to allow strings to be translated.
56 *
57 * @since 1.0.0
58 * @param Int $id Post ID of the template being rendered.
59 * @return Int $id Post ID of the template being rendered, Passed through the `wpml_object_id` id.
60 */
61 public function easyel_wpml_object( $id ) {
62 $translated_id = apply_filters( 'wpml_object_id', $id );
63
64 if ( defined( 'POLYLANG_BASENAME' ) ) {
65
66 if ( null === $translated_id ) {
67
68 // The current language is not defined yet or translation is not available.
69 return $id;
70 } else {
71
72 // Return translated post ID.
73 return $translated_id;
74 }
75 }
76
77 if ( null === $translated_id ) {
78 $translated_id = '';
79 }
80
81 return $translated_id;
82 }
83 }
84
85 /**
86 * Initiate the class.
87 */
88 EASYEL_WPML_Compatibility::instance();
89