ID, $this->model->get_languages_list( array( 'fields' => 'page_on_front' ) ) ) ) { $post_states['page_on_front'] = __( 'Front Page' ); } if ( in_array( $post->ID, $this->model->get_languages_list( array( 'fields' => 'page_for_posts' ) ) ) ) { $post_states['page_for_posts'] = __( 'Posts Page' ); } return $post_states; } /** * refresh language cache when a static front page has been translated * * @since 1.8 * * @param int $post_id not used * @param object $post not used * @param array $translations */ public function pll_save_post( $post_id, $post, $translations ) { if ( in_array( $this->page_on_front, $translations ) ) { $this->model->clean_languages_cache(); } } /** * prevents choosing an untranslated static front page * displays an error message * * @since 1.6 * * @param int $page_id new page on front page id * @param int $old_id old page on front page_id * @return int */ public function update_page_on_front( $page_id, $old_id ) { if ( $page_id ) { $translations = count( $this->model->post->get_translations( $page_id ) ); $languages = count( $this->model->get_languages_list() ); if ( $languages > 1 && $translations != $languages ) { $page_id = $old_id; add_settings_error( 'reading', 'pll_page_on_front_error', __( 'The chosen static front page must be translated in all languages.', 'polylang' ) ); } } return $page_id; } /** * Prevents WP resetting the option if the admin language filter is active for a language with no pages * * @since 1.9.3 * * @param string $value * @param string $old_value * @return string */ public function update_show_on_front( $value, $old_value ) { if ( ! empty( $GLOBALS['pagenow'] ) && 'options-reading.php' === $GLOBALS['pagenow'] && 'posts' === $value && ! get_pages() && get_pages( array( 'lang' => '' ) ) ) { $value = $old_value; } return $value; } }