PluginProbe
Polylang / 2.8
Polylang v2.8
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-static-pages.php +32 -8 2.7.22.8 View file →
@@ -1,5 +1,8 @@
1 1 <?php
2 +/**
3 + * @package Polylang
4 + */
2 5
3 6 /**
4 7 * Manages the static front page and the page for posts on admin side
5 8 *
@@ -199,9 +202,31 @@
199 202 */
200 203 public function notice_must_translate() {
201 204 $screen = get_current_screen();
202 205
203 - if ( $this->page_on_front && ( 'toplevel_page_mlang' === $screen->id || 'edit-page' === $screen->id ) ) {
206 + if ( 'toplevel_page_mlang' === $screen->id || 'edit-page' === $screen->id ) {
207 + $message = $this->get_must_translate_message();
208 +
209 + if ( ! empty( $message ) ) {
210 + printf(
211 + '<div class="error"><p>%s</p></div>',
212 + $message // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
213 + );
214 + }
215 + }
216 + }
217 +
218 + /**
219 + * Returns the message asking to translate the static front page in all languages.
220 + *
221 + * @since 2.8
222 + *
223 + * @return string
224 + */
225 + public function get_must_translate_message() {
226 + $message = '';
227 +
228 + if ( $this->page_on_front ) {
204 229 $untranslated = array();
205 230
206 231 foreach ( $this->model->get_languages_list() as $language ) {
207 232 if ( ! $this->model->post->get( $this->page_on_front, $language ) ) {
@@ -213,16 +238,15 @@
213 238 }
214 239 }
215 240
216 241 if ( ! empty( $untranslated ) ) {
217 - printf(
218 - '<div class="error"><p>%s</p></div>',
219 - sprintf(
220 - /* translators: %s is a comma separated list of native language names */
221 - esc_html__( 'You must translate your static front page in %s.', 'polylang' ),
222 - implode( ', ', $untranslated ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
223 - )
242 + $message = sprintf(
243 + /* translators: %s is a comma separated list of native language names */
244 + esc_html__( 'You must translate your static front page in %s.', 'polylang' ),
245 + implode( ', ', $untranslated ) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
224 246 );
225 247 }
226 248 }
249 +
250 + return $message;
227 251 }
228 252 }