HEX
Server: Apache
System: Linux sys.digiflyeg.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User: opal (1023)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/opal/public_html/wp-content/plugins/sitepress-multilingual-cms/classes/utilities/Labels.php
<?php

namespace WPML\Utilities;

use WPML\LIB\WP\Hooks;

use function WPML\FP\spreadArgs;

class Labels implements \IWPML_Frontend_Action, \IWPML_Backend_Action {

	public function add_hooks() {
		Hooks::onFilter( 'wpml_labelize_string' )
			->then( spreadArgs( [ $this, 'labelize' ] ) );
	}

	/**
	 * @param string|mixed $string
	 *
	 * @return string|mixed
	 */
	public static function labelize( $string ) {
		if ( ! is_string( $string ) ) {
			return $string;
		}

		$string = strtr(
			$string,
			[
				'-' => ' ',
				'_' => ' ',
			]
		);

		return preg_replace_callback(
			'/\b\p{L}/u',
			function ( $matches ) {
				return mb_convert_case( $matches[0], MB_CASE_UPPER, 'UTF-8' );
			},
			$string
		);
	}
}