PluginProbe
Polylang / 2.5.2
Polylang v2.5.2
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 +4 -14 2.72.5.2 View file →
@@ -5,9 +5,8 @@
5 5 *
6 6 * @since 2.5
7 7 */
8 8 class PLL_Admin_Block_Editor {
9 - public $model;
10 9
11 10 /**
12 11 * Constructor: setups filters and actions
13 12 *
@@ -15,11 +14,8 @@
15 14 *
16 15 * @param object $polylang
17 16 */
18 17 public function __construct( &$polylang ) {
19 - $this->model = &$polylang->model;
20 - $this->pref_lang = &$polylang->pref_lang;
21 -
22 18 add_filter( 'block_editor_preload_paths', array( $this, 'preload_paths' ), 10, 2 );
23 19 }
24 20
25 21 /**
@@ -33,19 +29,13 @@
33 29 * @param object $post The post resource data.
34 30 * @return array
35 31 */
36 32 public function preload_paths( $preload_paths, $post ) {
37 - if ( $this->model->is_translated_post_type( $post->post_type ) ) {
38 - $lang = $this->model->post->get_language( $post->ID );
33 + $lang = pll_get_post_language( $post->ID );
39 34
40 - if ( ! $lang ) {
41 - $lang = $this->pref_lang;
42 - }
43 -
44 - foreach ( $preload_paths as $k => $path ) {
45 - if ( is_string( $path ) && '/' !== $path ) {
46 - $preload_paths[ $k ] = $path . "&lang={$lang->slug}";
47 - }
35 + foreach ( $preload_paths as $k => $path ) {
36 + if ( is_string( $path ) && '/' !== $path ) {
37 + $preload_paths[ $k ] = $path . "&lang={$lang}";
48 38 }
49 39 }
50 40
51 41 return $preload_paths;