| @@ -1,8 +1,5 @@ | ||
| 1 | 1 | <?php |
| 2 | -/** | |
| 3 | - * @package Polylang | |
| 4 | - */ | |
| 5 | 2 | |
| 6 | 3 | /** |
| 7 | 4 | * Manages the static front page and the page for posts on admin side |
| 8 | 5 | * |
| @@ -88,10 +85,10 @@ | ||
| 88 | 85 | * Add post state for translations of the front page and posts page |
| 89 | 86 | * |
| 90 | 87 | * @since 1.8 |
| 91 | 88 | * |
| 92 | - * @param array $post_states An array of post display states. | |
| 93 | - * @param object $post The current post object. | |
| 89 | + * @param array $post_states | |
| 90 | + * @param object $post | |
| 94 | 91 | * @return array |
| 95 | 92 | */ |
| 96 | 93 | public function display_post_states( $post_states, $post ) { |
| 97 | 94 | if ( in_array( $post->ID, $this->model->get_languages_list( array( 'fields' => 'page_on_front' ) ) ) ) { |
| @@ -202,31 +199,9 @@ | ||
| 202 | 199 | */ |
| 203 | 200 | public function notice_must_translate() { |
| 204 | 201 | $screen = get_current_screen(); |
| 205 | 202 | |
| 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 ) { | |
| 203 | + if ( $this->page_on_front && ( 'toplevel_page_mlang' === $screen->id || 'edit-page' === $screen->id ) ) { | |
| 229 | 204 | $untranslated = array(); |
| 230 | 205 | |
| 231 | 206 | foreach ( $this->model->get_languages_list() as $language ) { |
| 232 | 207 | if ( ! $this->model->post->get( $this->page_on_front, $language ) ) { |
| @@ -238,15 +213,16 @@ | ||
| 238 | 213 | } |
| 239 | 214 | } |
| 240 | 215 | |
| 241 | 216 | if ( ! empty( $untranslated ) ) { |
| 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 | |
| 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 | + ) | |
| 246 | 224 | ); |
| 247 | 225 | } |
| 248 | 226 | } |
| 249 | - | |
| 250 | - return $message; | |
| 251 | 227 | } |
| 252 | 228 | } |