@@ -55,7 +55,7 @@ public function filterTemplateInclude($file)
55
55
public function filterThemeTemplates ($ _templates , $ _theme , $ _post , $ post_type )
56
56
{
57
57
return collect ($ _templates )
58
- ->merge ($ this ->getTemplates ($ post_type ))
58
+ ->merge ($ this ->getTemplates ($ post_type, $ _theme -> load_textdomain () ? $ _theme -> get ( ' TextDomain ' ) : '' ))
59
59
->unique ()
60
60
->toArray ();
61
61
}
@@ -69,9 +69,10 @@ public function filterThemeTemplates($_templates, $_theme, $_post, $post_type)
69
69
* @link https://github.com/WordPress/WordPress/blob/5.8.1/wp-includes/class-wp-theme.php#L1203-L1221
70
70
*
71
71
* @param string $post_type
72
+ * @param string $text_domain
72
73
* @return string[]
73
74
*/
74
- protected function getTemplates ($ post_type = '' )
75
+ protected function getTemplates ($ post_type = '' , $ text_domain = '' )
75
76
{
76
77
if ($ templates = wp_cache_get ('acorn/post_templates ' , 'themes ' )) {
77
78
return $ templates [$ post_type ] ?? [];
@@ -109,6 +110,14 @@ protected function getTemplates($post_type = '')
109
110
}
110
111
}
111
112
113
+ if ($ text_domain ) {
114
+ foreach ($ templates as $ type => $ files ) {
115
+ foreach ($ files as $ file => $ name ) {
116
+ $ templates [$ type ][$ file ] = translate ($ name , $ text_domain );
117
+ }
118
+ }
119
+ }
120
+
112
121
wp_cache_add ('acorn/post_templates ' , $ templates , 'themes ' );
113
122
114
123
return $ templates [$ post_type ] ?? [];
0 commit comments