| @@ -190,8 +190,28 @@ | ||
| 190 | 190 | { |
| 191 | 191 | // if the post ID is set, get the permalink directly |
| 192 | 192 | if ($post_id) |
| 193 | 193 | { |
| 194 | + /** | |
| 195 | + * Added support to WPML, since it is unable to properly obtain the | |
| 196 | + * correct permalink depending the requested language tag. | |
| 197 | + * | |
| 198 | + * @since 10.1.55 | |
| 199 | + */ | |
| 200 | + $wpml_post_lang = apply_filters('wpml_post_language_details', null, $post_id); | |
| 201 | + | |
| 202 | + /** | |
| 203 | + * Make sure we haven't received an error object from WPML. | |
| 204 | + * | |
| 205 | + * @since 10.1.60 | |
| 206 | + */ | |
| 207 | + if ($wpml_post_lang && !is_wp_error($wpml_post_lang)) | |
| 208 | + { | |
| 209 | + // WPML supported, go ahead | |
| 210 | + return apply_filters('wpml_permalink', get_permalink($post_id), $wpml_post_lang['language_code']); | |
| 211 | + } | |
| 212 | + | |
| 213 | + // WPML not supported, fallback to the default behavior | |
| 194 | 214 | return get_permalink($post_id); |
| 195 | 215 | } |
| 196 | 216 | |
| 197 | 217 | // otherwise get the current permalink |