PluginProbe
Polylang / 2.6.2
Polylang v2.6.2
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-term.php

view-translations-term.php in Polylang 2.6.2, at admin/view-translations-term.php

98 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Displays the translations fields for terms
5 */
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit; // Don't access directly
9 };
10
11 if ( isset( $term_id ) ) {
12 // Edit term form ?>
13 <th scope="row"><?php esc_html_e( 'Translations', 'polylang' ); ?></th>
14 <td>
15 <?php
16 }
17 else {
18 // Add term form
19 ?>
20 <p><?php esc_html_e( 'Translations', 'polylang' ); ?></p>
21 <?php
22 }
23 ?>
24 <table class="widefat term-translations" id="<?php echo isset( $term_id ) ? 'edit' : 'add'; ?>-term-translations">
25 <?php
26 foreach ( $this->model->get_languages_list() as $language ) {
27 if ( $language->term_id == $lang->term_id ) {
28 continue;
29 }
30
31 // Look for any existing translation in this language
32 // Take care not to propose a self link
33 $translation = 0;
34 if ( isset( $term_id ) && ( $translation_id = $this->model->term->get_translation( $term_id, $language ) ) && $translation_id != $term_id ) {
35 $translation = get_term( $translation_id, $taxonomy );
36 }
37 if ( ! empty( $from_term_id ) && ( $translation_id = $this->model->term->get( $from_term_id, $language ) ) && ! $this->model->term->get_translation( $translation_id, $lang ) ) {
38 $translation = get_term( $translation_id, $taxonomy );
39 }
40
41 if ( isset( $term_id ) ) { // Do not display the add new link in add term form ( $term_id not set !!! )
42 $link = $add_link = $this->links->new_term_translation_link( $term_id, $taxonomy, $post_type, $language );
43 }
44
45 if ( $translation ) {
46 $link = $this->links->edit_term_translation_link( $translation->term_id, $taxonomy, $post_type );
47 }
48 ?>
49 <tr>
50 <th class = "pll-language-column">
51 <span class = "pll-translation-flag"><?php echo $language->flag ? $language->flag : esc_html( $language->slug ); // phpcs:ignore WordPress.Security.EscapeOutput ?></span>
52 <?php
53 printf(
54 '<span class="pll-language-name%1$s">%2$s</span>',
55 isset( $term_id ) ? '' : ' screen-reader-text',
56 esc_html( $language->name )
57 );
58 ?>
59 </th>
60 <?php
61 if ( isset( $term_id ) ) {
62 ?>
63 <td class = "hidden"><?php echo $add_link; // phpcs:ignore WordPress.Security.EscapeOutput ?></td>
64 <td class = "pll-edit-column"><?php echo $link; // phpcs:ignore WordPress.Security.EscapeOutput ?></td>
65 <?php
66 }
67 ?>
68 <td class = "pll-translation-column">
69 <?php
70 printf(
71 '<label class="screen-reader-text" for="tr_lang_%1$s">%2$s</label>
72 <input type="hidden" class="htr_lang" name="term_tr_lang[%1$s]" id="htr_lang_%1$s" value="%3$s" />
73 <span lang="%6$s" dir="%7$s"><input type="text" class="tr_lang" id="tr_lang_%1$s" value="%4$s"%5$s /></span>',
74 esc_attr( $language->slug ),
75 /* translators: accessibility text */
76 esc_html__( 'Translation', 'polylang' ),
77 ( empty( $translation ) ? 0 : esc_attr( $translation->term_id ) ),
78 ( empty( $translation ) ? '' : esc_attr( $translation->name ) ),
79 disabled( empty( $disabled ), false, false ),
80 esc_attr( $language->get_locale( 'display' ) ),
81 ( $language->is_rtl ? 'rtl' : 'ltr' )
82 );
83 ?>
84 </td>
85 </tr>
86 <?php
87 } // End foreach
88 ?>
89 </table>
90 <?php
91
92 if ( isset( $term_id ) ) {
93 // Edit term form
94 ?>
95 </td>
96 <?php
97 }
98