PluginProbe
Polylang / 3.8.6
Polylang v3.8.6
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 / src / admin / view-translations-post.php

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

80 lines 2.8 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 WP_Post $post The post 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 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->get_new_post_link_html( $post, $language );
32 $link = $add_link;
33 $translation = null;
34 if ( $translation_id ) {
35 $translation = get_post( $translation_id );
36
37 if ( $translation instanceof WP_Post ) {
38 $link = $this->links->get_edit_post_link_html( $translation );
39 }
40 }
41 ?>
42 <tr>
43 <th class = "pll-language-column"><?php echo $language->flag ?: esc_html( $language->slug ); // phpcs:ignore WordPress.Security.EscapeOutput ?></th>
44 <td class = "hidden"><?php echo $add_link; // phpcs:ignore WordPress.Security.EscapeOutput ?></td>
45 <td class = "pll-edit-column pll-column-icon"><?php echo $link; // phpcs:ignore WordPress.Security.EscapeOutput ?></td>
46 <?php
47
48 /**
49 * Fires before the translation column is outputted in the language metabox.
50 * The dynamic portion of the hook name, `$lang`, refers to the language code.
51 *
52 * @since 2.1
53 * @since 3.8 New `$post_type` parameter.
54 *
55 * @param string $post_type The post type.
56 */
57 do_action( 'pll_before_post_translation_' . $language->slug, $post->post_type );
58 ?>
59 <td class = "pll-translation-column">
60 <?php
61 printf(
62 '<label class="screen-reader-text" for="tr_lang_%1$s">%2$s</label>
63 <input type="hidden" name="post_tr_lang[%1$s]" id="htr_lang_%1$s" value="%3$s" />
64 <span lang="%5$s" dir="%6$s"><input type="text" class="tr_lang" id="tr_lang_%1$s" value="%4$s" /></span>',
65 esc_attr( $language->slug ),
66 /* translators: accessibility text */
67 esc_html__( 'Translation', 'polylang' ),
68 ( empty( $translation ) ? '0' : esc_attr( (string) $translation->ID ) ),
69 ( empty( $translation ) ? '' : esc_attr( $translation->post_title ) ),
70 esc_attr( $language->get_locale( 'display' ) ),
71 ( $language->is_rtl ? 'rtl' : 'ltr' )
72 );
73 ?>
74 </td>
75 </tr>
76 <?php
77 }
78 ?>
79 </table>
80