WPSEO_Metabox_Formatter::get_translations()privateYoast 1.0

Returns Jed compatible YoastSEO.js translations.

Метод класса: WPSEO_Metabox_Formatter{}

Хуков нет.

Возвращает

Массив.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->get_translations();

Код WPSEO_Metabox_Formatter::get_translations() Yoast 21.5

private function get_translations() {
	$locale = \get_user_locale();

	$file = WPSEO_PATH . 'languages/wordpress-seo-' . $locale . '.json';
	if ( file_exists( $file ) ) {
		// phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- Retrieving a local file.
		$file = file_get_contents( $file );
		if ( is_string( $file ) && $file !== '' ) {
			return json_decode( $file, true );
		}
	}

	return [];
}