HEX
Server: Apache
System: Linux sxb1plmcpnl510113.prod.sxb1.secureserver.net 4.18.0-553.58.1.lve.el8.x86_64 #1 SMP Fri Jul 4 12:07:06 UTC 2025 x86_64
User: acnbijigo78q (10488831)
PHP: 8.3.30
Disabled: NONE
Upload Files
File: /home/acnbijigo78q/public_html/wp-content/plugins/wpml-elasticpress/src/Traits/TranslationModes.php
<?php

namespace WPML\ElasticPress\Traits;

trait TranslationModes {

	/** @var null|array */
	private $translatablePostTypes = null;

	/**
	 * @return array
	 */
	private function getTranslatablePostTypes() {
		if ( null === $this->translatablePostTypes ) {
			$this->translatablePostTypes = array_keys( apply_filters( 'wpml_translatable_documents', [] ) );
		}
		return $this->translatablePostTypes;
	}

	/**
	 * @param  string $postType
	 *
	 * @return bool
	 */
	private function isNotTranslatable( $postType ) {
		return ( ! in_array( $postType, $this->getTranslatablePostTypes(), true ) );
	}

	/**
	 * @param  string $postType
	 *
	 * @return bool
	 */
	private function isDisplayAsTranslated( $postType ) {
		return apply_filters( 'wpml_is_display_as_translated_post_type', false, $postType );
	}

	/**
	 * @param  int    $postId
	 * @param  string $postType
	 * @param  string $postLanguage
	 *
	 * @return array
	 */
	private function getDisplayAsTranslatedLanguages( $postId, $postType, $postLanguage ) {
		if ( $postLanguage !== $this->defaultLanguage ) {
			return [ $postLanguage ];
		}

		$activeLanguages = $this->activeLanguages;
		$elementType     = apply_filters( 'wpml_element_type', $postType );
		$trid            = apply_filters( 'wpml_element_trid', null, $postId, $elementType );
		$translations    = apply_filters( 'wpml_get_element_translations', [], $trid, $elementType );
		foreach ( $activeLanguages as $key => $language ) {
			if (
				array_key_exists( $language, $translations )
				&& $translations[ $language ]->element_id != $postId
			) {
				unset( $activeLanguages[ $key ] );
			}
		}

		if ( empty( $activeLanguages ) ) {
			return [ $postLanguage ];
		}

		return $activeLanguages;
	}

	/**
	 * @return int|false
	 */
	private function getDisplayAsTranslatedDefaultPostId( $postId, $postType, $postLanguage ) {
		if ( $postLanguage === $this->defaultLanguage ) {
			return $postId;
		}
		$elementType    = apply_filters( 'wpml_element_type', $postType );
		$originalPostId = apply_filters( 'wpml_original_element_id', '', $postId, $elementType );

		return $originalPostId;
	}
}