comment_post_ID ); } if ( ! $post instanceof \WP_Post ) { return $lang; } $language_details = \apply_filters( 'wpml_post_language_details', null, $post->ID ); if ( \is_array( $language_details ) && isset( $language_details['language_code'] ) ) { $lang = $language_details['language_code']; } return $lang; } /** * Store the language a Mastodon app set for a post with WPML. * * A language WPML does not know is left to Enable Mastodon Apps, which stores it as post meta. * * @param bool $stored Whether the language has been stored elsewhere. * @param int $post_id The post ID. * @param string $language The language code the app submitted. * * @return bool True when WPML stored the language. */ public static function save_status_language( $stored, $post_id, $language ) { $languages = \apply_filters( 'wpml_active_languages', null ); if ( ! isset( $languages[ $language ] ) ) { return $stored; } \do_action( 'wpml_set_element_language_details', array( 'element_id' => $post_id, 'element_type' => 'post_' . \get_post_type( $post_id ), 'language_code' => $language, ) ); return true; } }