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/jetk.sa/wp-content/plugins/acfml/classes/StringTaxonomyHooks.php
<?php

namespace ACFML;

use SitePress;
use WPML\FP\Str;

class StringTaxonomyHooks implements \IWPML_Backend_Action {

	const TAXONOMY_SINGULAR_NAME_PREFIX = 'taxonomy singular name: ';
	const TAXONOMY_GENERAL_NAME_PREFIX  = 'taxonomy general name: ';

	/**
	 * @var SitePress
	 */
	private $sitepress;

	public function __construct( SitePress $sitepress ) {
		$this->sitepress = $sitepress;
	}

	public function add_hooks() {
		add_filter(
			'wpml_taxonomy_strings_source_language',
			[ $this, 'acfmlTaxonomyStringsSourceLanguage' ],
			10,
			3
		);
	}

	/**
	 *
	 * @param string|null $sourceLang
	 * @param string      $text
	 * @param string      $name
	 *
	 * @return string|null The filtered source language
	 */
	public function acfmlTaxonomyStringsSourceLanguage( $sourceLang, $text, $name ) {
		$acfTaxonomies       = wp_list_pluck( acf_get_acf_taxonomies(), 'labels' );
		$acfTaxonomiesValues = [];

		if ( Str::startsWith( self::TAXONOMY_SINGULAR_NAME_PREFIX, $name ) ) {
			$acfTaxonomiesValues = wp_list_pluck( $acfTaxonomies, 'singular_name' );
		} elseif ( Str::startsWith( self::TAXONOMY_GENERAL_NAME_PREFIX, $name ) ) {
			$acfTaxonomiesValues = wp_list_pluck( $acfTaxonomies, 'name' );
		}

		if ( in_array( $text, $acfTaxonomiesValues, true ) ) {
			return $this->sitepress->get_default_language();
		}

		return $sourceLang;
	}
}