HEX
Server: nginx
System: Linux pool195-106-36.bur.atomicsites.net 6.12.57+deb12-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.57-1~bpo12+1 (2025-11-17) x86_64
User: (0)
PHP: 8.3.32
Disabled: pcntl_fork
Upload Files
File: //srv/htdocs/wp-content/themes/Divi/includes/builder/tests/codeception/wpunit/Translations.php
<?php

namespace ET\Builder\Codeception\WPUnit;

/**
 * Records how many time gettext is called for the same string.
 *
 * @since 4.4.9
 */
class Translations {
	protected static $stats = array();

	public static function gettext( $translation, $text, $domain ) {
		if ( isset( self::$stats[ $domain ][ $text ] ) ) {
			self::$stats[ $domain ][ $text ] += 1;
		} else {
			self::$stats[ $domain ][ $text ] = 1;
		}
		return $translation;
	}

	public static function gettext_with_context( $translation, $text, $context, $domain ) {
		return self::gettext( $translation, $text, $domain );
	}

	public static function stats() {
		return self::$stats;
	}

	public static function add_filters() {
		// Add gettext filters.
		add_filter( 'gettext', __CLASS__ . '::gettext', 99, 3 );
		add_filter( 'gettext_with_context', __CLASS__ . '::gettext_with_context', 99, 4 );
	}
}

Translations::add_filters();