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