| @@ -31,9 +31,9 @@ | ||
| 31 | 31 | public function __construct( &$polylang ) { |
| 32 | 32 | $this->model = &$polylang->model; |
| 33 | 33 | $this->pref_lang = &$polylang->pref_lang; |
| 34 | 34 | |
| 35 | - add_filter( 'block_editor_preload_paths', array( $this, 'preload_paths' ), 10, 2 ); | |
| 35 | + new PLL_Block_Editor_Filter_Preload_Paths( array( $this, 'preload_paths' ), 10, 2 ); | |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * Filters the preload REST requests by the current language of the post. |
| @@ -46,9 +46,9 @@ | ||
| 46 | 46 | * @param WP_Post $post The post resource data. |
| 47 | 47 | * @return (string|string[])[] |
| 48 | 48 | */ |
| 49 | 49 | public function preload_paths( $preload_paths, $post ) { |
| 50 | - if ( $this->model->is_translated_post_type( $post->post_type ) ) { | |
| 50 | + if ( $post instanceof WP_Post && $this->model->is_translated_post_type( $post->post_type ) ) { | |
| 51 | 51 | $lang = $this->model->post->get_language( $post->ID ); |
| 52 | 52 | |
| 53 | 53 | if ( ! $lang ) { |
| 54 | 54 | $lang = $this->pref_lang; |