PluginProbe
Polylang / 3.1.4
Polylang v3.1.4
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-block-editor.php +22 -9 2.73.1.4 View file →
@@ -1,5 +1,8 @@
1 1 <?php
2 +/**
3 + * @package Polylang
4 + */
2 5
3 6 /**
4 7 * Manages filters and actions related to the block editor
5 8 *
@@ -5,11 +8,21 @@
5 8 *
6 9 * @since 2.5
7 10 */
8 11 class PLL_Admin_Block_Editor {
9 - public $model;
12 + /**
13 + * @var PLL_Model
14 + */
15 + protected $model;
10 16
11 17 /**
18 + * Preferred language to assign to a new post.
19 + *
20 + * @var PLL_Language
21 + */
22 + protected $pref_lang;
23 +
24 + /**
12 25 * Constructor: setups filters and actions
13 26 *
14 27 * @since 2.5
15 28 *
@@ -18,24 +31,24 @@
18 31 public function __construct( &$polylang ) {
19 32 $this->model = &$polylang->model;
20 33 $this->pref_lang = &$polylang->pref_lang;
21 34
22 - 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 );
23 36 }
24 37
25 38 /**
26 - * Filter the preload REST requests by the current language of the post
27 - * Necessary otherwise subsequent REST requests all filtered by the language
28 - * would not hit the preloaded requests
39 + * Filters the preload REST requests by the current language of the post.
40 + * Necessary otherwise subsequent REST requests, all filtered by the language,
41 + * would not hit the preloaded requests.
29 42 *
30 43 * @since 2.5
31 44 *
32 - * @param array $preload_paths Array of paths to preload.
33 - * @param object $post The post resource data.
34 - * @return array
45 + * @param (string|string[])[] $preload_paths Array of paths to preload.
46 + * @param WP_Post $post The post resource data.
47 + * @return (string|string[])[]
35 48 */
36 49 public function preload_paths( $preload_paths, $post ) {
37 - 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 ) ) {
38 51 $lang = $this->model->post->get_language( $post->ID );
39 52
40 53 if ( ! $lang ) {
41 54 $lang = $this->pref_lang;