HEX
Server: Apache/2.4.57 (Debian)
System: Linux web-server-k8s-e92jnr3j-6f99bff6b6-rp2wg 6.1.0-22-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.94-1 (2024-06-21) x86_64
User: apache (48)
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,
Upload Files
File: /var/www/sites/1250.info/wp-content/plugins/wcboost-variation-swatches/includes/compatibility.php
<?php
/**
 * Compatible with other plugins/themes
 */
namespace WCBoost\VariationSwatches;

defined( 'ABSPATH' ) || exit;

class Compatibility {
	/**
	 * The single instance of the class
	 *
	 * @var WCBoost\VariationSwatches\Compatibility
	 */
	protected static $_instance = null;

	/**
	 * Main instance
	 *
	 * @return WCBoost\VariationSwatches\Compatibility
	 */
	public static function instance() {
		if ( null == self::$_instance ) {
			self::$_instance = new self();
		}

		return self::$_instance;
	}

	/**
	 * Class constructor
	 */
	public function __construct() {
		add_action( 'init', [ $this, 'check_compatible_hooks' ] );
	}

	/**
	 * Check compatibility with other plugins/themes and add hooks
	 */
	public function check_compatible_hooks() {
		if ( defined( 'ICL_SITEPRESS_VERSION' ) ) {
			add_filter( 'wcboost_variation_swatches_translate_term_meta', array( $this, 'translate_term_meta' ), 10, 3 );
		}
	}

	/**
	 * Copy swatches metadata from the original term
	 *
	 * @return mixed
	 */
	public function translate_term_meta( $meta_value, $term_id, $meta_key ) {
		$term         = get_term( $term_id );
		$default_lang = apply_filters( 'wpml_default_language', null );

		$original_term_id = apply_filters( 'wpml_object_id', $term->term_id, $term->taxonomy, false, $default_lang );

		if ( $original_term_id ) {
			$meta_value = get_term_meta( $original_term_id, $meta_key, true );
		}

		return $meta_value;
	}
}

Compatibility::instance();