| @@ -292,10 +292,11 @@ | ||
| 292 | 292 | */ |
| 293 | 293 | public function safe_copy_elementor_meta( $from_post_id, $to_post_id ) { |
| 294 | 294 | // It's from WP-Admin & not from Elementor. |
| 295 | 295 | if ( ! did_action( 'elementor/db/before_save' ) ) { |
| 296 | + $from_document = Plugin::$instance->documents->get( $from_post_id ); | |
| 296 | 297 | |
| 297 | - if ( ! Plugin::$instance->db->is_built_with_elementor( $from_post_id ) ) { | |
| 298 | + if ( ! $from_document || ! $from_document->is_built_with_elementor() ) { | |
| 298 | 299 | return; |
| 299 | 300 | } |
| 300 | 301 | |
| 301 | 302 | // It's an exited Elementor auto-save |
| @@ -350,8 +351,9 @@ | ||
| 350 | 351 | * |
| 351 | 352 | * Check whether the post was built with Elementor. |
| 352 | 353 | * |
| 353 | 354 | * @since 1.0.10 |
| 355 | + * @deprecated 3.2.0 Use `Plugin::$instance->documents->get( $post_id )->is_built_with_elementor()` instead | |
| 354 | 356 | * @access public |
| 355 | 357 | * |
| 356 | 358 | * @param int $post_id Post ID. |
| 357 | 359 | * |
| @@ -357,9 +359,24 @@ | ||
| 357 | 359 | * |
| 358 | 360 | * @return bool Whether the post was built with Elementor. |
| 359 | 361 | */ |
| 360 | 362 | public function is_built_with_elementor( $post_id ) { |
| 361 | - return ! ! get_post_meta( $post_id, '_elementor_edit_mode', true ); | |
| 363 | + Plugin::$instance->modules_manager | |
| 364 | + ->get_modules( 'dev-tools' ) | |
| 365 | + ->deprecation | |
| 366 | + ->deprecated_function( | |
| 367 | + __METHOD__, | |
| 368 | + '3.2.0', | |
| 369 | + 'Plugin::$instance->documents->get( $post_id )->is_built_with_elementor()' | |
| 370 | + ); | |
| 371 | + | |
| 372 | + $document = Plugin::$instance->documents->get( $post_id ); | |
| 373 | + | |
| 374 | + if ( ! $document ) { | |
| 375 | + return false; | |
| 376 | + } | |
| 377 | + | |
| 378 | + return $document->is_built_with_elementor(); | |
| 362 | 379 | } |
| 363 | 380 | |
| 364 | 381 | /** |
| 365 | 382 | * Switch to post. |