@@ -114,26 +114,38 @@ function ggl_get_localized_title( int|WP_Post $post = 0 ): string {
114114
115115 // Check if the function shall return the real titles for the movie/event
116116 $ show_details = apply_filters ( "ggl__show_full_details " , false , $ post );
117+ if ( $ show_details ) {
118+ // as we only want to get the language for the localization we take a
119+ // substring of the first two characters here as those are the
120+ // language part of the BCP 47 tag that are returned by get_user_locale
121+ $ desired_language = substr ( get_user_locale (), 0 , 2 );
122+ $ meta_prefix = match ( $ desired_language ) {
123+ "de " => "german " ,
124+ default => "english "
125+ };
126+
127+ // now return the appropriate post metadata
128+ return get_post_meta ( $ post ->ID , $ meta_prefix . "_title " , true );
129+ }
130+
131+ if ( $ post ->post_type === "event " ) {
132+ return __ ( "An unnamed event " , "ggl-post-types " );
133+ }
117134
118- if ( ! $ show_details ) {
119- if ( $ post ->post_type === "event " ) {
120- return __ ( "An unnamed event " , "ggl-post-types " );
121- } else {
122- return __ ( "An unnamed movie " , "ggl-post-types " );
123- }
135+
136+ $ is_in_special_program = get_post_meta ( $ post ->ID , "program_type " , true ) === "special_program " ;
137+ if ( ! $ is_in_special_program ) {
138+ return get_post_meta ( $ post ->ID , "original_title " , true );
124139 }
125140
126- // as we only want to get the language for the localization we take a
127- // substring of the first two characters here as those are the
128- // language part of the BCP 47 tag that are returned by get_user_locale
129- $ desired_language = substr ( get_user_locale (), 0 , 2 );
130- $ meta_prefix = match ( $ desired_language ) {
131- "de " => "german " ,
132- default => "english "
133- };
134-
135- // now return the appropriate post metadata
136- return get_post_meta ( $ post ->ID , $ meta_prefix . "_title " , true );
141+ $ assigned_special_program = array_first ( wp_get_post_terms ( $ post ->ID , "special-program " ) );
142+ if ( $ assigned_special_program === null ) {
143+ return __ ( "An unnamed special " , "ggl-post-types " );
144+ } else {
145+ return $ assigned_special_program ->name ;
146+ }
147+
148+
137149}
138150
139151/**
0 commit comments