PluginProbe
Polylang / 2.5.2
Polylang v2.5.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
← All changes | admin/admin-links.php +30 -69 2.72.5.2 View file →
@@ -7,64 +7,17 @@
7 7 */
8 8 class PLL_Admin_Links extends PLL_Links {
9 9
10 10 /**
11 - * Returns html markup for a new translation link
12 - *
13 - * @since 2.6
14 - *
15 - * @param string $link The new translation link.
16 - * @param object $language The language of the new translation.
17 - * @return string
18 - */
19 - protected function new_translation_link( $link, $language ) {
20 - $str = '';
21 -
22 - if ( $link ) {
23 - /* translators: accessibility text, %s is a native language name */
24 - $hint = sprintf( __( 'Add a translation in %s', 'polylang' ), $language->name );
25 -
26 - $str = sprintf(
27 - '<a href="%1$s" title="%2$s" class="pll_icon_add"><span class="screen-reader-text">%3$s</span></a>',
28 - esc_url( $link ),
29 - esc_attr( $hint ),
30 - esc_html( $hint )
31 - );
32 - }
33 -
34 - return $str;
35 - }
36 -
37 - /**
38 - * Returns html markup for a translation link
39 - *
40 - * @since 2.6
41 - *
42 - * @param string $link The translation link.
43 - * @param object $language The language of the translation.
44 - * @return string
45 - */
46 - public function edit_translation_link( $link, $language ) {
47 - return $link ? sprintf(
48 - '<a href="%1$s" class="pll_icon_edit"><span class="screen-reader-text">%2$s</span></a>',
49 - esc_url( $link ),
50 - /* translators: accessibility text, %s is a native language name */
51 - esc_html( sprintf( __( 'Edit the translation in %s', 'polylang' ), $language->name ) )
52 - ) : '';
53 - }
54 -
55 - /**
56 11 * Get the link to create a new post translation
57 12 *
58 13 * @since 1.5
59 14 *
60 - * @param int $post_id The source post id.
61 - * @param object $language The language of the new translation.
62 - * @param string $context Optional. Defaults to 'display' which encodes '&' to '&amp;'.
63 - * Otherwise, preserves '&'.
15 + * @param int $post_id the source post id
16 + * @param object $language the language of the new translation
64 17 * @return string
65 18 */
66 - public function get_new_post_translation_link( $post_id, $language, $context = 'display' ) {
19 + public function get_new_post_translation_link( $post_id, $language ) {
67 20 $post_type = get_post_type( $post_id );
68 21 $post_type_object = get_post_type_object( get_post_type( $post_id ) );
69 22 if ( ! current_user_can( $post_type_object->cap->create_posts ) ) {
70 23 return '';
@@ -77,9 +30,9 @@
77 30 return '';
78 31 }
79 32 }
80 33
81 - if ( 'attachment' === $post_type ) {
34 + if ( 'attachment' == $post_type ) {
82 35 $args = array(
83 36 'action' => 'translate_media',
84 37 'from_media' => $post_id,
85 38 'new_lang' => $language->slug,
@@ -84,16 +37,10 @@
84 37 'from_media' => $post_id,
85 38 'new_lang' => $language->slug,
86 39 );
87 40
88 - $link = add_query_arg( $args, admin_url( 'admin.php' ) );
89 -
90 41 // Add nonce for media as we will directly publish a new attachment from a click on this link
91 - if ( 'display' === $context ) {
92 - $link = wp_nonce_url( $link, 'translate_media' );
93 - } else {
94 - $link = add_query_arg( '_wpnonce', wp_create_nonce( 'translate_media' ), $link );
95 - }
42 + $link = wp_nonce_url( add_query_arg( $args, admin_url( 'admin.php' ) ), 'translate_media' );
96 43 } else {
97 44 $args = array(
98 45 'post_type' => $post_type,
99 46 'from_post' => $post_id,
@@ -99,15 +46,9 @@
99 46 'from_post' => $post_id,
100 47 'new_lang' => $language->slug,
101 48 );
102 49
103 - $link = add_query_arg( $args, admin_url( 'post-new.php' ) );
104 -
105 - if ( 'display' === $context ) {
106 - $link = wp_nonce_url( $link, 'new-post-translation' );
107 - } else {
108 - $link = add_query_arg( '_wpnonce', wp_create_nonce( 'new-post-translation' ), $link );
109 - }
50 + $link = wp_nonce_url( add_query_arg( $args, admin_url( 'post-new.php' ) ), 'new-post-translation' );
110 51 }
111 52
112 53 /**
113 54 * Filter the new post translation link
@@ -131,9 +72,14 @@
131 72 * @return string
132 73 */
133 74 public function new_post_translation_link( $post_id, $language ) {
134 75 $link = $this->get_new_post_translation_link( $post_id, $language );
135 - return $this->new_translation_link( $link, $language );
76 + return $link ? sprintf(
77 + '<a href="%1$s" class="pll_icon_add"><span class="screen-reader-text">%2$s</span></a>',
78 + esc_url( $link ),
79 + /* translators: accessibility text, %s is a native language name */
80 + esc_html( sprintf( __( 'Add a translation in %s', 'polylang' ), $language->name ) )
81 + ) : '';
136 82 }
137 83
138 84 /**
139 85 * Returns html markup for a translation link
@@ -145,9 +91,14 @@
145 91 */
146 92 public function edit_post_translation_link( $post_id ) {
147 93 $link = get_edit_post_link( $post_id );
148 94 $language = $this->model->post->get_language( $post_id );
149 - return $this->edit_translation_link( $link, $language );
95 + return $link ? sprintf(
96 + '<a href="%1$s" class="pll_icon_edit"><span class="screen-reader-text">%2$s</span></a>',
97 + esc_url( $link ),
98 + /* translators: accessibility text, %s is a native language name */
99 + esc_html( sprintf( __( 'Edit the translation in %s', 'polylang' ), $language->name ) )
100 + ) : '';
150 101 }
151 102
152 103 /**
153 104 * Get the link to create a new term translation
@@ -201,9 +152,14 @@
201 152 * @return string
202 153 */
203 154 public function new_term_translation_link( $term_id, $taxonomy, $post_type, $language ) {
204 155 $link = $this->get_new_term_translation_link( $term_id, $taxonomy, $post_type, $language );
205 - return $this->new_translation_link( $link, $language );
156 + return $link ? sprintf(
157 + '<a href="%1$s" class="pll_icon_add"><span class="screen-reader-text">%2$s</span></a>',
158 + esc_url( $link ),
159 + /* translators: accessibility text, %s is a native language name */
160 + esc_html( sprintf( __( 'Add a translation in %s', 'polylang' ), $language->name ) )
161 + ) : '';
206 162 }
207 163
208 164 /**
209 165 * Returns html markup for a term translation link
@@ -217,7 +173,12 @@
217 173 */
218 174 public function edit_term_translation_link( $term_id, $taxonomy, $post_type ) {
219 175 $link = get_edit_term_link( $term_id, $taxonomy, $post_type );
220 176 $language = $this->model->term->get_language( $term_id );
221 - return $this->edit_translation_link( $link, $language );
177 + return $link ? sprintf(
178 + '<a href="%1$s" class="pll_icon_edit"><span class="screen-reader-text">%2$s</span></a>',
179 + esc_url( $link ),
180 + /* translators: accessibility text, %s is a native language name */
181 + esc_html( sprintf( __( 'Edit the translation in %s', 'polylang' ), $language->name ) )
182 + ) : '';
222 183 }
223 184 }