| Server IP : 89.39.208.18 / Your IP : 216.73.217.74 Web Server : LiteSpeed System : User : ( ) PHP Version : 7.4.33 Disable Function : eval,./,ln,passthru,dl,system,exec,popen,shell_exec,posix_getpwuid,posix_uname,ftp_exec,posix_uname,posix_getpwuid,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,get_current_user,getmyuid,getmygid,listen,chgrp,apache_note,apache_setenv,apache_child_terminate,closelog,debugger_off,debugge_on,ini_restore,netscript,escapeshellarg,cmd,backtick,virtual,show_sourc,show_source,pclose,pcntl_exec,datasec,old_offset,ctrl_dir,ini_alter,leak,listen,chgrp,apache_setenv,define_syslog_variables,root,diskfreespace,disk_free_space,disk_total_space,posix_kill,getmyuid,getmygid,apache_child_terminate,php_ini_scanned_files,ls,ps_aux,chown,getrusage,posixc,posame,chgrp,posix_setuid,posix_setsid,posix_setgid,apache_note,apache_setenv,x_getuid,e_ini_file,nfo,SQL,mysql_li,t_dbs,filegroup,highlight_file,ilegetcontents,get_dir,popen,popens,pfsockopen,dos_conv,apache_get_modules,crack_check,crack_closedict,rar_open,bzopen,bzread,bzwrite,shellcode,posix_isatty,posix_getservbyname,escapeshellarg,hypot,pg_host,pos,posix_access,inurl,posix_times,posix_mknod,pclose,ps_fill,symlink,id,escapeshellcmd,php_uname,phpinfo MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /home3/mahyarcake/public_html/wp-content/plugins/elementor/core/utils/ |
Upload File : |
<?php
namespace Elementor\Core\Utils;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Assets_Translation_Loader {
public static function for_handles( array $handles, $domain = null, $replace_callback = null ) {
self::set_domain( $handles, $domain );
self::replace_translation_path( $handles, $replace_callback );
}
private static function set_domain( array $handles, $domain = null ) {
if ( empty( $domain ) || ! is_string( $domain ) ) {
return;
}
foreach ( $handles as $handle ) {
wp_set_script_translations( $handle, $domain );
}
}
/**
* The purpose of this function is to replace the requested translation file
* with a file that contains all the translations for specific scripts.
*
* When developing a module and using Webpack's dynamic load feature, the script will be split into multiple chunks.
* As a result, the WordPress translations expressions will also be split into multiple files.
* Therefore, we replace the requested translation file with another file (generated in the build process)
* that contains all the translations for the specific script (including dynamically loaded chunks).
*
* Want to go deeper? Read the following article:
* @see https://developer.wordpress.com/2022/01/06/wordpress-plugin-i18n-webpack-and-composer/
*
* @param array $handles
* @param callable|null $replace_callback
*/
private static function replace_translation_path( array $handles, $replace_callback = null ) {
$sources = self::map_handles_to_src( $handles );
add_filter( 'load_script_textdomain_relative_path', function ( $relative_path, $src ) use ( $sources, $replace_callback ) {
if ( ! in_array( $src, $sources, true ) ) {
return $relative_path;
}
if ( is_callable( $replace_callback ) ) {
return $replace_callback( $relative_path, $src );
}
return self::default_replace_translation( $relative_path );
}, 10, 2 );
}
private static function map_handles_to_src( array $handles ) {
return array_map( function ( $handle ) {
return wp_scripts()->registered[ $handle ]->src;
}, $handles );
}
private static function default_replace_translation( $relative_path ) {
// Translations are always based on the non-minified filename.
$relative_path_without_ext = preg_replace( '/(\.min)?\.js$/i', '', $relative_path );
// By default, we suffix the file with `.strings` (e.g 'assets/js/editor.js' => 'assets/js/editor.strings.js').
return implode( '.', [
$relative_path_without_ext,
'strings',
'js',
] );
}
}