← All changes
|
modules/global-classes/global-classes-relations.php
+22
-16
4.1.0-dev3
→
4.3.0-beta3
View file →
| @@ -277,18 +277,22 @@ | ||
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | $elements_data = $document->get_elements_data(); |
| 280 | 280 | |
| 281 | - if ( empty( $elements_data ) ) { | |
| 282 | - return []; | |
| 281 | + if ( ! empty( $elements_data ) ) { | |
| 282 | + Plugin::$instance->db->iterate_data( $elements_data, function ( $element_data ) use ( &$used_class_ids ) { | |
| 283 | + $used_class_ids = array_merge( | |
| 284 | + $used_class_ids, | |
| 285 | + Atomic_Elements_Utils::collect_class_ids_from_element_data( $element_data ) | |
| 286 | + ); | |
| 287 | + } ); | |
| 283 | 288 | } |
| 284 | 289 | |
| 285 | - Plugin::$instance->db->iterate_data( $elements_data, function ( $element_data ) use ( &$used_class_ids ) { | |
| 286 | - $used_class_ids = array_merge( | |
| 287 | - $used_class_ids, | |
| 288 | - Atomic_Elements_Utils::collect_class_ids_from_element_data( $element_data ) | |
| 289 | - ); | |
| 290 | - } ); | |
| 290 | + $used_class_ids = apply_filters( | |
| 291 | + 'elementor/global_classes/extract_class_ids_from_post', | |
| 292 | + $used_class_ids, | |
| 293 | + $post_id | |
| 294 | + ); | |
| 291 | 295 | |
| 292 | 296 | return array_values( array_unique( $used_class_ids ) ); |
| 293 | 297 | } |
| 294 | 298 | |
| @@ -343,15 +347,9 @@ | ||
| 343 | 347 | private function get_document_for_post( int $post_id ): ?Document { |
| 344 | 348 | $documents = Plugin::$instance->documents; |
| 345 | 349 | |
| 346 | 350 | if ( ! $this->is_preview() ) { |
| 347 | - $document = $documents->get( $post_id ); | |
| 348 | - | |
| 349 | - if ( ! $document ) { | |
| 350 | - return null; | |
| 351 | - } | |
| 352 | - | |
| 353 | - return $document ?? null; | |
| 351 | + return $this->get_document_or_null( $documents->get( $post_id ) ); | |
| 354 | 352 | } |
| 355 | 353 | |
| 356 | 354 | $document = $documents->get_doc_or_auto_save( $post_id, get_current_user_id() ); |
| 357 | 355 | |
| @@ -358,7 +356,15 @@ | ||
| 358 | 356 | if ( ! $document ) { |
| 359 | 357 | $document = $documents->get( $post_id ); |
| 360 | 358 | } |
| 361 | 359 | |
| 362 | - return $document ?? null; | |
| 360 | + return $this->get_document_or_null( $document ); | |
| 361 | + } | |
| 362 | + | |
| 363 | + private function get_document_or_null( $document ): ?Document { | |
| 364 | + if ( empty( $document ) ) { | |
| 365 | + return null; | |
| 366 | + } | |
| 367 | + | |
| 368 | + return $document; | |
| 363 | 369 | } |
| 364 | 370 | } |