| 1 |
<?php |
| 2 |
/** |
| 3 |
* Displays the translations fields for media |
| 4 |
* |
| 5 |
* @package Polylang |
| 6 |
* |
| 7 |
* @var PLL_Admin_Classic_Editor $this PLL_Admin_Classic_Editor object. |
| 8 |
* @var PLL_Language $lang The media language. Default language if no language assigned yet. |
| 9 |
* @var WP_Post $post The media object. |
| 10 |
*/ |
| 11 |
|
| 12 |
defined( 'ABSPATH' ) || exit; |
| 13 |
?> |
| 14 |
<p><strong><?php esc_html_e( 'Translations', 'polylang' ); ?></strong></p> |
| 15 |
<table> |
| 16 |
<?php |
| 17 |
foreach ( $this->model->get_languages_list() as $language ) { |
| 18 |
if ( $language->term_id === $lang->term_id ) { |
| 19 |
continue; |
| 20 |
} |
| 21 |
|
| 22 |
$translation_id = $this->model->post->get_translation( $post->ID, $language ); |
| 23 |
$translation = null; |
| 24 |
|
| 25 |
if ( ! empty( $translation_id ) && $translation_id !== $post->ID ) { |
| 26 |
$translation = get_post( $translation_id ); |
| 27 |
} |
| 28 |
?> |
| 29 |
<tr> |
| 30 |
<td class = "pll-media-language-column"><span class = "pll-translation-flag"><?php echo $language->get_admin_flag( 'aria-hidden' ); // phpcs:ignore WordPress.Security.EscapeOutput ?></span><?php echo esc_html( $language->name ); ?></td> |
| 31 |
<td class = "pll-media-edit-column"> |
| 32 |
<?php |
| 33 |
if ( $translation instanceof WP_Post ) { |
| 34 |
// The translation exists. |
| 35 |
printf( |
| 36 |
'<input type="hidden" name="media_tr_lang[%s]" value="%d" />', |
| 37 |
esc_attr( $language->slug ), |
| 38 |
(int) $translation->ID |
| 39 |
); |
| 40 |
echo $this->links->get_edit_post_link_html( $translation ); // phpcs:ignore WordPress.Security.EscapeOutput |
| 41 |
} else { |
| 42 |
// The translation doesn't exist. |
| 43 |
echo $this->links->get_new_post_link_html( $post, $language ); // phpcs:ignore WordPress.Security.EscapeOutput |
| 44 |
} |
| 45 |
?> |
| 46 |
</td> |
| 47 |
</tr> |
| 48 |
<?php |
| 49 |
} // End foreach |
| 50 |
?> |
| 51 |
</table> |
| 52 |
|