| @@ -9,18 +9,18 @@ | ||
| 9 | 9 | * @since 1.8 |
| 10 | 10 | */ |
| 11 | 11 | class PLL_Admin_Static_Pages extends PLL_Static_Pages { |
| 12 | 12 | /** |
| 13 | - * @var PLL_Admin_Links | |
| 13 | + * @var PLL_Admin_Links|null | |
| 14 | 14 | */ |
| 15 | 15 | protected $links; |
| 16 | 16 | |
| 17 | 17 | /** |
| 18 | - * Constructor: setups filters and actions | |
| 18 | + * Constructor: setups filters and actions. | |
| 19 | 19 | * |
| 20 | 20 | * @since 1.8 |
| 21 | 21 | * |
| 22 | - * @param object $polylang | |
| 22 | + * @param object $polylang An array of attachment metadata. | |
| 23 | 23 | */ |
| 24 | 24 | public function __construct( &$polylang ) { |
| 25 | 25 | parent::__construct( $polylang ); |
| 26 | 26 | |
| @@ -25,16 +25,12 @@ | ||
| 25 | 25 | parent::__construct( $polylang ); |
| 26 | 26 | |
| 27 | 27 | $this->links = &$polylang->links; |
| 28 | 28 | |
| 29 | - // Removes the editor and the template select dropdown for pages for posts | |
| 30 | - add_filter( 'use_block_editor_for_post', array( $this, 'use_block_editor_for_post' ), 10, 2 ); // Since WP 5.0 | |
| 31 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ), 10, 2 ); | |
| 32 | - | |
| 33 | 29 | // Add post state for translations of the front page and posts page |
| 34 | 30 | add_filter( 'display_post_states', array( $this, 'display_post_states' ), 10, 2 ); |
| 35 | 31 | |
| 36 | - // Refresh language cache when a static front page has been translated | |
| 32 | + // Refreshes the language cache when a static front page or page for for posts has been translated. | |
| 37 | 33 | add_action( 'pll_save_post', array( $this, 'pll_save_post' ), 10, 3 ); |
| 38 | 34 | |
| 39 | 35 | // Prevents WP resetting the option |
| 40 | 36 | add_filter( 'pre_update_option_show_on_front', array( $this, 'update_show_on_front' ), 10, 2 ); |
| @@ -42,50 +38,8 @@ | ||
| 42 | 38 | add_action( 'admin_notices', array( $this, 'notice_must_translate' ) ); |
| 43 | 39 | } |
| 44 | 40 | |
| 45 | 41 | /** |
| 46 | - * Don't use the block editor for the translations of the pages for posts | |
| 47 | - * | |
| 48 | - * @since 2.5 | |
| 49 | - * | |
| 50 | - * @param bool $use_block_editor Whether the post can be edited or not. | |
| 51 | - * @param WP_Post $post The post being checked. | |
| 52 | - * @return bool | |
| 53 | - */ | |
| 54 | - public function use_block_editor_for_post( $use_block_editor, $post ) { | |
| 55 | - if ( 'page' === $post->post_type ) { | |
| 56 | - add_filter( 'option_page_for_posts', array( $this, 'translate_page_for_posts' ) ); | |
| 57 | - | |
| 58 | - if ( ( get_option( 'page_for_posts' ) == $post->ID ) && empty( $post->post_content ) ) { | |
| 59 | - return false; | |
| 60 | - } | |
| 61 | - } | |
| 62 | - | |
| 63 | - return $use_block_editor; | |
| 64 | - } | |
| 65 | - | |
| 66 | - /** | |
| 67 | - * Removes the editor for the translations of the pages for posts. | |
| 68 | - * Removes the page template select dropdown in page attributes metabox too. | |
| 69 | - * | |
| 70 | - * @since 2.2.2 | |
| 71 | - * | |
| 72 | - * @param string $post_type Current post type. | |
| 73 | - * @param WP_Post $post Current post. | |
| 74 | - * @return void | |
| 75 | - */ | |
| 76 | - public function add_meta_boxes( $post_type, $post ) { | |
| 77 | - if ( 'page' === $post_type ) { | |
| 78 | - add_filter( 'option_page_for_posts', array( $this, 'translate_page_for_posts' ) ); | |
| 79 | - | |
| 80 | - if ( ( get_option( 'page_for_posts' ) == $post->ID ) && empty( $post->post_content ) ) { | |
| 81 | - add_action( 'edit_form_after_title', '_wp_posts_page_notice' ); | |
| 82 | - remove_post_type_support( $post_type, 'editor' ); | |
| 83 | - } | |
| 84 | - } | |
| 85 | - } | |
| 86 | - | |
| 87 | - /** | |
| 88 | 42 | * Adds post state for translations of the front page and posts page. |
| 89 | 43 | * |
| 90 | 44 | * @since 1.8 |
| 91 | 45 | * |
| @@ -105,9 +59,9 @@ | ||
| 105 | 59 | return $post_states; |
| 106 | 60 | } |
| 107 | 61 | |
| 108 | 62 | /** |
| 109 | - * Refreshes the language cache when a static front page has been translated. | |
| 63 | + * Refreshes the language cache when a static front page or page for for posts has been translated. | |
| 110 | 64 | * |
| 111 | 65 | * @since 1.8 |
| 112 | 66 | * |
| 113 | 67 | * @param int $post_id Not used. |
| @@ -115,20 +69,20 @@ | ||
| 115 | 69 | * @param int[] $translations Translations of the post being saved. |
| 116 | 70 | * @return void |
| 117 | 71 | */ |
| 118 | 72 | public function pll_save_post( $post_id, $post, $translations ) { |
| 119 | - if ( in_array( $this->page_on_front, $translations ) ) { | |
| 73 | + if ( in_array( $this->page_on_front, $translations ) || in_array( $this->page_for_posts, $translations ) ) { | |
| 120 | 74 | $this->model->clean_languages_cache(); |
| 121 | 75 | } |
| 122 | 76 | } |
| 123 | 77 | |
| 124 | 78 | /** |
| 125 | - * Prevents WP resetting the option if the admin language filter is active for a language with no pages | |
| 79 | + * Prevents WP resetting the option if the admin language filter is active for a language with no pages. | |
| 126 | 80 | * |
| 127 | 81 | * @since 1.9.3 |
| 128 | 82 | * |
| 129 | - * @param string $value | |
| 130 | - * @param string $old_value | |
| 83 | + * @param string $value The new, unserialized option value. | |
| 84 | + * @param string $old_value The old option value. | |
| 131 | 85 | * @return string |
| 132 | 86 | */ |
| 133 | 87 | public function update_show_on_front( $value, $old_value ) { |
| 134 | 88 | if ( ! empty( $GLOBALS['pagenow'] ) && 'options-reading.php' === $GLOBALS['pagenow'] && 'posts' === $value && ! get_pages() && get_pages( array( 'lang' => '' ) ) ) { |