WordPress filter load_textdomain_mofile not working inside a child theme’s functions.php but works form inside a plugin

Đã có trọn bộ đề thi thử THPT Quốc Gia 2022 các môn: vip.dethihsg247.com

Function in a plugin is behaving differently than function in the functions.php inside a child theme.

I have a custom simple plain plugin with nothing but the following code in it and it works perfectly. It translates wpamelia plugin correctly with all strings as expected.

When I put the same code into my child theme’s functions.php file and disable the custom plugin with code above, translation stops showing.

When I output all $mofile variables from the load_textdomain_mofile filter into error_log for debugging purposes, all but ‘wpamelia’ textdomain are present. So I tried translating another plugin this way, to make sure it is plugin related issue, again it worked from the plugin file, but not from functions.php.

The .mo file path is tested and valid, file exists.

I tried using different function name instead of load_custom_plugin_translation_file so there is no conflict with the disabled plugin.

Why is the same function behaving differently when part of a plugin and differently when in functions.php? Is child theme not meant to be used with load_textdomain_mofile?

UPDATE

In the original plugin WPAmelia’s code, translation is loaded this way:

So I put following line into the after_setup_theme function and and moved the .mo file into this directory, it started partialy working.

Everything is translated fine, front end, back end, but the wp admin menu in back-end is not.

Back-end admin menu is quite important for using this plugin correctly. I tried to play with after_setup_theme‘s priority, (0 – 999) but it did not help at all.

Xin chào các bạn và quý Thầy Cô. Hãy nhập từ khóa mình muốn vào ô tìm kiếm trên Website để tìm kiếm mọi thứ hoặc trên google các bạn hãy nhập từ khóa + dethihsg247.com để tìm kiếm các bài viết của chúng tôi nhé.
  • Hiện tại chúng tôi có hơn 25 nghìn bài văn mẫu các thể loại.
  • Kho tài liệu, đề thi học sinh giỏi các lớp vô cùng phong phú.
  • Mỗi ngày cập nhật hơn 100 đề thi chất lượng từ các website bán tài liệu lớn.

Tải đề thi VIP với giá siêu rẻ tại Vip.Dethihsg247.Com