PluginProbe
Polylang / 3.7.1
Polylang v3.7.1
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
polylang / admin / view-translations-post.php

view-translations-post.php in Polylang 3.7.1, at admin/view-translations-post.php

74 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Displays the translations fields for posts
4 *
5 * @package Polylang
6 *
7 * @var PLL_Admin_Classic_Editor $this PLL_Admin_Classic_Editor object.
8 * @var PLL_Language $lang The post language. Default language if no language assigned yet.
9 * @var int $post_ID The post id.
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 if ( ! $translation_id || $translation_id === $post_ID ) { // $translation_id == $post_ID happens if the post has been (auto)saved before changing the language.
24 $translation_id = 0;
25 }
26
27 if ( ! empty( $from_post_id ) ) {
28 $translation_id = $this->model->post->get( $from_post_id, $language );
29 }
30
31 $add_link = $this->links->new_post_translation_link( $post_ID, $language );
32 $link = $add_link;
33 $translation = null;
34 if ( $translation_id ) {
35 $translation = get_post( $translation_id );
36 $link = $this->links->edit_post_translation_link( $translation_id );
37 }
38 ?>
39 <tr>
40 <th class = "pll-language-column"><?php echo $language->flag ?: esc_html( $language->slug ); // phpcs:ignore WordPress.Security.EscapeOutput ?></th>
41 <td class = "hidden"><?php echo $add_link; // phpcs:ignore WordPress.Security.EscapeOutput ?></td>
42 <td class = "pll-edit-column pll-column-icon"><?php echo $link; // phpcs:ignore WordPress.Security.EscapeOutput ?></td>
43 <?php
44
45 /**
46 * Fires before the translation column is outputted in the language metabox.
47 * The dynamic portion of the hook name, `$lang`, refers to the language code.
48 *
49 * @since 2.1
50 */
51 do_action( 'pll_before_post_translation_' . $language->slug );
52 ?>
53 <td class = "pll-translation-column">
54 <?php
55 printf(
56 '<label class="screen-reader-text" for="tr_lang_%1$s">%2$s</label>
57 <input type="hidden" name="post_tr_lang[%1$s]" id="htr_lang_%1$s" value="%3$s" />
58 <span lang="%5$s" dir="%6$s"><input type="text" class="tr_lang" id="tr_lang_%1$s" value="%4$s" /></span>',
59 esc_attr( $language->slug ),
60 /* translators: accessibility text */
61 esc_html__( 'Translation', 'polylang' ),
62 ( empty( $translation ) ? '0' : esc_attr( (string) $translation->ID ) ),
63 ( empty( $translation ) ? '' : esc_attr( $translation->post_title ) ),
64 esc_attr( $language->get_locale( 'display' ) ),
65 ( $language->is_rtl ? 'rtl' : 'ltr' )
66 );
67 ?>
68 </td>
69 </tr>
70 <?php
71 }
72 ?>
73 </table>
74