PluginProbe
Polylang / 2.6.2
Polylang v2.6.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.php +15 -34 2.7.22.6.2 View file →
@@ -24,14 +24,10 @@
24 24 * sync => reference to PLL_Admin_Sync object
25 25 * block_editor => reference to PLL_Admin_Block_Editor object
26 26 * classic_editor => reference to PLL_Admin_Classic_Editor object
27 27 * filters_media => optional, reference to PLL_Admin_Filters_Media object
28 - * bulk_translate => reference, a PLL_Bulk_Translate subclass instance
29 - * wizard => reference, a PLL_Wizard object
30 28 *
31 29 * @since 1.2
32 - * @since 2.7 Added a reference to a PLL_Bulk_Translate instance.
33 - * @since 2.7 Added a reference to a PLL_Wizard object.
34 30 */
35 31 class PLL_Admin extends PLL_Admin_Base {
36 32 public $filters, $filters_columns, $filters_post, $filters_term, $nav_menu, $sync, $filters_media;
37 33
@@ -63,9 +59,14 @@
63 59 // Setup filters for admin pages
64 60 // Priority 5 to make sure filters are there before customize_register is fired
65 61 if ( $this->model->get_languages_list() ) {
66 62 add_action( 'wp_loaded', array( $this, 'add_filters' ), 5 );
67 - add_action( 'admin_init', array( $this, 'maybe_load_sync_post' ), 20 ); // After fusion Builder.
63 + add_action( 'admin_init', array( $this, 'maybe_load_sync_post' ) );
64 +
65 + // Bulk Translate
66 + if ( class_exists( 'PLL_Bulk_Translate' ) ) {
67 + add_action( 'current_screen', array( $this->bulk_translate = new PLL_Bulk_Translate( $this ), 'init' ) );
68 + }
68 69 }
69 70 }
70 71
71 72 /**
@@ -98,9 +99,8 @@
98 99 /**
99 100 * Setup filters for admin pages
100 101 *
101 102 * @since 1.2
102 - * @since 2.7 instantiate a PLL_Bulk_Translate instance.
103 103 */
104 104 public function add_filters() {
105 105 // All these are separated just for convenience and maintainability
106 106 $classes = array( 'Filters', 'Filters_Columns', 'Filters_Post', 'Filters_Term', 'Nav_Menu', 'Sync', 'Classic_Editor', 'Block_Editor' );
@@ -126,15 +126,8 @@
126 126
127 127 $this->posts = new PLL_CRUD_Posts( $this );
128 128 $this->terms = new PLL_CRUD_Terms( $this );
129 129
130 - // Bulk Translate
131 - // Needs to be loaded before other modules.
132 - if ( class_exists( 'PLL_Bulk_Translate' ) ) {
133 - $this->bulk_translate = new PLL_Bulk_Translate( $this->model );
134 - add_action( 'current_screen', array( $this->bulk_translate, 'init' ) );
135 - }
136 -
137 130 // Advanced media
138 131 if ( $this->options['media_support'] && class_exists( 'PLL_Admin_Advanced_Media' ) ) {
139 132 $this->advanced_media = new PLL_Admin_Advanced_Media( $this );
140 133 }
@@ -143,8 +136,12 @@
143 136 if ( get_option( 'permalink_structure' ) && $this->options['force_lang'] && class_exists( 'PLL_Admin_Share_Term_Slug' ) ) {
144 137 $this->share_term_slug = new PLL_Admin_Share_Term_Slug( $this );
145 138 }
146 139
140 + if ( class_exists( 'PLL_Sync_Content' ) ) {
141 + $this->sync_content = new PLL_Sync_Content( $this );
142 + }
143 +
147 144 // Duplicate content
148 145 if ( class_exists( 'PLL_Duplicate' ) ) {
149 146 $this->duplicate = new PLL_Duplicate( $this );
150 147 }
@@ -152,23 +149,12 @@
152 149 if ( class_exists( 'PLL_Duplicate_REST' ) ) {
153 150 $this->duplicate_rest = new PLL_Duplicate_REST();
154 151 }
155 152
156 - if ( class_exists( 'PLL_Sync_Post_Model' ) ) {
157 - $this->sync_post_model = new PLL_Sync_Post_Model( $this );
158 - }
159 -
160 153 // Block editor metabox
161 154 if ( pll_use_block_editor_plugin() ) {
162 155 $this->block_editor_plugin = new PLL_Block_Editor_Plugin( $this );
163 156 }
164 -
165 - // FIXME: Specific for WP CRON and WP CLI as the action admin_init is not fired.
166 - // Waiting for a better way to handle the cases without loading the complete admin.
167 - if ( wp_doing_cron() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
168 - $this->maybe_load_sync_post();
169 - }
170 -
171 157 }
172 158
173 159 /**
174 160 * Load the post synchronization object, depending on the editor in use.
@@ -189,23 +175,18 @@
189 175
190 176 /**
191 177 * Load the post synchronization object, depending on the editor in use.
192 178 *
193 - * We must make sure to instantiate the class only once, as the function may be called from a filter,
194 - * and that the synchronization model has been instantiated (due to InfiniteWP messing the actions wp_loaded and admin_init).
195 - *
196 179 * @since 2.6
197 180 *
198 - * @param bool $is_block_editor Whether to use the block editor or not.
181 + * @param bool $is_block_editor Whether to use the block editor or not
199 182 * @return bool
200 183 */
201 184 public function _maybe_load_sync_post( $is_block_editor ) {
202 - if ( ! isset( $this->sync_post ) && isset( $this->sync_post_model ) ) {
203 - if ( class_exists( 'PLL_Sync_Post_REST' ) && pll_use_block_editor_plugin() && $is_block_editor ) {
204 - $this->sync_post = new PLL_Sync_Post_REST( $this );
205 - } elseif ( class_exists( 'PLL_Sync_Post' ) ) {
206 - $this->sync_post = new PLL_Sync_Post( $this );
207 - }
185 + if ( class_exists( 'PLL_Sync_Post_REST' ) && pll_use_block_editor_plugin() && $is_block_editor ) {
186 + $this->sync_post = new PLL_Sync_Post_REST( $this );
187 + } elseif ( class_exists( 'PLL_Sync_Post' ) ) {
188 + $this->sync_post = new PLL_Sync_Post( $this );
208 189 }
209 190
210 191 return $is_block_editor;
211 192 }