| @@ -189,8 +189,11 @@ | ||
| 189 | 189 | |
| 190 | 190 | /** |
| 191 | 191 | * Load the post synchronization object, depending on the editor in use. |
| 192 | 192 | * |
| 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 | + * | |
| 193 | 196 | * @since 2.6 |
| 194 | 197 | * |
| 195 | 198 | * @param bool $is_block_editor Whether to use the block editor or not. |
| 196 | 199 | * @return bool |
| @@ -195,9 +198,9 @@ | ||
| 195 | 198 | * @param bool $is_block_editor Whether to use the block editor or not. |
| 196 | 199 | * @return bool |
| 197 | 200 | */ |
| 198 | 201 | public function _maybe_load_sync_post( $is_block_editor ) { |
| 199 | - if ( ! isset( $this->sync_post ) ) { // Make sure to instantiate the class only once, as the function may be called from a filter. | |
| 202 | + if ( ! isset( $this->sync_post ) && isset( $this->sync_post_model ) ) { | |
| 200 | 203 | if ( class_exists( 'PLL_Sync_Post_REST' ) && pll_use_block_editor_plugin() && $is_block_editor ) { |
| 201 | 204 | $this->sync_post = new PLL_Sync_Post_REST( $this ); |
| 202 | 205 | } elseif ( class_exists( 'PLL_Sync_Post' ) ) { |
| 203 | 206 | $this->sync_post = new PLL_Sync_Post( $this ); |