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