HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //proc/self/cwd/wp-content/plugins/wp-sheet-editor-premium/modules/wpml/wpml.php
<?php

if (!class_exists('WP_Sheet_Editor_WPML')) {

	class WP_Sheet_Editor_WPML {

		static private $instance = false;

		private function __construct() {
			
		}

		/**
		 * Creates or returns an instance of this class.
		 */
		static function get_instance() {
			if (null == WP_Sheet_Editor_WPML::$instance) {
				WP_Sheet_Editor_WPML::$instance = new WP_Sheet_Editor_WPML();
				WP_Sheet_Editor_WPML::$instance->init();
			}
			return WP_Sheet_Editor_WPML::$instance;
		}

		function init() {
			if (!defined('ICL_SITEPRESS_VERSION') || !interface_exists('IWPML_Action')) {
				return;
			}
			$files = VGSE()->helpers->get_files_list(__DIR__ . '/inc');
			foreach ($files as $file) {
				require_once $file;
			}
			add_filter('vg_sheet_editor/js_data', array($this, 'always_use_initial_language'));
		}

		function always_use_initial_language($settings) {
			global $sitepress;
			$settings['ajax_url'] = add_query_arg('lang', $sitepress->get_current_language(), $settings['ajax_url']);
			return $settings;
		}

		function __set($name, $value) {
			$this->$name = $value;
		}

		function __get($name) {
			return $this->$name;
		}

		function filter_posts_query_by_language($sql) {
			global $wpdb, $sitepress;

			if (strpos($sql, $wpdb->posts) === false && strpos($sql, $wpdb->postmeta) !== false) {
				$sql = str_replace(' WHERE ', " LEFT JOIN " . $wpdb->posts . " p 
ON $wpdb->postmeta.post_id = p.ID WHERE ", $sql);
			}

			$sql = str_replace(' WHERE ', " LEFT JOIN " . $wpdb->prefix . "icl_translations i
ON CONCAT('post_', p.post_type ) = i.element_type
AND i.element_id = p.ID
WHERE i.language_code  = '" . esc_sql($sitepress->get_current_language()) . "' AND ", $sql);
			return $sql;
		}

		function is_not_the_default_language() {
			global $sitepress;
			return $sitepress->get_default_language() !== $sitepress->get_current_language();
		}

		function get_main_id($translation_id, $type) {
			$original_id = (int) SitePress::get_original_element_id($translation_id, $type);
			return $original_id;
		}

		function get_main_translation_id($translation_id, $type, $is_original_id = false) {
			global $wpdb;
			$original_id = (!$is_original_id ) ? $this->get_main_id($translation_id, $type) : $translation_id;

			if (!$original_id) {
				return $original_id;
			}

			$id = (int) $wpdb->get_var("SELECT trid FROM {$wpdb->prefix}icl_translations WHERE element_type = '" . esc_sql($type) . "' AND element_id = " . (int) $original_id);
			return $id;
		}

		function is_the_default_language() {
			return !$this->is_not_the_default_language();
		}

	}

}


if (!function_exists('WP_Sheet_Editor_WPML_Obj')) {

	function WP_Sheet_Editor_WPML_Obj() {
		return WP_Sheet_Editor_WPML::get_instance();
	}

}


add_action('vg_sheet_editor/initialized', 'WP_Sheet_Editor_WPML_Obj');